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); }
public void CompareController_RemoveEmployerJS_Success_ReturnAddButtons() { // Arrange var controller = UiTestHelper.GetController <CompareController>(); long organisationId = 123; string employerIdentifier = "abc123"; string returnUrl = @"\viewing\search-results"; var employer = new Core.Models.EmployerSearchModel() { OrganisationIdEncrypted = employerIdentifier, OrganisationId = organisationId.ToString() }; controller.SearchViewService.LastSearchResults = new SearchViewModel() { Employers = new PagedResult <Core.Models.EmployerSearchModel>() { Results = new List <Core.Models.EmployerSearchModel>() { employer } } }; controller.CompareViewService.AddToBasket(employer.OrganisationIdEncrypted); var model = new AddRemoveButtonViewModel() { OrganisationIdEncrypted = employer.OrganisationIdEncrypted, OrganisationName = employer.Name }; // Act var result = controller.RemoveEmployerJs(employerIdentifier, 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, 0); Assert.IsFalse(controller.CompareViewService.ComparedEmployers.Value.Contains(employer.OrganisationIdEncrypted)); controller.AssertCookieDeleted(CookieNames.LastCompareQuery); }