public async Task GivenStartNumberGreaterThanLimitNumber_WhenGetFizzBuzz_ThenReturnBadRequest() { // Arrange var configuration = GetConfig(); var fizzBuzzService = new FizzBuzzService(new NullLogger <FizzBuzzService>()); var sut = new FizzBuzzController(configuration, new NullLogger <FizzBuzzController>(), fizzBuzzService); var startNumber = 30; // Act var fizzBuzzResult = await sut.GetFizzBuzz(startNumber); // Assert var badRequestObjectResult = (BadRequestObjectResult)fizzBuzzResult.Result; Assert.IsInstanceOf <BadRequestObjectResult>(badRequestObjectResult); Assert.AreEqual("The start number should not be greater than 30", badRequestObjectResult.Value); }
public async Task GivenStartNumber_WhenGetFizzBuzz_ThenReturnExpectedResult() { // Arrange var configuration = GetConfig(); var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperProfile()); }); var mapper = mockMapper.CreateMapper(); var fizzBuzzService = new FizzBuzzAppService(mapper, new FizzBuzzService(new NullLogger <FizzBuzzService>())); var sut = new FizzBuzzController(configuration, new NullLogger <FizzBuzzController>(), fizzBuzzService); // Act var fizzBuzzResult = await sut.GetFizzBuzz(1); // Assert Assert.IsInstanceOf <OkObjectResult>(fizzBuzzResult.Result); var okObjectResult = (OkObjectResult)fizzBuzzResult.Result; Assert.IsInstanceOf <FizzBuzzDto>(okObjectResult.Value); Assert.AreEqual(30, ((FizzBuzzDto)okObjectResult.Value).FizzBuzzResults.Count); }