Ejemplo n.º 1
0
        public void History_Returns_ViewResult_And_Model_With_Two_Versions()
        {
            // Arrange
            Page page = AddDummyPage1();

            _repository.PageContents.Add(new PageContent()
            {
                VersionNumber = 2, Page = page, Id = Guid.NewGuid(), Text = "v2text"
            });

            // Act
            ActionResult result = _pagesController.History(page.Id);

            // Assert
            Assert.That(result, Is.TypeOf <ViewResult>(), "ViewResult");
            ViewResult viewResult = result as ViewResult;

            List <PageHistoryViewModel> model = viewResult.ModelFromActionResult <IEnumerable <PageHistoryViewModel> >().ToList();

            Assert.That(model.Count, Is.EqualTo(2));
            Assert.That(model[0].PageId, Is.EqualTo(page.Id));
            Assert.That(model[1].PageId, Is.EqualTo(page.Id));
            Assert.That(model[0].VersionNumber, Is.EqualTo(2));             // latest first
            Assert.That(model[1].VersionNumber, Is.EqualTo(1));
        }