Пример #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);
 }
Пример #2
0
        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);
        }
Пример #3
0
        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;
        }
Пример #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
 private static ICampaignRepository GetCampaignRepositoryForInsert(Campaign insertedCampaign, Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.Insert(insertedCampaign).Returns(expectedCampaign);
     return campaignRepository;
 }
Пример #6
0
 private static ICampaignRepository GetCampaignRepositoryForGetById(Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.GetById(4).Returns(expectedCampaign);
     return campaignRepository;
 }
Пример #7
0
        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);
        }
Пример #8
0
 public void Update(Campaign campaign)
 {
     campaignsDb.Update(campaign);
 }
Пример #9
0
 public Campaign Insert(Campaign campaign)
 {
     return campaignsDb.Insert(campaign);
 }
Пример #10
0
 public void Update(Campaign campaign)
 {
     db.Campaigns.UpdateById(campaign);
 }
Пример #11
0
        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 });
        }
Пример #12
0
 private int InsertCampaign(Campaign campaign)
 {
     var savedCampaign = this.campaignService.Insert(campaign);
     return savedCampaign.Id;
 }
Пример #13
0
 public ActionResult Create(Campaign campaign)
 {
     var newId = this.InsertCampaign(campaign);
     return RedirectToAction("Show", new { id = newId });
 }
Пример #14
0
 public void Update(Campaign campaign)
 {
     databaseProvider.GetDatabase().Campaigns.UpdateById(campaign);
 }
Пример #15
0
 public Campaign Insert(Campaign campaign)
 {
     return databaseProvider.GetDatabase().Campaigns.Insert(campaign);
 }
Пример #16
0
 public Campaign Insert(Campaign campaign)
 {
     return campaignRepository.Insert(campaign);
 }
Пример #17
0
 public void Update(Campaign campaign)
 {
     campaignRepository.Update(campaign);
 }
Пример #18
0
 public Campaign Insert(Campaign campaign)
 {
     return db.Campaigns.Insert(campaign);
 }