예제 #1
0
        public void GetReturnsCorrectPageFromRepository()
        {
            var urlModel = new PageUrlViewModel();
            var page = new Page();
            var expectedModel = new PageViewModel();

            Mock.Get(repository).Setup(r => r.SinglePage(It.IsAny<string>())).Returns(page);
            Mock.Get(mapper).Setup(m => m.Map<PageViewModel>(page)).Returns(expectedModel);

            var result = controller.Single(urlModel) as ViewResult;

            Assert.IsNotNull(result);
            Assert.That(result.Model, Is.EqualTo(expectedModel));
            Mock.Get(repository).Verify(r => r.SinglePage(urlModel.UrlTitle));
        }
예제 #2
0
        public void ReturnsCorrectSinglePageFromRavenDb()
        {
            const string url = "a-page-url";

            var expectedPage = new Page { Url = url };

            var session = WithSessionContainingPosts(new Page { Url = "not-the-correct-page" },
                                                     expectedPage,
                                                     new Page { Url = "also-not-the-correct-page" });

            var repository = new PageRepository(session);

            var post = repository.SinglePage(url);

            Assert.That(post, Is.EqualTo(expectedPage));
        }