示例#1
0
        public void FqdnReturnsCorrectString()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John,OU=Users,DC=domain,DC=com");

            // Exercise system and verify outcome
            dn.Fqdn.Should().Be("domain.com");
        }
示例#2
0
        public void DomainReturnsNullIfNoDcRdns()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John,OU=Users");

            // Exercise system and verify outcome
            dn.Domain.Should().BeNull();
        }
示例#3
0
        public void DNIsValidIfObjectContainsInWellknownGenericContainer(string dn)
        {
            // Fixture setup
            Action call = () => DN.Parse(dn);

            // Exercise system and verify outcome
            call.Should().NotThrow <ArgumentOutOfRangeException>();
        }
示例#4
0
        public void ParentReturnsIfNoParentRdn()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John");

            // Exercise system and verify outcome
            dn.Parent.Should().BeNull();
        }
示例#5
0
        public void CorrectExceptionThrownForInvalidValueOnParse(string value)
        {
            // Fixture setup
            Action call = () => DN.Parse(value);

            // Exercise system and verify outcome
            call.Should().Throw <ArgumentOutOfRangeException>()
            .WithMessage("DN string can not be null or white space.");
        }
示例#6
0
        public void AddressableObjectNameReturnsFirstRdn()
        {
            // Fixture setup
            var dn       = DN.Parse("CN=John,OU=Users");
            var expected = Rdn.Parse("CN=John");

            // Exercise system and verify outcome
            dn.AddressableObjectName.Should().Be(expected);
        }
示例#7
0
        public void DomainReturnsDnFromDcRdns()
        {
            // Fixture setup
            var dn       = DN.Parse("CN=John,OU=Users,DC=domain,DC=com");
            var expected = DN.Parse("DC=domain,DC=com");

            // Exercise system and verify outcome
            dn.Domain.Should().Be(expected);
        }
示例#8
0
        public void RdnSequenceCorrectnessShouldBeChecked(string dn)
        {
            // Fixture setup
            Action call = () => DN.Parse(dn);

            // Exercise system and verify outcome
            call.Should().Throw <ArgumentOutOfRangeException>()
            .WithMessage($"Rdn sequence '{dn}' can not be converted to valid DN instance.");
        }
        public void OneTypedPropertyValueShouldBeReaded(PropertyValueCollection collection)
        {
            // Fixture setup

            // Exercise system
            collection.SetValue(DirectoryProperty.Member, john);

            // Verify outcome
            collection.GetValue <DN>(DirectoryProperty.Member).Should().Be(DN.Parse(john));
        }
示例#10
0
        public void DistinguishedNameShouldHaveCorrectGetter()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John");
            var directoryObject = Fixture.Create <DirectoryObject>();

            directoryObject.SetPropertyValue(DirectoryProperty.DistinguishedName, dn);

            // Exercise system and verify outcome
            directoryObject.DistinguishedName.Should().Be(dn);
        }
示例#11
0
        public void AppendDNReturnsUpdatedInstance()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John Doe,OU=Users");

            // Exercise system
            dn = dn.Append(DN.Parse("DC=domain,DC=com"));

            // Verify outcome
            dn.ToString().Should().Be("CN=John Doe,OU=Users,DC=domain,DC=com");
        }
示例#12
0
        public void ParseCorrectDnStringReturnsCorrectDn()
        {
            // Fixture setup
            var dnString = @"CN=John\, Doe , OU=Users , DC=domain , DC=com";

            // Exercise system
            var dn = DN.Parse(dnString);

            // Verify outcome
            dn.ToString().Should().Be(@"CN=John\, Doe,OU=Users,DC=domain,DC=com");
        }
        public void OnePropertyValueShouldBeAppended(PropertyValueCollection collection)
        {
            // Fixture setup
            collection.SetValue(DirectoryProperty.Member, DN.Parse(john));

            // Exercise system
            collection.AppendValue(DirectoryProperty.Member, DN.Parse(paul));

            // Verify outcome
            collection.GetValues <DN>(DirectoryProperty.Member)
            .Should().BeEquivalentTo(DN.Parse(john), DN.Parse(paul));
        }
示例#14
0
        public void NameShouldBeCorrectComputed()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John");
            var directoryObject = Fixture.Create <DirectoryObject>();

            // Exercise system
            directoryObject.SetPropertyValue(DirectoryProperty.DistinguishedName, dn);

            // Verify outcome
            directoryObject.Name.Should().Be("John");
        }
示例#15
0
        public void ExceptionThrownForCandidateWithoutEscaping()
        {
            // Fixture setup

            // Exercise system
            Action call = () => DN.Parse("CN=John, Doe,OU=Users,DC=domain,DC=com");

            // Exercise system and verify outcome
            call.Should().Throw <ArgumentOutOfRangeException>()
            .WithMessage(
                "String 'CN=John, Doe,OU=Users,DC=domain,DC=com' can not be converted to valid DN instance.");
        }
示例#16
0
        public void RdnsPropertyReturnsSameCollectionAsConstructedFrom()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John,OU=Users");

            var expected = new[]
            {
                new Rdn(NamingAttribute.Cn, new LdapName("John")),
                new Rdn(NamingAttribute.Ou, new LdapName("Users"))
            };

            // Exercise system and verify outcome
            // ReSharper disable once CoVariantArrayConversion
            dn.Rdns.Should().BeEquivalentTo(expected);
        }
示例#17
0
        public void PublicInterfaceThrowsExceptionForNullArguments()
        {
            // Fixture setup
            var fixture = new Fixture();

            fixture.Inject(DN.Parse("CN=John"));
            var assertion = new GuardClauseAssertion(fixture);

            // Exercise system and verify outcome
            assertion.Verify(typeof(DN).GetConstructors());

            assertion.Verify(typeof(DN).GetMethod("Append", new[] { typeof(Rdn[]) }));
            assertion.Verify(typeof(DN).GetMethod("Append", new[] { typeof(DN) }));

            assertion.Verify(typeof(DN).GetMethod("Prepend", new[] { typeof(Rdn[]) }));
            assertion.Verify(typeof(DN).GetMethod("Prepend", new[] { typeof(DN) }));
        }
示例#18
0
        public void EqualityMembersCorrectDefined()
        {
            // Fixture setup
            var dn      = DN.Parse("CN=John,OU=Users,DC=domain,DC=com");
            var otherDn = DN.Parse("CN=John,OU=Users,DC=OMSK,DC=domain,DC=com");

            // ReSharper disable once ImplicitlyCapturedClosure
            Fixture.Inject(dn.Rdns.ToArray());

            var configuration = EqualityTestsConfigurer <DN>
                                .Instance(dn)
                                .ShouldBeEqualTo(dn)
                                .ShouldNotBeEqualTo(otherDn);

            // Exercise system and verify outcome
            EqualityTestsFor <DN> .Assert(() => configuration, Fixture);
        }
示例#19
0
        public void DNPropertyShouldConvertFromDirectoryValue()
        {
            // Fixture setup
            var dn = DN.Parse("CN=John");

            var properties = Enumeration.GetAll <DirectoryProperty>()
                             .Where(p => p.Syntax == DirectoryPropertySyntax.DNString && p.NotionalType == typeof(DN));

            // Exercise system
            var dns = properties
                      .Select(p => p.ConvertFromDirectoryValue("CN=John"))
                      .ToList();

            // Verify outcome
            dns.Should().HaveCountGreaterThan(0);
            dns.ForEach(r => r.Should().Be(dn));
        }
示例#20
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);
            }