public static TaskScoreQuery Create(int taskId, string userId) { Fail.If(taskId <= 0); Fail.IfNullOrEmpty(userId); return(new TaskScoreQuery(taskId, userId)); }
public static CreateContestCommand Create(string name, ClaimsPrincipal user) { Fail.IfNullOrEmpty(name); Fail.IfNull(user); return(new CreateContestCommand(name, user)); }
public static CompilationQuery Create(string sourceCode, string input, ProgrammingLanguage language) { Fail.IfNullOrEmpty(sourceCode); Fail.IfNull(input); Fail.IfNull(language); return(new CompilationQuery(sourceCode, input, language)); }
public static CreateSolutionCommand Create(string sourceCode, string languageCode, int taskId, string username) { Fail.IfNullOrEmpty(sourceCode); Fail.IfNullOrEmpty(languageCode); Fail.IfNull(taskId); Fail.IfNull(username); return(new CreateSolutionCommand(sourceCode, languageCode, taskId, username)); }
public static int GetScore(decimal percentagePassed, ScorePolicy scorePolicy) { Fail.IfNull(scorePolicy); Fail.IfNullOrEmpty(scorePolicy.ScoreRules); var rules = scorePolicy.ScoreRules .OrderBy(sr => sr.Threshold) .ToList(); var score = 0; foreach (var rule in rules) { if (percentagePassed < rule.Threshold) { break; } score = rule.Score; } return(score); }
public void IfNullOrEmpty_GivenSampleCollection_NoExceptionThrown() { Action act = () => Fail.IfNullOrEmpty(new int[] { 1, 2, 3, 4 }); act.Should().NotThrow(); }
public void IfNullOrEmpty_GivenEmptyCollection_ThrowDesignByContractException() { Action act = () => Fail.IfNullOrEmpty(Array.Empty <int>()); act.Should().Throw <DesignByContractException>(); }
public void IfNullOrEmpty_GivenNullCollection_ThrowDesignByContractException() { Action act = () => Fail.IfNullOrEmpty <int[]>(null); act.Should().Throw <DesignByContractException>(); }
public static CreateScorePolicyCommand Create(string name, string description, List <ScoreRuleDto> scoreRules) { Fail.IfNullOrEmpty(name); Fail.IfNullOrEmpty(scoreRules); return(new CreateScorePolicyCommand(name, description, scoreRules)); }