コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }