public BDDNUnitTestMethod(MethodInfo method, Type testTypeAttribute, IReflectionProvider reflectionProvider, ITestDescriber testDescriber, ITestExceptionWriter testExceptionWriter)
     : base(method)
 {
     _reflectionProvider = reflectionProvider;
     _testDescriber = testDescriber;
     _testExceptionWriter = testExceptionWriter;
     TestTypeAttribute = testTypeAttribute;
     GivenMethods = new BDDNUnitTestMethod[0];
     WhenMethods = new BDDNUnitTestMethod[0];
 }
        public void GivenBDDNUnitTestMethodWithGivenAndWhenMethodsWhenRun()
        {
            _mockReflectionProvider = new Mock<IReflectionProvider>();
            _mockTestDescriptionWriter = new Mock<ITestDescriber>();
            _givenMethods = new[]
                           {
                               new BDDNUnitTestMethod(typeof (BDDTestFixtureTestClass).GetMethod("GivenMethod1"),typeof(GivenAttribute), _mockReflectionProvider.Object, new Mock<ITestDescriber>().Object,  new Mock<ITestExceptionWriter>().Object)
                           };
            _whenMethods = new[]
                           {
                               new BDDNUnitTestMethod(typeof (BDDTestFixtureTestClass).GetMethod("WhenMethod1"), typeof(WhenAttribute), _mockReflectionProvider.Object, new Mock<ITestDescriber>().Object,  new Mock<ITestExceptionWriter>().Object)
                           };

            _testName = "TestMethod1";
            _bddNUnitTestMethod = new BDDNUnitTestMethod(typeof(BDDTestFixtureTestClass).GetMethod(_testName),
                                                         typeof(ThenAttribute), _mockReflectionProvider.Object, _mockTestDescriptionWriter.Object, new Mock<ITestExceptionWriter>().Object)
                                      {
                                          GivenMethods = _givenMethods,
                                          WhenMethods = _whenMethods
                                      };

            _bddNUnitTestMethod.RunTest();
        }
        public void GivenBDDNUnitTestMethodWithGivenAndWhenMethodsIsRunWhenAnExceptionIsThrown()
        {
            thrownException = TestExceptionHelper.GenerateException();
            _mockTestExceptionWriter = new Mock<ITestExceptionWriter>();
            _mockTestDescriptionWriter = new Mock<ITestDescriber>();
            var mockReflectionProvider = new Mock<IReflectionProvider>();
            mockReflectionProvider.Setup(rp => rp.InvokeMethod(It.IsAny<MethodInfo>(), It.IsAny<object>())).Throws(thrownException);

            _testName = "TestMethod1";
            _bddNUnitTestMethod = new BDDNUnitTestMethod(typeof (BDDTestFixtureTestClass).GetMethod(_testName),
                                                         typeof (ThenAttribute), mockReflectionProvider.Object,
                                                         _mockTestDescriptionWriter.Object,
                                                         _mockTestExceptionWriter.Object)
                                      {
                                          GivenMethods = new[]
                                                             {
                                                                 new BDDNUnitTestMethod(
                                                                     typeof (BDDTestFixtureTestClass).GetMethod(
                                                                         "GivenMethod1"), typeof (GivenAttribute),
                                                                     mockReflectionProvider.Object,
                                                                     new Mock<ITestDescriber>().Object,
                                                                     new Mock<ITestExceptionWriter>().Object)
                                                             }
                                      };
            try
            {
                _bddNUnitTestMethod.RunTest();
            }
            catch (Exception exception)
            {
                _caughtException = exception;
            }
        }