Skip to content

Commit

Permalink
Change NUnit v2 to v3
Browse files Browse the repository at this point in the history
Applied automatic fixes with the help of https://github.com/wachulski/nunit-migrator.
  • Loading branch information
wachulski authored and savornicesei committed Jan 26, 2020
1 parent 45e4999 commit 4d7e393
Show file tree
Hide file tree
Showing 27 changed files with 15,797 additions and 6,455 deletions.
Binary file modified Tools/NUnit/framework/nunit.framework.dll
Binary file not shown.
22,078 changes: 15,698 additions & 6,380 deletions Tools/NUnit/framework/nunit.framework.xml

Large diffs are not rendered by default.

96 changes: 57 additions & 39 deletions project/UnitTests/Core/Config/PreprocessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public void TestAttrNodesetDefine()
AssertNodeExists(nav, "/root/test-two/outer-content/nodeset-content");
}

[Test, ExpectedException(typeof(InvalidMarkupException))]
[Test]
public void TestAttributeWithNoName()
{
_Preprocess("TestInvalidAttribute2.xml");
Assert.Throws<InvalidMarkupException>(() =>
{
_Preprocess("TestInvalidAttribute2.xml");
});
}

[Test]
Expand Down Expand Up @@ -110,20 +113,23 @@ public void TestExplicitDefine1()
AssertNodeValue(nav, "/root/@foo", "foo_val");
}

[Test, ExpectedException(typeof(ExplicitDefinitionRequiredException))]
[Test]
public void TestExplicitDefine2()
{
var settings = new PreprocessorSettings();
try
Assert.Throws<ExplicitDefinitionRequiredException>(() =>
{
Environment.SetEnvironmentVariable("foo", "foo_val");
settings.ExplicitDeclarationRequired = true;
_Preprocess("TestExplicitDefine.xml", settings);
}
finally
{
Environment.SetEnvironmentVariable("foo", null);
}
var settings = new PreprocessorSettings();
try
{
Environment.SetEnvironmentVariable("foo", "foo_val");
settings.ExplicitDeclarationRequired = true;
_Preprocess("TestExplicitDefine.xml", settings);
}
finally
{
Environment.SetEnvironmentVariable("foo", null);
}
});
}

[Test]
Expand Down Expand Up @@ -204,23 +210,29 @@ public void TestInitialDefine()
AssertNodeValue(nav, "/root/@foo", "foo_val");
}

[Test, ExpectedException(typeof(ExplicitDefinitionRequiredException))]
[Test]
public void TestInitialDefine2()
{
var settings = new PreprocessorSettings();
var defs = new Dictionary<string, string>();
defs["foo"] = "foo_val";
settings.InitialDefinitions = defs;
settings.ExplicitDeclarationRequired = true;
XmlDocument doc = _Preprocess("TestExplicitDefine.xml", settings);
XPathNavigator nav = doc.CreateNavigator();
AssertNodeValue(nav, "/root/@foo", "foo_val");
Assert.Throws<ExplicitDefinitionRequiredException>(() =>
{
var settings = new PreprocessorSettings();
var defs = new Dictionary<string, string>();
defs["foo"] = "foo_val";
settings.InitialDefinitions = defs;
settings.ExplicitDeclarationRequired = true;
XmlDocument doc = _Preprocess("TestExplicitDefine.xml", settings);
XPathNavigator nav = doc.CreateNavigator();
AssertNodeValue(nav, "/root/@foo", "foo_val");
});
}

[Test, ExpectedException(typeof(InvalidMarkupException))]
[Test]
public void TestMisplacedAttribute()
{
_Preprocess("TestInvalidAttribute.xml");
Assert.Throws<InvalidMarkupException>(() =>
{
_Preprocess("TestInvalidAttribute.xml");
});
}

[Test]
Expand Down Expand Up @@ -347,24 +359,27 @@ public void TestIncludeStack()
}
}

