public async Task PostGatewayReturnsBadRequestResult() { int testId = 1; bool success = true; var mockLogger = new Mock <ILogger <ConcertsController> >(); var mockService = new Mock <IGatewayService>(); mockService.Setup(c => c.PostConcert(It.IsAny <Concert>())) .ReturnsAsync((true, GetTestConcerts()[0])); mockService.Setup(c => c.PutSchedule(It.IsAny <Schedule>())) .ReturnsAsync(false); var controller = new ConcertsController(mockService.Object, mockLogger.Object); // Act var result = await controller.Post(concert : null); // Assert var requestResult = Assert.IsType <BadRequestResult>(result); }
public async Task PostGatewayReturnsCreatedAtActionResult() { int testId = 1; bool success = true; var mockLogger = new Mock <ILogger <ConcertsController> >(); var mockService = new Mock <IGatewayService>(); Schedule schedule = new Schedule(); mockService.Setup(c => c.PostSchedule(It.IsAny <Schedule>())) .ReturnsAsync(true); Concert concert = GetTestConcerts()[0]; mockService.Setup(c => c.PostConcert(It.IsAny <Concert>())) .ReturnsAsync((true, concert)); var controller = new ConcertsController(mockService.Object, mockLogger.Object); // Act var result = await controller.Post(concert); // Assert var requestResult = Assert.IsType <CreatedAtActionResult>(result); }