public void Equals()
        {
            var ext1 = new ExtensionSubtag();
            var ext2 = new ExtensionSubtag();

            var ext3 = new ExtensionSubtag('a', "aaa");
            var ext4 = new ExtensionSubtag('a', "aaa");

            var ext5 = new ExtensionSubtag('b', "aaa");
            var ext6 = new ExtensionSubtag('b', "bbb");

            Assert.IsFalse(ext1.Equals(null));
            Assert.IsTrue(ext1.Equals((object)ext2));
            Assert.IsTrue(ext1.Equals(ext1));
            Assert.IsTrue(ext1.Equals(ext2));
            Assert.IsFalse(ext1.Equals(ext3));
            Assert.IsTrue(ext3.Equals(ext3));
            Assert.IsTrue(ext3.Equals(ext4));
            Assert.IsFalse(ext4.Equals(ext5));
            Assert.IsFalse(ext5.Equals(ext6));

            Assert.IsTrue(ext1 == ext2);
            Assert.IsFalse(ext1 != ext2);

            Assert.IsTrue(ext3 != ext5);
            Assert.IsFalse(ext3 == ext5);
        }
        public void Empty()
        {
            var empty = new ExtensionSubtag();

            Assert.IsTrue(empty.IsEmpty);
            Assert.AreEqual("", empty.ToString());
            Assert.That(empty.ToArray(), Is.Empty);
        }
Exemple #3
0
        public static ExtensionSubtag ParseFromExtensionSubtag(this string text)
        {
            var result = ExtensionSubtag.TryParse(new LanguageTag.TokenEnumerator(text));

            if (result.HasValue)
            {
                return(result.Value);
            }

            throw new FormatException("unexpected extension subtag '" + text + "'");
        }
        public void Enumerate(string[] subtags)
        {
            var ext = new ExtensionSubtag('a', subtags);

            Assert.That(ext, Is.EquivalentTo(subtags));
        }
        public void ToString(string[] subtags, string expected)
        {
            var ext = new ExtensionSubtag('a', subtags);

            Assert.AreEqual(expected, ext.ToString());
        }