public void ShouldEvalEqualsMemoryWithConstValue() { EvaluatorContext context = new EvaluatorContext(); FakeConsoleRam ram = new FakeConsoleRam(0xFF); ram.Data[4] = 42; // 0xH0004 == 42 ReadMemoryValue readMemory = new ReadMemoryValue { Address = 0x0004, Kind = MemoryAddressKind.Int8 }; ConstValue constValue = new ConstValue(42); CompareInstruction compareInst = new CompareInstruction { Left = readMemory, Right = constValue, Operation = ConditionCompare.Equals }; var result = compareInst.Evaluate(ram, context); Assert.True(result); }
public void ShouldEvaluateDeltaValue() { EvaluatorContext context = new EvaluatorContext(); FakeConsoleRam ram = new FakeConsoleRam(0xFF); ram.Data[4] = 4; // 0xH0004 < d0xH004 ReadMemoryValue readMemory = new ReadMemoryValue { Address = 0x0004, Kind = MemoryAddressKind.Int8 }; DeltaValue deltaValue = new DeltaValue(readMemory); CompareInstruction compareInst = new CompareInstruction { Left = readMemory, Right = deltaValue, Operation = ConditionCompare.Less }; Assert.False(compareInst.Evaluate(ram, context)); ram.Data[4] = 2; Assert.True(compareInst.Evaluate(ram, context)); Assert.False(compareInst.Evaluate(ram, context)); }
public override decimal?Invoke(EvaluatorContext context) { var leftValue = Left.Invoke(context); var rightValue = Right.Invoke(context); return(leftValue + rightValue); }
public void ShouldOnlyReturnTrueWhenHitCountIsReached() { EvaluatorContext context = new EvaluatorContext(); FakeConsoleRam ram = new FakeConsoleRam(0xFF); ram.Data[4] = 42; // 0xH0004 == 42 ReadMemoryValue readMemory = new ReadMemoryValue { Address = 0x0004, Kind = MemoryAddressKind.Int8 }; ConstValue constValue = new ConstValue(42); CompareInstruction compareInst = new CompareInstruction { Left = readMemory, Right = constValue, Operation = ConditionCompare.Equals }; ConditionInstruction condition = new ConditionInstruction { TargetHitCount = 2, CompareInstruction = compareInst }; Assert.False(condition.Evaluate(ram, context)); Assert.True(condition.Evaluate(ram, context)); }
public RunningTaskImpl(EvaluatorManager evaluatorManager, string taskId, EvaluatorContext evaluatorContext) { LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "INIT: TaskRuntime id [{0}] on evaluator id [{1}]", taskId, evaluatorManager.Id)); _id = taskId; _evaluatorManager = evaluatorManager; _evaluatorContext = evaluatorContext; }
public static void TestJValueCommonInvalidScenarios( JObject dataJObj, string dataJPath, JObject resourceJObj, string resourceJPath) { var context = new EvaluatorContext(dataJObj, dataJPath, resourceJObj, resourceJPath, Direction.ContextToResource); Assert.False(new DummyValusEvaluator().Evaluate(context)); }
public void GreaterThanEvaluatorPositiveBehavior( JObject dataJObj, string dataJPath, JObject resourceJObj, string resourceJPath) { var evaluator = new GreaterThanEvaluator(); var context = new EvaluatorContext(dataJObj, dataJPath, resourceJObj, resourceJPath, Direction.ContextToResource); Assert.True(evaluator.Evaluate(context)); }
public void ContainsEvaluatorNegativeBehavior( JObject dataJObj, string dataJPath, JObject resourceJObj, string resourceJPath) { var evaluator = new ContainsEvaluator(); var context = new EvaluatorContext(dataJObj, dataJPath, resourceJObj, resourceJPath, Direction.ContextToResource); Assert.False(evaluator.Evaluate(context)); }
public object Evaluate(EvaluatorContext evaluationContext) { try { this.contexts.SetValue(evaluatorCore, new[] {evaluationContext}); return Accept(filterCriteria); } finally { this.contexts.SetValue(evaluatorCore, null); } }
public override decimal?Invoke(EvaluatorContext context) { var leftValue = Left.Invoke(context); var rightValue = Right.Invoke(context); if (leftValue == null || rightValue == null) { return(null); } return((decimal)Math.Pow((double)leftValue.Value, (double)rightValue.Value)); }
public override decimal?Invoke(EvaluatorContext context) { var values = new List <decimal?>(); foreach (var p in Parameters) { values.Add(p.Invoke(context)); } var func = context.GetFunction(Name); return(func?.Invoke(values.ToArray())); }
public override decimal?Invoke(EvaluatorContext context) { var leftValue = Left.Invoke(context); var rightValue = Right.Invoke(context); // Don't throw a divide by zero exception, return 0 // Buuuutttt, if the left value is null then let's return null rather. if (rightValue == 0) { return(leftValue == null ? (decimal?)null : 0M); } return(leftValue / rightValue); }
public void InitializesLeftAndRightOperandsCorrectly() { var context = new EvaluatorContext(dataObj, dataJPath, resourceObj, resourceJPath, Direction.ContextToResource); Assert.Same(context.LeftJObject, dataObj); Assert.Same(context.LeftJPath, dataJPath); Assert.Same(context.RightJObject, resourceObj); Assert.Same(context.RightJPath, resourceJPath); context = new EvaluatorContext(dataObj, dataJPath, resourceObj, resourceJPath, Direction.ResourceToContext); Assert.Same(context.LeftJObject, resourceObj); Assert.Same(context.LeftJPath, resourceJPath); Assert.Same(context.RightJObject, dataObj); Assert.Same(context.RightJPath, dataJPath); }
public override decimal?Invoke(EvaluatorContext context) { var value = Expression.Invoke(context); return(value * -1); }
private bool Fit(EvaluatorContext evaluationContext) { return (bool) Evaluate(evaluationContext); }
public abstract override decimal?Invoke(EvaluatorContext context);
public ProblemRepository(EvaluatorContext context) : base(context) { }
public ProgresStatusRepository(EvaluatorContext db) : base(db) { }
public UserInformationRepository(EvaluatorContext repoContext) : base(repoContext) { }
public override decimal?Invoke(EvaluatorContext context) { return(context.GetParameter(Name)); }
public RepositoryBase(EvaluatorContext repoContext) { RepositoryContext = repoContext; }
public SubmisionContestRepository(EvaluatorContext db) : base(db) { }
public abstract decimal?Invoke(EvaluatorContext context);
public ContestRepository(EvaluatorContext db) : base(db) { }
public AnnouncementRepository(EvaluatorContext db) : base(db) { }
public SolutionRepository(EvaluatorContext db) : base(db) { }
public TestsRepository(EvaluatorContext db) : base(db) { }
public override decimal?Invoke(EvaluatorContext context) { return(Value); }