public void SaveConditions(AwardDefinition awardDefinition, List<AwardCondition> conditions)
		{
			_awardConditionRepository.DeleteConditions(awardDefinition.AwardDefinitionID);
			foreach (var condition in conditions)
				condition.AwardDefinitionID = awardDefinition.AwardDefinitionID;
			_awardConditionRepository.SaveConditions(conditions);
		}
		public void CreateMapsObjectToRepo()
		{
			var awardDef = new AwardDefinition {AwardDefinitionID = "blah", Title = "title", Description = "desc", IsSingleTimeAward = true};
			var service = GetService();
			service.Create(awardDef);
			_awardDefRepo.Verify(x => x.Create(awardDef.AwardDefinitionID, awardDef.Title, awardDef.Description, awardDef.IsSingleTimeAward), Times.Once());
		}
		public void SaveConditionsDeletesOldOnes()
		{
			var awardDef = new AwardDefinition {AwardDefinitionID = "awarddef"};
			var service = GetService();
			service.SaveConditions(awardDef, new List<AwardCondition>());
			_awardConditionRepo.Verify(x => x.DeleteConditions(awardDef.AwardDefinitionID), Times.Once());
		}
		public void IssueMapsFieldsToRepoCall()
		{
			var user = new User(123, DateTime.MinValue);
			var awardDef = new AwardDefinition {AwardDefinitionID = "blah", Description = "desc", Title = "title", IsSingleTimeAward = true};
			var service = GetService();
			service.IssueAward(user, awardDef);
			_userAwardRepo.Verify(x => x.IssueAward(user.UserID, awardDef.AwardDefinitionID, awardDef.Title, awardDef.Description, It.IsAny<DateTime>()), Times.Once());
		}
		public void IsAwardedMapsAndReturnsRightValue()
		{
			var user = new User(123, DateTime.MinValue);
			var awardDef = new AwardDefinition { AwardDefinitionID = "blah" };
			var service = GetService();
			_userAwardRepo.Setup(x => x.IsAwarded(user.UserID, awardDef.AwardDefinitionID)).Returns(true);
			var result = service.IsAwarded(user, awardDef);
			Assert.IsTrue(result);
		}
 public void SaveConditions(AwardDefinition awardDefinition, List <AwardCondition> conditions)
 {
     _awardConditionRepository.DeleteConditions(awardDefinition.AwardDefinitionID);
     foreach (var condition in conditions)
     {
         condition.AwardDefinitionID = awardDefinition.AwardDefinitionID;
     }
     _awardConditionRepository.SaveConditions(conditions);
 }
Exemple #7
0
        public async Task SaveConditions(AwardDefinition awardDefinition, List <AwardCondition> conditions)
        {
            await _awardConditionRepository.DeleteConditions(awardDefinition.AwardDefinitionID);

            foreach (var condition in conditions)
            {
                condition.AwardDefinitionID = awardDefinition.AwardDefinitionID;
            }
            await _awardConditionRepository.SaveConditions(conditions);
        }
		public void SaveConditionsSetsAllAwardDefIDs()
		{
			var awardDef = new AwardDefinition { AwardDefinitionID = "awarddef" };
			var list = new List<AwardCondition> { new AwardCondition { AwardDefinitionID = "bad" }, new AwardCondition { AwardDefinitionID = "toobad" } };
			var savingList = new List<AwardCondition>();
			var service = GetService();
			_awardConditionRepo.Setup(x => x.SaveConditions(It.IsAny<List<AwardCondition>>())).Callback<List<AwardCondition>>(x => savingList = x);
			service.SaveConditions(awardDef, list);
			Assert.AreEqual(savingList[0].AwardDefinitionID, awardDef.AwardDefinitionID);
			Assert.AreEqual(savingList[1].AwardDefinitionID, awardDef.AwardDefinitionID);
		}
		public void ProcessNeverCallsIssueIfAwardedAndSingleAward()
		{
			var calc = GetCalc();
			var eventDef = new EventDefinition {EventDefinitionID = "oi"};
			var user = new User(1, DateTime.MinValue);
			var awardDef = new AwardDefinition {AwardDefinitionID = "sweet", IsSingleTimeAward = true};
			_awardCalcRepo.Setup(x => x.Dequeue()).Returns(new KeyValuePair<string, int>(eventDef.EventDefinitionID, user.UserID));
			_eventDefService.Setup(x => x.GetEventDefinition(It.IsAny<string>())).Returns(eventDef);
			_userRepo.Setup(x => x.GetUser(It.IsAny<int>())).Returns(user);
			_awardDefService.Setup(x => x.GetByEventDefinitionID(eventDef.EventDefinitionID)).Returns(new List<AwardDefinition> {awardDef});
			_userAwardService.Setup(x => x.IsAwarded(user, awardDef)).Returns(true);
			calc.ProcessOneCalculation();
			_userAwardService.Verify(x => x.IssueAward(It.IsAny<User>(), It.IsAny<AwardDefinition>()), Times.Never());
		}
		public AwardDefinition Get(string awardDefinitionID)
		{
			AwardDefinition awardDefinition = null;
			_sqlObjectFactory.GetConnection().Using(connection =>
			    connection.Command("SELECT AwardDefinitionID, Title, Description, IsSingleTimeAward FROM pf_AwardDefinition WHERE AwardDefinitionID = @AwardDefinitionID")
			    .AddParameter("@AwardDefinitionID", awardDefinitionID)
			    .ExecuteReader()
			    .ReadOne(r => awardDefinition = new AwardDefinition
			        {
						AwardDefinitionID = r.GetString(0),
						Title = r.GetString(1),
						Description = r.GetString(2),
						IsSingleTimeAward = r.GetBoolean(3)
			        }));
			return awardDefinition;
		}
 public void Create(AwardDefinition awardDefinition)
 {
     _awardDefinitionRepository.Create(awardDefinition.AwardDefinitionID, awardDefinition.Title, awardDefinition.Description, awardDefinition.IsSingleTimeAward);
 }
		public void Create(AwardDefinition awardDefinition)
		{
			_awardDefinitionRepository.Create(awardDefinition.AwardDefinitionID, awardDefinition.Title, awardDefinition.Description, awardDefinition.IsSingleTimeAward);
		}
