示例#1
0
        public void OfNullCollection_ShouldHaveZeroHashCode()
        {
            var firstCollection = (string[])null;
            var firstByValue    = new CollectionByValue <string>(firstCollection, StrictOptions);

            Assert.AreEqual(0, firstByValue.GetHashCode());
        }
示例#2
0
        public void OfSameCountCollectionsWithSameFirstItem_ShouldHaveSameHashCode()
        {
            var firstCollection  = new[] { "1" };
            var secondCollection = new[] { "1" };
            var firstByValue     = new CollectionByValue <string>(firstCollection, StrictOptions);
            var secondByValue    = new CollectionByValue <string>(secondCollection, StrictOptions);

            Assert.AreEqual(firstByValue.GetHashCode(), secondByValue.GetHashCode());
        }
示例#3
0
        public void OfCollectionWithNotComparableItems_ShouldNotThrowWhenGetHashCode([Values] bool strictOrdering)
        {
            var collection = new[]
            {
                new NotComparableClass(),
                new NotComparableClass()
            };

            var byValue = new CollectionByValue <NotComparableClass>(
                collection,
                new Options <NotComparableClass>(strictOrdering, null));

            Assert.DoesNotThrow(() => byValue.GetHashCode());
        }