Skip to content

Commit

Permalink
Update tests to NUnit 4.1.0 and 3.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Sep 18, 2024
1 parent cf1dea6 commit 1089e14
Show file tree
Hide file tree
Showing 25 changed files with 120 additions and 95 deletions.
20 changes: 10 additions & 10 deletions src/NUnitConsole/nunit3-console.tests/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void GetArgsFromFiles(string commandline, string files, params string[] e

// Then
Assert.That(expandedArgs, Is.EqualTo(expectedArgs));
Assert.IsEmpty(options.ErrorMessages);
Assert.That(options.ErrorMessages, Is.Empty);
}

[TestCase("--arg1 @file1.txt --arg2", "The file \"file1.txt\" was not found.")]
Expand Down Expand Up @@ -406,7 +406,7 @@ public void ResultOptionWithFilePath()
var spec = options.ResultOutputSpecifications[0];
Assert.That(spec.OutputPath, Is.EqualTo("results.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit3"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand All @@ -420,7 +420,7 @@ public void ResultOptionWithFilePathAndFormat()
var spec = options.ResultOutputSpecifications[0];
Assert.That(spec.OutputPath, Is.EqualTo("results.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit2"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand Down Expand Up @@ -479,12 +479,12 @@ public void ResultOptionMayBeRepeated()
var spec1 = specs[0];
Assert.That(spec1.OutputPath, Is.EqualTo("results.xml"));
Assert.That(spec1.Format, Is.EqualTo("nunit3"));
Assert.Null(spec1.Transform);
Assert.That(spec1.Transform, Is.Null);

var spec2 = specs[1];
Assert.That(spec2.OutputPath, Is.EqualTo("nunit2results.xml"));
Assert.That(spec2.Format, Is.EqualTo("nunit2"));
Assert.Null(spec2.Transform);
Assert.That(spec2.Transform, Is.Null);

var spec3 = specs[2];
Assert.That(spec3.OutputPath, Is.EqualTo("myresult.xml"));
Expand All @@ -502,7 +502,7 @@ public void DefaultResultSpecification()
var spec = options.ResultOutputSpecifications[0];
Assert.That(spec.OutputPath, Is.EqualTo("TestResult.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit3"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand Down Expand Up @@ -562,7 +562,7 @@ public void ExploreOptionWithFilePath()
var spec = options.ExploreOutputSpecifications[0];
Assert.That(spec.OutputPath, Is.EqualTo("results.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit3"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand All @@ -577,7 +577,7 @@ public void ExploreOptionWithFilePathAndFormat()
var spec = options.ExploreOutputSpecifications[0];
Assert.That(spec.OutputPath, Is.EqualTo("results.xml"));
Assert.That(spec.Format, Is.EqualTo("cases"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand Down Expand Up @@ -869,14 +869,14 @@ private static IFileSystem GetFileSystemContainingFile(string fileName)
private static FieldInfo GetFieldInfo(string fieldName)
{
FieldInfo field = typeof(ConsoleOptions).GetField(fieldName);
Assert.IsNotNull(field, "The field '{0}' is not defined", fieldName);
Assert.That(field, Is.Not.Null, "The field '{0}' is not defined", fieldName);
return field;
}

private static PropertyInfo GetPropertyInfo(string propertyName)
{
PropertyInfo property = typeof(ConsoleOptions).GetProperty(propertyName);
Assert.IsNotNull(property, "The property '{0}' is not defined", propertyName);
Assert.That(property, Is.Not.Null, "The property '{0}' is not defined", propertyName);
return property;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void FileNameOnly()
var spec = new Spec("MyFile.xml", null);
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit3"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand All @@ -49,7 +49,7 @@ public void FileNamePlusFormat()
var spec = new Spec("MyFile.xml;format=nunit2", null);
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
Assert.That(spec.Format, Is.EqualTo("nunit2"));
Assert.Null(spec.Transform);
Assert.That(spec.Transform, Is.Null);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CreateResult()
var engineResult = AddMetadata(new TestEngineResult(xmlText));
_result = engineResult.Xml;

Assert.NotNull(_result, "Unable to create report result.");
Assert.That(_result, Is.Not.Null, "Unable to create report result.");
}

[SetUp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnitLite" Version="3.13.3" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnitLite" Version="4.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net462'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void GetDirectories_Asterisk_Tools()
var result = finder.GetDirectories(baseDir, "*");
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("*", SIO.SearchOption.TopDirectoryOnly);
this.GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand All @@ -126,7 +126,7 @@ public void GetDirectories_Asterisk_Metamorphosator()
var result = finder.GetDirectories(baseDir, "*");
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
this.GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand All @@ -144,7 +144,7 @@ public void GetDirectories_Greedy_Tools()
var result = finder.GetDirectories(baseDir, "**");
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("*", SIO.SearchOption.AllDirectories);
this.GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand All @@ -171,7 +171,7 @@ public void GetDirectories_Greedy_Metamorphosator()
var result = finder.GetDirectories(baseDir, "**");
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("*", SIO.SearchOption.AllDirectories);
this.GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand Down Expand Up @@ -207,7 +207,7 @@ public void GetDirectories_WordWithWildcard_OneMatch(string pattern)
var result = finder.GetDirectories(baseDir, pattern);
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories(pattern, SIO.SearchOption.TopDirectoryOnly);
}
Expand All @@ -225,7 +225,7 @@ public void GetDirectories_WordWithWildcard_MultipleMatches(string pattern)
var result = finder.GetDirectories(baseDir, pattern);
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories(pattern, SIO.SearchOption.TopDirectoryOnly);
}
Expand Down Expand Up @@ -285,7 +285,7 @@ public void GetDirectories_MultipleComponents_MultipleMatches(string pattern)
var result = finder.GetDirectories(baseDir, pattern);
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
}

[TestCase("*/tests/v*")]
Expand All @@ -307,7 +307,7 @@ public void GetDirectories_MultipleComponents_MultipleMatches_Asterisk(string pa
var result = finder.GetDirectories(baseDir, pattern);
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
testsDir.Received().GetDirectories("v*", SIO.SearchOption.TopDirectoryOnly);
}
Expand All @@ -331,7 +331,7 @@ public void GetDirectories_MultipleComponents_MultipleMatches_QuestionMark(strin
var result = finder.GetDirectories(baseDir, pattern);
var actual = result.Select(x => x.FullName);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
testsDir.Received().GetDirectories("v?", SIO.SearchOption.TopDirectoryOnly);
}
Expand All @@ -346,7 +346,7 @@ public void GetDirectories_MultipleComponents_AllDirectories(string pattern)

var actual = finder.GetDirectories(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("*", SIO.SearchOption.AllDirectories);
foreach (var dir in this.fakedDirectories.Values.Where(x => x != baseDir))
Expand Down Expand Up @@ -375,7 +375,7 @@ public void GetDirectories_GreedyThenWordThenGreedy()

var actual = finder.GetDirectories(baseDir, "**/tests/**");

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("*", SIO.SearchOption.AllDirectories);
this.GetFakeDirectory("tools", "frobuscator").Received().GetDirectories("tests", SIO.SearchOption.TopDirectoryOnly);
Expand All @@ -396,7 +396,7 @@ public void GetDirectories_WordWithAsteriskThenGreedyThenWord()

var actual = finder.GetDirectories(baseDir, "meta*/**/v1");

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Received().GetDirectories("meta*", SIO.SearchOption.TopDirectoryOnly);
this.GetFakeDirectory("tools", "frobuscator").DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand All @@ -413,7 +413,7 @@ public void GetDirectories_Parent()

var actual = finder.GetDirectories(baseDir, "../");

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
}
Expand All @@ -429,7 +429,7 @@ public void GetDirectories_ParentThenParentThenWordThenWord()

var actual = finder.GetDirectories(baseDir, "../../metamorphosator/addins");

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
baseDir.Parent.Parent.Received().GetDirectories("metamorphosator", SIO.SearchOption.TopDirectoryOnly);
Expand Down Expand Up @@ -476,7 +476,7 @@ public void GetFiles_WordWithWildcard(string pattern)

var actual = finder.GetFiles(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Received().GetFiles(pattern);
baseDir.Parent.DidNotReceive().GetFiles(Arg.Any<string>());
}
Expand All @@ -497,7 +497,7 @@ public void GetFiles_AsteriskThenWordWithWildcard(string pattern)

var actual = finder.GetFiles(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
abcDir.Received().GetFiles(filePattern);
defDir.Received().GetFiles(filePattern);
baseDir.Parent.DidNotReceive().GetFiles(Arg.Any<string>());
Expand Down Expand Up @@ -534,7 +534,7 @@ public void GetFiles_GreedyThenWordWithWildcard(string pattern)

var actual = finder.GetFiles(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
foreach (var dir in this.fakedDirectories.Values.Where(x => x.FullName != GetRoot()))
{
dir.Received().GetFiles(filePattern);
Expand All @@ -561,7 +561,7 @@ public void GetFiles_WordThenParentThenWordWithWildcardThenWord()

var actual = finder.GetFiles(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
targetDir.Received().GetFiles(filename);
foreach (var dir in this.fakedDirectories.Values.Where(x => x != targetDir))
{
Expand All @@ -583,7 +583,7 @@ public void GetFiles_CurrentDirThenAsterisk()

var actual = finder.GetFiles(baseDir, pattern);

CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
baseDir.Received().GetFiles("*");
baseDir.Parent.DidNotReceive().GetFiles(Arg.Any<string>());
baseDir.Parent.DidNotReceive().GetDirectories(Arg.Any<string>(), Arg.Any<SIO.SearchOption>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public void Init()

var directory = new Directory(path);

Assert.AreEqual(path, directory.FullName);
Assert.AreEqual(parent, directory.Parent.FullName);
Assert.That(directory.FullName, Is.EqualTo(path));
Assert.That(directory.Parent.FullName, Is.EqualTo(parent));
}

[Test]
Expand Down Expand Up @@ -53,8 +53,8 @@ public void Init_TrailingDirectorySeparator()

var directory = new Directory(path);

Assert.AreEqual(path, directory.FullName);
Assert.AreEqual(parent, directory.Parent.FullName);
Assert.That(directory.FullName, Is.EqualTo(path));
Assert.That(directory.Parent.FullName, Is.EqualTo(parent));
}

// Skip this test on non-Windows systems since System.IO.DirectoryInfo appends '\\server\share' to the current working-directory, making this test useless.
Expand All @@ -64,8 +64,8 @@ public void Init_NoParent_SMB()
var path = "\\\\server\\share";
var directory = new Directory(path);

Assert.AreEqual(path, directory.FullName);
Assert.IsNull(directory.Parent);
Assert.That(directory.FullName, Is.EqualTo(path));
Assert.That(directory.Parent, Is.Null);
}

// Skip this test on non-Windows systems since System.IO.DirectoryInfo appends 'x:\' to the current working-directory, making this test useless.
Expand All @@ -75,8 +75,8 @@ public void Init_NoParent_Drive()
var path = "x:\\";
var directory = new Directory(path);

Assert.AreEqual(path, directory.FullName);
Assert.IsNull(directory.Parent);
Assert.That(directory.FullName, Is.EqualTo(path));
Assert.That(directory.Parent, Is.Null);
}

[Test]
Expand All @@ -87,8 +87,8 @@ public void Init_NoParent_Root()

var directory = new Directory(path);

Assert.AreEqual(expected, directory.FullName);
Assert.IsNull(directory.Parent);
Assert.That(directory.FullName, Is.EqualTo(expected));
Assert.That(directory.Parent, Is.Null);
}

[Test]
Expand All @@ -101,7 +101,7 @@ public void GetFiles()
var actualFiles = directory.GetFiles("*");

var actual = actualFiles.Select(x => x.FullName);
CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
}

[Test]
Expand All @@ -127,7 +127,7 @@ public void GetFiles_WithPattern()
var actualFiles = directory.GetFiles("*.dll");

var actual = actualFiles.Select(x => x.FullName);
CollectionAssert.AreEquivalent(expected, actual);
Assert.That(actual, Is.EquivalentTo(expected));
}

[Test]
Expand Down
Loading

0 comments on commit 1089e14

Please sign in to comment.