Beispiel #1
0
        public void TestEquals()
        {
            HdTimeSpan a1 = new HdTimeSpan(123);
            HdTimeSpan a2 = new HdTimeSpan(123);
            HdTimeSpan b  = new HdTimeSpan(42);

            Assert.True(a1 == a1);
            Assert.False(a1 != a1);

            Assert.True(a1 == a2);
            Assert.False(a1 != a2);
            Assert.True(a1.Equals(a2));
            Assert.True(a2.Equals(a1));

            Assert.True(a1.Equals((Object)a1));
            Assert.True(a1.Equals((Object)a2));
            Assert.True(a2.Equals((Object)a1));
            Assert.True(((Object)a1).Equals((Object)a1));
            Assert.True(((Object)a1).Equals((Object)a2));
            Assert.True(((Object)a2).Equals((Object)a1));
            Assert.True(((Object)a1).Equals((Object)a2));
            Assert.True(((Object)a2).Equals((Object)a1));

            Assert.False(a1 == b);
            Assert.False(a2 == b);
            Assert.True(a1 != b);

            Assert.False(a1.Equals(b));
            Assert.False(a2.Equals(b));

            Assert.False(a1.Equals((Object)b));
            Assert.False(((Object)a1).Equals(b));
            Assert.False(((Object)a1).Equals((Object)b));
        }
Beispiel #2
0
        private void CheckParse(String from, String fmt, HdTimeSpan expected)
        {
            HdTimeSpan parsed = HdTimeSpan.Parse(from, fmt);

            if (!expected.Equals(parsed))
            {
                // Comparison is here to avoid problems with Formatter affecting tests for Parser
                Assert.AreEqual(expected, parsed);
                Assert.AreEqual(expected.ToString(), parsed.ToString());
            }

            Assert.AreEqual(expected.TotalNanoseconds, parsed.TotalNanoseconds);
        }