diff --git a/Directory.Packages.props b/Directory.Packages.props
index 17699cd2..64b9a6be 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -6,30 +6,31 @@
-
+
-
+
-
+
+
-
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/IsIdentifiable/Reporting/Destinations/ReportDestination.cs b/IsIdentifiable/Reporting/Destinations/ReportDestination.cs
index 98ae9f06..c27be22c 100644
--- a/IsIdentifiable/Reporting/Destinations/ReportDestination.cs
+++ b/IsIdentifiable/Reporting/Destinations/ReportDestination.cs
@@ -1,3 +1,4 @@
+using System;
using IsIdentifiable.Options;
using System.Data;
using System.IO.Abstractions;
@@ -51,7 +52,10 @@ public virtual void WriteHeader(params string[] headers) { }
///
/// Override to perform any tidyup on the destination e.g. close file handles / end transactions
///
- public virtual void Dispose() { }
+ public virtual void Dispose()
+ {
+ GC.SuppressFinalize(this);
+ }
///
/// Returns with whitespace stripped (if it is a string and
diff --git a/Tests/IsIdentifiableTests/AllowListRuleTests.cs b/Tests/IsIdentifiableTests/AllowListRuleTests.cs
index d9c8d8c0..0295681b 100644
--- a/Tests/IsIdentifiableTests/AllowListRuleTests.cs
+++ b/Tests/IsIdentifiableTests/AllowListRuleTests.cs
@@ -1,4 +1,4 @@
-using IsIdentifiable.Failures;
+using IsIdentifiable.Failures;
using IsIdentifiable.Rules;
using NUnit.Framework;
@@ -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]
@@ -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]
@@ -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");
+ });
}
@@ -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");
+ });
}
diff --git a/Tests/IsIdentifiableTests/ConsensusRuleTests.cs b/Tests/IsIdentifiableTests/ConsensusRuleTests.cs
index 910de90d..255f1ce4 100644
--- a/Tests/IsIdentifiableTests/ConsensusRuleTests.cs
+++ b/Tests/IsIdentifiableTests/ConsensusRuleTests.cs
@@ -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)]
@@ -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]
@@ -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]
@@ -84,10 +93,13 @@ public void TestDeserialization()
var deserializer = IsIdentifiableAbstractRunner.GetDeserializer();
var ruleSet = deserializer.Deserialize(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
diff --git a/Tests/IsIdentifiableTests/DatabaseTests.cs b/Tests/IsIdentifiableTests/DatabaseTests.cs
index df6d7d6e..be797dc8 100644
--- a/Tests/IsIdentifiableTests/DatabaseTests.cs
+++ b/Tests/IsIdentifiableTests/DatabaseTests.cs
@@ -36,7 +36,7 @@ public void CheckFiles()
ImplementationManager.Load();
ImplementationManager.Load();
- 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);
@@ -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().Any(row2 => dt1.Columns.Cast().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)}");
}
}
diff --git a/Tests/IsIdentifiableTests/ExampleUsage.cs b/Tests/IsIdentifiableTests/ExampleUsage.cs
index 21570bae..0c74188f 100644
--- a/Tests/IsIdentifiableTests/ExampleUsage.cs
+++ b/Tests/IsIdentifiableTests/ExampleUsage.cs
@@ -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"));
+ });
}
}
diff --git a/Tests/IsIdentifiableTests/IsIdentifiable.Tests.csproj b/Tests/IsIdentifiableTests/IsIdentifiable.Tests.csproj
index f3b20ece..8e19e965 100644
--- a/Tests/IsIdentifiableTests/IsIdentifiable.Tests.csproj
+++ b/Tests/IsIdentifiableTests/IsIdentifiable.Tests.csproj
@@ -18,6 +18,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Tests/IsIdentifiableTests/IsIdentifiableRelationalDatabaseOptionsTests.cs b/Tests/IsIdentifiableTests/IsIdentifiableRelationalDatabaseOptionsTests.cs
index 745717a1..e70d56b3 100644
--- a/Tests/IsIdentifiableTests/IsIdentifiableRelationalDatabaseOptionsTests.cs
+++ b/Tests/IsIdentifiableTests/IsIdentifiableRelationalDatabaseOptionsTests.cs
@@ -1,4 +1,4 @@
-using FAnsi;
+using FAnsi;
using IsIdentifiable.Options;
using NUnit.Framework;
using System;
@@ -21,28 +21,40 @@ public void TestReturnValueForUsingTargets()
{
var opt = new IsIdentifiableRelationalDatabaseOptions();
- // no file no problem
- Assert.AreEqual(0, opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem));
- Assert.IsEmpty(targets);
+ Assert.Multiple(() =>
+ {
+ // no file no problem
+ Assert.That(opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem), Is.EqualTo(0));
+ Assert.That(targets, Is.Empty);
+ });
var ff = "fff.yaml";
opt.TargetsFile = ff;
- // error code because file does not exist
- Assert.AreEqual(1, opt.UpdateConnectionStringsToUseTargets(out targets, _fileSystem));
- Assert.IsEmpty(targets);
+ Assert.Multiple(() =>
+ {
+ // error code because file does not exist
+ Assert.That(opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem), Is.EqualTo(1));
+ Assert.That(targets, Is.Empty);
+ });
_fileSystem.File.WriteAllText(ff, @$"");
- // file exists but is empty
- Assert.AreEqual(2, opt.UpdateConnectionStringsToUseTargets(out targets, _fileSystem));
- Assert.IsEmpty(targets);
+ Assert.Multiple(() =>
+ {
+ // file exists but is empty
+ Assert.That(opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem), Is.EqualTo(2));
+ Assert.That(targets, Is.Empty);
+ });
_fileSystem.File.WriteAllText(ff, @$"Ahoy ye pirates");
- // file exists and has random garbage in it
- Assert.AreEqual(4, opt.UpdateConnectionStringsToUseTargets(out targets, _fileSystem));
- Assert.IsEmpty(targets);
+ Assert.Multiple(() =>
+ {
+ // file exists and has random garbage in it
+ Assert.That(opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem), Is.EqualTo(4));
+ Assert.That(targets, Is.Empty);
+ });
_fileSystem.File.WriteAllText(
ff,
@@ -50,16 +62,19 @@ public void TestReturnValueForUsingTargets()
ConnectionString: yarg
DatabaseType: MySql");
- // valid Targets file
- Assert.AreEqual(0, opt.UpdateConnectionStringsToUseTargets(out targets, _fileSystem));
- Assert.AreEqual(1, targets.Count);
+ Assert.Multiple(() =>
+ {
+ // valid Targets file
+ Assert.That(opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem), Is.EqualTo(0));
+ Assert.That(targets, Has.Count.EqualTo(1));
+ });
}
[TestCase("fff", false)]
[TestCase("MyServer", true)]
[TestCase("myserver", true)]
[TestCase(null, false)]
- public void TestUsingTargetNameForConstr(string constr, bool expectToUseTargets)
+ public void TestUsingTargetNameForConstr(string? constr, bool expectToUseTargets)
{
var targetConstr = "Server=localhost;Username=root;Password=fff";
@@ -93,24 +108,33 @@ private void Test(IsIdentifiableRelationalDatabaseOptions opt, string constr, st
{
// there is 1 target
opt.UpdateConnectionStringsToUseTargets(out var targets, _fileSystem);
- Assert.AreEqual(1, targets.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(targets, Has.Count.EqualTo(1));
- Assert.IsNull(getter(opt));
+ Assert.That(getter(opt), Is.Null);
+ });
setter(opt, constr);
opt.UpdateConnectionStringsToUseTargets(out _, _fileSystem);
if (expectToUseTargets)
{
- Assert.AreEqual(targetConstr, getter(opt));
- Assert.AreEqual(DatabaseType.MySql, getterDbType(opt));
+ Assert.Multiple(() =>
+ {
+ Assert.That(getter(opt), Is.EqualTo(targetConstr));
+ Assert.That(getterDbType(opt), Is.EqualTo(DatabaseType.MySql));
+ });
}
else
{
- Assert.AreEqual(constr, getter(opt));
+ Assert.Multiple(() =>
+ {
+ Assert.That(getter(opt), Is.EqualTo(constr));
- // the default
- Assert.IsTrue(getterDbType(opt) == DatabaseType.MicrosoftSQLServer || getterDbType(opt) == null);
+ // the default
+ Assert.That(getterDbType(opt) == DatabaseType.MicrosoftSQLServer || getterDbType(opt) == null, Is.True);
+ });
}
}
}
diff --git a/Tests/IsIdentifiableTests/IsIdentifiableYamlRulesTests.cs b/Tests/IsIdentifiableTests/IsIdentifiableYamlRulesTests.cs
index 0e5b6ae8..101813c9 100644
--- a/Tests/IsIdentifiableTests/IsIdentifiableYamlRulesTests.cs
+++ b/Tests/IsIdentifiableTests/IsIdentifiableYamlRulesTests.cs
@@ -1,4 +1,4 @@
-using IsIdentifiable.Failures;
+using IsIdentifiable.Failures;
using IsIdentifiable.Rules;
using NUnit.Framework;
using System;
@@ -36,17 +36,15 @@ public void TestYamlDeserialization_OfRules()
var deserializer = new Deserializer();
var ruleSet = deserializer.Deserialize(yaml);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ruleSet.BasicRules, Has.Count.EqualTo(3));
+ Assert.That(ruleSet.BasicRules[0].Action, Is.EqualTo(RuleAction.Ignore));
- Assert.AreEqual(3, ruleSet.BasicRules.Count);
-
- Assert.AreEqual(RuleAction.Ignore, ruleSet.BasicRules[0].Action);
-
-
- Assert.AreEqual(1, ruleSet.SocketRules.Count);
-
- Assert.AreEqual("127.0.123.123", ruleSet.SocketRules[0].Host);
- Assert.AreEqual(8080, ruleSet.SocketRules[0].Port);
-
+ Assert.That(ruleSet.SocketRules, Has.Count.EqualTo(1));
+ Assert.That(ruleSet.SocketRules[0].Host, Is.EqualTo("127.0.123.123"));
+ Assert.That(ruleSet.SocketRules[0].Port, Is.EqualTo(8080));
+ });
}
[TestCase(true)]
@@ -60,14 +58,14 @@ public void TestOneRule_IsColumnMatch_NoPattern(bool isReport)
As = FailureClassification.Date
};
- Assert.AreEqual(isReport ? RuleAction.Report : RuleAction.Ignore, rule.Apply("MODALITY", "CT", out var bad));
+ Assert.That(rule.Apply("MODALITY", "CT", out var bad), Is.EqualTo(isReport ? RuleAction.Report : RuleAction.Ignore));
if (isReport)
- Assert.AreEqual(FailureClassification.Date, bad.Single().Classification);
+ Assert.That(bad.Single().Classification, Is.EqualTo(FailureClassification.Date));
else
- Assert.IsEmpty(bad);
+ Assert.That(bad, Is.Empty);
- Assert.AreEqual(RuleAction.None, rule.Apply("ImageType", "PRIMARY", out _));
+ Assert.That(rule.Apply("ImageType", "PRIMARY", out _), Is.EqualTo(RuleAction.None));
}
[TestCase(true)]
@@ -82,26 +80,27 @@ public void Test_RegexMultipleMatches(bool isReport)
As = FailureClassification.Date
};
- Assert.AreEqual(isReport ? RuleAction.Report : RuleAction.Ignore, rule.Apply("MODALITY", "1,2,3", out var bad));
+ Assert.That(rule.Apply("MODALITY", "1,2,3", out var bad), Is.EqualTo(isReport ? RuleAction.Report : RuleAction.Ignore));
if (isReport)
{
- var b = bad.ToArray();
-
- Assert.AreEqual(2, b.Length);
-
- Assert.AreEqual("1,", b[0].Word);
- Assert.AreEqual(FailureClassification.Date, b[0].Classification);
- Assert.AreEqual(0, b[0].Offset);
-
- Assert.AreEqual("2,", b[1].Word);
- Assert.AreEqual(FailureClassification.Date, b[1].Classification);
- Assert.AreEqual(2, b[1].Offset);
+ Assert.Multiple(() =>
+ {
+ var b = bad.ToArray();
+
+ Assert.That(b[0].Word, Is.EqualTo("1,"));
+ Assert.That(b[0].Classification, Is.EqualTo(FailureClassification.Date));
+ Assert.That(b[0].Offset, Is.EqualTo(0));
+
+ Assert.That(b[1].Word, Is.EqualTo("2,"));
+ Assert.That(b[1].Classification, Is.EqualTo(FailureClassification.Date));
+ Assert.That(b[1].Offset, Is.EqualTo(2));
+ });
}
else
- Assert.IsEmpty(bad);
+ Assert.That(bad, Is.Empty);
- Assert.AreEqual(RuleAction.None, rule.Apply("ImageType", "PRIMARY", out _));
+ Assert.That(rule.Apply("ImageType", "PRIMARY", out _), Is.EqualTo(RuleAction.None));
}
[TestCase(true)]
@@ -116,9 +115,12 @@ public void TestOneRule_IsColumnMatch_WithPattern(bool isReport)
As = FailureClassification.Date
};
- Assert.AreEqual(isReport ? RuleAction.Report : RuleAction.Ignore, rule.Apply("Modality", "CT", out _));
- Assert.AreEqual(RuleAction.None, rule.Apply("Modality", "MR", out _));
- Assert.AreEqual(RuleAction.None, rule.Apply("ImageType", "PRIMARY", out _));
+ Assert.Multiple(() =>
+ {
+ Assert.That(rule.Apply("Modality", "CT", out _), Is.EqualTo(isReport ? RuleAction.Report : RuleAction.Ignore));
+ Assert.That(rule.Apply("Modality", "MR", out _), Is.EqualTo(RuleAction.None));
+ Assert.That(rule.Apply("ImageType", "PRIMARY", out _), Is.EqualTo(RuleAction.None));
+ });
}
[TestCase(true)]
@@ -132,9 +134,12 @@ public void TestOneRule_NoColumn_WithPattern(bool isReport)
As = FailureClassification.Date
};
- Assert.AreEqual(isReport ? RuleAction.Report : RuleAction.Ignore, rule.Apply("Modality", "CT", out _));
- Assert.AreEqual(isReport ? RuleAction.Report : RuleAction.Ignore, rule.Apply("ImageType", "CT", out _)); //ignore both because no restriction on column
- Assert.AreEqual(RuleAction.None, rule.Apply("ImageType", "PRIMARY", out _));
+ Assert.Multiple(() =>
+ {
+ Assert.That(rule.Apply("Modality", "CT", out _), Is.EqualTo(isReport ? RuleAction.Report : RuleAction.Ignore));
+ Assert.That(rule.Apply("ImageType", "CT", out _), Is.EqualTo(isReport ? RuleAction.Report : RuleAction.Ignore)); //ignore both because no restriction on column
+ Assert.That(rule.Apply("ImageType", "PRIMARY", out _), Is.EqualTo(RuleAction.None));
+ });
}
[Test]
@@ -143,28 +148,34 @@ public void TestAreIdentical()
var rule1 = new RegexRule();
var rule2 = new RegexRule();
- Assert.IsTrue(rule1.AreIdentical(rule2));
+ Assert.That(rule1.AreIdentical(rule2), Is.True);
rule2.IfPattern = "\r\n";
- Assert.IsFalse(rule1.AreIdentical(rule2));
+ Assert.That(rule1.AreIdentical(rule2), Is.False);
rule1.IfPattern = "\r\n";
- Assert.IsTrue(rule1.AreIdentical(rule2));
+ Assert.That(rule1.AreIdentical(rule2), Is.True);
rule2.IfColumn = "MyCol";
- Assert.IsFalse(rule1.AreIdentical(rule2));
+ Assert.That(rule1.AreIdentical(rule2), Is.False);
rule1.IfColumn = "MyCol";
- Assert.IsTrue(rule1.AreIdentical(rule2));
+ Assert.That(rule1.AreIdentical(rule2), Is.True);
rule2.Action = RuleAction.Ignore;
rule1.Action = RuleAction.Report;
- Assert.IsFalse(rule1.AreIdentical(rule2, true));
- Assert.IsTrue(rule1.AreIdentical(rule2, false));
+ Assert.Multiple(() =>
+ {
+ Assert.That(rule1.AreIdentical(rule2, true), Is.False);
+ Assert.That(rule1.AreIdentical(rule2, false), Is.True);
+ });
rule2.Action = RuleAction.Report;
rule1.Action = RuleAction.Report;
- Assert.IsTrue(rule1.AreIdentical(rule2, false));
- Assert.IsTrue(rule1.AreIdentical(rule2, true));
+ Assert.Multiple(() =>
+ {
+ Assert.That(rule1.AreIdentical(rule2, false), Is.True);
+ Assert.That(rule1.AreIdentical(rule2, true), Is.True);
+ });
}
[TestCase(true)]
@@ -179,6 +190,6 @@ public void TestOneRule_NoColumn_NoPattern(bool isReport)
var ex = Assert.Throws(() => rule.Apply("Modality", "CT", out _));
- Assert.AreEqual("Illegal rule setup. You must specify either a column or a pattern (or both)", ex.Message);
+ Assert.That(ex.Message, Is.EqualTo("Illegal rule setup. You must specify either a column or a pattern (or both)"));
}
}
diff --git a/Tests/IsIdentifiableTests/IsIdentifiable_TestRegexDetections.cs b/Tests/IsIdentifiableTests/IsIdentifiable_TestRegexDetections.cs
index 90d87ec8..214fef56 100644
--- a/Tests/IsIdentifiableTests/IsIdentifiable_TestRegexDetections.cs
+++ b/Tests/IsIdentifiableTests/IsIdentifiable_TestRegexDetections.cs
@@ -28,8 +28,11 @@ public void TestChiInString()
var p = runner.ResultsOfValidate.Single();
- Assert.AreEqual("0101010101", p.Word);
- Assert.AreEqual(10, p.Offset);
+ Assert.Multiple(() =>
+ {
+ Assert.That(p.Word, Is.EqualTo("0101010101"));
+ Assert.That(p.Offset, Is.EqualTo(10));
+ });
}
[Test]
@@ -37,7 +40,7 @@ public void TestChiBadDate()
{
var runner = new TestRunner("2902810123 would be a CHI if 1981 had been a leap year", _fileSystem);
runner.Run();
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
[Test]
@@ -45,36 +48,63 @@ public void TestCaching()
{
var runner = new TestRunner("hey there,0101010101 excited to see you", _fileSystem);
runner.Run();
- Assert.AreEqual(0, runner.ValidateCacheHits);
- Assert.AreEqual(1, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(0));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(1));
+ });
runner.Run();
- Assert.AreEqual(1, runner.ValidateCacheHits);
- Assert.AreEqual(1, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(1));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(1));
+ });
runner.Run();
- Assert.AreEqual(2, runner.ValidateCacheHits);
- Assert.AreEqual(1, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(2));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(1));
+ });
runner.ValueToTest = "ffffff";
runner.Run();
- Assert.AreEqual(2, runner.ValidateCacheHits);
- Assert.AreEqual(2, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(2));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(2));
+ });
runner.Run();
- Assert.AreEqual(3, runner.ValidateCacheHits);
- Assert.AreEqual(2, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(3));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(2));
+ });
runner.Run();
- Assert.AreEqual(4, runner.ValidateCacheHits);
- Assert.AreEqual(2, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(4));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(2));
+ });
runner.FieldToTest = "OtherField";
runner.Run();
- Assert.AreEqual(4, runner.ValidateCacheHits);
- Assert.AreEqual(3, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(4));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(3));
+ });
runner.Run();
- Assert.AreEqual(5, runner.ValidateCacheHits);
- Assert.AreEqual(3, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(5));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(3));
+ });
runner.Run();
- Assert.AreEqual(6, runner.ValidateCacheHits);
- Assert.AreEqual(3, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(6));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(3));
+ });
}
[Test]
public void Test_NoCaching()
@@ -85,14 +115,23 @@ public void Test_NoCaching()
};
runner.Run();
- Assert.AreEqual(0, runner.ValidateCacheHits);
- Assert.AreEqual(1, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(0));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(1));
+ });
runner.Run();
- Assert.AreEqual(0, runner.ValidateCacheHits);
- Assert.AreEqual(2, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(0));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(2));
+ });
runner.Run();
- Assert.AreEqual(0, runner.ValidateCacheHits);
- Assert.AreEqual(3, runner.ValidateCacheMisses);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ValidateCacheHits, Is.EqualTo(0));
+ Assert.That(runner.ValidateCacheMisses, Is.EqualTo(3));
+ });
runner.Run();
}
[TestCase("DD3 7LB")]
@@ -105,10 +144,13 @@ public void IsIdentifiable_TestPostcodes(string code)
var p = runner.ResultsOfValidate.Single();
- //this would be nice
- Assert.AreEqual(code, p.Word);
- Assert.AreEqual(17, p.Offset);
- Assert.AreEqual(FailureClassification.Postcode, p.Classification);
+ Assert.Multiple(() =>
+ {
+ //this would be nice
+ Assert.That(p.Word, Is.EqualTo(code));
+ Assert.That(p.Offset, Is.EqualTo(17));
+ Assert.That(p.Classification, Is.EqualTo(FailureClassification.Postcode));
+ });
}
[TestCase("DD3 7LB")]
@@ -127,7 +169,7 @@ public void IsIdentifiable_TestPostcodes_AllowlistDD3(string code)
runner.Run();
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
[TestCase("DD3 7LB")]
@@ -140,7 +182,7 @@ public void IsIdentifiable_TestPostcodes_IgnorePostcodesFlagSet(string code)
runner.Run();
//there won't be any failure results reported
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
@@ -155,10 +197,13 @@ public void IsIdentifiable_TestPostcodes_EmbeddedInText(string find, string expe
var p = runner.ResultsOfValidate.Single();
- //this would be nice
- Assert.AreEqual(expectedMatch, p.Word);
- Assert.AreEqual(FailureClassification.Postcode, p.Classification);
- Assert.AreEqual(1, runner.CountOfFailureParts);
+ Assert.Multiple(() =>
+ {
+ //this would be nice
+ Assert.That(p.Word, Is.EqualTo(expectedMatch));
+ Assert.That(p.Classification, Is.EqualTo(FailureClassification.Postcode));
+ Assert.That(runner.CountOfFailureParts, Is.EqualTo(1));
+ });
}
[TestCase("dd3000")]
@@ -170,7 +215,7 @@ public void IsIdentifiable_TestNotAPostcode(string code)
var runner = new TestRunner($"Patient lives at {code}", _fileSystem);
runner.Run();
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
@@ -198,23 +243,32 @@ public void IsIdentifiable_TestNotAPostcode(string code)
//[TestCase("05:50:06", "05:50:06", null, null)]
[TestCase("2015 May", "2015 May", null, null)]
//[TestCase("AB 13:10", "13:10", null, null)]
- public void IsIdentifiable_TestDates(string date, string expectedMatch1, string expectedMatch2, string expectedMatch3)
+ public void IsIdentifiable_TestDates(string date, string expectedMatch1, string? expectedMatch2, string? expectedMatch3)
{
var runner = new TestRunner($"Patient next appointment is {date}", _fileSystem);
runner.Run();
- Assert.AreEqual(expectedMatch1, runner.ResultsOfValidate[0].Word);
- Assert.AreEqual(FailureClassification.Date, runner.ResultsOfValidate[0].Classification);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ResultsOfValidate[0].Word, Is.EqualTo(expectedMatch1));
+ Assert.That(runner.ResultsOfValidate[0].Classification, Is.EqualTo(FailureClassification.Date));
+ });
if (expectedMatch2 != null)
{
- Assert.AreEqual(expectedMatch2, runner.ResultsOfValidate[1].Word);
- Assert.AreEqual(FailureClassification.Date, runner.ResultsOfValidate[1].Classification);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ResultsOfValidate[1].Word, Is.EqualTo(expectedMatch2));
+ Assert.That(runner.ResultsOfValidate[1].Classification, Is.EqualTo(FailureClassification.Date));
+ });
}
if (expectedMatch3 != null)
{
- Assert.AreEqual(expectedMatch3, runner.ResultsOfValidate[2].Word);
- Assert.AreEqual(FailureClassification.Date, runner.ResultsOfValidate[2].Classification);
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.ResultsOfValidate[2].Word, Is.EqualTo(expectedMatch3));
+ Assert.That(runner.ResultsOfValidate[2].Classification, Is.EqualTo(FailureClassification.Date));
+ });
}
}
@@ -229,7 +283,7 @@ public void IsIdentifiable_Test_NotADate(string input)
var runner = new TestRunner(input, _fileSystem);
runner.Run();
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
[Test]
@@ -238,24 +292,27 @@ public void TestChiAndNameInString()
var runner = new TestRunner("David Smith should be referred to with chi 0101010101", _fileSystem);
runner.Run();
- Assert.AreEqual(1, runner.ResultsOfValidate.Count);
+ Assert.That(runner.ResultsOfValidate, Has.Count.EqualTo(1));
var w1 = runner.ResultsOfValidate[0];
- /* Names are now picked up by the Socket NER Daemon
- //FailurePart w2 = runner.ResultsOfValidate[1];
- //FailurePart w3 = runner.ResultsOfValidate[2];
+ Assert.Multiple(() =>
+ {
+ /* Names are now picked up by the Socket NER Daemon
+ //FailurePart w2 = runner.ResultsOfValidate[1];
+ //FailurePart w3 = runner.ResultsOfValidate[2];
+
-
- Assert.AreEqual("David", w1.Word);
- Assert.AreEqual(0, w1.Offset);
+ Assert.AreEqual("David", w1.Word);
+ Assert.AreEqual(0, w1.Offset);
- Assert.AreEqual("Smith", w2.Word);
- Assert.AreEqual(6, w2.Offset);
- */
+ Assert.AreEqual("Smith", w2.Word);
+ Assert.AreEqual(6, w2.Offset);
+ */
- Assert.AreEqual("0101010101", w1.Word);
- Assert.AreEqual(43, w1.Offset);
+ Assert.That(w1.Word, Is.EqualTo("0101010101"));
+ Assert.That(w1.Offset, Is.EqualTo(43));
+ });
}
[TestCase(true)]
@@ -276,9 +333,9 @@ public void TestCaseSensitivity_BlackBox(bool caseSensitive)
runner.Run();
if (caseSensitive)
- Assert.AreEqual(1, runner.ResultsOfValidate.Count);
+ Assert.That(runner.ResultsOfValidate, Has.Count.EqualTo(1));
else
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
///
@@ -308,7 +365,7 @@ public void TestRuleOrdering_BlackBox(bool ignoreFirst)
runner.Run();
- Assert.IsEmpty(runner.ResultsOfValidate);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
[Test]
@@ -324,7 +381,7 @@ public void TestSopDoesNotMatch()
var runner = new TestRunner(exampleSop, testOpts, _fileSystem, sopKey);
runner.Run();
- Assert.AreEqual(0, runner.ResultsOfValidate.Count);
+ Assert.That(runner.ResultsOfValidate, Is.Empty);
}
[Test]
@@ -333,7 +390,7 @@ public void TestEmptyRulesDir()
var emptyDir = "empty";
_fileSystem.Directory.CreateDirectory(emptyDir);
- Assert.IsEmpty(_fileSystem.Directory.GetFiles(emptyDir, "*.yaml"), "Expected the empty dir not to have any rules yaml files", _fileSystem);
+ Assert.That(_fileSystem.Directory.GetFiles(emptyDir, "*.yaml"), Is.Empty, $"Expected the empty dir not to have any rules yaml files");
var testOpts = new TestOpts
{
@@ -341,7 +398,7 @@ public void TestEmptyRulesDir()
};
var ex = Assert.Throws(() => new TestRunner("fff", testOpts, _fileSystem));
- StringAssert.Contains(" did not contain any rules files containing rules", ex.Message);
+ Assert.That(ex.Message, Does.Contain(" did not contain any rules files containing rules"));
}
[Test]
public void TestMissingRulesDir()
@@ -354,8 +411,8 @@ public void TestMissingRulesDir()
};
var ex = Assert.Throws(() => new TestRunner("fff", testOpts, _fileSystem));
- StringAssert.Contains("Could not find a part of the path", ex.Message);
- StringAssert.Contains("hahaIdontexist", ex.Message);
+ Assert.That(ex.Message, Does.Contain("Could not find a part of the path"));
+ Assert.That(ex.Message, Does.Contain("hahaIdontexist"));
}
[TestCase("#this is an empty yaml file with no rules")]
@@ -370,7 +427,7 @@ public void TestOnlyEmptyRulesFilesInDir(string yaml)
//notice that this file is empty
_fileSystem.File.WriteAllText(rulePath, yaml);
- Assert.IsNotEmpty(_fileSystem.Directory.GetFiles(emptyishDir, "*.yaml"));
+ Assert.That(_fileSystem.Directory.GetFiles(emptyishDir, "*.yaml"), Is.Not.Empty);
var testOpts = new TestOpts
{
@@ -378,7 +435,7 @@ public void TestOnlyEmptyRulesFilesInDir(string yaml)
};
var ex = Assert.Throws(() => new TestRunner("fff", testOpts, _fileSystem));
- StringAssert.Contains(" did not contain any rules files containing rules", ex.Message);
+ Assert.That(ex.Message, Does.Contain(" did not contain any rules files containing rules"));
}
diff --git a/Tests/IsIdentifiableTests/PackageListIsCorrectTests.cs b/Tests/IsIdentifiableTests/PackageListIsCorrectTests.cs
index b791ad96..746e7a5a 100644
--- a/Tests/IsIdentifiableTests/PackageListIsCorrectTests.cs
+++ b/Tests/IsIdentifiableTests/PackageListIsCorrectTests.cs
@@ -46,7 +46,7 @@ public void TestPackagesDocumentCorrect(string rootPath = null)
.Select(m => m.Groups[1].Value).Except(packagesMarkdown).Select(BuildRecommendedMarkdownLine);
undocumented.AppendJoin(Environment.NewLine, undocumentedPackages);
- Assert.IsEmpty(undocumented.ToString());
+ Assert.That(undocumented.ToString(), Is.Empty);
}
///
@@ -72,7 +72,7 @@ private static DirectoryInfo FindRoot(string path = null)
var root = new DirectoryInfo(TestContext.CurrentContext.TestDirectory);
while (!root.EnumerateFiles("*.sln", SearchOption.TopDirectoryOnly).Any() && root.Parent != null)
root = root.Parent;
- Assert.IsNotNull(root.Parent, "Could not find root of repository");
+ Assert.That(root.Parent, Is.Not.Null, "Could not find root of repository");
return root;
}
@@ -94,7 +94,7 @@ private static IEnumerable GetCsprojFiles(DirectoryInfo root)
private static string GetPackagesMarkdown(DirectoryInfo root)
{
var path = root.EnumerateFiles("packages.md", EnumerationOptions).Select(f => f.FullName).SingleOrDefault();
- Assert.IsNotNull(path, "Could not find packages.md");
+ Assert.That(path, Is.Not.Null, "Could not find packages.md");
return path;
}
diff --git a/Tests/IsIdentifiableTests/PixelDataReportTests.cs b/Tests/IsIdentifiableTests/PixelDataReportTests.cs
index cc587a12..64ac7fd5 100644
--- a/Tests/IsIdentifiableTests/PixelDataReportTests.cs
+++ b/Tests/IsIdentifiableTests/PixelDataReportTests.cs
@@ -37,7 +37,7 @@ public void SetUp()
public void TestReportReader_PixelReport()
{
var reader = new ReportReader(_fileSystem.FileInfo.New(_pixelDataReportPath), (s) => { }, _fileSystem, CancellationToken.None);
- Assert.IsNotEmpty(reader.Failures);
+ Assert.That(reader.Failures, Is.Not.Empty);
}
@@ -57,7 +57,7 @@ public void IgnoreRuleGenerator_PixelReport()
{
var f = GetPixelFailure(out var ocrOutput);
var g = new IgnoreRuleGenerator(_fileSystem);
- Assert.AreEqual($"^{Regex.Escape(ocrOutput)}$", g.RulesFactory.GetPattern(this, f), "When the user ignores OCR data the ignore pattern should exactly match the full text discovered");
+ Assert.That(g.RulesFactory.GetPattern(this, f), Is.EqualTo($"^{Regex.Escape(ocrOutput)}$"), "When the user ignores OCR data the ignore pattern should exactly match the full text discovered");
}
[Test]
@@ -65,7 +65,7 @@ public void UpdateRuleGenerator_PixelReport()
{
var f = GetPixelFailure(out var ocrOutput);
var g = new RowUpdater(_fileSystem);
- Assert.AreEqual($"^{Regex.Escape(ocrOutput)}$", g.RulesFactory.GetPattern(this, f), "When the user markes problematic the OCR data the pattern should exactly match the full text discovered");
+ Assert.That(g.RulesFactory.GetPattern(this, f), Is.EqualTo($"^{Regex.Escape(ocrOutput)}$"), "When the user markes problematic the OCR data the pattern should exactly match the full text discovered");
}
[TestCase(typeof(SymbolsRulesFactory))]
@@ -75,7 +75,7 @@ public void SymbolsRulesFactory_PixelReport(Type factoryType)
{
var f = GetPixelFailure(out var ocrOutput);
var factory = (IRulePatternFactory)Activator.CreateInstance(factoryType);
- Assert.AreEqual($"^{Regex.Escape(ocrOutput)}$", factory.GetPattern(this, f), "All pattern generators should just return the full string for OCR data");
+ Assert.That(factory.GetPattern(this, f), Is.EqualTo($"^{Regex.Escape(ocrOutput)}$"), "All pattern generators should just return the full string for OCR data");
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/MatchProblemValuesPatternFactoryTests.cs b/Tests/IsIdentifiableTests/ReviewerTests/MatchProblemValuesPatternFactoryTests.cs
index 654a353a..6807beb0 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/MatchProblemValuesPatternFactoryTests.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/MatchProblemValuesPatternFactoryTests.cs
@@ -16,7 +16,7 @@ public void OverlappingMatches_SinglePart()
{ ProblemValue = "Frequent Problems" };
var factory = new MatchProblemValuesPatternFactory();
- Assert.AreEqual("^(F)", factory.GetPattern(null, f));
+ Assert.That(factory.GetPattern(null, f), Is.EqualTo("^(F)"));
}
[Test]
@@ -30,7 +30,7 @@ public void OverlappingMatches_ExactOverlap()
{ ProblemValue = "Frequent Problems" };
var factory = new MatchProblemValuesPatternFactory();
- Assert.AreEqual("^(Freq)", factory.GetPattern(null, f));
+ Assert.That(factory.GetPattern(null, f), Is.EqualTo("^(Freq)"));
}
[Test]
public void OverlappingMatches_OffsetOverlaps()
@@ -45,7 +45,7 @@ public void OverlappingMatches_OffsetOverlaps()
var factory = new MatchProblemValuesPatternFactory();
//fallback onto full match because of overlapping problem words
- Assert.AreEqual("(req)", factory.GetPattern(null, f));
+ Assert.That(factory.GetPattern(null, f), Is.EqualTo("(req)"));
}
[Test]
@@ -59,6 +59,6 @@ public void OverlappingMatches_NoOverlaps()
{ ProblemValue = "Frequent Problems" };
var factory = new MatchProblemValuesPatternFactory();
- Assert.AreEqual("(requent)", factory.GetPattern(null, f));
+ Assert.That(factory.GetPattern(null, f), Is.EqualTo("(requent)"));
}
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/ReviewerOptionsTests.cs b/Tests/IsIdentifiableTests/ReviewerTests/ReviewerOptionsTests.cs
index abf33c60..96b9d91a 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/ReviewerOptionsTests.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/ReviewerOptionsTests.cs
@@ -18,10 +18,13 @@ public void TestFillMissingWithValuesUsing_MissingValues()
local.InheritValuesFrom(global);
- Assert.AreEqual("aa", local.IgnoreList);
- Assert.AreEqual("bb", local.Reportlist);
- Assert.AreEqual("cc", local.TargetsFile);
- Assert.AreEqual("dd", local.Theme);
+ Assert.Multiple(() =>
+ {
+ Assert.That(local.IgnoreList, Is.EqualTo("aa"));
+ Assert.That(local.Reportlist, Is.EqualTo("bb"));
+ Assert.That(local.TargetsFile, Is.EqualTo("cc"));
+ Assert.That(local.Theme, Is.EqualTo("dd"));
+ });
}
[Test]
public void TestFillMissingWithValuesUsing_DoNotOverride()
@@ -42,9 +45,12 @@ public void TestFillMissingWithValuesUsing_DoNotOverride()
local.InheritValuesFrom(global);
- Assert.AreEqual("11", local.IgnoreList);
- Assert.AreEqual("22", local.Reportlist);
- Assert.AreEqual("33", local.TargetsFile);
- Assert.AreEqual("44", local.Theme);
+ Assert.Multiple(() =>
+ {
+ Assert.That(local.IgnoreList, Is.EqualTo("11"));
+ Assert.That(local.Reportlist, Is.EqualTo("22"));
+ Assert.That(local.TargetsFile, Is.EqualTo("33"));
+ Assert.That(local.Theme, Is.EqualTo("44"));
+ });
}
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/SettingsFileTests.cs b/Tests/IsIdentifiableTests/ReviewerTests/SettingsFileTests.cs
index a3de2517..c6a54e61 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/SettingsFileTests.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/SettingsFileTests.cs
@@ -1,6 +1,7 @@
-using ii;
+using ii;
using NUnit.Framework;
using System;
+using NUnit.Framework.Legacy;
namespace IsIdentifiable.Tests.ReviewerTests
{
@@ -9,69 +10,90 @@ public class SettingsFileTests
[Test]
public void TestCutSettingsFileArgs_NoArgs()
{
- Assert.IsNull(Program.CutSettingsFileArgs(Array.Empty(), out var result));
- Assert.IsEmpty(result);
+ Assert.Multiple(() =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(Array.Empty(), out var result), Is.Null);
+ Assert.That(result, Is.Empty);
+ });
}
[Test]
public void TestCutSettingsFileArgs_NoYamlFile()
{
- Assert.IsNull(Program.CutSettingsFileArgs(new[] { "review", "somefish" }, out var result));
- Assert.AreEqual(2, result.Length);
- Assert.AreEqual("review", result[0]);
- Assert.AreEqual("somefish", result[1]);
+ Assert.Multiple(static () =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(new[] { "review", "somefish" }, out var result), Is.Null);
+ Assert.That(result, Has.Length.EqualTo(2));
+ Assert.That(result[0], Is.EqualTo("review"));
+ Assert.That(result[1], Is.EqualTo("somefish"));
+ });
}
[Test]
public void TestCutSettingsFileArgs_DashYOnly()
{
- // missing argument, let CommandLineParser sort them out
- Assert.IsNull(Program.CutSettingsFileArgs(new[] { "-y" }, out var result));
- Assert.AreEqual(1, result.Length);
- Assert.AreEqual("-y", result[0]);
+ Assert.Multiple(static () =>
+ {
+ // missing argument, let CommandLineParser sort them out
+ Assert.That(Program.CutSettingsFileArgs(new[] { "-y" }, out var result), Is.Null);
+ Assert.That(result, Has.Length.EqualTo(1));
+ Assert.That(result[0], Is.EqualTo("-y"));
+ });
}
[Test]
public void TestCutSettingsFileArgs_YamlOnly()
{
- Assert.AreEqual("myfile.yaml", Program.CutSettingsFileArgs(new[] { "-y", "myfile.yaml" }, out var result));
- Assert.IsEmpty(result);
+ Assert.Multiple(static () =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(new[] { "-y", "myfile.yaml" }, out var result), Is.EqualTo("myfile.yaml"));
+ Assert.That(result, Is.Empty);
+ });
}
[Test]
public void TestCutSettingsFileArgs_YamlAfter()
{
- Assert.AreEqual("myfile.yaml", Program.CutSettingsFileArgs(new[] { "review", "db", "someconstr", "-y", "myfile.yaml" }, out var result));
+ Assert.Multiple(static () =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(new[] { "review", "db", "someconstr", "-y", "myfile.yaml" }, out var result), Is.EqualTo("myfile.yaml"));
- Assert.AreEqual(3, result.Length);
- Assert.AreEqual("review", result[0]);
- Assert.AreEqual("db", result[1]);
- Assert.AreEqual("someconstr", result[2]);
+ Assert.That(result, Has.Length.EqualTo(3));
+ Assert.That(result[0], Is.EqualTo("review"));
+ Assert.That(result[1], Is.EqualTo("db"));
+ Assert.That(result[2], Is.EqualTo("someconstr"));
+ });
}
[Test]
public void TestCutSettingsFileArgs_YamlBefore()
{
- Assert.AreEqual("myfile.yaml", Program.CutSettingsFileArgs(new[] { "-y", "myfile.yaml", "review", "db", "someconstr" }, out var result));
+ Assert.Multiple(() =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(new[] { "-y", "myfile.yaml", "review", "db", "someconstr" }, out var result), Is.EqualTo("myfile.yaml"));
- Assert.AreEqual(3, result.Length);
- Assert.AreEqual("review", result[0]);
- Assert.AreEqual("db", result[1]);
- Assert.AreEqual("someconstr", result[2]);
+ Assert.That(result, Has.Length.EqualTo(3));
+ Assert.That(result[0], Is.EqualTo("review"));
+ Assert.That(result[1], Is.EqualTo("db"));
+ Assert.That(result[2], Is.EqualTo("someconstr"));
+ });
}
[Test]
public void TestCutSettingsFileArgs_YamlInMiddle()
{
- Assert.AreEqual("myfile.yaml", Program.CutSettingsFileArgs(new[] { "review", "-y", "myfile.yaml", "db", "someconstr" }, out var result));
+ Assert.Multiple(static () =>
+ {
+ Assert.That(Program.CutSettingsFileArgs(new[] { "review", "-y", "myfile.yaml", "db", "someconstr" }, out var result), Is.EqualTo("myfile.yaml"));
- Assert.AreEqual(3, result.Length);
- Assert.AreEqual("review", result[0]);
- Assert.AreEqual("db", result[1]);
- Assert.AreEqual("someconstr", result[2]);
+ Assert.That(result, Has.Length.EqualTo(3));
+ Assert.That(result[0], Is.EqualTo("review"));
+ Assert.That(result[1], Is.EqualTo("db"));
+ Assert.That(result[2], Is.EqualTo("someconstr"));
+ });
}
[Test]
@@ -81,8 +103,11 @@ public void TestDeserialize_SmiServices_DefaultYaml()
FileAssert.Exists(f);
var opts = Program.Deserialize(f, new System.IO.Abstractions.FileSystem());
- Assert.IsNotNull(opts.IsIdentifiableReviewerOptions);
- Assert.IsNotNull(opts.IsIdentifiableOptions);
+ Assert.Multiple(() =>
+ {
+ Assert.That(opts.IsIdentifiableReviewerOptions, Is.Not.Null);
+ Assert.That(opts.IsIdentifiableOptions, Is.Not.Null);
+ });
}
}
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/SymbolsRulesFactoryTests.cs b/Tests/IsIdentifiableTests/ReviewerTests/SymbolsRulesFactoryTests.cs
index c384d6f3..eb7b21ef 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/SymbolsRulesFactoryTests.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/SymbolsRulesFactoryTests.cs
@@ -24,7 +24,7 @@ public void TestSymbols_OnePart(string input, string part, string expectedOutput
ProblemValue = input
};
- Assert.AreEqual(expectedOutput, f.GetPattern(this, failure));
+ Assert.That(f.GetPattern(this, failure), Is.EqualTo(expectedOutput));
}
@@ -43,7 +43,7 @@ public void TestSymbols_TwoParts_NoOverlap(string input, string part1, string pa
ProblemValue = input
};
- Assert.AreEqual(expectedOutput, f.GetPattern(this, failure));
+ Assert.That(f.GetPattern(this, failure), Is.EqualTo(expectedOutput));
}
[TestCase("There's a candy coloured clown they call the Sandman", "clown they", "they call", @"([a-z][a-z][a-z][a-z][a-z]\ [a-z][a-z][a-z][a-z]\ [a-z][a-z][a-z][a-z])")]
@@ -61,14 +61,14 @@ public void TestSymbols_TwoParts_Overlap(string input, string part1, string part
ProblemValue = input
};
- Assert.AreEqual(expectedOutput, f.GetPattern(this, failure));
+ Assert.That(f.GetPattern(this, failure), Is.EqualTo(expectedOutput));
}
[Test]
public void TestNoParts()
{
var f = new SymbolsRulesFactory();
var ex = Assert.Throws(() => f.GetPattern(this, new Failure(Array.Empty()) { ProblemValue = "fdslkfl;asdf" }));
- Assert.AreEqual("Failure had no Parts", ex.Message);
+ Assert.That(ex.Message, Is.EqualTo("Failure had no Parts"));
}
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/TestIgnoreRuleGenerator.cs b/Tests/IsIdentifiableTests/ReviewerTests/TestIgnoreRuleGenerator.cs
index 40d7da28..4d2e3168 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/TestIgnoreRuleGenerator.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/TestIgnoreRuleGenerator.cs
@@ -36,7 +36,7 @@ public void TestRepeatedIgnoring()
var ignorer = new IgnoreRuleGenerator(_fileSystem, newRules);
//it should be novel i.e. require user decision
- Assert.IsTrue(ignorer.OnLoad(failure, out _));
+ Assert.That(ignorer.OnLoad(failure, out _), Is.True);
//we tell it to ignore this value
ignorer.Add(failure);
@@ -48,7 +48,7 @@ public void TestRepeatedIgnoring()
", _fileSystem.File.ReadAllText(newRules.FullName)); //btw slash space is a 'literal space' so legit
//it should be no longer be novel
- Assert.IsFalse(ignorer.OnLoad(failure, out _));
+ Assert.That(ignorer.OnLoad(failure, out _), Is.False);
}
@@ -117,7 +117,7 @@ public void Test_SaveYaml()
ignorer.Rules.Clear();
ignorer.Save();
- Assert.IsTrue(string.IsNullOrWhiteSpace(_fileSystem.File.ReadAllText(newRules.FullName)));
+ Assert.That(string.IsNullOrWhiteSpace(_fileSystem.File.ReadAllText(newRules.FullName)), Is.True);
}
@@ -148,7 +148,7 @@ public void TestUndo()
var ignorer = new IgnoreRuleGenerator(_fileSystem, newRules);
//it should be novel i.e. require user decision
- Assert.IsTrue(ignorer.OnLoad(failure, out _));
+ Assert.That(ignorer.OnLoad(failure, out _), Is.True);
//we tell it to ignore this value
ignorer.Add(failure);
@@ -159,22 +159,28 @@ public void TestUndo()
IfPattern: ^We\ aren't\ in\ Kansas\ anymore\ Toto$
", _fileSystem.File.ReadAllText(newRules.FullName)); //btw slash space is a 'literal space' so legit
- //it should be no longer be novel
- Assert.IsFalse(ignorer.OnLoad(failure, out _));
+ Assert.Multiple(() =>
+ {
+ //it should be no longer be novel
+ Assert.That(ignorer.OnLoad(failure, out _), Is.False);
- //Undo
- Assert.AreEqual(1, ignorer.History.Count);
- Assert.AreEqual(2, ignorer.Rules.Count);
+ //Undo
+ Assert.That(ignorer.History, Has.Count.EqualTo(1));
+ Assert.That(ignorer.Rules, Has.Count.EqualTo(2));
+ });
ignorer.Undo();
- Assert.AreEqual(0, ignorer.History.Count);
- Assert.AreEqual(1, ignorer.Rules.Count);
+ Assert.Multiple(() =>
+ {
+ Assert.That(ignorer.History, Is.Empty);
+ Assert.That(ignorer.Rules, Has.Count.EqualTo(1));
- //only the original one should be there
- Assert.AreEqual(@"- Action: Ignore
+ //only the original one should be there
+ Assert.That(_fileSystem.File.ReadAllText(newRules.FullName), Is.EqualTo(@"- Action: Ignore
IfColumn: Narrative
IfPattern: ^Joker Wuz Ere$
-", _fileSystem.File.ReadAllText(newRules.FullName));
+"));
+ });
//repeated undo calls do nothing
ignorer.Undo();
@@ -209,7 +215,7 @@ public void Test_DeleteRule()
var ignorer = new IgnoreRuleGenerator(_fileSystem, newRules);
//it should be novel i.e. require user decision
- Assert.IsTrue(ignorer.OnLoad(failure, out _));
+ Assert.That(ignorer.OnLoad(failure, out _), Is.True);
//we tell it to ignore this value
ignorer.Add(failure);
@@ -220,30 +226,36 @@ public void Test_DeleteRule()
IfPattern: ^We\ aren't\ in\ Kansas\ anymore\ Toto$
", _fileSystem.File.ReadAllText(newRules.FullName)); //btw slash space is a 'literal space' so legit
- //it should be no longer be novel
- Assert.IsFalse(ignorer.OnLoad(failure, out _));
+ Assert.Multiple(() =>
+ {
+ //it should be no longer be novel
+ Assert.That(ignorer.OnLoad(failure, out _), Is.False);
- //Remove the last one
- Assert.AreEqual(2, ignorer.Rules.Count);
+ //Remove the last one
+ Assert.That(ignorer.Rules, Has.Count.EqualTo(2));
+ });
var result = ignorer.Delete(ignorer.Rules[1]);
- Assert.IsTrue(result);
+ Assert.Multiple(() =>
+ {
+ Assert.That(result, Is.True);
- //deleted from memory
- Assert.AreEqual(1, ignorer.Rules.Count);
+ //deleted from memory
+ Assert.That(ignorer.Rules, Has.Count.EqualTo(1));
+ });
var newRulebaseYaml = _fileSystem.File.ReadAllText(newRules.FullName);
//only the original one should be there
- StringAssert.Contains(@"- Action: Ignore
+ Assert.That(newRulebaseYaml, Does.Contain(@"- Action: Ignore
IfColumn: Narrative
IfPattern: ^Joker Wuz Ere$
-", newRulebaseYaml);
+"));
- StringAssert.Contains("# Rule deleted by ", newRulebaseYaml);
+ Assert.That(newRulebaseYaml, Does.Contain("# Rule deleted by "));
- StringAssert.DoesNotContain("Kansas", newRulebaseYaml);
+ Assert.That(newRulebaseYaml, Does.Not.Contain("Kansas"));
//repeated undo calls do nothing
ignorer.Undo();
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/TestUpdater.cs b/Tests/IsIdentifiableTests/ReviewerTests/TestUpdater.cs
index 2f4d9cc3..202678c5 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/TestUpdater.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/TestUpdater.cs
@@ -63,12 +63,12 @@ public void Test(DatabaseType dbType)
};
//it should be novel i.e. require user decision
- Assert.IsTrue(updater.OnLoad(db.Server, failure, out _));
+ Assert.That(updater.OnLoad(db.Server, failure, out _), Is.True);
updater.Update(db.Server, failure, null);
var result = tbl.GetDataTable();
- Assert.AreEqual("We aren't in SMI_REDACTED anymore SMI_REDACTED", result.Rows[0]["Narrative"]);
+ Assert.That(result.Rows[0]["Narrative"], Is.EqualTo("We aren't in SMI_REDACTED anymore SMI_REDACTED"));
TestHelpers.Contains(
@"- Action: Report
@@ -78,7 +78,7 @@ public void Test(DatabaseType dbType)
", _fileSystem.File.ReadAllText(newRules.FullName)); //btw slash space is a 'literal space' so legit
//it should be updated automatically and not require user decision
- Assert.IsFalse(updater.OnLoad(db.Server, failure, out _));
+ Assert.That(updater.OnLoad(db.Server, failure, out _), Is.False);
}
@@ -136,19 +136,19 @@ public void Test_RegexUpdateStrategy(DatabaseType dbType, bool provideCaptureGro
updater.UpdateStrategy = new RegexUpdateStrategy();
//it should be novel i.e. require user decision
- Assert.IsTrue(updater.OnLoad(db.Server, failure, out _));
+ Assert.That(updater.OnLoad(db.Server, failure, out _), Is.True);
updater.Update(db.Server, failure, null);//<- null here will trigger the rule pattern factory to prompt 'user' for pattern which is "(Toto)$"
var result = tbl.GetDataTable();
if (provideCaptureGroup)
- Assert.AreEqual("We aren't in Kansas anymore SMI_REDACTED", result.Rows[0]["Narrative"], "Expected update to only affect the capture group ToTo");
+ Assert.That(result.Rows[0]["Narrative"], Is.EqualTo("We aren't in Kansas anymore SMI_REDACTED"), "Expected update to only affect the capture group ToTo");
else
- Assert.AreEqual("We aren't in SMI_REDACTED anymore SMI_REDACTED", result.Rows[0]["Narrative"], "Because regex had no capture group we expected the update strategy to fallback on Failure Part matching");
+ Assert.That(result.Rows[0]["Narrative"], Is.EqualTo("We aren't in SMI_REDACTED anymore SMI_REDACTED"), "Because regex had no capture group we expected the update strategy to fallback on Failure Part matching");
//it should be updated automatically and not require user decision
- Assert.IsFalse(updater.OnLoad(db.Server, failure, out _));
+ Assert.That(updater.OnLoad(db.Server, failure, out _), Is.False);
}
}
diff --git a/Tests/IsIdentifiableTests/ReviewerTests/UnattendedTests.cs b/Tests/IsIdentifiableTests/ReviewerTests/UnattendedTests.cs
index 1548753a..6890ab90 100644
--- a/Tests/IsIdentifiableTests/ReviewerTests/UnattendedTests.cs
+++ b/Tests/IsIdentifiableTests/ReviewerTests/UnattendedTests.cs
@@ -34,7 +34,7 @@ public void SetUp()
public void NoFileToProcess_Throws()
{
var ex = Assert.Throws(() => new UnattendedReviewer(new IsIdentifiableReviewerOptions(), null, new IgnoreRuleGenerator(_fileSystem), new RowUpdater(_fileSystem), _fileSystem));
- Assert.AreEqual("Unattended requires a file of errors to process", ex.Message);
+ Assert.That(ex.Message, Is.EqualTo("Unattended requires a file of errors to process"));
}
[Test]
@@ -44,7 +44,7 @@ public void NonExistantFileToProcess_Throws()
{
FailuresCsv = "troll.csv"
}, null, new IgnoreRuleGenerator(_fileSystem), new RowUpdater(_fileSystem), _fileSystem));
- StringAssert.Contains("Could not find Failures file", ex.Message);
+ Assert.That(ex.Message, Does.Contain("Could not find Failures file"));
}
[Test]
@@ -57,7 +57,7 @@ public void NoTarget_Throws()
{
FailuresCsv = fi
}, null, new IgnoreRuleGenerator(_fileSystem), new RowUpdater(_fileSystem), _fileSystem));
- StringAssert.Contains("A single Target must be supplied for database updates", ex.Message);
+ Assert.That(ex.Message, Does.Contain("A single Target must be supplied for database updates"));
}
[Test]
@@ -70,7 +70,7 @@ public void NoOutputPath_Throws()
{
FailuresCsv = fi
}, new Target(), new IgnoreRuleGenerator(_fileSystem), new RowUpdater(_fileSystem), _fileSystem));
- StringAssert.Contains("An output path must be specified ", ex.Message);
+ Assert.That(ex.Message, Does.Contain("An output path must be specified "));
}
@@ -88,10 +88,13 @@ public void Passes_NoFailures()
UnattendedOutputPath = fiOut
}, new Target(), new IgnoreRuleGenerator(_fileSystem), new RowUpdater(_fileSystem), _fileSystem);
- Assert.AreEqual(0, reviewer.Run());
+ Assert.Multiple(() =>
+ {
+ Assert.That(reviewer.Run(), Is.EqualTo(0));
- //just the headers
- StringAssert.AreEqualIgnoringCase("Resource,ResourcePrimaryKey,ProblemField,ProblemValue,PartWords,PartClassifications,PartOffsets", _fileSystem.File.ReadAllText(fiOut).TrimEnd());
+ //just the headers
+ Assert.That(_fileSystem.File.ReadAllText(fiOut).TrimEnd(), Is.EqualTo("Resource,ResourcePrimaryKey,ProblemField,ProblemValue,PartWords,PartClassifications,PartOffsets").IgnoreCase);
+ });
}
[Test]
@@ -117,15 +120,18 @@ public void Passes_FailuresAllUnprocessed()
_fileSystem
);
- Assert.AreEqual(0, reviewer.Run());
+ Assert.That(reviewer.Run(), Is.EqualTo(0));
//all that we put in is unprocessed so should come out the same
TestHelpers.AreEqualIgnoringCaseAndLineEndings(inputFile, _fileSystem.File.ReadAllText(fiOut).TrimEnd());
- Assert.AreEqual(1, reviewer.Total);
- Assert.AreEqual(0, reviewer.Ignores);
- Assert.AreEqual(1, reviewer.Unresolved);
- Assert.AreEqual(0, reviewer.Updates);
+ Assert.Multiple(() =>
+ {
+ Assert.That(reviewer.Total, Is.EqualTo(1));
+ Assert.That(reviewer.Ignores, Is.EqualTo(0));
+ Assert.That(reviewer.Unresolved, Is.EqualTo(1));
+ Assert.That(reviewer.Updates, Is.EqualTo(0));
+ });
}
[TestCase(true)]
@@ -156,15 +162,18 @@ public void Passes_FailuresAllIgnored(bool rulesOnly)
OnlyRules = rulesOnly
}, new Target(), new IgnoreRuleGenerator(fileSystem: _fileSystem), new RowUpdater(fileSystem: _fileSystem), _fileSystem);
- Assert.AreEqual(0, reviewer.Run());
+ Assert.Multiple(() =>
+ {
+ Assert.That(reviewer.Run(), Is.EqualTo(0));
- //headers only since Allowlist eats the rest
- StringAssert.AreEqualIgnoringCase(@"Resource,ResourcePrimaryKey,ProblemField,ProblemValue,PartWords,PartClassifications,PartOffsets", _fileSystem.File.ReadAllText(fiOut).TrimEnd());
+ //headers only since Allowlist eats the rest
+ Assert.That(_fileSystem.File.ReadAllText(fiOut).TrimEnd(), Is.EqualTo(@"Resource,ResourcePrimaryKey,ProblemField,ProblemValue,PartWords,PartClassifications,PartOffsets").IgnoreCase);
- Assert.AreEqual(1, reviewer.Total);
- Assert.AreEqual(1, reviewer.Ignores);
- Assert.AreEqual(0, reviewer.Unresolved);
- Assert.AreEqual(0, reviewer.Updates);
+ Assert.That(reviewer.Total, Is.EqualTo(1));
+ Assert.That(reviewer.Ignores, Is.EqualTo(1));
+ Assert.That(reviewer.Unresolved, Is.EqualTo(0));
+ Assert.That(reviewer.Updates, Is.EqualTo(0));
+ });
}
[TestCase(true)]
@@ -198,7 +207,7 @@ public void Passes_FailuresAllUpdated(bool ruleCoversThis)
OnlyRules = true //prevents it going to the database
}, new Target(), new IgnoreRuleGenerator(fileSystem: _fileSystem), new RowUpdater(fileSystem: _fileSystem), _fileSystem);
- Assert.AreEqual(0, reviewer.Run());
+ Assert.That(reviewer.Run(), Is.EqualTo(0));
//it matches the UPDATE rule but since OnlyRules is true it didn't actually update the database! so the record should definitely be in the output
@@ -219,10 +228,12 @@ public void Passes_FailuresAllUpdated(bool ruleCoversThis)
}
-
- Assert.AreEqual(1, reviewer.Total);
- Assert.AreEqual(0, reviewer.Ignores);
- Assert.AreEqual(ruleCoversThis ? 0 : 1, reviewer.Unresolved);
- Assert.AreEqual(ruleCoversThis ? 1 : 0, reviewer.Updates);
+ Assert.Multiple(() =>
+ {
+ Assert.That(reviewer.Total, Is.EqualTo(1));
+ Assert.That(reviewer.Ignores, Is.EqualTo(0));
+ Assert.That(reviewer.Unresolved, Is.EqualTo(ruleCoversThis ? 0 : 1));
+ Assert.That(reviewer.Updates, Is.EqualTo(ruleCoversThis ? 1 : 0));
+ });
}
}
diff --git a/Tests/IsIdentifiableTests/RunnerTests/DicomFileRunnerTest.cs b/Tests/IsIdentifiableTests/RunnerTests/DicomFileRunnerTest.cs
index b4cae5d3..bce1aeaa 100644
--- a/Tests/IsIdentifiableTests/RunnerTests/DicomFileRunnerTest.cs
+++ b/Tests/IsIdentifiableTests/RunnerTests/DicomFileRunnerTest.cs
@@ -1,4 +1,4 @@
-using IsIdentifiable.Options;
+using IsIdentifiable.Options;
using IsIdentifiable.Reporting.Reports;
using IsIdentifiable.Runners;
using NUnit.Framework;
@@ -67,7 +67,7 @@ public void IgnorePixelDataLessThan(bool ignoreShortText)
var runner = new DicomFileRunner(opts, fileSystem);
var fileInfo = fileSystem.FileInfo.New(fileName);
- Assert.True(fileInfo.Exists);
+ Assert.That(fileInfo.Exists, Is.True);
var toMemory = new ToMemoryFailureReport();
runner.Reports.Add(toMemory);
@@ -75,7 +75,7 @@ public void IgnorePixelDataLessThan(bool ignoreShortText)
runner.ValidateDicomFile(fileInfo);
var failures = toMemory.Failures.ToList();
- Assert.AreEqual(ignoreShortText ? 1 : 3, failures.Count);
+ Assert.That(failures, Has.Count.EqualTo(ignoreShortText ? 1 : 3));
}
#endregion
diff --git a/Tests/IsIdentifiableTests/RunnerTests/FileRunnerTests.cs b/Tests/IsIdentifiableTests/RunnerTests/FileRunnerTests.cs
index c5f531d9..824d8503 100644
--- a/Tests/IsIdentifiableTests/RunnerTests/FileRunnerTests.cs
+++ b/Tests/IsIdentifiableTests/RunnerTests/FileRunnerTests.cs
@@ -35,7 +35,7 @@ public void FileRunner_CsvWithCHI()
var reporter = new Mock(MockBehavior.Strict);
- reporter.Setup(f => f.Add(It.IsAny())).Callback(f => Assert.AreEqual("0102821172", f.ProblemValue));
+ reporter.Setup(f => f.Add(It.IsAny())).Callback(f => Assert.That(f.ProblemValue, Is.EqualTo("0102821172")));
reporter.Setup(f => f.DoneRows(1));
reporter.Setup(f => f.CloseReport());
@@ -69,7 +69,7 @@ public void FileRunner_TopX()
var done = 0;
- reporter.Setup(f => f.Add(It.IsAny())).Callback(f => Assert.AreEqual("0102821172", f.ProblemValue));
+ reporter.Setup(f => f.Add(It.IsAny())).Callback(f => Assert.That(f.ProblemValue, Is.EqualTo("0102821172")));
reporter.Setup(f => f.DoneRows(1)).Callback(() => done++);
reporter.Setup(f => f.CloseReport());
@@ -80,6 +80,6 @@ public void FileRunner_TopX()
reporter.Verify();
- Assert.AreEqual(22, done);
+ Assert.That(done, Is.EqualTo(22));
}
}
diff --git a/Tests/IsIdentifiableTests/RunnerTests/MongoDbTests.cs b/Tests/IsIdentifiableTests/RunnerTests/MongoDbTests.cs
index 0f21cb17..b1c54780 100644
--- a/Tests/IsIdentifiableTests/RunnerTests/MongoDbTests.cs
+++ b/Tests/IsIdentifiableTests/RunnerTests/MongoDbTests.cs
@@ -22,7 +22,7 @@ public void SetUp()
_fileSystem = new MockFileSystem();
}
- public static MongoClientSettings GetMongoClientSettings()
+ private static MongoClientSettings GetMongoClientSettings()
{
var deserializer = new DeserializerBuilder()
.IgnoreUnmatchedProperties()
@@ -178,10 +178,10 @@ public void TestAnalyseIdentifiableDataInMongoDb(string json, string column, str
doc
}.Select(d => new InsertOneModel(d)));
- Assert.IsTrue(res.IsAcknowledged);
+ Assert.That(res.IsAcknowledged, Is.True);
var read = collection.WithReadConcern(ReadConcern.Available);
- Assert.AreEqual(1, read.CountDocuments((d) => true), "There should be exactly 1 document in the collection");
+ Assert.That(read.CountDocuments((d) => true), Is.EqualTo(1), "There should be exactly 1 document in the collection");
var settings = GetMongoClientSettings();
@@ -204,13 +204,19 @@ public void TestAnalyseIdentifiableDataInMongoDb(string json, string column, str
var toMem = new ToMemoryFailureReport();
runner.Reports.Add(toMem);
- Assert.AreEqual(0, runner.Run(), "MongoDb runner returned a non zero exit code. Indicating failure");
- Assert.AreEqual(1, runner.CountOfFailureParts, "IsIdentifiable did not find exactly 1 failing value, this test only caters for single matches");
+ Assert.Multiple(() =>
+ {
+ Assert.That(runner.Run(), Is.EqualTo(0), "MongoDb runner returned a non zero exit code. Indicating failure");
+ Assert.That(runner.CountOfFailureParts, Is.EqualTo(1), "IsIdentifiable did not find exactly 1 failing value, this test only caters for single matches");
+ });
var f = toMem.Failures.Single();
- Assert.AreEqual(expectedFullPath, f.ProblemField);
- Assert.AreEqual(expectedFailingValue, f.ProblemValue);
+ Assert.Multiple(() =>
+ {
+ Assert.That(f.ProblemField, Is.EqualTo(expectedFullPath));
+ Assert.That(f.ProblemValue, Is.EqualTo(expectedFailingValue));
+ });
}
}
}
diff --git a/Tests/IsIdentifiableTests/ServiceTests/IsIdentifiableAbstractOptionsTests.cs b/Tests/IsIdentifiableTests/ServiceTests/IsIdentifiableAbstractOptionsTests.cs
index 00614115..9bc29030 100644
--- a/Tests/IsIdentifiableTests/ServiceTests/IsIdentifiableAbstractOptionsTests.cs
+++ b/Tests/IsIdentifiableTests/ServiceTests/IsIdentifiableAbstractOptionsTests.cs
@@ -1,4 +1,4 @@
-using FAnsi;
+using FAnsi;
using IsIdentifiable.Options;
using NUnit.Framework;
using System;
@@ -35,15 +35,15 @@ public void FillMissingWithValuesUsing_Override()
var testVal = GetTestValue(cliProp);
gProp.SetValue(globalOpts, testVal);
- Assert.AreNotEqual(testVal, cliProp.GetValue(opts));
+ Assert.That(cliProp.GetValue(opts), Is.Not.EqualTo(testVal));
opts.InheritValuesFrom(globalOpts);
- Assert.AreEqual(testVal, cliProp.GetValue(opts));
+ Assert.That(cliProp.GetValue(opts), Is.EqualTo(testVal));
propsCounted++;
}
// we did test some properties right!
- Assert.Greater(propsCounted, 0);
+ Assert.That(propsCounted, Is.GreaterThan(0));
}
@@ -82,20 +82,20 @@ public void FillMissingWithValuesUsing_NoOverride()
cliProp.SetValue(opts, testVal2);
// we should not have the yaml file entry
- Assert.AreNotEqual(testVal1, cliProp.GetValue(opts));
+ Assert.That(cliProp.GetValue(opts), Is.Not.EqualTo(testVal1));
// we ask to fill in missing values using the yaml entries
opts.InheritValuesFrom(globalOpts);
// but we had an entry on CLI already so that should take precedence
- Assert.AreNotEqual(testVal1, cliProp.GetValue(opts));
- Assert.AreEqual(testVal2, cliProp.GetValue(opts));
+ Assert.That(cliProp.GetValue(opts), Is.Not.EqualTo(testVal1));
+ Assert.That(cliProp.GetValue(opts), Is.EqualTo(testVal2));
propsCounted++;
}
// we did test some properties right!
- Assert.Greater(propsCounted, 0);
+ Assert.That(propsCounted, Is.GreaterThan(0));
}
diff --git a/Tests/IsIdentifiableTests/SocketRuleTests.cs b/Tests/IsIdentifiableTests/SocketRuleTests.cs
index e671273e..0809aaa7 100644
--- a/Tests/IsIdentifiableTests/SocketRuleTests.cs
+++ b/Tests/IsIdentifiableTests/SocketRuleTests.cs
@@ -12,7 +12,7 @@ class SocketRuleTests
public void TestSocket_NegativeResponse()
{
var bad = SocketRule.HandleResponse("\0");
- Assert.IsEmpty(bad);
+ Assert.That(bad, Is.Empty);
}
[Test]
@@ -20,9 +20,12 @@ public void TestSocket_PositiveResponse()
{
var bad = SocketRule.HandleResponse("Person\010\0Dave\0").Single();
- Assert.AreEqual(FailureClassification.Person, bad.Classification);
- Assert.AreEqual(10, bad.Offset);
- Assert.AreEqual("Dave", bad.Word);
+ Assert.Multiple(() =>
+ {
+ Assert.That(bad.Classification, Is.EqualTo(FailureClassification.Person));
+ Assert.That(bad.Offset, Is.EqualTo(10));
+ Assert.That(bad.Word, Is.EqualTo("Dave"));
+ });
}
[Test]
@@ -30,27 +33,30 @@ public void TestSocket_TwoPositiveResponses()
{
var bad = SocketRule.HandleResponse("Person\010\0Dave\0ORGANIZATION\00\0The University of Dundee\0").ToArray();
- Assert.AreEqual(2, bad.Length);
+ Assert.That(bad, Has.Length.EqualTo(2));
- Assert.AreEqual(FailureClassification.Person, bad[0].Classification);
- Assert.AreEqual(10, bad[0].Offset);
- Assert.AreEqual("Dave", bad[0].Word);
+ Assert.Multiple(() =>
+ {
+ Assert.That(bad[0].Classification, Is.EqualTo(FailureClassification.Person));
+ Assert.That(bad[0].Offset, Is.EqualTo(10));
+ Assert.That(bad[0].Word, Is.EqualTo("Dave"));
- Assert.AreEqual(FailureClassification.Organization, bad[1].Classification);
- Assert.AreEqual(0, bad[1].Offset);
- Assert.AreEqual("The University of Dundee", bad[1].Word);
+ Assert.That(bad[1].Classification, Is.EqualTo(FailureClassification.Organization));
+ Assert.That(bad[1].Offset, Is.EqualTo(0));
+ Assert.That(bad[1].Word, Is.EqualTo("The University of Dundee"));
+ });
}
[Test]
public void TestSocket_InvalidResponses()
{
var ex = Assert.Throws(() => SocketRule.HandleResponse("Cadbury\010\0Cream Egg\0").ToArray());
- StringAssert.Contains("'Cadbury' (expected a member of Enum FailureClassification)", ex?.Message);
+ Assert.That(ex?.Message, Does.Contain("'Cadbury' (expected a member of Enum FailureClassification)"));
ex = Assert.Throws(() => SocketRule.HandleResponse("Person\0fish\0Cream Egg\0").ToArray());
- StringAssert.Contains("Response was 'fish' (expected int)", ex?.Message);
+ Assert.That(ex?.Message, Does.Contain("Response was 'fish' (expected int)"));
ex = Assert.Throws(() => SocketRule.HandleResponse("Person\0").ToArray());
- StringAssert.Contains("Expected tokens to arrive in multiples of 3 (but got '1')", ex?.Message);
+ Assert.That(ex?.Message, Does.Contain("Expected tokens to arrive in multiples of 3 (but got '1')"));
}
}
diff --git a/Tests/IsIdentifiableTests/StoreReportTests.cs b/Tests/IsIdentifiableTests/StoreReportTests.cs
index b0ecff25..acb6651a 100644
--- a/Tests/IsIdentifiableTests/StoreReportTests.cs
+++ b/Tests/IsIdentifiableTests/StoreReportTests.cs
@@ -50,27 +50,31 @@ public void TestReconstructionFromCsv()
var created = dir.GetFiles("*HappyOzz*.csv").SingleOrDefault();
- Assert.IsNotNull(created);
+ Assert.That(created, Is.Not.Null);
var failures2 = FailureStoreReport.Deserialize(created).ToArray();
- //read failure ok
- Assert.AreEqual(1, failures2.Length);
- Assert.AreEqual(failure.ProblemValue, failures2[0].ProblemValue);
- Assert.AreEqual(failure.ProblemField, failures2[0].ProblemField);
- Assert.AreEqual(failure.ResourcePrimaryKey, failures2[0].ResourcePrimaryKey);
- Assert.AreEqual(failure.Resource, failures2[0].Resource);
+ Assert.Multiple(() =>
+ {
+ //read failure ok
+ Assert.That(failures2, Has.Length.EqualTo(1));
+
+ Assert.That(failures2[0].ProblemValue, Is.EqualTo(failure.ProblemValue));
+ Assert.That(failures2[0].ProblemField, Is.EqualTo(failure.ProblemField));
+ Assert.That(failures2[0].ResourcePrimaryKey, Is.EqualTo(failure.ResourcePrimaryKey));
+ Assert.That(failures2[0].Resource, Is.EqualTo(failure.Resource));
- //read parts ok
- Assert.AreEqual(2, failures2[0].Parts.Count);
+ //read parts ok
+ Assert.That(failures2[0].Parts, Has.Count.EqualTo(2));
- Assert.AreEqual(failure.Parts[0].Classification, failures2[0].Parts[0].Classification);
- Assert.AreEqual(failure.Parts[0].Offset, failures2[0].Parts[0].Offset);
- Assert.AreEqual(failure.Parts[0].Word, failures2[0].Parts[0].Word);
+ Assert.That(failures2[0].Parts[0].Classification, Is.EqualTo(failure.Parts[0].Classification));
+ Assert.That(failures2[0].Parts[0].Offset, Is.EqualTo(failure.Parts[0].Offset));
+ Assert.That(failures2[0].Parts[0].Word, Is.EqualTo(failure.Parts[0].Word));
- Assert.AreEqual(failure.Parts[1].Classification, failures2[0].Parts[1].Classification);
- Assert.AreEqual(failure.Parts[1].Offset, failures2[0].Parts[1].Offset);
- Assert.AreEqual(failure.Parts[1].Word, failures2[0].Parts[1].Word);
+ Assert.That(failures2[0].Parts[1].Classification, Is.EqualTo(failure.Parts[1].Classification));
+ Assert.That(failures2[0].Parts[1].Offset, Is.EqualTo(failure.Parts[1].Offset));
+ Assert.That(failures2[0].Parts[1].Word, Is.EqualTo(failure.Parts[1].Word));
+ });
}
@@ -82,12 +86,15 @@ public void Test_Includes()
var part = new FailurePart("fff", FailureClassification.Organization, origin.IndexOf("fff"));
- Assert.IsFalse(part.Includes(0));
- Assert.IsFalse(part.Includes(9));
- Assert.IsTrue(part.Includes(10));
- Assert.IsTrue(part.Includes(11));
- Assert.IsTrue(part.Includes(12));
- Assert.IsFalse(part.Includes(13));
+ Assert.Multiple(() =>
+ {
+ Assert.That(part.Includes(0), Is.False);
+ Assert.That(part.Includes(9), Is.False);
+ Assert.That(part.Includes(10), Is.True);
+ Assert.That(part.Includes(11), Is.True);
+ Assert.That(part.Includes(12), Is.True);
+ Assert.That(part.Includes(13), Is.False);
+ });
}
[Test]
@@ -97,12 +104,15 @@ public void Test_IncludesSingleChar()
var part = new FailurePart("f", FailureClassification.Organization, origin.IndexOf("f"));
- Assert.IsFalse(part.Includes(0));
- Assert.IsFalse(part.Includes(9));
- Assert.IsTrue(part.Includes(10));
- Assert.IsFalse(part.Includes(11));
- Assert.IsFalse(part.Includes(12));
- Assert.IsFalse(part.Includes(13));
+ Assert.Multiple(() =>
+ {
+ Assert.That(part.Includes(0), Is.False);
+ Assert.That(part.Includes(9), Is.False);
+ Assert.That(part.Includes(10), Is.True);
+ Assert.That(part.Includes(11), Is.False);
+ Assert.That(part.Includes(12), Is.False);
+ Assert.That(part.Includes(13), Is.False);
+ });
}
@@ -139,9 +149,12 @@ public void Test_HaveSameProblem()
ResourcePrimaryKey = "1.2.3"
};
- Assert.IsTrue(f1.HaveSameProblem(f2));
- Assert.IsFalse(f1.HaveSameProblem(f3));
- Assert.IsFalse(f1.HaveSameProblem(f4));
+ Assert.Multiple(() =>
+ {
+ Assert.That(f1.HaveSameProblem(f2), Is.True);
+ Assert.That(f1.HaveSameProblem(f3), Is.False);
+ Assert.That(f1.HaveSameProblem(f4), Is.False);
+ });
}
}
diff --git a/Tests/IsIdentifiableTests/TerminalGuiThemeTests.cs b/Tests/IsIdentifiableTests/TerminalGuiThemeTests.cs
index 58be323c..98edc62b 100644
--- a/Tests/IsIdentifiableTests/TerminalGuiThemeTests.cs
+++ b/Tests/IsIdentifiableTests/TerminalGuiThemeTests.cs
@@ -1,4 +1,4 @@
-using ii;
+using ii;
using NUnit.Framework;
using Terminal.Gui;
using YamlDotNet.Serialization;
@@ -15,21 +15,27 @@ public void TestDeserialization()
var theme = des.Deserialize(System.IO.File.ReadAllText(themeFile));
- Assert.AreNotEqual(default(Color), theme.Base.HotFocusBackground);
- Assert.AreNotEqual(default(Color), theme.Base.HotFocusForeground);
- Assert.AreEqual(Color.Black, theme.Base.FocusForeground);
- Assert.AreNotEqual(default(Color), theme.Base.FocusBackground);
- Assert.AreNotEqual(default(Color), theme.Base.HotNormalBackground);
- Assert.AreNotEqual(default(Color), theme.Base.HotNormalForeground);
+ Assert.Multiple(() =>
+ {
+ Assert.That(theme.Base.HotFocusBackground, Is.Not.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotFocusForeground, Is.Not.EqualTo(default(Color)));
+ Assert.That(theme.Base.FocusForeground, Is.EqualTo(Color.Black));
+ Assert.That(theme.Base.FocusBackground, Is.Not.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotNormalBackground, Is.Not.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotNormalForeground, Is.Not.EqualTo(default(Color)));
+ });
theme = new TerminalGuiTheme();
- Assert.AreEqual(default(Color), theme.Base.HotFocusBackground);
- Assert.AreEqual(default(Color), theme.Base.HotFocusForeground);
- Assert.AreEqual(default(Color), theme.Base.FocusForeground);
- Assert.AreEqual(default(Color), theme.Base.FocusBackground);
- Assert.AreEqual(default(Color), theme.Base.HotNormalBackground);
- Assert.AreEqual(default(Color), theme.Base.HotNormalForeground);
+ Assert.Multiple(() =>
+ {
+ Assert.That(theme.Base.HotFocusBackground, Is.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotFocusForeground, Is.EqualTo(default(Color)));
+ Assert.That(theme.Base.FocusForeground, Is.EqualTo(default(Color)));
+ Assert.That(theme.Base.FocusBackground, Is.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotNormalBackground, Is.EqualTo(default(Color)));
+ Assert.That(theme.Base.HotNormalForeground, Is.EqualTo(default(Color)));
+ });
}
}
diff --git a/Tests/IsIdentifiableTests/TestDestinations.cs b/Tests/IsIdentifiableTests/TestDestinations.cs
index 0b54057d..2cd2fc4d 100644
--- a/Tests/IsIdentifiableTests/TestDestinations.cs
+++ b/Tests/IsIdentifiableTests/TestDestinations.cs
@@ -108,7 +108,7 @@ public void CsvDestination_WithCsvConfiguration()
var fileCreatedContents = _fileSystem.File.ReadAllText(_fileSystem.Path.Combine(OUT_DIR, "test.csv"));
- Assert.True(fileCreatedContents.StartsWith("foo|bar"));
+ Assert.That(fileCreatedContents, Does.StartWith("foo|bar"));
}
}
diff --git a/Tests/IsIdentifiableTests/TestHelpers.cs b/Tests/IsIdentifiableTests/TestHelpers.cs
index 52dcec25..3048c49c 100644
--- a/Tests/IsIdentifiableTests/TestHelpers.cs
+++ b/Tests/IsIdentifiableTests/TestHelpers.cs
@@ -7,21 +7,21 @@ public class TestHelpers
// Assert two strings match apart from line endings
public static void AreEqualIgnoringCaseAndLineEndings(string a, string b)
{
- StringAssert.AreEqualIgnoringCase(a.Replace("\r\n", "\n"), b.Replace("\r\n", "\n"));
+ Assert.That(b.Replace("\r\n", "\n"), Is.EqualTo(a.Replace("\r\n", "\n")).IgnoreCase);
}
// Assert two strings match apart from line endings, case sensitive
public static void AreEqualIgnoringLineEndings(string a, string b)
{
- StringAssert.AreEqualIgnoringCase(a.Replace("\r\n", "\n"), b.Replace("\r\n", "\n"));
+ Assert.That(b.Replace("\r\n", "\n"), Is.EqualTo(a.Replace("\r\n", "\n")).IgnoreCase);
}
public static void Contains(string needle, string haystack)
{
- StringAssert.Contains(needle.Replace("\r\n", "\n"), haystack.Replace("\r\n", "\n"));
+ Assert.That(haystack.Replace("\r\n", "\n"), Does.Contain(needle.Replace("\r\n", "\n")));
}
public static void DoesNotContain(string needle, string haystack)
{
- StringAssert.DoesNotContain(needle.Replace("\r\n", "\n"), haystack.Replace("\r\n", "\n"));
+ Assert.That(haystack.Replace("\r\n", "\n"), Does.Not.Contain(needle.Replace("\r\n", "\n")));
}
}
diff --git a/ii/Views/RulesView.cs b/ii/Views/RulesView.cs
index 51ceaacc..9787c950 100644
--- a/ii/Views/RulesView.cs
+++ b/ii/Views/RulesView.cs
@@ -365,8 +365,8 @@ private void EvaluateRuleCoverage()
var cts = new CancellationTokenSource();
using var btn = new Button("Cancel");
- var cancelFunc = () => { cts.Cancel(); };
- var closeFunc = () => { Application.RequestStop(); };
+ void cancelFunc() { cts.Cancel(); }
+ void closeFunc() { Application.RequestStop(); }
btn.Clicked += cancelFunc;
using var dlg = new Dialog("Evaluating", Constants.DlgWidth, 6, btn);