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); }
public void QuickDonation(Donation donation) { donationsDb.Insert(donation); }
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); } } }
public ActionResult SaveDonation(Donation donation) { _donationsService.QuickDonation(donation); return RedirectToAction("Index"); }
public void QuickDonation(Donation donation) { repository.Insert(donation); }
public void Update(Donation item) { databaseProvider.GetDatabase().Donations.UpdateById(item); }
public Donation Insert(Donation donation) { return databaseProvider.GetDatabase().Donations.Insert(donation); }
public Donation Insert(Donation donation) { return db.Donations.Insert(donation); }
public void Update(Donation item) { db.Donations.UpdateById(item); }