public void ChooseWithLastChoiceByOpponentIsNoneReturnsDefect() { // Arrange var strategy = new EvilCooperationStrategy(); // Act var choice = strategy.Choose(CooperationChoice.None); // Assert Assert.Equal(CooperationChoice.Defect, choice); }
public void ConstructorWithNullStrategyAThrowsArgumentNullException() { // Arrange CooperationStrategy nullStrategyA = null; var strategyB = new EvilCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); // Act // Assert Assert.Throws<ArgumentNullException>(() => new CooperationStrategyMatchup(nullStrategyA, strategyB, cooperationChoicePayoff)); }
public void CooperationChoicePayoffsReturnsCooperationChoicePayoffsSuppliedToConstructor() { // Arrange var strategyA = new NaiveCooperationStrategy(); var strategyB = new EvilCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); // Act var cooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, strategyB, cooperationChoicePayoff); // Assert Assert.Equal(cooperationChoicePayoff, cooperationStrategyMatchup.CooperationChoicesPayoff); }
public void CooperationStrategyMatchupReturnsCooperationStrategyMatchupSuppliedToConstructor() { // Arrange var strategyA = new NaiveCooperationStrategy(); var strategyB = new EvilCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); var matchup = new CooperationStrategyMatchup(strategyA, strategyB, cooperationChoicePayoff); // Act var simulation = new CooperationStrategyMatchupSimulation(matchup); // Assert Assert.Equal(matchup, simulation.Matchup); }
public void PlayReturnsCorrectCooperationStrategyMatchupResultForStrategyB() { // Arrange var strategyA = new NaiveCooperationStrategy(); var strategyB = new EvilCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); var cooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, strategyB, cooperationChoicePayoff); // Act var cooperationStrategyMatchupResult = cooperationStrategyMatchup.Play(); // Assert var correctCooperationStrategyResultForStrategyB = new CooperationStrategyResult { Strategy = strategyB, ChoiceMade = CooperationChoice.Defect, Payoff = CooperationChoicesPayoff.DefaultPayoffForDefectAndCooperate, }; Assert.Equal(correctCooperationStrategyResultForStrategyB, cooperationStrategyMatchupResult.StrategyBResult); }
public void EqualsWithUnequalStrategyBReturnsFalse() { // Arrange var strategyA = new EvilCooperationStrategy(); var cooperationChoicesPayoff = new CooperationChoicesPayoff(); var cooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, new NaiveCooperationStrategy(), cooperationChoicesPayoff); var unequalCooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, new EvilCooperationStrategy(), cooperationChoicesPayoff); // Act var objectsAreEqual = cooperationStrategyMatchup.Equals(unequalCooperationStrategyMatchup); // Assert Assert.False(objectsAreEqual); }
public void EqualsWithSameObjectInstanceReturnsTrue() { // Arrange var strategy = new EvilCooperationStrategy(); // Act var objectsAreEqual = strategy.Equals((object)strategy); // Assert Assert.True(objectsAreEqual); }