Ejemplo n.º 1
0
        public VisitorStatus GetVisitorStatus(IMember member)
        {
            // A logged in user does not get any prompts.

            if (member != null)
            {
                return new VisitorStatus {
                           Frequency = VisitorFrequency.Heavy, ShouldPrompt = false
                }
            }
            ;

            var views             = GetValue(SessionKeys.Views);
            var applications      = GetValue(SessionKeys.Applications);
            var occasionalPrompts = GetValue(SessionKeys.OccasionalPrompts);
            var casualPrompts     = GetValue(SessionKeys.CasualPrompts);
            var status            = _visitorStatusQuery.GetVisitorStatus(views, applications, occasionalPrompts, casualPrompts);

            // Keep track of how many times the prompts have been shown.

            if (status.ShouldPrompt)
            {
                switch (status.Frequency)
                {
                case VisitorFrequency.Occasional:
                    _session[SessionKeys.OccasionalPrompts] = occasionalPrompts + 1;
                    break;

                case VisitorFrequency.Casual:
                    _session[SessionKeys.CasualPrompts] = casualPrompts + 1;
                    break;
                }
            }

            return(status);
        }
Ejemplo n.º 2
0
        public void TestSearches()
        {
            var search = 0;

            // Less than the first prompt is a new visitor.

            for (; search < _occasionalPrompts[0]; ++search)
            {
                AssertStatus(VisitorFrequency.New, false, _visitorStatusQuery.GetVisitorStatus(search, 0, 0, 0));
            }

            // Prompt on the next search and frequency changes.

            AssertStatus(VisitorFrequency.Occasional, true, _visitorStatusQuery.GetVisitorStatus(search, 0, 0, 0));

            // Look for next prompts.

            var prompt = 1;

            for (; prompt < _occasionalPrompts.Length; ++prompt)
            {
                // No prompt.

                ++search;
                for (; search < _occasionalPrompts[prompt]; ++search)
                {
                    AssertStatus(VisitorFrequency.Occasional, false, _visitorStatusQuery.GetVisitorStatus(search, 0, prompt, 0));
                }

                // Prompt.

                AssertStatus(VisitorFrequency.Occasional, true, _visitorStatusQuery.GetVisitorStatus(search, 0, prompt, 0));
            }

            // After that no prompt.

            ++search;
            for (; search < 100; ++search)
            {
                AssertStatus(VisitorFrequency.Occasional, false, _visitorStatusQuery.GetVisitorStatus(search, 0, prompt, 0));
            }
        }