Skip to content

Commit

Permalink
Bump NUnit from 3.14.0 to 4.0.0 (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Dec 7, 2023
1 parent e6db4a7 commit 141c6fc
Show file tree
Hide file tree
Showing 29 changed files with 604 additions and 389 deletions.
15 changes: 8 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0"/>
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="CsvHelper" Version="30.0.1" />
<PackageVersion Include="Equ" Version="2.3.0" />
<PackageVersion Include="fo-dicom.Imaging.ImageSharp" Version="5.1.0" />
<PackageVersion Include="HIC.DicomTypeTranslation" Version="4.0.3" />
<PackageVersion Include="HIC.FAnsiSql" Version="3.1.1" />
<PackageVersion Include="HIC.RDMP.Plugin" Version="8.0.7" />
<PackageVersion Include="IKVM" Version="8.7.1"/>
<PackageVersion Include="IKVM" Version="8.7.1" />
<PackageVersion Include="Lib.Harmony" Version="2.2.2" />
<PackageVersion Include="Magick.NET-Q16-AnyCPU" Version="13.4.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageVersion Include="NLog" Version="5.2.6" />
<PackageVersion Include="SecurityCodeScan.VS2019" Version="5.6.7"/>
<PackageVersion Include="NUnit.Analyzers" Version="3.10.0" />
<PackageVersion Include="SecurityCodeScan.VS2019" Version="5.6.7" />
<PackageVersion Include="System.IO.Abstractions" Version="19.2.87" />
<PackageVersion Include="System.IO.FileSystem" Version="4.3.0" />
<PackageVersion Include="Terminal.Gui" Version="1.14.1" />
<PackageVersion Include="Tesseract" Version="4.1.1" />
<PackageVersion Include="YamlDotNet" Version="13.7.1" />
<PackageVersion Include="YamlDotNet" Version="13.7.1" />
<!-- Test Packages -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="NUnit" Version="4.0.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="19.2.87" />
</ItemGroup>
</Project>
</Project>
6 changes: 5 additions & 1 deletion IsIdentifiable/Reporting/Destinations/ReportDestination.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using IsIdentifiable.Options;
using System.Data;
using System.IO.Abstractions;
Expand Down Expand Up @@ -51,7 +52,10 @@ public virtual void WriteHeader(params string[] headers) { }
/// <summary>
/// Override to perform any tidyup on the destination e.g. close file handles / end transactions
/// </summary>
public virtual void Dispose() { }
public virtual void Dispose()
{
GC.SuppressFinalize(this);
}

/// <summary>
/// Returns <paramref name="o"/> with whitespace stripped (if it is a string and <see cref="IsIdentifiableOptions.DestinationNoWhitespace"/>
Expand Down
69 changes: 40 additions & 29 deletions Tests/IsIdentifiableTests/AllowListRuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using IsIdentifiable.Failures;
using IsIdentifiable.Failures;
using IsIdentifiable.Rules;
using NUnit.Framework;

Expand All @@ -16,15 +16,18 @@ public void TestAllowlistRule_IfPattern_CaseSensitivity()
IfPattern = "fff"
};

Assert.IsFalse(rule.CaseSensitive);
Assert.Multiple(() =>
{
Assert.That(rule.CaseSensitive, Is.False);

Assert.AreEqual(
RuleAction.Ignore, rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)));
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)), Is.EqualTo(RuleAction.Ignore));
});

rule.CaseSensitive = true;

Assert.AreEqual(
RuleAction.None, rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)));
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)), Is.EqualTo(RuleAction.None));
}

[Test]
Expand All @@ -36,15 +39,18 @@ public void TestAllowlistRule_IfPartPattern_CaseSensitivity()
IfPartPattern = "^troll$"
};

Assert.IsFalse(rule.CaseSensitive);
Assert.Multiple(() =>
{
Assert.That(rule.CaseSensitive, Is.False);

Assert.AreEqual(
RuleAction.Ignore, rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)));
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)), Is.EqualTo(RuleAction.Ignore));
});

rule.CaseSensitive = true;

Assert.AreEqual(
RuleAction.None, rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)));
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll", new FailurePart("Troll", FailureClassification.Location, 0)), Is.EqualTo(RuleAction.None));
}

