public void CandidateFirstVisit(bool showSearchTourPreference) { var candidateId = Guid.NewGuid(); var candidateService = new Mock <ICandidateService>(); var helpPreferences = new HelpPreferences { ShowSearchTour = showSearchTourPreference }; candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).With(helpPreferences).Build); var provider = new HelpCookieProviderBuilder().With(candidateService).Build(); var httpResponse = new Mock <HttpResponseBase>(); var responseCookies = new HttpCookieCollection(); httpResponse.Setup(m => m.Cookies).Returns(responseCookies); var httpContext = new HttpContextBuilder().With(httpResponse).Build(); var showSearchTour = provider.ShowSearchTour(httpContext, candidateId); showSearchTour.Should().Be(showSearchTourPreference); var cookie = responseCookies.Get(HelpCookieProvider.CookieName); cookie.Should().NotBeNull(); var cookieValue = cookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()]; cookieValue.Should().Be(candidateId.ToString()); candidateService.Verify(cs => cs.GetCandidate(It.IsAny <Guid>()), Times.Once); }
public CandidateBuilder(Guid candidateId) { _candidateId = candidateId; _helpPreferences = new HelpPreferences(); _applicationTemplate = new ApplicationTemplate(); }
public CandidateBuilder With(HelpPreferences helpPreferences) { _helpPreferences = helpPreferences; return(this); }