private void CriteriaScopeValidation(EvaluationDataType dataType, CriteriaScope scope, CriteriaQueryType queryType, ActorType actorType) { if (queryType == CriteriaQueryType.Sum && (dataType == EvaluationDataType.Boolean || dataType == EvaluationDataType.String)) { throw new ArgumentException($"Cannot create EvaluationCriteria as DataType {dataType} cannot be summed"); } switch (scope) { case CriteriaScope.Actor: break; case CriteriaScope.RelatedUsers: if (actorType == ActorType.Undefined) { throw new ArgumentException($"Cannot create EvaluationCriteria using CriteriaScope {scope} and ActorType {actorType}"); } if (queryType != CriteriaQueryType.Sum && queryType != CriteriaQueryType.Count) { throw new ArgumentException($"Cannot create EvaluationCriteria as only CriteriaQueryType {CriteriaQueryType.Sum} can be used with CriteriaScope {scope}"); } break; case CriteriaScope.RelatedGroups: if (actorType != ActorType.Group) { throw new ArgumentException($"Cannot create EvaluationCriteria using CriteriaScope {scope} and ActorType {actorType}"); } if (queryType != CriteriaQueryType.Sum && queryType != CriteriaQueryType.Count) { throw new ArgumentException($"Cannot create EvaluationCriteria as only CriteriaQueryType {CriteriaQueryType.Sum} can be used with CriteriaScope {scope}"); } break; case CriteriaScope.RelatedGroupUsers: if (actorType != ActorType.Group) { throw new ArgumentException($"Cannot create EvaluationCriteria using CriteriaScope {scope} and ActorType {actorType}"); } if (queryType != CriteriaQueryType.Sum && queryType != CriteriaQueryType.Count) { throw new ArgumentException($"Cannot create EvaluationCriteria as only CriteriaQueryType {CriteriaQueryType.Sum} can be used with CriteriaScope {scope}"); } break; } }
// todo scopes for user and group #region Helpers private Evaluation CreateCountEvaluation(string token, ActorType actorType, EvaluationDataType evaluationDataType, CriteriaScope scope, int value) { return(_evaluationController.Create( new Achievement { GameId = Fixture.EvaluationDataGameId, Name = $"{token} Name", Description = $"{token} Description", ActorType = actorType, Token = token, EvaluationCriterias = new List <EvaluationCriteria> { new EvaluationCriteria { EvaluationDataKey = Fixture.GenerateEvaluationDataKey(evaluationDataType), EvaluationDataCategory = EvaluationDataCategory.GameData, EvaluationDataType = evaluationDataType, CriteriaQueryType = CriteriaQueryType.Count, ComparisonType = ComparisonType.GreaterOrEqual, Scope = scope, Value = value.ToString() } } })); }