[Test]
Expand All @@ -57,14 +63,16 @@ public void TestAllowlistRule_As()
As = FailureClassification.Person
};

Assert.Multiple(() =>
{
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll",
new FailurePart("Troll", FailureClassification.Location, 0)), Is.EqualTo(RuleAction.None), "Rule should not apply when FailureClassification is Location");

Assert.AreEqual(
RuleAction.None, rule.ApplyAllowlistRule("aba", "FFF Troll",
new FailurePart("Troll", FailureClassification.Location, 0)), "Rule should not apply when FailureClassification is Location");

Assert.AreEqual(
RuleAction.Ignore, rule.ApplyAllowlistRule("aba", "FFF Troll",
new FailurePart("Troll", FailureClassification.Person, 0)), "Rule SHOULD apply when FailureClassification matches As");
Assert.That(
rule.ApplyAllowlistRule("aba", "FFF Troll",
new FailurePart("Troll", FailureClassification.Person, 0)), Is.EqualTo(RuleAction.Ignore), "Rule SHOULD apply when FailureClassification matches As");
});

}

Expand All @@ -77,17 +85,20 @@ public void TestCombiningPatternAndPart()
IfPattern = "^MR Brian And Skull$"
};

Assert.AreEqual(
RuleAction.Ignore, rule.ApplyAllowlistRule("aba", "MR Brian And Skull",
new FailurePart("Brian", FailureClassification.Person, 0)), "Rule matches on both patterns");

Assert.AreEqual(
RuleAction.None, rule.ApplyAllowlistRule("aba", "MR Brian And Skull",
new FailurePart("Skull", FailureClassification.Person, 0)), "Rule does not match on both whole string AND part so should not be ignored");

Assert.AreEqual(
RuleAction.None, rule.ApplyAllowlistRule("aba", "MR Brian And Skull Dr Fisher",
new FailurePart("Brian", FailureClassification.Person, 0)), "Rule does not match on both whole string AND part so should not be ignored");
Assert.Multiple(() =>
{
Assert.That(
rule.ApplyAllowlistRule("aba", "MR Brian And Skull",
new FailurePart("Brian", FailureClassification.Person, 0)), Is.EqualTo(RuleAction.Ignore), "Rule matches on both patterns");

Assert.That(
rule.ApplyAllowlistRule("aba", "MR Brian And Skull",
new FailurePart("Skull", FailureClassification.Person, 0)), Is.EqualTo(RuleAction.None), "Rule does not match on both whole string AND part so should not be ignored");

Assert.That(
rule.ApplyAllowlistRule("aba", "MR Brian And Skull Dr Fisher",
new FailurePart("Brian", FailureClassification.Person, 0)), Is.EqualTo(RuleAction.None), "Rule does not match on both whole string AND part so should not be ignored");
});
}


Expand Down
34 changes: 23 additions & 11 deletions Tests/IsIdentifiableTests/ConsensusRuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ public void NoConsensus_OnlyOneHasProblem()

var result = rule.Apply("ff", "vv", out var badParts);

Assert.AreEqual(RuleAction.None, result);
Assert.IsEmpty(badParts);
Assert.Multiple(() =>
{
Assert.That(result, Is.EqualTo(RuleAction.None));
Assert.That(badParts, Is.Empty);
});
}

[TestCase(-1)]
Expand All @@ -42,8 +45,11 @@ public void Consensus_Exact(int offset)

var result = rule.Apply("ff", "vv", out var badParts);

Assert.AreEqual(RuleAction.Report, result);
Assert.AreEqual(offset, badParts.Single().Offset);
Assert.Multiple(() =>
{
Assert.That(result, Is.EqualTo(RuleAction.Report));
Assert.That(badParts.Single().Offset, Is.EqualTo(offset));
});
}

[Test]
Expand All @@ -61,10 +67,13 @@ public void Consensus_SingleOverlap()

var result = rule.Apply("ff", "abc is so cool", out var badParts);

Assert.AreEqual(RuleAction.Report, result);
Assert.That(result, Is.EqualTo(RuleAction.Report));
var badPart = badParts.Single();
Assert.AreEqual(10, badPart.Offset);
Assert.AreEqual("ab", badPart.Word);
Assert.Multiple(() =>
{
Assert.That(badPart.Offset, Is.EqualTo(10));
Assert.That(badPart.Word, Is.EqualTo("ab"));
});
}

