コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
 public void QuickDonation(Donation donation)
 {
     donationsDb.Insert(donation);
 }
コード例 #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);
                }
            }
        }
コード例 #5
0
        public ActionResult SaveDonation(Donation donation)
        {
            _donationsService.QuickDonation(donation);

            return RedirectToAction("Index");
        }
コード例 #6
0
 public void QuickDonation(Donation donation)
 {
     repository.Insert(donation);
 }
コード例 #7
0
ファイル: Donations.cs プロジェクト: nbarnwell/GiveCRM
 public void Update(Donation item)
 {
     databaseProvider.GetDatabase().Donations.UpdateById(item);
 }
コード例 #8
0
ファイル: Donations.cs プロジェクト: nbarnwell/GiveCRM
 public Donation Insert(Donation donation)
 {
     return databaseProvider.GetDatabase().Donations.Insert(donation);
 }
コード例 #9
0
ファイル: Donations.cs プロジェクト: tombuildsstuff/GiveCRM
 public Donation Insert(Donation donation)
 {
     return db.Donations.Insert(donation);
 }
コード例 #10
0
ファイル: Donations.cs プロジェクト: naeemsarfraz/GiveCRM
 public void Update(Donation item)
 {
     db.Donations.UpdateById(item);
 }