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"); }
public void DomainReturnsNullIfNoDcRdns() { // Fixture setup var dn = DN.Parse("CN=John,OU=Users"); // Exercise system and verify outcome dn.Domain.Should().BeNull(); }
public void DNIsValidIfObjectContainsInWellknownGenericContainer(string dn) { // Fixture setup Action call = () => DN.Parse(dn); // Exercise system and verify outcome call.Should().NotThrow <ArgumentOutOfRangeException>(); }
public void ParentReturnsIfNoParentRdn() { // Fixture setup var dn = DN.Parse("CN=John"); // Exercise system and verify outcome dn.Parent.Should().BeNull(); }
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."); }
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); }
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); }
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)); }
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); }
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"); }
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)); }
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"); }
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."); }
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); }
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) })); }
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); }
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)); }
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); }