title: Button Unit Testing C#
body: <p>I want to test if my button is doing what it was expected. But I even can't test this simple example:</p>
  
  <pre><code>public int k = 0;
  
  public void button3_Click(object sender, EventArgs e)
  {
      k = 1;
  }
  </code></pre>
  
  <p>Unit test:</p>
  
  <pre><code>[TestMethod]
  public void ButtonClick3_ret1()
  {
      //arrange
      int x;
      int expected = 1;
  
      //act
      int actual;
      Form c = new Form();
      c.button3.PerformClick();
      actual = c.k;
  
      //assert
      Assert.AreEqual(expected,actual );
  }
  </code></pre>