Example #1
0
        public void GetHashCode_NullValue_ReturnsZero()
        {
            var expected = 0;
            var actual   = Evaluate.GetHashCode(default(FakeTestItem));

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        public void GenerateHashCode_WithParamsArray_MatchesExpected()
        {
            var values   = new object[] { DateTime.Today, 2342, "asdsdfa2342345" };
            var expected = values.Aggregate(0, (i, o) => (i * 397) + Evaluate.GetHashCode(o));
            var actual   = Evaluate.GenerateHashCode(values);

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void GenerateHashCode_WithObjectEnumerable_MatchesExpected()
        {
            IEnumerable <object> values = Array.Empty <object>();
            var expected = values.Aggregate(0, (i, o) => (i * 397) + Evaluate.GetHashCode(o));
            var actual   = Evaluate.GenerateHashCode(values);

            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void GetHashCode_TestObject_ReturnsHashCode()
        {
            var value = new FakeTestItem {
                TestInt = 23252, TestString = "SomeString"
            };
            var expected = value.GetHashCode();
            var actual   = Evaluate.GetHashCode(value);

            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public void GenerateHashCode_WithSelectors_MatchesExpected()
        {
            var item = new FakeTestItem {
                TestDateTime = DateTime.Today, TestInt = 2342, TestString = "asdsdfa2342345"
            };
            IEnumerable <Func <FakeTestItem, object> > selectors = new Func <FakeTestItem, object>[]
            {
                dest => dest.TestDateTime,
                dest => dest.TestInt,
                dest => dest.TestString
            };

            var expected = new object[] { item.TestDateTime, item.TestInt, item.TestString }.Aggregate(
                0, (i, o) => (i * 397) + Evaluate.GetHashCode(o));

            var actual = Evaluate.GenerateHashCode(item, selectors);

            Assert.AreEqual(expected, actual);
        }