Exemple #13
0
 public bool IsAwarded(User user, AwardDefinition awardDefinition)
 {
     return(_userAwardRepository.IsAwarded(user.UserID, awardDefinition.AwardDefinitionID));
 }
Exemple #14
0
 public void IssueAward(User user, AwardDefinition awardDefinition)
 {
     _userAwardRepository.IssueAward(user.UserID, awardDefinition.AwardDefinitionID, awardDefinition.Title, awardDefinition.Description, DateTime.UtcNow);
 }
		public void AwardGetsFromRepo()
		{
			var controller = GetController();
			var awardDef = new AwardDefinition {AwardDefinitionID = "qwerty"};
			_awardDefService.Setup(x => x.Get(awardDef.AwardDefinitionID)).Returns(awardDef);
			_eventDefService.Setup(x => x.GetAll()).Returns(new List<EventDefinition>());
			var result = controller.Award(awardDef.AwardDefinitionID);
			Assert.AreSame(awardDef, result.Model);
		}
Exemple #16
0
 public async Task Create(AwardDefinition awardDefinition)
 {
     await _awardDefinitionRepository.Create(awardDefinition.AwardDefinitionID, awardDefinition.Title, awardDefinition.Description, awardDefinition.IsSingleTimeAward);
 }
 public async Task <bool> IsAwarded(User user, AwardDefinition awardDefinition)
 {
     return(await _userAwardRepository.IsAwarded(user.UserID, awardDefinition.AwardDefinitionID));
 }
		public void ProcessNeverCallsIfEventCountNotHighEnough()
		{
			var calc = GetCalc();
			var eventDef = new EventDefinition { EventDefinitionID = "oi" };
			var user = new User(1, DateTime.MinValue);
			var awardDef = new AwardDefinition {AwardDefinitionID = "sweet", IsSingleTimeAward = true};
			var conditions = new List<AwardCondition>
			        {
			            new AwardCondition { AwardDefinitionID = awardDef.AwardDefinitionID, EventDefinitionID ="qwerty", EventCount = 3},
			            new AwardCondition { AwardDefinitionID = awardDef.AwardDefinitionID, EventDefinitionID ="asdfgh", EventCount = 5}
			        };
			_awardCalcRepo.Setup(x => x.Dequeue()).Returns(new KeyValuePair<string, int>(eventDef.EventDefinitionID, user.UserID));
			_eventDefService.Setup(x => x.GetEventDefinition(It.IsAny<string>())).Returns(eventDef);
			_userRepo.Setup(x => x.GetUser(It.IsAny<int>())).Returns(user);
			_awardDefService.Setup(x => x.GetByEventDefinitionID(eventDef.EventDefinitionID)).Returns(new List<AwardDefinition> { awardDef });
			_userAwardService.Setup(x => x.IsAwarded(user, awardDef)).Returns(false);
			_awardDefService.Setup(x => x.GetConditions(awardDef.AwardDefinitionID)).Returns(conditions);
			_pointLedgerRepo.Setup(x => x.GetEntryCount(user.UserID, conditions[0].EventDefinitionID)).Returns(10);
			_pointLedgerRepo.Setup(x => x.GetEntryCount(user.UserID, conditions[1].EventDefinitionID)).Returns(4);
			calc.ProcessOneCalculation();
			_userAwardService.Verify(x => x.IssueAward(It.IsAny<User>(), It.IsAny<AwardDefinition>()), Times.Never());
		}
		public void AddAwardCallsAdd()
		{
			var controller = GetController();
			var awardDef = new AwardDefinition();
			controller.AddAward(awardDef);
			_awardDefService.Verify(x => x.Create(awardDef), Times.Once());
		}
		public void AwardGetsConditions()
		{
			var controller = GetController();
			var awardDef = new AwardDefinition { AwardDefinitionID = "qwerty" };
			_awardDefService.Setup(x => x.Get(awardDef.AwardDefinitionID)).Returns(awardDef);
			_eventDefService.Setup(x => x.GetAll()).Returns(new List<EventDefinition>());
			var conditions = new List<AwardCondition>();
			_awardDefService.Setup(x => x.GetConditions(awardDef.AwardDefinitionID)).Returns(conditions);
			var result = controller.Award(awardDef.AwardDefinitionID);
			Assert.AreSame(conditions, result.ViewBag.Conditions);
		}
		public bool IsAwarded(User user, AwardDefinition awardDefinition)
		{
			return _userAwardRepository.IsAwarded(user.UserID, awardDefinition.AwardDefinitionID);
		}
		public void IssueAward(User user, AwardDefinition awardDefinition)
		{
			_userAwardRepository.IssueAward(user.UserID, awardDefinition.AwardDefinitionID, awardDefinition.Title, awardDefinition.Description, DateTime.UtcNow);
		}
		public ActionResult AddAward(AwardDefinition awardDefinition)
		{
			_awardDefinitionService.Create(awardDefinition);
			return RedirectToAction("Award", new { id = awardDefinition.AwardDefinitionID });
		}