public void CompareController_AddEmployer_Success_RedirectToReturnUrl() { // Arrange var controller = UiTestHelper.GetController <CompareController>(); long organisationId = 123; var expectedObfuscatedOrganisationId = ViewingControllerTests.ConfigureObfuscator(organisationId); var employerIdentifier = expectedObfuscatedOrganisationId; var returnUrl = @"\viewing\search-results"; controller.SearchViewService.LastSearchResults = new SearchViewModel() { Employers = new PagedResult <Core.Models.EmployerSearchModel>() { Results = new List <Core.Models.EmployerSearchModel>() { new Core.Models.EmployerSearchModel() { OrganisationIdEncrypted = employerIdentifier, OrganisationId = organisationId.ToString() } } } }; // Act var result = controller.AddEmployer(employerIdentifier, returnUrl) as LocalRedirectResult; // Assert Assert.NotNull(result); Assert.AreEqual(returnUrl, result.Url); Assert.AreEqual(controller.CompareViewService.BasketItemCount, 1); Assert.IsTrue(controller.CompareViewService.ComparedEmployers.Value.Contains(employerIdentifier)); controller.AssertCookieAdded(CookieNames.LastCompareQuery, expectedObfuscatedOrganisationId); }
public void CompareController_AddEmployerJS_Success_RedirectToReturnUrl() { // Arrange Config.SetAppSetting("SearchService:CacheResults", "true"); var controller = UiTestHelper.GetController <CompareController>(); string returnUrl = @"\viewing\search-results"; var organisationId = 123; var expectedObfuscatedOrganisationId = ViewingControllerTests.ConfigureObfuscator(organisationId); var employer = new Core.Models.EmployerSearchModel() { OrganisationIdEncrypted = expectedObfuscatedOrganisationId, OrganisationId = "123", Name = "Org123" }; var model = new AddRemoveButtonViewModel() { OrganisationIdEncrypted = employer.OrganisationIdEncrypted, OrganisationName = employer.Name }; controller.SearchViewService.LastSearchResults = new SearchViewModel() { Employers = new PagedResult <Core.Models.EmployerSearchModel>() { Results = new List <Core.Models.EmployerSearchModel>() { employer } } }; // Act var result = controller.AddEmployerJs(employer.OrganisationIdEncrypted, returnUrl) as PartialViewResult; // Assert Assert.NotNull(result); Assert.AreEqual(returnUrl, controller.ViewBag.ReturnUrl); Assert.AreEqual("Basket_Button", result.ViewName); CompareHelpers.Compare(model, result.Model); Assert.AreEqual(controller.CompareViewService.BasketItemCount, 1); Assert.IsTrue(controller.CompareViewService.ComparedEmployers.Value.Contains(model.OrganisationIdEncrypted)); controller.AssertCookieAdded(CookieNames.LastCompareQuery, expectedObfuscatedOrganisationId); }