Exemple #1
0
        public void WhenParameterlessConstructorIsInvoked_ThenFixtureAndAttributeProviderAreCreated()
        {
            // Arrange
            // Act
            var attribute = new AutoMoqDataAttribute();

            // Assert
            attribute.Fixture.Should().NotBeNull();
            attribute.Provider.Should().NotBeNull();
            attribute.IgnoreVirtualMembers.Should().BeFalse();
        }
Exemple #2
0
        public void GivenExistingFixtureAndAttributeProvider_WhenConstructorIsInvoked_ThenHasSpecifiedFixtureAndAttributeProvider(Fixture fixture)
        {
            // Arrange
            var provider = new Mock <IAutoFixtureAttributeProvider>().Object;

            // Act
            var attribute = new AutoMoqDataAttribute(fixture, provider);

            // Assert
            attribute.Fixture.Should().Be(fixture);
            attribute.Provider.Should().Be(provider);
            attribute.IgnoreVirtualMembers.Should().BeFalse();
        }
Exemple #3
0
            private new static IFixture CreateFixture()
            {
                var fixture = AutoMoqDataAttribute.CreateFixture();

                var user = fixture.Build <User>()
                           .Without(u => u.AccountDisabled)
                           .Without(u => u.PasswordRequired)
                           .Without(u => u.Manager)
                           .Create();

                user.SetPropertyValue(DistinguishedName, DN.Parse("CN=John Doe,OU=users,DC=domain,DC=com"));

                fixture.Inject((IUser)user);
                fixture.Inject(DN.Parse("CN=manager,OU=users,DC=domain,DC=com"));

                return(fixture);
            }
Exemple #4
0
        public void WhenGetDataIsInvoked_ThenFixtureIsConfiguredAndDataReturned(bool ignoreVirtualMembers)
        {
            // Arrange
            var data = new[]
            {
                new object[] { 1, 2, 3 },
                new object[] { 4, 5, 6 },
                new object[] { 7, 8, 9 }
            };
            var fixture        = new Mock <IFixture>();
            var customizations = new List <ICustomization>();

            fixture.Setup(x => x.Customize(It.IsAny <ICustomization>())).Callback <ICustomization>(customization => customizations.Add(customization));
            var dataAttribute = new Mock <DataAttribute>();

            dataAttribute.Setup(a => a.GetData(It.IsAny <MethodInfo>())).Returns(data);
            var provider = new Mock <IAutoFixtureAttributeProvider>();

            provider.Setup(p => p.GetAttribute(It.IsAny <IFixture>())).Returns(dataAttribute.Object);
            var attribute = new AutoMoqDataAttribute(fixture.Object, provider.Object)
            {
                IgnoreVirtualMembers = ignoreVirtualMembers
            };
            var methodInfo = typeof(AutoMoqDataAttributeTests).GetMethod("TestMethod");

            // Act
            var result = attribute.GetData(methodInfo);

            // Assert
            result.Should().BeSameAs(data);
            provider.VerifyAll();
            dataAttribute.VerifyAll();

            customizations[0].Should().BeOfType <AutoMoqDataCustomization>();
            customizations[1].Should().BeOfType <IgnoreVirtualMembersCustomization>();
            ((IgnoreVirtualMembersCustomization)customizations[1]).IgnoreVirtualMembers.Should().Be(ignoreVirtualMembers);
        }
 private static IFixture CreateFixture()
 {
     return(AutoMoqDataAttribute.CreateFixture()
            .Customize(new PlayerOnRoadCustomization()));
 }
 private static IFixture CreateFixture()
 {
     return(AutoMoqDataAttribute.CreateFixture()
            .Customize(new DomainCustomization()));
 }
Exemple #7
0
 public static IFixture CreateFixture()
 {
     return(AutoMoqDataAttribute.CreateFixture()
            .Customize(new TextProcessing.Tests.DomainCustomization())
            .Customize(new DomainCustomization()));
 }
Exemple #8
0
 private static IFixture CreateFixture()
 {
     return(AutoMoqDataAttribute.CreateFixture()
            .Customize(new SingleGroupCustomization()));
 }