Ejemplo n.º 1
0
        public async Task FetchPromotionsAsync_ShouldBeNoContentResult()
        {
            // Arrange
            TestMock.PromotionService.Setup(promotionService => promotionService.FetchPromotionsAsync()).ReturnsAsync(new List <Promotion>()).Verifiable();

            var controller = new PromotionController(TestMock.PromotionService.Object, TestMapper);

            // Act
            var result = await controller.FetchPromotionsAsync();

            // Assert
            result.Should().BeOfType <NoContentResult>();
            TestMock.PromotionService.Verify(promotionService => promotionService.FetchPromotionsAsync(), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task FetchPromotionsAsync_ShouldBeOkObjectResult()
        {
            // Arrange
            TestMock.PromotionService.Setup(promotionService => promotionService.FetchPromotionsAsync()).ReturnsAsync(GeneratePromotions()).Verifiable();

            var controller = new PromotionController(TestMock.PromotionService.Object, TestMapper);

            // Act
            var result = await controller.FetchPromotionsAsync();

            // Assert
            result.Should().BeOfType <OkObjectResult>();
            result.As <OkObjectResult>().Value.Should().BeEquivalentTo(TestMapper.Map <PromotionDto[]>(GeneratePromotions()));
            TestMock.PromotionService.Verify(promotionService => promotionService.FetchPromotionsAsync(), Times.Once);
        }