public void Search() { // Arrange var spec = DomainModelFactory.TicketSpecification(); var items = DomainModelFactory.PagedList_TicketSearchResult(2); controller.ValueProvider = DomainModelFactory.ValueProvider(spec); ValidationServiceMock .Setup(validationService => validationService.Validate(It.IsAny <TicketSpecification>())) .Callback <TicketSpecification>(s => AssertHelper.Equal(spec, s)) .Returns(true); mockMementoService .Setup(memento => memento.Save(It.IsAny <TicketSpecification>())) .Returns(true); mockTicketService .Setup(ticketService => ticketService.SearchTickets(It.IsAny <TicketSpecification>(), null, null)) .Returns(items); // Act var result = controller.Search() as ViewResult; // Assert Assert.NotNull(result); Assert.Equal("List", result.ViewName); var viewdata = result.ViewData.Model as TicketListViewData; Assert.NotNull(viewdata); Assert.NotNull(viewdata.Specification); AssertHelper.Equal(spec, viewdata.Specification); Assert.NotNull(viewdata.Items); Assert.Equal(items, viewdata.Items); }
protected override void Dispose(bool disposing) { if (!disposing) { return; } DependencyResolver.Reset(); ValidationServiceMock.VerifyAll(); UnitOfWorkMock.VerifyAll(); DependencyResolverMock.VerifyAll(); }
public void Search_Validation_Failed() { // Arrange SetupViewDataLists(); ValidationServiceMock .Setup(validationService => validationService.Validate(It.IsAny <TicketSpecification>())) .Returns(false); // Act var result = controller.Search() as ViewResult; // Assert Assert.NotNull(result); Assert.Equal(string.Empty, result.ViewName); }