예제 #1
0
        public void ShouldGetLastFiveReleases()
        {
            //given
            var releaseRepository = new ReleaseRepository();
            var expectedReleaseDetailsModels = new List<Release>
                                                   {
                                                       new ReleaseBuilder().WithReleaseNumber("REL05").WithReleaseDate(DateTime.Today.AddDays(-1)).Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL04").WithReleaseDate(DateTime.Today.AddMonths(-1)).Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL03").WithReleaseDate(DateTime.Today.AddMonths(-1)).Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL02").WithReleaseDate(DateTime.Today.AddMonths(-2).AddDays(2)).Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL01").WithReleaseDate(DateTime.Today.AddMonths(-2)).Build()
                                                   };

            var lastfiveReleases = new Release[expectedReleaseDetailsModels.Count];
            expectedReleaseDetailsModels.CopyTo(lastfiveReleases);

            expectedReleaseDetailsModels.Add(new ReleaseBuilder().WithReleaseNumber("REL06").WithReleaseDate(DateTime.Today.AddMonths(-3).AddDays(-1)).Build());

            //when
            foreach (Release expectedReleaseDetailsModel in expectedReleaseDetailsModels)
            {
                releaseRepository.SaveReleaseDetails(expectedReleaseDetailsModel);
            }

            // then
            IEnumerable<Release> releaseDetailsModels = releaseRepository.GetLastFiveReleases();
            IEnumerable<Release> expectedReleases = lastfiveReleases.ToList();
            Assert.That(releaseDetailsModels, Is.EqualTo(expectedReleases));
        }
예제 #2
0
        public void ShouldGetAllReleases()
        {
            //given
            var releaseRepository = new ReleaseRepository();
            var expectedReleaseDetailsModels = new List<Release>
                                                   {
                                                       new ReleaseBuilder().WithReleaseNumber("REL01").Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL02").Build(),
                                                       new ReleaseBuilder().Build(),
                                                       new ReleaseBuilder().WithReleaseNumber("REL1234").Build()
                                                   };

            //when
            foreach (Release expectedReleaseDetailsModel in expectedReleaseDetailsModels)
            {
                releaseRepository.SaveReleaseDetails(expectedReleaseDetailsModel);
            }

            // then
            IEnumerable<Release> releaseDetailsModels = releaseRepository.GetReleases();
            Assert.That(releaseDetailsModels, Is.EqualTo(expectedReleaseDetailsModels));
        }
예제 #3
0
        public void ShouldSaveReleaseData()
        {
            //given
            var releaseRepository = new ReleaseRepository();

            //todo: put this inside the builder (for instante on the Build method as default)
            var expectedReleaseDetailsModel = new ReleaseBuilder().WithReleaseNumber("REL01").Build();
            //when
            releaseRepository.SaveReleaseDetails(expectedReleaseDetailsModel);

            //then
            Release release = releaseRepository.GetReleaseDetails("REL01");
            Assert.That(release, Is.EqualTo(expectedReleaseDetailsModel));
        }