public ViewResult Index(HazardousSubstanceRiskAssessmentSearchViewModel model) { var viewModel = _searchRiskAssessmentsViewModelFactory .WithTitle(model.title) .WithCompanyId(CurrentUser.CompanyId) .WithCreatedFrom(model.createdFrom) .WithCreatedTo(model.createdTo) .WithHazardousSubstanceId(model.hazardousSubstanceId) .WithAllowedSiteIds(CurrentUser.GetSitesFilter()) .WithCurrentUserId(CurrentUser.UserId) .WithSiteId(model.siteId) .WithSiteGroupId(model.siteGroupId) .WithShowDeleted(model.showDeleted) .WithShowArchived(model.showArchived) .WithPageNumber(model.Page !=default(int) ? model.Page : 1) .WithPageSize(model.Size != default(int) ? model.Size : PAGE_SIZE) .WithOrderBy(model.OrderBy) .GetViewModel(_hazardousSubstanceRiskAssessmentService); return View(viewModel); }
public void SetUp() { _allowedSites = new List<long>() {123L, 456L, 789L}; _searchViewModel = new HazardousSubstanceRiskAssessmentSearchViewModel() { title = "title", companyId = _companyId, createdFrom = _createdFrom, createdTo = _createdTo, siteGroupId = null, siteId = null, showDeleted = false, showArchived = false, isGeneralRiskAssessmentTemplating = false, hazardousSubstanceId = 123L, Page = 1, Size = 10, OrderBy = "Title-desc" }; _hazardousSubstanceAssessmentService = new Mock<IHazardousSubstanceRiskAssessmentService>(); _searchViewModelFactory = new Mock<ISearchRiskAssessmentsViewModelFactory>() {CallBase = true}; _searchViewModelFactory .Setup(x => x.WithTitle(It.IsAny<string>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithCompanyId(It.IsAny<long>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithCreatedFrom(It.IsAny<string>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithCreatedTo(It.IsAny<string>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithHazardousSubstanceId(It.IsAny<long>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithAllowedSiteIds(It.IsAny<IList<long>>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithCurrentUserId(It.IsAny<Guid>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithSiteId(It.IsAny<long?>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithSiteGroupId(It.IsAny<long?>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithShowArchived(It.IsAny<bool>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithShowDeleted(It.IsAny<bool>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithPageNumber(It.IsAny<int>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.WithPageSize(It.IsAny<int>())) .Returns(_searchViewModelFactory.Object); _searchViewModelFactory .Setup(x => x.GetViewModel(_hazardousSubstanceAssessmentService.Object)) .Returns(new SearchRiskAssessmentsViewModel()); _searchViewModelFactory .Setup(x => x.WithOrderBy(It.IsAny<string>())) .Returns(_searchViewModelFactory.Object); _createViewModelFactory = new Mock<ICreateRiskAssessmentViewModelFactory>(); _createViewModelFactory .Setup(x => x.WithCompanyId(It.IsAny<long>())) .Returns(_createViewModelFactory.Object); _createViewModelFactory .Setup(x => x.WithNewHazardousSubstanceId(It.IsAny<long>())) .Returns(_createViewModelFactory.Object); _createViewModelFactory .Setup(x => x.GetViewModel()) .Returns(new CreateRiskAssessmentViewModel()); _riskAssessmentService = new Mock<IHazardousSubstanceRiskAssessmentService>(); }