[Test, ExpectedException(typeof(MissingIncludeException))]
[Test]
public void TestMissingIncludeFile()
{
string filename = "TestMissingIncludeFile.xml";

using (XmlReader input = GetInput(filename))
Assert.Throws<MissingIncludeException>(() =>
{
using (XmlWriter output = GetOutput())
string filename = "TestMissingIncludeFile.xml";
using (XmlReader input = GetInput(filename))
{
ConfigPreprocessor preprocessor = new ConfigPreprocessor();
preprocessor.PreProcess(
input, output,
new FileNotFoundTestResolver(FAKE_ROOT + filename),
new Uri(FAKE_ROOT + filename));
using (XmlWriter output = GetOutput())
{
ConfigPreprocessor preprocessor = new ConfigPreprocessor();
preprocessor.PreProcess(
input, output,
new FileNotFoundTestResolver(FAKE_ROOT + filename),
new Uri(FAKE_ROOT + filename));
}
}
}
});
}

[Test]
public void TestScope()
{
Expand All @@ -375,10 +390,13 @@ public void TestScope()
AssertNodeValue( doc, "/root/inner/test[2]", "val2_redef" );
}

[Test,ExpectedException(typeof(CyclicalEvaluationException))]
[Test]
public void TestCycle()
{
_Preprocess( "TestCycle.xml" );
{
Assert.Throws<CyclicalEvaluationException>(() =>
{
_Preprocess("TestCycle.xml");
});
}

[Test]
Expand Down
28 changes: 17 additions & 11 deletions project/UnitTests/Core/Label/DefaultLabellerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,29 +261,35 @@ public void GeneratePrefixedLabelFromLabelPrefixFileAndLabelPrefixsFileSearchPat


[Test]
[ExpectedException(ExpectedMessage = "File DummyFile.txt does not exist")]
public void MustThrowExceptionWhenSpecifyingNonExistentFile()
{
string lblFile = "DummyFile.txt";
var ex = Assert.Throws<System.Exception>(() =>
{
string lblFile = "DummyFile.txt";
labeller.LabelPrefixFile = lblFile;
labeller.LabelPrefixFile = lblFile;
labeller.Generate(SuccessfulResult("1.3.4.35"));
labeller.Generate(SuccessfulResult("1.3.4.35"));
});
Assert.That(ex.Message, Is.EqualTo("File DummyFile.txt does not exist"));
}


[Test]
[ExpectedException(ExpectedMessage = "No valid prefix data found in file : thelabelprefix.txt")]
public void MustThrowExceptionWhenContentsOfLabelPrefixFileDoesNotMatchLabelPrefixsFileSearchPattern()
{
string lblFile = "thelabelprefix.txt";
System.IO.File.WriteAllText(lblFile, "ho ho ho");
var ex = Assert.Throws<System.Exception>(() =>
{
string lblFile = "thelabelprefix.txt";
System.IO.File.WriteAllText(lblFile, "ho ho ho");
labeller.LabelPrefixFile = lblFile;
labeller.LabelPrefixsFileSearchPattern = @"\d+\.\d+\.\d+\.";
labeller.LabelPrefixFile = lblFile;
labeller.LabelPrefixsFileSearchPattern = @"\d+\.\d+\.\d+\.";
labeller.Generate(SuccessfulResult("1.3.4.35"));
labeller.Generate(SuccessfulResult("1.3.4.35"));
});
Assert.That(ex.Message, Is.EqualTo("No valid prefix data found in file : thelabelprefix.txt"));
}

}
}
}
4 changes: 2 additions & 2 deletions project/UnitTests/Core/Publishers/PackagePublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class PackagePublisherTests
#endregion

