コード例 #1
0
        public async Task GetSingleGameHasCorrectID()
        {
            ControllerTestHelper helper = new ControllerTestHelper();
            Guid targetClientId         = helper.Games[0].ClientID;
            Guid targetGameId           = helper.Games[0].GameID;

            helper.Repository.Setup(x => x.GetGameByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(helper.Games[0]))
            .Verifiable();

            Game game = (Game)((await helper.ClientController.GetGame(targetClientId, targetGameId)).Result as OkObjectResult).Value;

            Assert.Equal(targetGameId, game.GameID);
        }
コード例 #2
0
        public async Task GetCharacterByCharacterIDAsyncHasCorrectID()
        {
            ControllerTestHelper helper = new ControllerTestHelper();

            Guid targetClientId    = helper.Clients[0].ClientID;
            Guid targetCharacterId = helper.Clients[0].Characters[0].CharacterID;

            helper.Repository
            .Setup(x => x.GetCharacterByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(helper.Clients[0].Characters[0]));

            Character character = (Character)((await helper.ClientController.GetCharacter(targetClientId, targetCharacterId)).Result as OkObjectResult).Value;

            Assert.Equal(targetCharacterId, character.CharacterID);
        }
コード例 #3
0
        public async Task CreateGameSuccessfulVerification()
        {
            ControllerTestHelper helper = new ControllerTestHelper();
            string targetName           = "Novum_Ludum";
            var    newGame        = new Game(helper.Clients[0].ClientID, targetName);
            Guid   targetClientId = helper.Clients[0].ClientID;

            helper.Repository.Setup(x => x.CreateGameAsync(It.IsAny <Guid>(), It.IsAny <string>()))
            .Returns(Task.FromResult(newGame))
            .Verifiable();

            Game game = (Game)((await helper.ClientController.PostGame(targetClientId, newGame)).Result as CreatedResult).Value;

            helper.Repository.Verify();
            Assert.NotNull(game);
        }
コード例 #4
0
        public async Task DeleteGameSuccessfulVerification()
        {
            ControllerTestHelper helper = new ControllerTestHelper();
            Guid targetClientId         = helper.Games[0].ClientID;
            Guid targetGameId           = helper.Games[0].GameID;

            helper.Repository.Setup(x => x.GetGameByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(helper.Games[0]))
            .Verifiable();
            helper.Repository.Setup(x => x.DeleteGameByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(true))
            .Verifiable();

            var result = await helper.ClientController.DeleteGame(targetClientId, targetGameId);

            helper.Repository.Verify();
        }
コード例 #5
0
        public async Task UpdateGameAsyncSuccessfulVerification()
        {
            ControllerTestHelper helper = new ControllerTestHelper();
            Guid targetClientId         = helper.Clients[0].ClientID;
            Guid targetGameId           = helper.Games[0].GameID;
            Game changedGame            = new Game();

            changedGame.GameName = "New Game Test Name";

            helper.Repository.Setup(x => x.GetGameByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(helper.Games[0]))
            .Verifiable();
            helper.Repository.Setup(x => x.UpdateGameAsync(It.IsAny <Guid>(), It.IsAny <Game>()))
            .Returns(Task.FromResult(true))
            .Verifiable();

            await helper.ClientController.PutGame(targetClientId, targetGameId, changedGame);

            helper.Repository.Verify();
        }
コード例 #6
0
        public async Task CreateCharacterAsyncSuccessfulVerification()
        {
            ControllerTestHelper helper = new ControllerTestHelper();

            Guid   targetClientId  = helper.Clients[0].ClientID;
            string targetFirstName = "Novum";
            string targetLastName  = "Ingenium";

            var  newCharacter      = new Character(targetClientId, targetFirstName, targetLastName);
            Guid targetCharacterId = newCharacter.CharacterID;

            helper.Repository
            .Setup(x => x.CreateCharacterAsync(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.FromResult(newCharacter))
            .Verifiable();

            var character = await helper.ClientController.PostCharacter(targetClientId, newCharacter);

            helper.Repository
            .Verify();
        }
コード例 #7
0
        public async Task UpdateCharacterAsyncSuccessfulVerification()
        {
            ControllerTestHelper helper = new ControllerTestHelper();

            Guid      targetClientId    = helper.Clients[0].ClientID;
            Guid      targetCharacterId = helper.Clients[0].Characters[0].CharacterID;
            Character changedCharacter  = new Character();

            helper.Repository
            .Setup(x => x.GetCharacterByIDAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(helper.Clients[0].Characters[0]))
            .Verifiable();
            helper.Repository
            .Setup(x => x.UpdateCharacterByIDAsync(It.IsAny <Guid>(), It.IsAny <Character>()))
            .Returns(Task.FromResult(true))
            .Verifiable();

            var character = await helper.ClientController.PutCharacter(targetClientId, targetCharacterId, changedCharacter);

            helper.Repository
            .Verify();
        }