コード例 #1
0
ファイル: ReleaseTests.cs プロジェクト: santosb/FIFairy
        public void ShouldDisplayReleaseNumbersOfTheLastThreeMonths()
        {
            //given
            IEnumerable<ReleaseDetailsModel> expectedReleaseModel = new List<ReleaseDetailsModel>
                                                                  {
                                                                      new ReleaseDetailsModel ("Enzo", "REL1216", new DateTime(2011,10,20)),
                                                                      new ReleaseDetailsModel("Enzo", "REL54164", new DateTime(2011,10,20)),
                                                                      new ReleaseDetailsModel("Colombo", "REL1000", new DateTime(2011,10,20))
                                                                  };

            //when
            var releaseRepository = new Mock<IReleaseRepository>();
            DateTime dateNow = new DateTime(2012,01,21);
            DateTime dateTo = dateNow.AddMonths(-3);

            releaseRepository.Setup(x => x.GetReleases(dateTo)).Returns(expectedReleaseModel);
            var releaseController = new ReleaseController(releaseRepository.Object);
            ViewResult result = releaseController.ReleaseByDate(dateTo.Year, dateTo.Month, dateTo.Day);
            var model = (IEnumerable<ReleaseDetailsModel>)result.ViewData.Model;

            //then
            Assert.That(result.ViewName, Is.EqualTo("Release"));
            Assert.That(model, Is.EqualTo(expectedReleaseModel));
            Assert.That(model.First().TeamName, Is.EqualTo("Enzo"));
        }
コード例 #2
0
        public void ShouldDisplayReleasesNewerThanDate()
        {
            // TODO: Should this be DisplayReleasesForTheLastThreeMonths?

            //given
            DateTime dateTo = new DateTime(2012, 01, 21);
            IEnumerable<Release> expectedReleases = new List<Release>
                                                        {new Release("Enzo", "REL1216", dateTo.AddDays(1)),};

            //when
            var releaseRepository = new Mock<IReleaseRepository>();
            releaseRepository.Setup(x => x.GetReleases(dateTo)).Returns(expectedReleases);

            var releaseController = new ReleaseController(releaseRepository.Object);
            ViewResult result = releaseController.ReleaseByDate(dateTo.Year, dateTo.Month, dateTo.Day);
            var model = (IEnumerable<Release>) result.ViewData.Model;

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