public void AddPawnsWithGameIdOrPlayerIdProblemTest() { var playerId = Guid.NewGuid(); IEnumerable <Pawn> pawns = RepositoryTestService.GetPawns(playerId, 5); var pawnsToCreate = this.autoMapper.Map <IEnumerable <PawnToCreateDTO> >(pawns); this.moqPawnsRepository.Setup(m => m.AddPawns(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IEnumerable <Pawn> >())).Returns(() => null); PawnsController pawnsController = new PawnsController(this.moqPawnsRepository.Object, this.autoMapper, this.moqGameStateManager.Object, this.moqBattleActionSimulator.Object); pawnsController = RepositoryTestService.AssignMockProblemDetailsFactoryToController <PawnsController>(pawnsController); var result = pawnsController.AddPawns(Guid.NewGuid(), playerId, pawnsToCreate); Assert.IsNotNull(result); Assert.That(result.Result, Is.InstanceOf(typeof(NotFoundResult))); }
public void AddPawnsTest() { var playerId = Guid.NewGuid(); IEnumerable <Pawn> pawns = RepositoryTestService.GetPawns(playerId, 5); var pawnsToCreate = this.autoMapper.Map <IEnumerable <PawnToCreateDTO> >(pawns); this.moqPawnsRepository.Setup(m => m.AddPawns(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IEnumerable <Pawn> >())).Returns(pawns); this.moqPawnsRepository.Setup(m => m.Save()).Returns(1); PawnsController pawnsController = new PawnsController(this.moqPawnsRepository.Object, this.autoMapper, this.moqGameStateManager.Object, this.moqBattleActionSimulator.Object); var result = pawnsController.AddPawns(Guid.NewGuid(), playerId, pawnsToCreate); Assert.IsNotNull(result); Assert.That(result.Result, Is.InstanceOf(typeof(CreatedAtRouteResult))); CreatedAtRouteResult createdAtRouteResult = result.Result as CreatedAtRouteResult; Assert.AreEqual(createdAtRouteResult.RouteName, "GetPawns"); Assert.AreEqual(createdAtRouteResult.StatusCode, 201); Assert.That(createdAtRouteResult.Value, Is.InstanceOf(typeof(IEnumerable <PawnDTO>))); }