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); }
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); }