コード例 #1
0
        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);
        }
コード例 #2
0
 public CandidateBuilder(Guid candidateId)
 {
     _candidateId         = candidateId;
     _helpPreferences     = new HelpPreferences();
     _applicationTemplate = new ApplicationTemplate();
 }
コード例 #3
0
 public CandidateBuilder With(HelpPreferences helpPreferences)
 {
     _helpPreferences = helpPreferences;
     return(this);
 }