Beispiel #1
0
 public void InsertCampaign()
 {
     var campaigns = new Campaigns();
     var campaign = new Campaign
                        {
                            Name = "Test",
                            Description = "Test"
                        };
     campaign = campaigns.Insert(campaign);
     Assert.AreNotEqual(0, campaign.Id);
     Assert.AreEqual("N", campaign.IsClosed);
 }
        public DonationsGenerator(Campaign campaign, ICollection<Member> members)
        {
            if (campaign == null)
            {
                throw new ArgumentException("campaign");
            }

            if (members == null)
            {
                throw new ArgumentException("members");
            }

            this.campaign = campaign;
            this.members = members;

            // donation rate is set somewhere between 1/3 and 2/3
            donationRate = 33 + random.Next(33);
        }
        private Campaign GenerateCampaign()
        {
            string campaignName = string.Format("{0} {1}", random.PickFromList(FemaleNames.Data), random.PickFromList(CampaignNames.CampaignSuffix));

            // close 10% of campaigns
            bool isClosed = random.Percent(10);

            // run (commit) 50% of campaigns, but all of the ones that are closed
            DateTime? runOn = isClosed || random.Percent(50) ? DateTime.Today : (DateTime?) null;

            var campaign = new Campaign
                               {
                                           Name = campaignName,
                                           Description = "A test campaign",
                                           IsClosed = isClosed  ? "Y" : "N",
                                           RunOn = runOn
                               };
            return campaign;
        }
        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);
                }
            }
        }
 private static ICampaignRepository GetCampaignRepositoryForInsert(Campaign insertedCampaign, Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.Insert(insertedCampaign).Returns(expectedCampaign);
     return campaignRepository;
 }
 private static ICampaignRepository GetCampaignRepositoryForGetById(Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.GetById(4).Returns(expectedCampaign);
     return campaignRepository;
 }
        public void Insert_ShouldReturnTheInsertedCampaignWithANewId()
        {
            const int expectedCampaignId = 20;
            var insertedCampaign = new Campaign { Name = "Test Campaign", IsClosed = "N" };
            var expectedCampaign = new Campaign { Id = expectedCampaignId, Name = "Test Campaign", IsClosed = "N" };

            var campaignRepository = GetCampaignRepositoryForInsert(insertedCampaign, expectedCampaign);
            var campaignService = GetCampaignService(campaignRepository);

            Campaign actualCampaign = campaignService.Insert(insertedCampaign);

            Assert.AreEqual(expectedCampaignId, actualCampaign.Id);
        }
 public void Update(Campaign campaign)
 {
     campaignsDb.Update(campaign);
 }
 public Campaign Insert(Campaign campaign)
 {
     return campaignsDb.Insert(campaign);
 }
Beispiel #10
0
 public void Update(Campaign campaign)
 {
     db.Campaigns.UpdateById(campaign);
 }
        public ActionResult Clone(int id)
        {
            var campaign = this.campaignService.Get(id);
            var campaignClone = new Campaign
                                         {
                                             Id = 0,
                                             Description = campaign.Description,
                                             IsClosed = "N",
                                             Name = campaign.Name + " (" + Resources.Literal_Cloned + ")",
                                             RunOn = null
                                         };

            campaignClone = this.campaignService.Insert(campaignClone);

            IEnumerable<MemberSearchFilter> memberSearchFilters = this.memberSearchFilterService.ForCampaign(id);

            foreach (MemberSearchFilter memberSearchFilter in memberSearchFilters)
            {
                this.memberSearchFilterService.Insert(new MemberSearchFilter
                                                  {
                                                      CampaignId = campaignClone.Id,
                                                      DisplayName = memberSearchFilter.DisplayName,
                                                      FilterType = memberSearchFilter.FilterType,
                                                      InternalName = memberSearchFilter.InternalName,
                                                      SearchOperator = memberSearchFilter.SearchOperator,
                                                      Value = memberSearchFilter.Value
                                                  });
            }

            return RedirectToAction("Show", new { id = campaignClone.Id });
        }
 private int InsertCampaign(Campaign campaign)
 {
     var savedCampaign = this.campaignService.Insert(campaign);
     return savedCampaign.Id;
 }
 public ActionResult Create(Campaign campaign)
 {
     var newId = this.InsertCampaign(campaign);
     return RedirectToAction("Show", new { id = newId });
 }
Beispiel #14
0
 public void Update(Campaign campaign)
 {
     databaseProvider.GetDatabase().Campaigns.UpdateById(campaign);
 }
Beispiel #15
0
 public Campaign Insert(Campaign campaign)
 {
     return databaseProvider.GetDatabase().Campaigns.Insert(campaign);
 }
Beispiel #16
0
 public Campaign Insert(Campaign campaign)
 {
     return campaignRepository.Insert(campaign);
 }
Beispiel #17
0
 public void Update(Campaign campaign)
 {
     campaignRepository.Update(campaign);
 }
Beispiel #18
0
 public Campaign Insert(Campaign campaign)
 {
     return db.Campaigns.Insert(campaign);
 }