Unit Test - Given When Then style


Really nice sample I found on the web that Explains the Given-When-Then Syntax style.


The Given When Then style correlates closely to the Arrange Act Assert style for unit testing.

Here's an example:
[Test]
public void RotateAngle_Given27Degress_Returns64Degrees()
{
   //Arrange or Given
   var someAngleClass = new Angle();

   //Act or When
   var result = someAngleClass.Rotate(27);

   //Assert or Then
   Assert.That(result, Is.EqualTo(64));
}

Thanks:  http://stackoverflow.com/users/445105/joseph

Comments

Popular posts from this blog

Intro to MongoDB

Starting our .NET Core WebAPI Journey – Step 2