2019-08-13 06:06:57 -04:00
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
2020-05-12 06:22:50 -04:00
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
2020-11-01 22:55:43 -05:00
|
|
|
|
using RulesEngine.ExpressionBuilders;
|
2019-08-13 06:06:57 -04:00
|
|
|
|
using RulesEngine.Models;
|
|
|
|
|
using System;
|
2020-11-01 22:55:43 -05:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2019-08-13 06:06:57 -04:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace RulesEngine.UnitTest
|
|
|
|
|
{
|
|
|
|
|
[Trait("Category","Unit")]
|
2020-11-01 22:55:43 -05:00
|
|
|
|
[ExcludeFromCodeCoverage]
|
2019-08-13 06:06:57 -04:00
|
|
|
|
public class RuleCompilerTest
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RuleCompiler_NullCheck()
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<ArgumentNullException>(() => new RuleCompiler(null, null));
|
2020-11-01 22:55:43 -05:00
|
|
|
|
var reSettings = new ReSettings();
|
|
|
|
|
var parser = new RuleExpressionParser(reSettings);
|
|
|
|
|
Assert.Throws<ArgumentNullException>(() => new RuleCompiler(new RuleExpressionBuilderFactory(reSettings,parser), null));
|
2019-08-13 06:06:57 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RuleCompiler_CompileRule_ThrowsException()
|
|
|
|
|
{
|
2020-11-01 22:55:43 -05:00
|
|
|
|
var reSettings = new ReSettings();
|
|
|
|
|
var parser = new RuleExpressionParser(reSettings);
|
|
|
|
|
var compiler = new RuleCompiler(new RuleExpressionBuilderFactory(reSettings,parser), new NullLogger<RuleCompiler>());
|
|
|
|
|
Assert.Throws<ArgumentNullException>(() => compiler.CompileRule(null, null));
|
|
|
|
|
Assert.Throws<ArgumentNullException>(() => compiler.CompileRule(null, new RuleParameter[] { null}));
|
2019-08-13 06:06:57 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|