Пример #1
0
        public void Equality()
        {
            var a = new TXTRecord
            {
                Name    = "the.printer.local",
                Strings = new List <string>
                {
                    "paper=A4",
                    "colour=false"
                }
            };
            var b = new TXTRecord
            {
                Name    = "the.printer.local",
                Strings = new List <string>
                {
                    "paper=A4",
                    "colour=true"
                }
            };

            Assert.IsTrue(a.Equals(a));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(a.Equals(null));
            Assert.AreNotEqual(a.GetHashCode(), new TXTRecord().GetHashCode());
        }
Пример #2
0
        /// <summary>
        ///   Add a property of the service to the <see cref="TXTRecord"/>.
        /// </summary>
        /// <param name="key">
        ///   The name of the property.
        /// </param>
        /// <param name="value">
        ///   The value of the property.
        /// </param>
        public void AddProperty(string key, string value)
        {
            var txt = Resources.OfType <TXTRecord>().FirstOrDefault();

            if (txt == null)
            {
                txt = new TXTRecord {
                    Name = FullyQualifiedName
                };
                Resources.Add(txt);
            }
            txt.Strings.Add(key + "=" + value);
        }
Пример #3
0
        public void NoStrings()
        {
            var a = new TXTRecord
            {
                Name = "the.printer.local",
            };
            var b = (TXTRecord) new ResourceRecord().Read(a.ToByteArray());

            Assert.AreEqual(a.Name, b.Name);
            Assert.AreEqual(a.Class, b.Class);
            Assert.AreEqual(a.Type, b.Type);
            Assert.AreEqual(a.TTL, b.TTL);
            CollectionAssert.AreEqual(a.Strings, b.Strings);
        }
Пример #4
0
        public void Roundtrip()
        {
            var a = new TXTRecord
            {
                Name    = "the.printer.local",
                Strings = new List <string>
                {
                    "paper=A4",
                    "colour=false"
                }
            };
            var b = (TXTRecord) new ResourceRecord().Read(a.ToByteArray());

            Assert.AreEqual(a.Name, b.Name);
            Assert.AreEqual(a.Class, b.Class);
            Assert.AreEqual(a.Type, b.Type);
            Assert.AreEqual(a.TTL, b.TTL);
            CollectionAssert.AreEqual(a.Strings, b.Strings);
        }
Пример #5
0
        public void Roundtrip_Master()
        {
            var a = new TXTRecord
            {
                Name    = "the.printer.local",
                Strings = new List <string>
                {
                    "paper=A4",
                    "colour=false",
                    "foo1=a b",
                    @"foo2=a\b",
                    "foo3=a\""
                }
            };
            var b = (TXTRecord) new ResourceRecord().Read(a.ToString());

            Assert.AreEqual(a.Name, b.Name);
            Assert.AreEqual(a.Class, b.Class);
            Assert.AreEqual(a.Type, b.Type);
            Assert.AreEqual(a.TTL, b.TTL);
            CollectionAssert.AreEqual(a.Strings, b.Strings);
        }