public void GetLatestDonations_ShouldReturnAnEmptyListOfDonations_WhenThereAreNoDonations() { var donationsRepository = Substitute.For<IDonationRepository>(); donationsRepository.GetAll().Returns(Enumerable.Empty<Donation>()); var donationsService = new DonationsService(donationsRepository); IEnumerable<Donation> latestDonations = donationsService.GetLatestDonations(1); CollectionAssert.AreEqual(Enumerable.Empty<Donation>(), latestDonations); }
public void GetLatestDonations_ShouldReturnAnEmptyListOfDonations_WhenThereAreNoDonations() { var donationsRepository = Substitute.For <IDonationRepository>(); donationsRepository.GetAll().Returns(Enumerable.Empty <Donation>()); var donationsService = new DonationsService(donationsRepository); IEnumerable <Donation> latestDonations = donationsService.GetLatestDonations(1); CollectionAssert.AreEqual(Enumerable.Empty <Donation>(), latestDonations); }
public void GetLatestDonations_ShouldReturnTheSpecifiedNumberOfDonations_WhenThereAreDonations() { var firstDonation = new Donation { Date = new DateTime(2011, 10, 21) }; var secondDonation = new Donation { Date = new DateTime(2011, 10, 22) }; var donations = new[] { firstDonation, secondDonation }; var donationsRepository = Substitute.For<IDonationRepository>(); donationsRepository.GetAll().Returns(donations); var donationsService = new DonationsService(donationsRepository); IEnumerable<Donation> latestDonations = donationsService.GetLatestDonations(1); CollectionAssert.AreEqual(new[] { secondDonation }, latestDonations); }
public void GetLatestDonations_ShouldReturnAListOfDonations_InDescendingOrderByDate_WhenThereAreDonations() { var firstDonation = new Donation { Date = new DateTime(2011, 10, 21) }; var secondDonation = new Donation { Date = new DateTime(2011, 10, 22) }; var donations = new[] { firstDonation, secondDonation }; var donationsRepository = Substitute.For <IDonationRepository>(); donationsRepository.GetAll().Returns(donations); var donationsService = new DonationsService(donationsRepository); IEnumerable <Donation> latestDonations = donationsService.GetLatestDonations(5); CollectionAssert.AreEqual(new[] { secondDonation, firstDonation }, latestDonations); }