public void ShouldGetRulesetsForProduct() { const string token = "O\'Doyle Rules!"; const int productId = 351; var rulesets = new List <MPProductRuleSet> { FactoryGirl.NET.FactoryGirl.Build <MPProductRuleSet>(r => { r.ProductId = r.ProductId + 2; r.RulesetId = r.RulesetId + 2; }), FactoryGirl.NET.FactoryGirl.Build <MPProductRuleSet>(r => { r.ProductId = r.ProductId + 3; r.RulesetId = r.RulesetId + 3; }), FactoryGirl.NET.FactoryGirl.Build <MPProductRuleSet>(r => { r.ProductId = r.ProductId + 4; r.RulesetId = r.RulesetId + 4; }) }; _apiUserRepository.Setup(m => m.GetToken()).Returns(token); _ministryPlatformRestRepository.Setup(m => m.UsingAuthenticationToken(token)).Returns(_ministryPlatformRestRepository.Object); _ministryPlatformRestRepository.Setup(m => m.Search <MPProductRuleSet>(It.IsAny <string>(), It.IsAny <string>(), null as string, false)).Returns(rulesets); var res = _fixture.GetProductRulesets(productId); Assert.AreEqual(3, res.Count); }
public bool VerifyCampRules(int eventId, int gender) { var currentCampers = _eventParticipantRepository.GetEventParticipantCountByGender(eventId, gender); var currentCampersPlusMe = currentCampers + 1; var ruleData = new Dictionary <string, object> { { "GenderId", gender }, { "registrantCount", currentCampersPlusMe } }; var mpEvent = _eventRepository.GetEvent(eventId); var productRulesets = _productRulesetsRepository.GetProductRulesets(mpEvent.OnlineProductId ?? 0); productRulesets = productRulesets.Where(p => (p.StartDate <= DateTime.Now && (p.EndDate == null || p.EndDate >= DateTime.Now))).ToList(); var rulesPass = _productRulesetsRepository.VerifyRulesets(productRulesets, ruleData); return(rulesPass); }