示例#1
0
        private static void test_GetHashCode <T>(T t1, T t2)
        {
            var strong1 = new StrongType <T>(t1);
            var strong2 = new StrongType <T>(t2);

            if (t1 != null)
            {
                Assert.AreEqual(t1.GetHashCode(), strong2.GetHashCode());
                Assert.AreEqual(t1.GetHashCode(), strong2.Value.GetHashCode());
            }

            if (t2 != null)
            {
                Assert.AreEqual(strong1.GetHashCode(), t2.GetHashCode());
                Assert.AreEqual(strong1.Value.GetHashCode(), t2.GetHashCode());
            }

            Assert.AreEqual(strong1.GetHashCode(), strong2.GetHashCode());
            if (strong1.Value != null)
            {
                Assert.AreEqual(strong1.Value.GetHashCode(), strong2.GetHashCode());
            }
            if (strong2.Value != null)
            {
                Assert.AreEqual(strong1.GetHashCode(), strong2.Value.GetHashCode());
            }
            if (strong1.Value != null && strong2.Value != null)
            {
                Assert.AreEqual(strong1.Value.GetHashCode(), strong2.Value.GetHashCode());
            }
        }
示例#2
0
        private static void compare_Value <T>(T t1, T t2, bool isSame)
        {
            var strong1 = new StrongType <T>(t1);
            var strong2 = new StrongType <T>(t2);

            if (strong1.Value != null)
            {
                Assert.AreEqual(isSame, strong1.Value.Equals(t2));
                Assert.AreEqual(isSame, strong1.Value.Equals(strong2.Value));
            }
            Assert.AreEqual(isSame, strong1.Equals(strong2.Value));
        }
示例#3
0
    static void Main(string[] args)
    {
#if !DONT_EVEN_CALL
        var inst = new StrongType();
        WriteLine($@"
Instance says   : {inst.Variant}
Its assembly is : {inst.MyAssy}
Maifest module  : {inst.MyAssy.ManifestModule.FullyQualifiedName}
Maifest MVID    : {inst.MyAssy.ManifestModule.ModuleVersionId}
");
#endif
    }
示例#4
0
        private static void compare_2_strong_types <T>(T t1, T t2, bool isSame)
        {
            var strong1 = new StrongType <T>(t1);
            var strong2 = new StrongType <T>(t2);

            // compare 2 strong types
            Assert.AreEqual(isSame, strong1.Equals(strong2));
            Assert.AreEqual(isSame, strong1 == strong2);
            Assert.AreEqual(!isSame, strong1 != strong2);
            // compare 2 strong types, order reversed
            Assert.AreEqual(isSame, strong2.Equals(strong1));
            Assert.AreEqual(isSame, strong2 == strong1);
            Assert.AreEqual(!isSame, strong2 != strong1);
        }
示例#5
0
        private static void compare_strong_type_to_value <T>(T t1, T t2, bool isSame)
        {
            var strong1 = new StrongType <T>(t1);
            var strong2 = new StrongType <T>(t2);

            // compare value (left) to strong type (right)
            Assert.AreEqual(isSame, t1 == strong2);
            Assert.AreEqual(!isSame, t1 != strong2);

            // compare strong type (left) to value (right)
            Assert.AreEqual(isSame, strong1.Equals(t2));
            Assert.AreEqual(isSame, strong1 == t2);
            Assert.AreEqual(!isSame, strong1 != t2);
        }
示例#6
0
        private static void test_ToString <T>(T t1, T t2)
        {
            var strong1 = new StrongType <T>(t1);
            var strong2 = new StrongType <T>(t2);

            Assert.AreEqual(t1?.ToString(), strong2?.ToString());
            Assert.AreEqual(t1?.ToString(), strong2.Value?.ToString());

            Assert.AreEqual(strong1?.ToString(), t2?.ToString());
            Assert.AreEqual(strong1?.ToString(), strong2?.ToString());
            Assert.AreEqual(strong1?.ToString(), strong2.Value?.ToString());

            Assert.AreEqual(strong1.Value?.ToString(), t2?.ToString());
            Assert.AreEqual(strong1.Value?.ToString(), strong2?.ToString());
            Assert.AreEqual(strong1.Value?.ToString(), strong2.Value?.ToString());
        }