public async Task Get_WhenCCGNotReturnedFromDataLayer_Returns404NotFound() { //Arrange _mockService.Setup(s => s.GetCCGDetails(It.IsAny <string>())).Returns(Task.FromResult <CCGModel>(null)); var sut = new CCGController(_mockService.Object); //Act var response = await sut.Get("So302un"); //Assert Assert.IsInstanceOf <NotFoundResult>(response, TestContext.CurrentContext.Test.Expectation()); }
public async Task Get_WithNoPostcode_Returns400BadRequest() { //Arrange var sut = new CCGController(_mockService.Object); //Act var response = await sut.Get(null); //Assert Assert.IsInstanceOf <BadRequestResult>(response, TestContext.CurrentContext.Test.Expectation()); //Act response = await sut.Get(""); //Assert Assert.IsInstanceOf <BadRequestResult>(response, TestContext.CurrentContext.Test.Expectation()); }
public async Task Get_WhenCCGReturnedFromDataLayer_Returns200OK() { //Arrange var expectedCCG = new CCGModel { Postcode = "So302un" }; _mockService.Setup(s => s.GetCCGDetails(It.IsAny <string>())).Returns(Task.FromResult(expectedCCG)); var sut = new CCGController(_mockService.Object); //Act var response = await sut.Get("So302un"); //Assert Assert.IsInstanceOf <OkObjectResult>(response, TestContext.CurrentContext.Test.Expectation()); var model = (response as OkObjectResult)?.Value; Assert.IsInstanceOf <CCGModel>(model, TestContext.CurrentContext.Test.Expectation()); Assert.AreEqual(expectedCCG.Postcode, ((CCGModel)model).Postcode, TestContext.CurrentContext.Test.Expectation()); }