public void CandidateSubsequentVisit()
        {
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();
            var provider         = new HelpCookieProviderBuilder().With(candidateService).Build();
            var httpRequest      = new Mock <HttpRequestBase>();
            var requestCookies   = new HttpCookieCollection();
            var existingCookie   = new HttpCookie(HelpCookieProvider.CookieName);

            existingCookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()] = candidateId.ToString();
            requestCookies.Add(existingCookie);
            httpRequest.Setup(m => m.Cookies).Returns(requestCookies);
            var httpResponse    = new Mock <HttpResponseBase>();
            var responseCookies = new HttpCookieCollection();

            httpResponse.Setup(m => m.Cookies).Returns(responseCookies);
            var httpContext = new HttpContextBuilder().With(httpRequest).With(httpResponse).Build();

            var showSearchTour = provider.ShowSearchTour(httpContext, candidateId);

            showSearchTour.Should().BeFalse();
            var cookie = responseCookies.Get(HelpCookieProvider.CookieName);

            cookie.Should().BeNull();
            candidateService.Verify(cs => cs.GetCandidate(It.IsAny <Guid>()), Times.Never);
        }
        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 void VisitorFirstVisit()
        {
            var provider        = new HelpCookieProviderBuilder().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, null);

            showSearchTour.Should().BeTrue();
            var cookie = responseCookies.Get(HelpCookieProvider.CookieName);

            cookie.Should().NotBeNull();
            var cookieValue = cookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()];

            cookieValue.Should().Be(Guid.Empty.ToString());
        }
        public void VisitorSubsequentVisit()
        {
            var provider       = new HelpCookieProviderBuilder().Build();
            var httpRequest    = new Mock <HttpRequestBase>();
            var requestCookies = new HttpCookieCollection();
            var existingCookie = new HttpCookie(HelpCookieProvider.CookieName);

            existingCookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()] = Guid.Empty.ToString();
            requestCookies.Add(existingCookie);
            httpRequest.Setup(m => m.Cookies).Returns(requestCookies);
            var httpResponse    = new Mock <HttpResponseBase>();
            var responseCookies = new HttpCookieCollection();

            httpResponse.Setup(m => m.Cookies).Returns(responseCookies);
            var httpContext = new HttpContextBuilder().With(httpRequest).With(httpResponse).Build();

            var showSearchTour = provider.ShowSearchTour(httpContext, null);

            showSearchTour.Should().BeFalse();
            var cookie = responseCookies.Get(HelpCookieProvider.CookieName);

            cookie.Should().BeNull();
        }