public void ShouldInsertMoveResponses() { //arrange var moveResponses = new MoveResponse[] { new MoveResponse() { Board = "____X____", Outcome = GameState.XWin, Player = Player.X, Response = Move.Southern }, new MoveResponse() { Board = "X__XX__OO", Outcome = GameState.OWin, Player = Player.O, Response = Move.Northern } }; IEnumerable <MoveResponseRecord> responsesReceived = null; MockLiteDatabase .Setup(a => a.InsertBulk(It.IsAny <IEnumerable <MoveResponseRecord> >())) .Callback <IEnumerable <MoveResponseRecord> >(a => responsesReceived = a); //act MoveResponseRepository.InsertMoveResponses(moveResponses); //assert var expectedMoveResponses = new MoveResponseRecord[] { new MoveResponseRecord() { Board = "____X____", Outcome = GameState.XWin, Player = Player.X, Response = Move.Southern }, new MoveResponseRecord() { Board = "X__XX__OO", Outcome = GameState.OWin, Player = Player.O, Response = Move.Northern } }; MockLiteDatabase .Verify(a => a.InsertBulk(It.IsAny <IEnumerable <MoveResponseRecord> >()), Times.Once()); MockLiteDatabase .Verify(a => a.EnsureIndex(It.IsAny <Expression <Func <MoveResponseRecord, string> > >(), false), Times.Once()); expectedMoveResponses.ShouldAllBeEquivalentTo(responsesReceived); }
public void ShouldFindMoveResponses() { //arrange var aBoardPosition = "___XOX___"; var aPlayer = Player.X; var moveResponseRecords = new MoveResponseRecord[] { new MoveResponseRecord() { Board = "____X____", Outcome = GameState.XWin, Player = Player.X, Response = Move.Southern }, new MoveResponseRecord() { Board = "X__XX__OO", Outcome = GameState.OWin, Player = Player.O, Response = Move.Northern } }; MockLiteDatabase .Setup(a => a.FindByIndex(It.IsAny <Expression <Func <MoveResponseRecord, bool> > >())) .Returns(moveResponseRecords); //act var results = MoveResponseRepository.FindMoveResponses(aBoardPosition, aPlayer); //assert var expectedMoveResponses = new MoveResponse[] { new MoveResponse() { Board = "____X____", Outcome = GameState.XWin, Player = Player.X, Response = Move.Southern } }; results.ShouldAllBeEquivalentTo(expectedMoveResponses); }