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)); }
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)); }
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)); }