Home

MikeBild edited this page Feb 22, 2011 · 6 revisions
Clone this wiki locally

Welcome to the Feature.Spex wiki!

A BDD-Testing-Style Testing-DSL with a feature-driven notation with the goal to test easy CQRS+Event Souring domain aggregates.

Goals

  • FDD-Syntax-Style management (level 1), ing (level 2), (level 3)
  • use partially BDD-Syntax-Style
  • use .NET 4.0 Dynamic for testing private fields and properties in domain aggregates
  • runs easy with Resharper-NUnit-TestRunner
  • expandable asserts through extension methods
  • compact syntax
namespace Feature.Spex.Demos.CalculatorManagement
{
    [Features]
    public class Calculating_with_calculator
    {
        internal readonly Given Object = new Calculator().IsGiven();

        [FeatureSpec]        
        public void action_add_1_should_result_1()
        {
            Object
                .When()
                .Then(result => result.Sum).ShouldBeEqual(0)                
                .When(action => action.Add(1))
                .Then(result => result.Sum).ShouldBeEqual(1)
                .When()
                .Then(result => result.Sum).ShouldBe<int>(i => i >= 0)
                ();
        }

        [FeatureSpec]
        public void action_calc_with_1_and_1_arguments_should_result_2()
        {
            Object
                .When(action => action.Calc(1, 1))
                .Then(@result => @result).ShouldBeEqual(2)
                ();
        }

        [FeatureSpec]
        public void action_test_with_null_in_argument_should_throw_argument_null_exception()
        {
            Object
                .When(action => action.Test(null))
                .Then().ShouldThrowException<ArgumentNullException>()
                ();
        }

        [FeatureSpec]
        [ExpectedException]
        public void action_test_with_null_in_argument_should_not_throw_invalid_operation_exception()
        {
            Object
                .When(action => action.Test(null))
                .Then().ShouldThrowException<InvalidOperationException>()
                ();
        }

        [FeatureSpec]
        public void action_test_with_5_argument_show_throw_invalid_operation_exception()
        {
            Object
                .When(action => action.Test(5))
                .Then().ShouldThrowException<InvalidOperationException>()
                ();
        }
    }
}