public void GetTicketByUserId_WithNonExistingUser_ReturnsNotFoundResults() { //Arrange var userId = "test"; repoStub.Setup(repo => repo.GetUserTickets(userId)) .Returns((List <Ticket>)null); var sut = new TicketController(repoStub.Object); //Act var result = sut.GetTicketByUserId(userId); //Assert repoStub.VerifyAll(); var returnValue = Assert.IsType <NotFoundObjectResult>(result); Assert.IsType <NotFoundObjectResult>(result); Assert.Equal($"Tickets associated with the User Id of {userId} do not exist", returnValue.Value); }
public void GetTicketByUserId_WithExistingUser_ListOfTicketsOkObjectResult(string userId, List <Ticket> tickets) { //Arrange repoStub.Setup(repo => repo.GetUserTickets(userId)) .Returns(tickets); //creates a controller object and passes in our mock dependency var sut = new TicketController(repoStub.Object); //Act var result = sut.GetTicketByUserId(userId); //Assert repoStub.VerifyAll(); var returnValue = Assert.IsType <OkObjectResult>(result); Assert.IsType <OkObjectResult>(result); Assert.Equal(tickets, returnValue.Value); }