Skip to content

Commit

Permalink
updated dependencies (#554)
Browse files Browse the repository at this point in the history
* updated dependencies

* updated changelog

* added test case to check both static and not static fields are accessible

* fixed warnings
  • Loading branch information
abbasc52 authored Nov 26, 2023
1 parent 178248b commit b783602
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [5.0.3]
- Updated dependencies to latest
- Fixed RulesEngine throwing exception when type name is same as input name

## [5.0.2]
- Fixed Scoped Params returning incorrect results in some corner case scenarios

Expand Down
2 changes: 1 addition & 1 deletion benchmark/RulesEngineBenchmark/RulesEngineBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.6" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<!--<PackageReference Include="RulesEngine" Version="3.0.2" />-->
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/RulesEngine/RulesEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<Version>5.0.2</Version>
<Version>5.0.3</Version>
<Copyright>Copyright (c) Microsoft Corporation.</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/microsoft/RulesEngine</PackageProjectUrl>
Expand Down Expand Up @@ -33,12 +33,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FastExpressionCompiler" Version="[3.3.3]" />
<PackageReference Include="FluentValidation" Version="11.5.2" />
<PackageReference Include="FastExpressionCompiler" Version="4.0.1" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.3" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.7" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion test/RulesEngine.UnitTest/CaseSensitiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class CaseSensitiveTests
[Theory]
[InlineData(true,true,false)]
[InlineData(false,true,true)]

public async Task CaseSensitiveTest(bool caseSensitive, bool expected1, bool expected2)
{
var reSettings = new ReSettings {
Expand Down Expand Up @@ -46,5 +45,9 @@ public async Task CaseSensitiveTest(bool caseSensitive, bool expected1, bool exp
Assert.Equal(expected1, result[0].IsSuccess);
Assert.Equal(expected2, result[1].IsSuccess);
}




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void OnSuccessWithSuccessTest()
successEventName = eventName;
});

Assert.True(successEventName.Equals("Test Rule 1"));
Assert.Equal("Test Rule 1", successEventName);
}

[Fact]
Expand Down Expand Up @@ -89,7 +89,7 @@ public void OnSuccessWithSuccessWithEventTest()
successEventName = eventName;
});

Assert.True(successEventName.Equals("Event 1"));
Assert.Equal("Event 1", successEventName);
}

[Fact]
Expand Down Expand Up @@ -128,7 +128,7 @@ public void OnSuccessWithouSuccessTest()
successEventName = eventName;
});

Assert.True(successEventName.Equals(string.Empty));
Assert.Equal(successEventName, string.Empty);
}


Expand Down
8 changes: 4 additions & 4 deletions test/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
111 changes: 111 additions & 0 deletions test/RulesEngine.UnitTest/TypedClassTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TypedClassTests
{
public class Transazione
{
public static string StaticProperty { get; set; } = "Hello";
public List<Attore> Attori { get; set; } = new();
}
public class Attore
Expand Down Expand Up @@ -84,5 +85,115 @@ public async Task TypedClassTest()
Assert.All(result, (res) => Assert.True(res.IsSuccess));

}


[Fact]
public async Task TypedClassInputSameNameAsTypeTest()
{
Workflow workflow = new() {
WorkflowName = "Conferimento",
Rules = new Rule[] {
new() {
RuleName = "Attore Da",
Enabled = true,
ErrorMessage = "Attore Da Id must be defined",
SuccessEvent = "10",
RuleExpressionType = RuleExpressionType.LambdaExpression,
Expression = "transazione.Attori.Any(a => a.RuoloAttore == 1)",
},
new() {
RuleName = "Attore A",
Enabled = true,
ErrorMessage = "Attore A must be defined",
SuccessEvent = "10",
RuleExpressionType = RuleExpressionType.LambdaExpression,
Expression = "transazione.Attori != null",
}

}
};
var reSettings = new ReSettings() {
CustomTypes = new Type[] {
typeof(Transazione)
}
};
var re = new RulesEngine(reSettings);
re.AddWorkflow(workflow);

var param = new Transazione {
Attori = new List<Attore>{
new Attore{
RuoloAttore = RuoloAttore.B,

},
new Attore {
RuoloAttore = RuoloAttore.C
}
}

};

var result = await re.ExecuteAllRulesAsync("Conferimento", new RuleParameter("Transazione", param));

Assert.All(result, (res) => Assert.True(res.IsSuccess));

}


[Fact]
public async Task TypedClassBothAccessibleTestWhenCaseInsensitive()
{
Workflow workflow = new() {
WorkflowName = "Conferimento",
Rules = new Rule[] {
new() {
RuleName = "Attore Da",
Enabled = true,
ErrorMessage = "Attore Da Id must be defined",
SuccessEvent = "10",
RuleExpressionType = RuleExpressionType.LambdaExpression,
Expression = "transazione.Attori.Any(a => a.RuoloAttore == 1)",
},
new() {
RuleName = "Attore A",
Enabled = true,
ErrorMessage = "Attore A must be defined",
SuccessEvent = "10",
RuleExpressionType = RuleExpressionType.LambdaExpression,
Expression = "transazione.Attori != null",
},
new() {
RuleName = "Static FieldTest",
Expression = "Transazione.StaticProperty == \"Hello\""
}
}
};
var reSettings = new ReSettings() {
CustomTypes = new Type[] {
typeof(Transazione)
},
IsExpressionCaseSensitive = true
};
var re = new RulesEngine(reSettings);
re.AddWorkflow(workflow);

var param = new Transazione {
Attori = new List<Attore>{
new Attore{
RuoloAttore = RuoloAttore.B,

},
new Attore {
RuoloAttore = RuoloAttore.C
}
}

};

var result = await re.ExecuteAllRulesAsync("Conferimento", new RuleParameter("transazione", param));

Assert.All(result, (res) => Assert.True(res.IsSuccess));

}
}
}

0 comments on commit b783602

Please sign in to comment.