示例#1
0
        public void GetDataOrdersCustomizationAttributes(string methodName)
        {
            // Arrange
            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 InlineAutoDataAttributeStub(() => fixture);

            // Act
            sut.BuildFrom(method, new TestSuite(this.GetType())).Single();
            // Assert
            Assert.False(customizationLog[0] is FreezeOnMatchCustomization);
            Assert.True(customizationLog[1] is FreezeOnMatchCustomization);
        }
        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
        }
示例#3
0
        public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource()
        {
            // Arrange
            var method = new MethodWrapper(
                typeof(TypeWithIParameterCustomizationSourceUsage),
                nameof(TypeWithIParameterCustomizationSourceUsage.DecoratedMethod));

            var customizationLog = new List <ICustomization>();
            var fixture          = new DelegatingFixture();

            fixture.OnCustomize = c =>
            {
                customizationLog.Add(c);
                return(fixture);
            };
            var sut = new InlineAutoDataAttributeStub(() => fixture, new[] { 42 });

            // Act
            sut.BuildFrom(method, new TestSuite(this.GetType())).ToArray();
            // Assert
            Assert.True(customizationLog[0] is TypeWithIParameterCustomizationSourceUsage.Customization);
        }
        public void ShouldRecognizeAttributesImplementingIParameterCustomizationSource()
        {
            // Fixture setup
            var method = new MethodWrapper(
                typeof(TypeWithIParameterCustomizationSourceUsage),
                nameof(TypeWithIParameterCustomizationSourceUsage.DecoratedMethod));

            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())).ToArray();
            // Verify outcome
            Assert.True(customizationLog[0] is TypeWithIParameterCustomizationSourceUsage.Customization);
            // Teardown
        }