public RulesEngine <TContentType, TConditionType> Build() { IOperatorEvalStrategyFactory operatorEvalStrategyFactory = new OperatorEvalStrategyFactory(); IDeferredEval deferredEval = new DeferredEval(operatorEvalStrategyFactory, this.rulesEngineOptions); IConditionsEvalEngine <TConditionType> conditionsEvalEngine = new ConditionsEvalEngine <TConditionType>(deferredEval); return(new RulesEngine <TContentType, TConditionType>(conditionsEvalEngine, this.rulesDataSource, this.rulesEngineOptions)); }
public void GetOperatorEvalStrategy_GivenUnknownOperator_ThrowsNotSupportedException() { // Arrange Operators expectedOperator = (Operators)(-1); OperatorEvalStrategyFactory sut = new OperatorEvalStrategyFactory(); // Act NotSupportedException notSupportedException = Assert.Throws <NotSupportedException>(() => sut.GetOperatorEvalStrategy(expectedOperator)); // Assert notSupportedException.Should().NotBeNull(); notSupportedException.Message.Should().Be("Operator evaluation is not supported for operator '-1'."); }
public void GetOperatorEvalStrategy_GivenOperator_ReturnsOperatorEvalStrategy(Operators @operator, Type type) { // Arrange Operators expectedOperator = @operator; Type expectedType = type; OperatorEvalStrategyFactory sut = new OperatorEvalStrategyFactory(); // Act IOperatorEvalStrategy actual = sut.GetOperatorEvalStrategy(expectedOperator); // Assert actual.Should().NotBeNull().And.BeOfType(expectedType); }