示例#1
0
        public void Equals_1()
        {
            var t1 = new InlineTag(Tag.S, "*", "*", "t", null, null, null);
            var t2 = new InlineTag(Tag.S, "*", "*", "t", null, null, null);
            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.ToInlineString().Equals(s2.ToInlineString()).Is(true);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(true);
            s1.Append("abc");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(false);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(false);
            s2.Append("abc");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(true);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(true);
            s1.Append("def");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(false);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(false);
            s2.Append("def");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(true);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(true);
            s1.Append(t1);
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(false);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(false);
            s2.Append(t2);
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(true);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(true);

            s1.Append("xxx");
            s2.Append("yyy");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(false);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(false);
        }
示例#2
0
        public void GetHashCode_1()
        {
            var t1 = new InlineTag(Tag.S, "*", "*", "t", null, null, null);
            var t2 = new InlineTag(Tag.S, "*", "*", "t", null, null, null);

            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.ToInlineString().GetHashCode().Is(s2.ToInlineString().GetHashCode());

            s1.Append("abc");
            s1.ToInlineString().GetHashCode().IsNot(s2.ToInlineString().GetHashCode()); // very likely but not guaranteed
            s2.Append("abc");
            s1.ToInlineString().GetHashCode().Is(s2.ToInlineString().GetHashCode());
            s1.Append("def");
            s1.ToInlineString().GetHashCode().IsNot(s2.ToInlineString().GetHashCode()); // very likely but not guaranteed
            s2.Append("def");
            s1.ToInlineString().GetHashCode().Is(s2.ToInlineString().GetHashCode());
            s1.Append(t1);
            s1.ToInlineString().GetHashCode().IsNot(s2.ToInlineString().GetHashCode()); // very likely but not guaranteed
            s2.Append(t2);
            s1.ToInlineString().GetHashCode().Is(s2.ToInlineString().GetHashCode());

            s1.Append("xxx");
            s1.ToInlineString().GetHashCode().IsNot(s2.ToInlineString().GetHashCode()); // very likely but not guaranteed
            s2.Append("yyy");
            s1.ToInlineString().GetHashCode().IsNot(s2.ToInlineString().GetHashCode()); // very likely but not guaranteed
        }
示例#3
0
        public void Append_1()
        {
            var t1 = new InlineTag(Tag.S, "*", "*", "t1", null, null, null);
            var t2 = new InlineTag(Tag.S, "*", "*", "t2", null, null, null);

            var s = new InlineBuilder();

            s.Is();
            s.Append("");
            s.Is();
            s.Append("abc");
            s.Is("abc");
            s.Append("def");
            s.Is(new InlineText("abcdef"));
            s.Append("");
            s.Is(new InlineText("abcdef"));
            s.Append(t1);
            s.Is(new InlineText("abcdef"), t1);
            s.Append(t2);
            s.Is(new InlineText("abcdef"), t1, t2);
            s.Append("");
            s.Is(new InlineText("abcdef"), t1, t2);
            s.Append("xyz");
            s.Is(new InlineText("abcdef"), t1, t2, new InlineText("xyz"));
        }
示例#4
0
        public void IsEmpty_2()
        {
            var s = new InlineBuilder();

            s.IsEmpty.IsTrue();
            s.Count().Is(0);
            s.Append(new InlineTag(Tag.S, "*", "*", "t1", null, null, null));
            s.IsEmpty.IsFalse();
            s.Count().Is(1);
            s.Append("");
            s.IsEmpty.IsFalse();
            s.Count().Is(1);
            s.Append("a");
            s.IsEmpty.IsFalse();
            s.Count().Is(2);
        }
示例#5
0
        public void Equals_2()
        {
            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.Append("abc").Append("def");
            s2.Append("abcdef");
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(true);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(true);
        }
示例#6
0
        public void IsEmpty_1()
        {
            var s = new InlineBuilder();

            s.IsEmpty.IsTrue();
            s.Count().Is(0);
            s.Append("");
            s.IsEmpty.IsTrue();
            s.Count().Is(0);
            s.Append("a");
            s.IsEmpty.IsFalse();
            s.Count().Is(1);
            s.Append("");
            s.IsEmpty.IsFalse();
            s.Count().Is(1);
            s.Append("a");
            s.IsEmpty.IsFalse();
            s.Count().Is(1);
        }
示例#7
0
        public void Equals_3()
        {
            var t  = new InlineTag(Tag.S, "*", "*", "t", null, null, null);
            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.Append("abc");
            s2.Append(t);
            s1.ToInlineString().Equals(s2.ToInlineString()).Is(false);
            s2.ToInlineString().Equals(s1.ToInlineString()).Is(false);
        }
示例#8
0
        public void Equals_4()
        {
            var t1 = new InlineTag(Tag.S, "*", "*", "t", null, "{t}", null);
            var t2 = new InlineTag(Tag.S, "*", "*", "t", null, "{T}", null);

            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.Append(t1);
            s2.Append(t2);
            s1.ToInlineString().Equals(s2.ToInlineString()).IsFalse();
            s2.ToInlineString().Equals(s1.ToInlineString()).IsFalse();
        }
示例#9
0
        public void GetHashCode_4()
        {
            // InlineTag.GetHashCode doesn't see Display string anymore,
            // Hence InlineString.GetHashCode, either.

            var t1 = new InlineTag(Tag.S, "*", "", "t", null, "{t}", null);
            var t2 = new InlineTag(Tag.S, "*", "", "t", null, "{T}", null);

            var s1 = new InlineBuilder();
            var s2 = new InlineBuilder();

            s1.Append(t1);
            s2.Append(t2);
            s1.ToInlineString().GetHashCode().Is(s2.ToInlineString().GetHashCode());
        }
示例#10
0
        public void Append_2()
        {
            var t = new InlineTag(Tag.S, "*", "*", "t", null, null, null);
            var s = new InlineBuilder();

            AssertEx.Catch <ArgumentNullException>(() => s.Append((string)null));
            AssertEx.Catch <ArgumentNullException>(() => s.Append((InlineTag)null));
            AssertEx.Is(s);

            s.Append(t);
            AssertEx.Catch <ArgumentNullException>(() => s.Append((string)null));
            AssertEx.Catch <ArgumentNullException>(() => s.Append((InlineTag)null));
            s.Is(t);

            s.Append("abc");
            AssertEx.Catch <ArgumentNullException>(() => s.Append((string)null));
            AssertEx.Catch <ArgumentNullException>(() => s.Append((InlineTag)null));
            s.Is(t, new InlineText("abc"));
        }