Exemplo n.º 1
0
        public async Task DivisionsSuccess()
        {
            //Arrange
            var playerName         = "Testing Name";
            var playerRegion       = "Testing Region";
            var expected           = "Divisions";
            var mockRiotApiService = new Mock <IRiotApiService>();

            mockRiotApiService.Setup(r => r.GetDivisions(playerName, playerRegion)).ReturnsAsync(expected);
            var controller = new PlayerStatsController(mockRiotApiService.Object);

            //Act
            var result = await controller.Divisions(playerName, playerRegion);

            //Assert
            var actionResult = Assert.IsType <ActionResult <string> >(result);
            var returnValue  = Assert.IsType <string>(actionResult.Value);

            Assert.Equal(expected, returnValue);
        }
Exemplo n.º 2
0
        public async Task DivisionsGenericError()
        {
            //Arrange
            var playerName         = "Testing Name";
            var playerRegion       = "Testing Region";
            var expected           = "Server error";
            var mockRiotApiService = new Mock <IRiotApiService>();

            mockRiotApiService.Setup(r => r.GetDivisions(playerName, playerRegion)).ThrowsAsync(new Exception());
            var controller = new PlayerStatsController(mockRiotApiService.Object);

            //Act
            var result = await controller.Divisions(playerName, playerRegion);

            //Assert
            var actionResult = Assert.IsType <ActionResult <string> >(result);
            var objectResult = Assert.IsType <ObjectResult>(actionResult.Result);

            Assert.Equal(500, objectResult.StatusCode);
            var returnValue = Assert.IsType <string>(objectResult.Value);

            Assert.Equal(expected, returnValue);
        }