Example #1
0
        public void TestStringNullY()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Name");

            int value = comparison(new TestClass(), null);

            Assert.AreEqual(-1, value);
        }
        public void TestIntXIsLess()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("Count");

            int value = comparison(TestStruct.SetCount(20), TestStruct.SetCount(100));

            Assert.AreEqual(-1, value);
        }
Example #3
0
        public void TestStringSameValue()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Name");

            int value = comparison(new TestClass(), new TestClass());

            Assert.AreEqual(0, value);
        }
Example #4
0
        public void TestIntSame()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Count");

            int value = comparison(new TestClass(), new TestClass());

            Assert.AreEqual(0, value);
        }
        public void TestStringNullXAndYProperties()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("Name");

            int value = comparison(TestStruct.NullName, TestStruct.NullName);

            Assert.AreEqual(0, value);
        }
        public void TestIntSame()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("Count");

            int value = comparison(TestStruct.Default, TestStruct.Default);

            Assert.AreEqual(0, value);
        }
        public void TestStringXIsGreater()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("Name");

            int value = comparison(TestStruct.SetName("Mario"), TestStruct.SetName("Abel"));

            Assert.AreEqual(1, value);
        }
        public void TestStringNullYProperty()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("Name");

            TestStruct t     = TestStruct.NullName;
            int        value = comparison(TestStruct.Default, t);

            Assert.AreEqual(1, value);
        }
        public void TestDateTimeSame()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("DateTime");

            DateTime time = DateTime.Now;

            int value = comparison(TestStruct.SetDateTime(time), TestStruct.SetDateTime(time));

            Assert.AreEqual(0, value);
        }
Example #10
0
        public void TestStringNullYProperty()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Name");

            TestClass t = new TestClass {
                Name = null
            };
            int value = comparison(new TestClass(), t);

            Assert.AreEqual(1, value);
        }
Example #11
0
        public void TestNullableIntBothNull()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("NullableInt");

            int value = comparison(new TestClass {
                NullableInt = null
            }, new TestClass {
                NullableInt = null
            });

            Assert.AreEqual(0, value);
        }
Example #12
0
        public void TestNullableIntYGreater()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("NullableInt");

            int value = comparison(new TestClass {
                NullableInt = 1
            }, new TestClass {
                NullableInt = 10
            });

            Assert.AreEqual(-1, value);
        }
        public void TestNullableIntYNull()
        {
            Comparison <TestStruct> comparison = DynamicType <TestStruct> .CreateComparison("NullableInt");

            int value = comparison(new TestStruct {
                NullableInt = 1
            }, new TestStruct {
                NullableInt = null
            });

            Assert.AreEqual(1, value);
        }
Example #14
0
        public void TestStringXIsGreater()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Name");

            int value = comparison(new TestClass {
                Name = "Mario"
            }, new TestClass {
                Name = "Able"
            });

            Assert.AreEqual(1, value);
        }
Example #15
0
        public void TestStringNullXAndYProperties()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Name");

            int value = comparison(new TestClass {
                Name = null
            }, new TestClass {
                Name = null
            });

            Assert.AreEqual(0, value);
        }
Example #16
0
        public void TestIntXIsGreater()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("Count");

            int value = comparison(new TestClass {
                Count = 100
            }, new TestClass {
                Count = 20
            });

            Assert.AreEqual(1, value);
        }
Example #17
0
        public void TestDateTimeSame()
        {
            Comparison <TestClass> comparison = DynamicType <TestClass> .CreateComparison("DateTime");

            DateTime time = DateTime.Now;

            int value = comparison(new TestClass {
                DateTime = time
            }, new TestClass {
                DateTime = time
            });

            Assert.AreEqual(0, value);
        }
        public void TestStringNullXProperty()
        {
            Comparison <TestStruct> dynComparison = DynamicType <TestStruct> .CreateComparison("Name");

            StructComparerString staticComparison = new StructComparerString();

            TestStruct x = TestStruct.NullName;
            TestStruct y = TestStruct.Default;

            int staticResult  = staticComparison.Compare(x, y);
            int dynamicResult = dynComparison(x, y);

            Assert.AreEqual(staticResult, dynamicResult);
            Assert.AreEqual(-1, dynamicResult);
        }