public void ChooseWithLastChoiceByOpponentIsNoneReturnsCooperate() { // Arrange var strategy = new TitForTatCooperationStrategy(); // Act var choice = strategy.Choose(CooperationChoice.None); // Assert Assert.Equal(CooperationChoice.Cooperate, choice); }
public void PlayWithNullLastMatchupResultThrowsArgumentNullException() { // Arrange var strategyA = new TitForTatCooperationStrategy(); var strategyB = new TitForTatCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); var cooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, strategyB, cooperationChoicePayoff); CooperationStrategyMatchupResult nullLastMatchupResult = null; // Act // Assert Assert.Throws<ArgumentNullException>(() => cooperationStrategyMatchup.Play(nullLastMatchupResult)); }
public void PlayWithLastMatchupResultReturnsCorrectCooperationStrategyMatchupResultForStrategyB() { // Arrange var strategyA = new TitForTatCooperationStrategy(); var strategyB = new TitForTatCooperationStrategy(); var cooperationChoicePayoff = new CooperationChoicesPayoff(); var cooperationStrategyMatchup = new CooperationStrategyMatchup(strategyA, strategyB, cooperationChoicePayoff); var lastMatchupResult = new CooperationStrategyMatchupResult( new CooperationStrategyResult { Strategy = strategyA, ChoiceMade = CooperationChoice.Cooperate, Payoff = cooperationChoicePayoff.Calculate( CooperationChoice.Cooperate, CooperationChoice.Cooperate), }, new CooperationStrategyResult { Strategy = strategyB, ChoiceMade = CooperationChoice.Cooperate, Payoff = cooperationChoicePayoff.Calculate( CooperationChoice.Cooperate, CooperationChoice.Cooperate), }); // Act var cooperationStrategyMatchupResult = cooperationStrategyMatchup.Play(lastMatchupResult); // Assert var correctCooperationStrategyResultForStrategyB = new CooperationStrategyResult { Strategy = strategyB, ChoiceMade = CooperationChoice.Cooperate, Payoff = CooperationChoicesPayoff.DefaultPayoffForCooperateAndCooperate }; Assert.Equal(correctCooperationStrategyResultForStrategyB, cooperationStrategyMatchupResult.StrategyBResult); }