コード例 #1
0
        public void NoCookieCallRepoForView()
        {
            var helper                = GetHelper();
            var mockTopicRepo         = new Mock <ITopicRepository>();
            var topicViewCountService = new TopicViewCountService(mockTopicRepo.Object);

            topicViewCountService.ProcessView(new Topic(123), helper.MockContext.Object);
            mockTopicRepo.Verify(t => t.IncrementViewCount(123), Times.Once());
        }
コード例 #2
0
        public void CookieIsSet()
        {
            var helper                = GetHelper();
            var mockTopicRepo         = new Mock <ITopicRepository>();
            var topicViewCountService = new TopicViewCountService(mockTopicRepo.Object);

            topicViewCountService.ProcessView(new Topic(123), helper.MockContext.Object);
            Assert.AreEqual(1, helper.MockResponse.Object.Cookies.Count);
            var cookie = helper.MockResponse.Object.Cookies[0];

            Assert.AreEqual("123", cookie.Value);
            Assert.AreEqual("PopForums.LastTopicID", cookie.Name);
        }
コード例 #3
0
        public void CookiePresentNoMatchCallRepoForView()
        {
            var helper = GetHelper();

            helper.MockRequest.Object.Cookies.Set(new HttpCookie("PopForums.LastTopicID")
            {
                Value = "456"
            });
            var mockTopicRepo         = new Mock <ITopicRepository>();
            var topicViewCountService = new TopicViewCountService(mockTopicRepo.Object);

            topicViewCountService.ProcessView(new Topic(123), helper.MockContext.Object);
            mockTopicRepo.Verify(t => t.IncrementViewCount(123), Times.Once());
        }