Exemplo n.º 1
0
    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)));
    }
Exemplo n.º 2
0
    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>)));
    }
Exemplo n.º 3
0
    public void GetPawnsTest()
    {
        var playerId = Guid.NewGuid();
        var gameId   = Guid.NewGuid();
        var pawns    = RepositoryTestService.GetPawns(playerId, 10);

        this.moqPawnsRepository.Setup(m => m.GetPawns(gameId, playerId)).Returns(pawns);
        PawnsController pawnsController = new PawnsController(this.moqPawnsRepository.Object, this.autoMapper, this.moqGameStateManager.Object, this.moqBattleActionSimulator.Object);

        pawnsController = RepositoryTestService.AssignUserToController(pawnsController, playerId.ToString(), "TestPlayer");
        ;
        var result = pawnsController.GetPawns(gameId, playerId);

        Assert.IsNotNull(result);
        Assert.That(result.Result, Is.InstanceOf(typeof(OkObjectResult)));
        OkObjectResult okObjectResult = result.Result as OkObjectResult;

        Assert.AreEqual(okObjectResult.StatusCode, 200);
        Assert.AreEqual((okObjectResult.Value as IList <PawnDTO>).Count, 10);
    }
Exemplo n.º 4
0
    internal static IEnumerable <Game> GetGames()
    {
        var player1 = RepositoryTestService.GetRandomPlayer("Player1");
        var pawns1  = RepositoryTestService.GetPawns(player1.Id, 1);
        var game1   = RepositoryTestService.GetGame(Guid.NewGuid(), new Player[] { player1 }, pawns1);

        var player2 = RepositoryTestService.GetRandomPlayer("Player2");
        var pawns2  = RepositoryTestService.GetPawns(player2.Id, 2);
        var game2   = RepositoryTestService.GetGame(Guid.NewGuid(), new Player[] { player2 }, pawns2);

        var player3 = RepositoryTestService.GetRandomPlayer("Player3");
        var pawns3  = RepositoryTestService.GetPawns(player3.Id, 3);
        var game3   = RepositoryTestService.GetGame(Guid.NewGuid(), new Player[] { player3 }, pawns3);


        var games = new List <Game>();

        games.Add(game1);
        games.Add(game2);
        games.Add(game3);

        return(games);
    }
Exemplo n.º 5
0
 internal static Pawn GetPawn(Guid playerId)
 {
     return(RepositoryTestService.GetPawns(playerId, 1)[0]);
 }