public void GetHashCode_Equal()
        {
            var c1 =
                new ClassContext(
                    typeof(BaseType1),
                    new[] { CreateBT1Mixin1Context(), CreateBT2Mixin2Context() },
                    new[] { typeof(IBT5MixinC1), typeof(IBT5MixinC2) });
            var c2 =
                new ClassContext(
                    typeof(BaseType1),
                    new[] { CreateBT1Mixin1Context(), CreateBT2Mixin2Context() },
                    new[] { typeof(IBT5MixinC1), typeof(IBT5MixinC2) });
            var c3 =
                new ClassContext(
                    typeof(BaseType1),
                    new[] { CreateBT2Mixin2Context(), CreateBT1Mixin1Context() },
                    new[] { typeof(IBT5MixinC1), typeof(IBT5MixinC2) });
            var c4 =
                new ClassContext(
                    typeof(BaseType1),
                    new[] { CreateBT1Mixin1Context(), CreateBT2Mixin2Context() },
                    new[] { typeof(IBT5MixinC2), typeof(IBT5MixinC1) });

            Assert.That(c2.GetHashCode(), Is.EqualTo(c1.GetHashCode()));
            Assert.That(c3.GetHashCode(), Is.EqualTo(c1.GetHashCode()));
            Assert.That(c4.GetHashCode(), Is.EqualTo(c1.GetHashCode()));

            var c5 = ClassContextObjectMother.Create(typeof(BaseType1));
            var c6 = ClassContextObjectMother.Create(typeof(BaseType1));

            Assert.That(c6.GetHashCode(), Is.EqualTo(c5.GetHashCode()));
        }
Example #2
0
 public override int GetHashCode()
 {
     return(ClassContext.GetHashCode() ^ RuntimeHelpers.GetHashCode(Instance));
 }