public void GetTopDonations_ShouldReturnAnEmptyListOfDonations_WhenThereAreNoDonations()
        {
            var donationsRepository = Substitute.For <IDonationRepository>();

            donationsRepository.GetAll().Returns(Enumerable.Empty <Donation>());

            var donationsService = new DonationsService(donationsRepository);

            IEnumerable <Donation> topDonations = donationsService.GetTopDonations(1);

            CollectionAssert.AreEqual(Enumerable.Empty <Donation>(), topDonations);
        }
Ejemplo n.º 2
0
        public void GetTopDonations_ShouldReturnAListOfDonations_InDescendingOrderByAmount_WhenThereAreDonations()
        {
            var smallDonation = new Donation { Amount = 10m };
            var largeDonation = new Donation { Amount = 100m };

            var donations = new[] { smallDonation, largeDonation };

            var donationsRepository = Substitute.For<IDonationRepository>();
            donationsRepository.GetAll().Returns(donations);

            var donationsService = new DonationsService(donationsRepository);

            IEnumerable<Donation> topDonations = donationsService.GetTopDonations(5);

            CollectionAssert.AreEqual(new[] { largeDonation, smallDonation }, topDonations);
        }
        public void GetTopDonations_ShouldReturnTheSpecifiedNumberOfDonations_WhenThereAreDonations()
        {
            var smallDonation = new Donation {
                Amount = 10m
            };
            var largeDonation = new Donation {
                Amount = 100m
            };

            var donations = new[] { smallDonation, largeDonation };

            var donationsRepository = Substitute.For <IDonationRepository>();

            donationsRepository.GetAll().Returns(donations);

            var donationsService = new DonationsService(donationsRepository);

            IEnumerable <Donation> topDonations = donationsService.GetTopDonations(1);

            CollectionAssert.AreEqual(new[] { largeDonation }, topDonations);
        }
Ejemplo n.º 4
0
        public void GetTopDonations_ShouldReturnAnEmptyListOfDonations_WhenThereAreNoDonations()
        {
            var donationsRepository = Substitute.For<IDonationRepository>();
            donationsRepository.GetAll().Returns(Enumerable.Empty<Donation>());

            var donationsService = new DonationsService(donationsRepository);

            IEnumerable<Donation> topDonations = donationsService.GetTopDonations(1);

            CollectionAssert.AreEqual(Enumerable.Empty<Donation>(), topDonations);
        }