public async Task GetRoomShouldReturnNotFound() { //arrange var mockRepo = new Mock <IRepository>(); var mockLogger = new Mock <ILogger <ComplexController> >(); mockRepo.Setup(r => r.ReadRoomAsync( It.IsAny <Guid>())).Throws(new InvalidOperationException()); var controller = new ComplexController(mockRepo.Object, mockLogger.Object); //act var result = await controller.GetRoomAsync(Guid.NewGuid()); //assert Assert.IsType <NotFoundResult>(result); }
public async Task GetRoomShouldReturnRoom() { //arrange var mockRepo = new Mock <IRepository>(); var mockLogger = new Mock <ILogger <ComplexController> >(); mockRepo.Setup(r => r.ReadRoomAsync( It.IsAny <Guid>())).Returns(Task.FromResult <Lib.Room>( new Lib.Room() )); var controller = new ComplexController(mockRepo.Object, mockLogger.Object); //act var result = await controller.GetRoomAsync(Guid.NewGuid()); //assert Assert.IsAssignableFrom <OkObjectResult>(result); }