예제 #1
0
            public void GetHashCode_ReturnsTheSameHashCode_WhenTheReferencesAreTheSame()
            {
                // Arrange
                IContext contextL = Substitute.For <IContext>();
                AbstractRepositoryFactory <IContext> abstractRepositoryFactoryL = Substitute.ForPartsOf <AbstractRepositoryFactory <IContext> >(contextL);
                int hashCodeL;

                AbstractRepositoryFactory <IContext> abstractRepositoryFactoryR = abstractRepositoryFactoryL;
                int hashCodeR;

                bool theSame;

                // Act
                hashCodeL = abstractRepositoryFactoryL.GetHashCode();
                hashCodeR = abstractRepositoryFactoryR.GetHashCode();
                theSame   = hashCodeL == hashCodeR;

                // Assert
                Assert.True(theSame);
            }
예제 #2
0
            public void GetHashCode_ReturnsDifferentHashCodes_WhenTheContextAndReferenceAreDifferent()
            {
                // Arrange
                IContext contextL = Substitute.For <IContext>();
                AbstractRepositoryFactory <IContext> abstractRepositoryFactoryL = Substitute.ForPartsOf <AbstractRepositoryFactory <IContext> >(contextL);
                int hashCodeL;

                IContext contextR = Substitute.For <IContext>();
                AbstractRepositoryFactory <IContext> abstractRepositoryFactoryR = Substitute.ForPartsOf <AbstractRepositoryFactory <IContext> >(contextR);
                int hashCodeR;

                bool theSame;

                // Act
                hashCodeL = abstractRepositoryFactoryL.GetHashCode();
                hashCodeR = abstractRepositoryFactoryR.GetHashCode();
                theSame   = hashCodeL == hashCodeR;

                // Assert
                Assert.False(theSame);
            }