public void Counts_Correct_When_History_Exists() { var history = new MoveHistory(); history.AddHistory(Moves.Rock, Moves.WaterBalloon); history.AddHistory(Moves.Scissors, Moves.Rock); var myHistoryCount = history.GetMyHistory().ToList().Count; var opponentHistoryCount = history.GetMyOppenentsHistory().ToList().Count; var bothCount = history.GetMyAndOpponentsHistory().ToList().Count(); Assert.Equal(2, myHistoryCount); Assert.Equal(2, opponentHistoryCount); Assert.Equal(2, bothCount); }
public void Predictions_Are_Null_When_Not_Enough_History() { var os = new OpponentRulesStrategy(3, new SimpleFitness()); var history = new MoveHistory(); var res = os.PredictOpponentsNextMove(history); Assert.Null(res); history.AddHistory(Moves.Rock, Moves.Rock); history.AddHistory(Moves.Rock, Moves.Rock); res = os.PredictOpponentsNextMove(history); Assert.Null(res); }
public void Retreived_Values_Correct_Order() { var history = new MoveHistory(); history.AddHistory(Moves.Rock, Moves.WaterBalloon); history.AddHistory(Moves.Scissors, Moves.Rock); var myHistory = history.GetMyHistory().ToList(); var opponentHistory = history.GetMyOppenentsHistory().ToList(); var both = history.GetMyAndOpponentsHistory().ToList(); Assert.Equal(myHistory[0], Moves.Scissors); Assert.Equal(myHistory[1], Moves.Rock); Assert.Equal(opponentHistory[0], Moves.Rock); Assert.Equal(opponentHistory[1], Moves.WaterBalloon); Assert.True(both[0].Equals(Tuple.Create(Moves.Scissors, Moves.Rock))); Assert.True(both[1].Equals(Tuple.Create(Moves.Rock, Moves.WaterBalloon))); }
public void Can_Make_Random_Predictions() { var mock = new Mock<IRandomNumber>(); int calls = 0; mock.Setup(r => r.Next(0, 4)) .Returns(() => calls) .Callback(() => calls++); var randomMovePredictor = new RandomStrategy(mock.Object, new SimpleFitness()); var moveHistory = new MoveHistory(); moveHistory.AddHistory(Moves.Rock, Moves.Rock); Assert.Equal(randomMovePredictor.PredictOpponentsNextMove(moveHistory), Moves.Paper); Assert.Equal(randomMovePredictor.PredictOpponentsNextMove(moveHistory), Moves.Scissors); Assert.Equal(randomMovePredictor.PredictOpponentsNextMove(moveHistory), Moves.Rock); Assert.Equal(randomMovePredictor.PredictOpponentsNextMove(moveHistory), Moves.Dynamite); Assert.Equal(randomMovePredictor.PredictOpponentsNextMove(moveHistory), Moves.WaterBalloon); }