コード例 #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
ファイル: CreateReleaseTests.cs プロジェクト: santosb/FIFairy
        public void ShouldCreateReleaseWithPrePatEmail()
        {
            //given
            var releaseRepository = new Mock<IReleaseRepository>();
            var releaseController = new ReleaseController(releaseRepository.Object);

            //We'll need mocks (fake) of Context, Request and a fake PostedFile
            var postedfile = new Mock<HttpPostedFileBase>();
            var release = new Release();

            //Someone is going to ask for Request.File and we'll need a mock (fake) of that.
            string expectedFileName = "Enzo Pre-PAT release 19122011 ref REL11125.0.00";
            string expectedFileTypeExtension = ".msg";
            string savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                String.Concat(expectedFileName, expectedFileTypeExtension));

            postedfile.Setup(f => f.ContentLength).Returns(8192);
            postedfile.Setup(f => f.FileName).Returns(String.Concat(expectedFileName, expectedFileTypeExtension));

            releaseRepository.Setup(m => m.SaveReleaseDetails(It.IsAny<Release>()));

            //when
            releaseController.Create(release, postedfile.Object);

            //Then
            releaseRepository.Verify(x => x.SaveReleaseDetails(It.IsAny<Release>()), Times.Once());
            postedfile.Verify(x => x.SaveAs(savedFileName), Times.Once());

            Assert.That(release.PrePatEmailFile.Name, Is.EqualTo(savedFileName));
            Assert.That(release.PrePatEmailFile.Length, Is.EqualTo(8192));
        }
コード例 #3
0
ファイル: CreateReleaseTests.cs プロジェクト: santosb/FIFairy
        public void ShouldBeAbleToCreateRelease()
        {
            //given
            var releaseRepository = new Mock<IReleaseRepository>();
            var releaseController = new ReleaseController(releaseRepository.Object);

            //when
            var redirectToRouteResult = (RedirectToRouteResult)releaseController.Create(new Release(), null);
            //then
            Assert.That(redirectToRouteResult.RouteValues["Controller"], Is.EqualTo("Release"));
            Assert.That(redirectToRouteResult.RouteValues["Action"], Is.EqualTo("Index"));
        }
コード例 #4
0
        public void ShouldBeAbleToCreateRelease()
        {
            //given
            var releaseRepository = new Mock<IReleaseRepository>();
            var releaseController = new ReleaseController(releaseRepository.Object);

            //when
            var release = new Release();
            var redirectToRouteResult = (RedirectToRouteResult) releaseController.Create(release, null);

            //then
            releaseRepository.Verify(x => x.SaveReleaseDetails(release), Times.Once());
            Assert.That(redirectToRouteResult.RouteValues["Controller"], Is.EqualTo("Release"));
            Assert.That(redirectToRouteResult.RouteValues["Action"], Is.EqualTo("Index"));
        }
コード例 #5
0
        public void ShouldCreateReleaseWithoutPrePatEmail()
        {
            //given

            var releaseRepository = new Mock<IReleaseRepository>();
            var releaseController = new ReleaseController(releaseRepository.Object);

            var releaseDetailsModel = new Release()
                                          {
                                              ReleaseNumber = "REL1216",
                                              ReleaseFiInstructions = "FI as Normal",
                                              TeamName = "ENZO",
                                              ServiceNowTicketLink = "www.google.co.uk"
                                          };

            //when
            releaseController.Create(releaseDetailsModel, null);

            //then
            releaseRepository.Verify(x => x.SaveReleaseDetails(releaseDetailsModel));
        }
コード例 #6
0
ファイル: ReleaseTests.cs プロジェクト: santosb/FIFairy
        public void ShouldDisplayReleases()
        {
            IEnumerable<ReleaseDetailsModel> expectedReleaseModel = new List<ReleaseDetailsModel>
                       {
                           new ReleaseDetailsModel("Enzo", "REL1216",  new DateTime(2011,10,20)),
                           new ReleaseDetailsModel("Enzo", "REL54164", new DateTime(2011,11,20)),
                           new ReleaseDetailsModel("Enzo", "REL123", new DateTime(2011,03,20)),
                           new ReleaseDetailsModel("Enzo", "REL124", new DateTime(2011,02,27)),
                           new ReleaseDetailsModel("Enzo", "REL125", new DateTime(2011,09,26)),
                           new ReleaseDetailsModel("Colombo", "REL1000", new DateTime(2011,12,25)),
                           new ReleaseDetailsModel("Colombo", "REL11122", new DateTime(2011,11,04))
                       };

            var releaseRepository = new Mock<IReleaseRepository>();
            releaseRepository.Setup(x => x.GetReleases()).Returns(expectedReleaseModel);
            var releaseController = new ReleaseController(releaseRepository.Object);
            ViewResult result = releaseController.Index();

            var model = (IEnumerable<ReleaseDetailsModel>)result.ViewData.Model;

            Assert.That(result.ViewName, Is.EqualTo("Release"));
            Assert.That(model, Is.EqualTo(expectedReleaseModel));
            Assert.That(model.First().TeamName, Is.EqualTo("Enzo"));
        }
コード例 #7
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));
        }
コード例 #8
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));
        }
コード例 #9
0
        public void ShouldDisplayAllReleases()
        {
            // TODO: tests about different types of data should happen in the repository
            // like different teams and different dates
            IEnumerable<Release> expectedReleaseModel = new List<Release>
                                                            {
                                                                new Release("Enzo", "REL1216",
                                                                            new DateTime(2011, 10, 20)),
                                                            };

            var releaseRepository = new Mock<IReleaseRepository>();
            releaseRepository.Setup(x => x.GetReleases()).Returns(expectedReleaseModel);
            var releaseController = new ReleaseController(releaseRepository.Object);
            ViewResult result = releaseController.Index();

            var model = (IEnumerable<Release>) result.ViewData.Model;

            Assert.That(result.ViewName, Is.EqualTo("Release"));
            Assert.That(model, Is.EqualTo(expectedReleaseModel));
        }