[Test]
Expand All @@ -84,10 +93,13 @@ public void TestDeserialization()
var deserializer = IsIdentifiableAbstractRunner.GetDeserializer();
var ruleSet = deserializer.Deserialize<RuleSet>(yaml);

Assert.IsInstanceOf(typeof(ConsensusRule), ruleSet.ConsensusRules.Single());
Assert.IsInstanceOf(typeof(SocketRule), ruleSet.ConsensusRules.Single().Rules[0]);
Assert.AreEqual(1234, ((SocketRule)ruleSet.ConsensusRules.Single().Rules[0]).Port);
Assert.AreEqual(567, ((SocketRule)ruleSet.ConsensusRules.Single().Rules[1]).Port);
Assert.That(ruleSet.ConsensusRules.Single(), Is.InstanceOf(typeof(ConsensusRule)));
Assert.Multiple(() =>
{
Assert.That(ruleSet.ConsensusRules.Single().Rules[0], Is.InstanceOf(typeof(SocketRule)));
Assert.That(((SocketRule)ruleSet.ConsensusRules.Single().Rules[0]).Port, Is.EqualTo(1234));
Assert.That(((SocketRule)ruleSet.ConsensusRules.Single().Rules[1]).Port, Is.EqualTo(567));
});
}

internal class TestRule : IAppliableRule
Expand Down
11 changes: 7 additions & 4 deletions Tests/IsIdentifiableTests/DatabaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void CheckFiles()
ImplementationManager.Load<OracleImplementation>();
ImplementationManager.Load<PostgreSqlImplementation>();

Assert.IsTrue(System.IO.File.Exists(TestFilename), "Could not find {0}", TestFilename);
Assert.That(System.IO.File.Exists(TestFilename), Is.True, $"Could not find {TestFilename}");

var doc = XDocument.Load(TestFilename);

Expand Down Expand Up @@ -154,13 +154,16 @@ protected static bool AreBasicallyEquals(object o, object o2, bool handleSlashRS

protected void AssertAreEqual(DataTable dt1, DataTable dt2)
{
Assert.AreEqual(dt1.Columns.Count, dt2.Columns.Count, "DataTables had a column count mismatch");
Assert.AreEqual(dt1.Rows.Count, dt2.Rows.Count, "DataTables had a row count mismatch");
Assert.Multiple(() =>
{
Assert.That(dt2.Columns, Has.Count.EqualTo(dt1.Columns.Count), "DataTables had a column count mismatch");
Assert.That(dt2.Rows, Has.Count.EqualTo(dt1.Rows.Count), "DataTables had a row count mismatch");
});

foreach (DataRow row1 in dt1.Rows)
{
var match = dt2.Rows.Cast<DataRow>().Any(row2 => dt1.Columns.Cast<DataColumn>().All(column => AreBasicallyEquals(row1[column.ColumnName], row2[column.ColumnName])));
Assert.IsTrue(match, "Couldn't find match for row:{0}", string.Join(",", row1.ItemArray));
Assert.That(match, Is.True, $"Couldn't find match for row:{string.Join(",", row1.ItemArray)}");
}

}
Expand Down
11 changes: 7 additions & 4 deletions Tests/IsIdentifiableTests/ExampleUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public void ExampleUsageOfIsIdentifiable()
// fetch and analyise data
runner.Run();

Assert.AreEqual(1, dest.Failures.Count);
Assert.AreEqual(2, dest.Failures[0].Parts.Count);
Assert.AreEqual("2Mar", dest.Failures[0].Parts[0].Word);
Assert.AreEqual("0101010101", dest.Failures[0].Parts[1].Word);
Assert.That(dest.Failures, Has.Count.EqualTo(1));
Assert.That(dest.Failures[0].Parts, Has.Count.EqualTo(2));
Assert.Multiple(() =>
{
Assert.That(dest.Failures[0].Parts[0].Word, Is.EqualTo("2Mar"));
Assert.That(dest.Failures[0].Parts[1].Word, Is.EqualTo("0101010101"));
});
}
}
4 changes: 4 additions & 0 deletions Tests/IsIdentifiableTests/IsIdentifiable.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 141c6fc

Please sign in to comment.