Project Description

BeeTest.Net is a small .NET 4.0 class library containing a fluent interface for behavior driven testing.

This library was inspired by Behavioral library that can also be found here on CodePlex.

Here is the complete calculator example of Behavioral done in BeeTest.Net with MSTest.

  1:     [TestClass]
  2:     public class CalculatorTests : BehaviorTestBase
  3:     {
  4:         [TestMethod]
  5:         public void AddintTwoPositiveNumbersShouldGiveCorrectResult()
  6:         {
  7:             this.Returns.Given(CalculatorDefaultConstructed)
  8:                 .Returns.When(TwoNumbersAdded, 13, 45)
  9:                 .Then(ResultIsEqualTo, 58);
 10:                 
 11:         }
 12: 
 13:         #region Behaviors
 14: 
 15:         private Calculator CalculatorDefaultConstructed()
 16:         {
 17:             return new Calculator();
 18:         }
 19: 
 20:         private int TwoNumbersAdded(Calculator c, int a, int b)
 21:         {
 22:             return c.Add(a, b);
 23:         }
 24: 
 25:         private void ResultIsEqualTo(int given, int expected)
 26:         {
 27:             Assert.AreEqual(expected, given);
 28:         }
 29: 
 30:         #endregion
 31:     }

And here is an alternative version that doesn’t need any behavior helpers defined.

  1:         [TestMethod]
  2:         public void AddIntsAlternative()
  3:         {
  4:             this.Returns.Given(() => { return new Calculator(); })
  5:                 .And.Returns.Given(13)
  6:                 .And.Returns.Given(45)
  7:                 .Returns.When((c, a, b) => { return c.Add(a, b); })
  8:                 .Then((r) => Assert.AreEqual(58, r));
  9:                 
 10:         }

 

 

For more detailed information on how to use BeeTest.Net see the documentation section.

Last edited Apr 14, 2013 at 6:27 PM by paiden36, version 19