コード例 #1
0
        public void IfCreateParametersThrowsExceptionThenReturnsNotRunnableTestMethodWithExceptionInfoAsSkipReason()
        {
            // Arrange
            // DummyFixture is set up to throw DummyException when invoked by AutoDataAttribute
            var autoDataAttributeStub = new AutoDataAttributeStub(new ThrowingStubFixture());

            var fixtureType = this.GetType();

            var methodWrapper = new MethodWrapper(fixtureType, fixtureType.GetMethod("DummyTestMethod"));
            var testSuite     = new TestSuite(fixtureType);

            // Act
            var testMethod = autoDataAttributeStub.BuildFrom(methodWrapper, testSuite).First();

            // Assert
            Assert.That(testMethod.RunState == RunState.NotRunnable);

            Assert.That(testMethod.Properties.Get(PropertyNames.SkipReason),
                        Is.EqualTo(ExceptionHelper.BuildMessage(new ThrowingStubFixture.DummyException())));
        }
コード例 #2
0
        public void IfCreateParametersThrowsExceptionThenReturnsNotRunnableTestMethodWithExceptionInfoAsSkipReason()
        {
            // Arrange
            // DummyFixture is set up to throw DummyException when invoked by AutoDataAttribute
            var autoDataAttributeStub = new AutoDataAttributeStub(new ThrowingStubFixture());

            var fixtureType = this.GetType();

            var methodWrapper = new MethodWrapper(fixtureType, fixtureType.GetMethod("DummyTestMethod"));
            var testSuite = new TestSuite(fixtureType);

            // Act
            var testMethod = autoDataAttributeStub.BuildFrom(methodWrapper, testSuite).First();

            // Assert
            Assert.That(testMethod.RunState == RunState.NotRunnable);

            Assert.That(testMethod.Properties.Get(PropertyNames.SkipReason),
                Is.EqualTo(ExceptionHelper.BuildMessage(new ThrowingStubFixture.DummyException())));
        }
コード例 #3
0
        public void GetDataOrdersCustomizationAttributes(string methodName)
        {
            // Fixture setup
            var method           = new MethodWrapper(typeof(TypeWithCustomizationAttributes), methodName);
            var customizationLog = new List <ICustomization>();
            var fixture          = new DelegatingFixture();

            fixture.OnCustomize = c =>
            {
                customizationLog.Add(c);
                return(fixture);
            };
            var sut = new AutoDataAttributeStub(fixture);

            // Exercise system
            sut.BuildFrom(method, new TestSuite(this.GetType())).Single();
            // Verify outcome
            Assert.False(customizationLog[0] is FreezeOnMatchCustomization);
            Assert.True(customizationLog[1] is FreezeOnMatchCustomization);
            // Teardown
        }
コード例 #4
0
        public void CanBeExtendedToTakeAnIFixture()
        {
            var stub = new AutoDataAttributeStub(new ThrowingStubFixture());

            Assert.That(stub, Is.AssignableTo <AutoDataAttribute>());
        }
コード例 #5
0
 public void GetDataOrdersCustomizationAttributes(string methodName)
 {
     // Fixture setup
     var method = new MethodWrapper(typeof(TypeWithCustomizationAttributes), methodName);
     var customizationLog = new List<ICustomization>();
     var fixture = new DelegatingFixture();
     fixture.OnCustomize = c =>
     {
         customizationLog.Add(c);
         return fixture;
     };
     var sut = new AutoDataAttributeStub(fixture);
     // Exercise system
     sut.BuildFrom(method, new TestSuite(this.GetType())).Single();
     // Verify outcome
     Assert.False(customizationLog[0] is FreezeOnMatchCustomization);
     Assert.True(customizationLog[1] is FreezeOnMatchCustomization);
     // Teardown
 }
コード例 #6
0
        public void CanBeExtendedToTakeAnIFixture()
        {
            var stub = new AutoDataAttributeStub(new ThrowingStubFixture());

            Assert.That(stub, Is.AssignableTo<AutoDataAttribute>());
        }