#region Setup
[TestFixtureSetUp]
[OneTimeSetUp]
public void Setup()
{
// Delete any outputs from the last build
Expand All @@ -33,7 +33,7 @@ public void Setup()
#endregion

#region CleanUp
[TestFixtureTearDown]
[OneTimeTearDown]
public void CleanUp()
{
if (File.Exists(dataFilePath)) File.Delete(dataFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void SetUp()
private string failedBuildLog;
private StatisticsResults results;

[TestFixtureSetUp]
[OneTimeSetUp]
public void LoadXML()
{
StreamReader reader = File.OpenText("buildlog.xml");
Expand Down
4 changes: 2 additions & 2 deletions project/UnitTests/Core/SourceControl/GitHistoryParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void ParsingSingleLogMessageProducesOneModification()
}

[Test]
[Ignore]
[Ignore("TODO: provide a reason")]
public void ParsingLogWithLF()
{
Modification[] modifications = git.Parse(File.OpenText("CCNet.git.log.txt"), new DateTime(2009, 01, 01, 10, 00, 00, DateTimeKind.Utc), new DateTime(2009, 01, 31, 10, 00, 00, DateTimeKind.Utc));
Expand Down Expand Up @@ -78,7 +78,7 @@ public void ParsingLogWithLF()
}

[Test]
[Ignore]
[Ignore("TODO: provide a reason")]
public void ParsingLargeGitLog()
{
Modification[] modifications = git.Parse(File.OpenText("CCNet.git.log.txt"), DateTime.MinValue, DateTime.MaxValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MksHistoryParserTest
private string TEST_DATA = String.Empty;
private string MEMBER_INFO = String.Empty;

[TestFixtureSetUp]
[OneTimeSetUp]
public void SetUp()
{
// Transform xml output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class SynergyCommandBuilderTest : IntegrationFixture
private SynergyProjectInfo project;
private IIntegrationResult result;

[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
Synergy synergy = (Synergy) NetReflector.Read(SynergyMother.ConfigValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class SynergyParserTest
private SynergyConnectionInfo connection;
private SynergyProjectInfo project;

[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
connection = new SynergyConnectionInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void ShouldFailIfProcessTimesOut()
mocks.Verify();

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/DumpValueTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DumpValueTaskTest
#endregion

#region Setup
[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
// Delete any outputs from the last build
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/ExecutableTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void ShouldFailIfProcessTimesOut()
task.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));

Verify();
}
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/FakeTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void ShouldFailIfProcessTimesOut()

mocks.VerifyAll();
Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

private IIntegrationResult GenerateResultMock(string workingDir, string artefactDir)
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/GendarmeTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void TimedOutExecutionShouldFailBuild()
task.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/MsBuildTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void TimedOutExecutionShouldFailBuild()
task.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/NAntTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void ShouldFailBuildIfProcessTimesOut()
builder.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/PowerShellTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void ShouldFailBuildIfProcessTimesOut()
mytask.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/Core/Tasks/RakeTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void TimedOutExecutionShouldFailBuild()
builder.Run(result);

Assert.That(result.Status, Is.EqualTo(IntegrationStatus.Failure));
Assert.That(result.TaskOutput, Is.StringMatching("Command line '.*' timed out after \\d+ seconds"));
Assert.That(result.TaskOutput, Does.Match("Command line '.*' timed out after \\d+ seconds"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/IntegrationTests/CCNet_1835.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ThoughtWorks.CruiseControl.UnitTests.IntegrationTests
public class CCNet_1835
{

[TestFixtureSetUp]
[OneTimeSetUp]
public void fixLog4Net()
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("test.config"));
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/IntegrationTests/CCNet_1902.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ThoughtWorks.CruiseControl.UnitTests.IntegrationTests
[Category("Integration")]
public class CCNet_1902
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void fixLog4Net()
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("test.config"));
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/IntegrationTests/PublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ThoughtWorks.CruiseControl.UnitTests.IntegrationTests
{
public class PublisherTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void fixLog4Net()
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("test.config"));
Expand Down
2 changes: 1 addition & 1 deletion project/UnitTests/IntegrationTests/SimpleScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SimpleScenarioTests
{
System.Collections.Generic.Dictionary<string, bool> IntegrationCompleted = new System.Collections.Generic.Dictionary<string, bool>();

[TestFixtureSetUp]
[OneTimeSetUp]
public void fixLog4Net()
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("test.config"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ThoughtWorks.CruiseControl.UnitTests.IntegrationTests
[Category("Integration")]
public class SpacesInBuildArgsOfTask
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void fixLog4Net()
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("test.config"));
Expand Down
Loading

0 comments on commit 4d7e393

Please sign in to comment.