コード例 #1
0
        public void PropertyValuesIsValid()
        {
            // Arrange.
            const string attributeTypeDescription = "description";

            object[] attributeValuesDescription = { "Contractor" };
            ModSpec  modSpecDescription         = new ModSpec(ModSpecType.Add, attributeTypeDescription, attributeValuesDescription);

            const string attributeTypeTelephoneNumber = "telephonenumber";

            object[] attributeValuesTelephoneNumber = { "+1 (415) 555 1234" };
            ModSpec  modSpecTelephoneNumber         = new ModSpec(ModSpecType.Replace, attributeTypeTelephoneNumber, attributeValuesTelephoneNumber);

            // Act.
            ChangeModify sut = new ChangeModify(DistinguishedName, new[] { modSpecDescription, modSpecTelephoneNumber });
            ModSpec      sutModSpecDescription     = sut.ModSpecs.First(x => x.AttributeType.Equals(attributeTypeDescription));
            ModSpec      sutModSpecTelephoneNumber = sut.ModSpecs.First(x => x.AttributeType.Equals(attributeTypeTelephoneNumber));

            // Assert.
            Assert.Equal(2, sut.ModSpecs.ToArray().Length);

            Assert.Equal(attributeTypeDescription, sutModSpecDescription.AttributeType);
            Assert.Equal(attributeValuesDescription, sutModSpecDescription.AttributeValues);

            Assert.Equal(attributeTypeTelephoneNumber, sutModSpecTelephoneNumber.AttributeType);
            Assert.Equal(attributeValuesTelephoneNumber, sutModSpecTelephoneNumber.AttributeValues);
        }
コード例 #2
0
        public void PropertyDistinguishedNameIsValid()
        {
            // Act.
            ChangeModify sut = new ChangeModify(DistinguishedName, ModSpecs);

            // Arrange.
            Assert.Equal(DistinguishedName, sut.DistinguishedName);
        }
コード例 #3
0
        public void PropertyCountIsValid()
        {
            // Act.
            ChangeModify sut = new ChangeModify(
                DistinguishedName,
                new[]
            {
                new ModSpec(ModSpecType.Add, "description", new object[] { "Contractor" }),
                new ModSpec(ModSpecType.Replace, "telephonenumber", new object[] { "+1 (415) 555 1234" })
            });

            // Arrange.
            Assert.Equal(2, sut.Count);
        }
コード例 #4
0
        public void ShouldReplaceAllValues()
        {
            // Arrange.
            ModSpec[] modSpec = { new ModSpec(ModSpecType.Replace, "telephonenumber", null) };
            string    dump    = string.Join(
                Environment.NewLine,
                "dn: CN=Leonardo Pisano Bigollo,OU=users,DC=company,DC=com",
                "changetype: modify",
                "replace: telephonenumber",
                "-",
                string.Empty);

            // Act.
            ChangeModify sut = new ChangeModify(DistinguishedName, modSpec);

            // Assert.
            Assert.Equal(dump, sut.Dump());
        }
コード例 #5
0
        public void ShouldDeleteSingleValues()
        {
            // Arrange.
            ModSpec[] modSpec = { new ModSpec(ModSpecType.Delete, "description", new object[] { "Contractor" }) };
            string    dump    = string.Join(
                Environment.NewLine,
                "dn: CN=Leonardo Pisano Bigollo,OU=users,DC=company,DC=com",
                "changetype: modify",
                "delete: description",
                "description: Contractor",
                "-",
                string.Empty);

            // Act.
            ChangeModify sut = new ChangeModify(DistinguishedName, modSpec);

            // Assert.
            Assert.Equal(dump, sut.Dump());
        }
コード例 #6
0
        public void ShouldAddOneValue()
        {
            // Arrange.
            ModSpec[] modSpec = { new ModSpec(ModSpecType.Add, "postaladdress", new object[] { "2400 Fulton St, San Francisco, CA 94118, USA" }) };
            string    dump    = string.Join(
                Environment.NewLine,
                "dn: CN=Leonardo Pisano Bigollo,OU=users,DC=company,DC=com",
                "changetype: modify",
                "add: postaladdress",
                "postaladdress: 2400 Fulton St, San Francisco, CA 94118, USA",
                "-",
                string.Empty);

            // Act.
            ChangeModify sut = new ChangeModify(DistinguishedName, modSpec);

            // Assert.
            Assert.Equal(dump, sut.Dump());
        }