Esempio n. 1
0
        public void ShouldDisplayLastFiveReleasesOrderedByDate()
        {
            //given
            IEnumerable <Release> expectedReleases = new List <Release>
            {
                new Release("Enzo", "REL4", DateTime.Today.AddMonths(-1).AddDays(2)),
                new Release("Enzo", "REL5", DateTime.Today.AddMonths(-1).AddDays(1)),
                new Release("Bob", "REL6", DateTime.Today.AddMonths(-1)),
                new Release("Enzo", "REL1", DateTime.Today.AddMonths(-2)),
                new Release("Phoenix", "REL2", DateTime.Today.AddMonths(-2)),
                new Release("Fire", "REL3", DateTime.Today.AddMonths(-2))
            };

            //when
            var releaseRepository = new Mock <IReleaseRepository>();

            releaseRepository.Setup(x => x.GetLastFiveReleases()).Returns(expectedReleases);

            var        dashboardController = new ReleaseController(releaseRepository.Object);
            ViewResult result = dashboardController.LastFiveReleases();
            var        model  = (IEnumerable <Release>)result.ViewData.Model;

            //then
            Assert.That(result.ViewName, Is.EqualTo("ReleaseSummary"));
            Assert.That(model, Is.EqualTo(expectedReleases));
        }