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 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);
        }
Esempio n. 3
0
 public void QuickDonation(Donation donation)
 {
     donationsDb.Insert(donation);
 }
Esempio n. 4
0
        private void GenerateCampaignDonationsForMember(Donations donationsRepo, Campaign campaign, Member member)
        {
            int numberOfDonations = random.NextInt(0, 3);

            for (int i = 0; i < numberOfDonations; i++)
            {
                // don't generate donations each time to simulate a miss
                if (this.random.Percent(donationRate))
                {
                    decimal amount = GenerateAmount();
                    Donation donation = new Donation
                            {
                                CampaignId = campaign.Id,
                                MemberId = member.Id,
                                Amount = amount,
                                Date = random.NextDateTime(),
                            };
                    donationsRepo.Insert(donation);
                }
            }
        }
Esempio n. 5
0
        public ActionResult SaveDonation(Donation donation)
        {
            _donationsService.QuickDonation(donation);

            return RedirectToAction("Index");
        }
Esempio n. 6
0
 public void QuickDonation(Donation donation)
 {
     repository.Insert(donation);
 }
Esempio n. 7
0
 public void Update(Donation item)
 {
     databaseProvider.GetDatabase().Donations.UpdateById(item);
 }
Esempio n. 8
0
 public Donation Insert(Donation donation)
 {
     return databaseProvider.GetDatabase().Donations.Insert(donation);
 }
Esempio n. 9
0
 public Donation Insert(Donation donation)
 {
     return db.Donations.Insert(donation);
 }
Esempio n. 10
0
 public void Update(Donation item)
 {
     db.Donations.UpdateById(item);
 }