public void GetHashCodeWithUnchangedNewInstancesReturnsEqualHashCodes() { // Arrange var cooperationStrategyResult = new CooperationStrategyResult(); var otherCooperationStrategyResult = new CooperationStrategyResult(); // Act var hashCode = cooperationStrategyResult.GetHashCode(); var otherHashCode = otherCooperationStrategyResult.GetHashCode(); // Assert Assert.Equal(hashCode, otherHashCode); }
public void GetHashCodeWithNullStrategyDoesNotThrowException() { // Arrange var cooperationStrategyResult = new CooperationStrategyResult { Strategy = null }; // Act cooperationStrategyResult.GetHashCode(); // Assert }
public void GetHashCodeWithEqualValuesReturnsEqualHashCodes() { // Arrange var strategy = new NaiveCooperationStrategy(); var cooperationStrategyResult = new CooperationStrategyResult { Strategy = strategy, ChoiceMade = CooperationChoice.Defect, Payoff = CooperationChoicesPayoff.DefaultPayoffForDefectAndDefect }; var otherCooperationStrategyResult = new CooperationStrategyResult { Strategy = strategy, ChoiceMade = CooperationChoice.Defect, Payoff = CooperationChoicesPayoff.DefaultPayoffForDefectAndDefect }; // Act var hashCode = cooperationStrategyResult.GetHashCode(); var otherHashCode = otherCooperationStrategyResult.GetHashCode(); // Assert Assert.Equal(hashCode, otherHashCode); }
public void GetHashCodeWithDifferentPayoffReturnsDifferentHashCodes() { // Arrange var cooperationStrategyResult = new CooperationStrategyResult { Payoff = CooperationChoicesPayoff.DefaultPayoffForCooperateAndDefect }; var otherCooperationStrategyResult = new CooperationStrategyResult { Payoff = CooperationChoicesPayoff.DefaultPayoffForDefectAndCooperate }; // Act var hashCode = cooperationStrategyResult.GetHashCode(); var otherHashCode = otherCooperationStrategyResult.GetHashCode(); // Assert Assert.NotEqual(hashCode, otherHashCode); }
public void GetHashCodeWithDifferentCooperationStrategiesReturnsDifferentHashCodes() { // Arrange var cooperationStrategyResult = new CooperationStrategyResult { Strategy = new NaiveCooperationStrategy() }; var otherCooperationStrategyResult = new CooperationStrategyResult { Strategy = new EvilCooperationStrategy() }; // Act var hashCode = cooperationStrategyResult.GetHashCode(); var otherHashCode = otherCooperationStrategyResult.GetHashCode(); // Assert Assert.NotEqual(hashCode, otherHashCode); }
public void GetHashCodeWithDifferentChoiceMadeReturnsDifferentHashCodes() { // Arrange var cooperationStrategyResult = new CooperationStrategyResult { ChoiceMade = CooperationChoice.Cooperate }; var otherCooperationStrategyResult = new CooperationStrategyResult { ChoiceMade = CooperationChoice.Defect }; // Act var hashCode = cooperationStrategyResult.GetHashCode(); var otherHashCode = otherCooperationStrategyResult.GetHashCode(); // Assert Assert.NotEqual(hashCode, otherHashCode); }