Ejemplo n.º 1
0
        public async Task AwardsControllerGetMissedAwardTest()
        {
            var awardsService = new Mock <AwardsService>(null);

            awardsService.Setup(c => c.GetAwardAsync(It.IsAny <int>())).ReturnsAsync(null);

            AwardsController controller = new AwardsController(awardsService.Object);

            IActionResult actionResult = await controller.Get(5);

            var contentResult = actionResult as ObjectResult;

            Assert.NotNull(contentResult);
            Assert.Equal(404, contentResult.StatusCode);
        }
Ejemplo n.º 2
0
        //[Fact]
        public async Task AwardsControllerGetAwardTest()
        {
            AwardResponse response = _fixture.Create <AwardResponse>();

            var awardsService = new Mock <AwardsService>(null);

            awardsService.Setup(c => c.GetAwardAsync(It.IsAny <int>())).ReturnsAsync(response);

            AwardsController controller = new AwardsController(awardsService.Object);

            IActionResult actionResult = await controller.Get(response.AwardId);

            var contentResult = actionResult as ObjectResult;

            Assert.NotNull(contentResult);

            var content = contentResult.Value as Award;

            Assert.NotNull(content);
            Assert.Equal(response.AwardId, content.Id);
            Assert.Equal(response.Name, content.Name);
            //Assert.Equal(200, contentResult.StatusCode);
        }