Skip to content

Commit

Permalink
Fix new set of bugs related to tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric L. Charlier committed Dec 30, 2018
1 parent c8797e8 commit f1e37d2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion NBi.Core/Scalar/Comparer/ToleranceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static Tolerance Instantiate(IColumnDefinition columnDefinition)

public static Tolerance Instantiate(ColumnType type, string value)
{

if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
return None(type);

Tolerance tolerance=null;
switch (type)
Expand Down
1 change: 1 addition & 0 deletions NBi.Testing/NBi.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
<Compile Include="Unit\Core\ResultSet\Lookup\LookupExistsAnalyzerTest.cs" />
<Compile Include="Unit\Core\Scalar\Casting\NumericCasterTest.cs" />
<Compile Include="Unit\Core\Scalar\Comparer\CellComparerTest.cs" />
<Compile Include="Unit\Core\Scalar\Comparer\ToleranceFactoryTest.cs" />
<Compile Include="Unit\Core\Scalar\Comparer\TextToleranceFactoryTest.cs" />
<Compile Include="Unit\Core\Query\Resolver\ReportDataSetQueryResolverTest.cs" />
<Compile Include="Unit\Core\Query\Resolver\SharedDataSetQueryResolverTest.cs" />
Expand Down
45 changes: 45 additions & 0 deletions NBi.Testing/Unit/Core/Scalar/Comparer/ToleranceFactoryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using NBi.Core.ResultSet;
using NBi.Core.Scalar.Comparer;
using NBi.Xml.Items.ResultSet;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace NBi.Testing.Unit.Core.Scalar.Comparer
{
public class ToleranceFactoryTest
{
[Test]
[TestCase(ColumnRole.Key)]
[TestCase(ColumnRole.Value)]
[TestCase(ColumnRole.Ignore)]
public void Instantiate_NoToleranceDefined_InstantiatedToNullOrNone(ColumnRole columnRole)
{
var colDef = new ColumnDefinitionXml()
{
Index = 0,
Role = columnRole,
Tolerance = string.Empty
};
var tolerance = ToleranceFactory.Instantiate(colDef);

Assert.That(Tolerance.IsNullOrNone(tolerance), Is.True);
}

[Test]
[TestCase(ColumnType.Text)]
[TestCase(ColumnType.Numeric)]
[TestCase(ColumnType.DateTime)]
[TestCase(ColumnType.Boolean)]
public void Instantiate_NoToleranceDefined_InstantiatedToNullOrNone(ColumnType columnType)
{
var tolerance = ToleranceFactory.Instantiate(columnType, string.Empty);
Assert.That(Tolerance.IsNullOrNone(tolerance), Is.True);
}
}
}
2 changes: 1 addition & 1 deletion NBi.Xml/Items/ResultSet/ColumnDefinitionXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ColumnDefinitionXml: IColumnDefinition
[XmlIgnore()]
public bool IsToleranceSpecified
{
get => string.IsNullOrEmpty(Tolerance);
get => !string.IsNullOrEmpty(Tolerance);
}

[XmlIgnore()]
Expand Down

0 comments on commit f1e37d2

Please sign in to comment.