Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93750dad17 | |||
| c0c0ae8017 |
@@ -495,6 +495,46 @@ namespace VAR.ExpressionEvaluator.Tests
|
||||
Assert.False((bool?)result);
|
||||
}
|
||||
|
||||
[Fact()]
|
||||
public void Relations__Var1NullEquals666_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("v1", null);
|
||||
string expression = "v1 = 666";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.False((bool?)result);
|
||||
}
|
||||
|
||||
[Fact()]
|
||||
public void Relations__Var1NullEqualsStringHello_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("v1", null);
|
||||
string expression = "v1 = \"Hello\"";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.False((bool?)result);
|
||||
}
|
||||
|
||||
[Fact()]
|
||||
public void Relations__Var1666Equals666_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("v1", 666);
|
||||
string expression = "v1 = 666";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.True((bool?)result);
|
||||
}
|
||||
|
||||
[Fact()]
|
||||
public void Relations__Var1HelloEqualsStringHello_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("v1", "Hello");
|
||||
string expression = "v1 = \"Hello\"";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.True((bool?)result);
|
||||
}
|
||||
|
||||
#endregion Relations
|
||||
|
||||
#region BooleanOps
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace VAR.ExpressionEvaluator
|
||||
{
|
||||
value = ((DateTime)value).ToString("s");
|
||||
}
|
||||
if ((value is string) == false && (value is bool) == false)
|
||||
if ((value is string) == false && (value is bool) == false && value != null)
|
||||
{
|
||||
value = Convert.ToDecimal(value);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace VAR.ExpressionEvaluator
|
||||
return string.Compare((string)leftValue, (string)rightValue) == 0;
|
||||
}
|
||||
|
||||
if ((leftValue is string && rightValue == null) || (leftValue == null && rightValue is string))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (leftValue is string)
|
||||
{
|
||||
if (string.IsNullOrEmpty((string)leftValue))
|
||||
|
||||
@@ -8,23 +8,20 @@
|
||||
<PropertyGroup>
|
||||
<PackageId>VAR.ExpressionEvaluator</PackageId>
|
||||
<Title>VAR.ExpressionEvaluator</Title>
|
||||
<Version>0.2.3</Version>
|
||||
<Version>0.2.4</Version>
|
||||
<Description>Expression Evaluation Library</Description>
|
||||
<Authors>VAR</Authors>
|
||||
<Company>VAR</Company>
|
||||
<Copyright>Copyright © VAR 2019-2020</Copyright>
|
||||
<Copyright>Copyright © VAR 2019-2021</Copyright>
|
||||
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
|
||||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://github.com/Kableado/VAR.ExpressionEvaluator</PackageProjectUrl>
|
||||
<PackageTags>Expression;Evaluation;Expression Evaluation</PackageTags>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE.txt" Link="LICENSE.txt" Pack="true" PackagePath=""/>
|
||||
<Content Include="..\LICENSE.txt" Link="LICENSE.txt" Pack="true" PackagePath="" />
|
||||
</ItemGroup>
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy
|
||||
SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg"
|
||||
DestinationFolder="Nuget\"
|
||||
/>
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="Nuget\" />
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user