Skip to content

Commit

Permalink
Update NUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
dbent committed Apr 3, 2017
1 parent 484ca1f commit be1d9a2
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ before_install:

script:
- ./build --configuration=$BUILD_CONFIGURATION
- ./build test+only --configuration=$BUILD_CONFIGURATION --exclude=FlakyNetwork
- ./build test+only --configuration=$BUILD_CONFIGURATION --where="cat != FlakyNetwork"

deploy:
# Releases (which are tagged) go to github
Expand Down
2 changes: 2 additions & 0 deletions CKAN.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/Environment/UnitTesting/ShadowCopy/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion Tests/Core/ModuleInstallerDirTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ModuleInstallerDirTest
/// Prep environment by setting up a single mod in
/// a disposable KSP instance.
/// </summary>
[TestFixtureSetUp]
[OneTimeSetUp]
public void SetUp()
{
_testModule = TestData.DogeCoinFlag_101_module();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Core/Relationships/SanityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SanityChecker
private CKAN.Registry registry;
private DisposableKSP ksp;

[TestFixtureSetUp]
[OneTimeSetUp]
public void Setup()
{
ksp = new DisposableKSP();
Expand Down
15 changes: 9 additions & 6 deletions Tests/Data/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using CKAN;
using CKAN.Versioning;
using Version = CKAN.Version;
Expand All @@ -12,12 +13,14 @@ static public class TestData
{
public static string DataDir()
{
// TODO: Have this actually walk our directory structure and find
// t/data. This means we can relocate our test executable and
// things will still work.
string current = Directory.GetCurrentDirectory();

return Path.Combine(current, "../../../../../Tests/Data");
// FIXME: Come up with a better solution for test data
// 1. This is fragile with respect to changes in directory structure.
// 2. This forces us to disable ReSharper's test assembly shadow copying
// 3. "Quick" solution is to embed test data as an archive and extract it on demand to a known temporary location.
// But this makes updates hard.
// 4. A better, but much harder solution, is to not require harded files on disk for any of our tests, but that's
// a lot of work.
return Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName, "../../../../../Tests/Data");
}

public static string DataDir(string file)
Expand Down
4 changes: 2 additions & 2 deletions Tests/GUI/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class ConfigurationTests
{
string tempDir;

[TestFixtureSetUp]
[OneTimeSetUp]
public void Setup()
{
tempDir = TestData.NewTempDir();
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void TearDown()
{
Directory.Delete(tempDir, true);
Expand Down
4 changes: 2 additions & 2 deletions Tests/GUI/GH1866.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class GH1866
new NetAsyncModulesDownloader(main.currentUser)
);*/

[TestFixtureSetUp]
[OneTimeSetUp]
public void Up()
{
_instance = new DisposableKSP();
Expand Down Expand Up @@ -84,7 +84,7 @@ public void Up()
}
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void Down()
{
_instance.Dispose();
Expand Down
12 changes: 6 additions & 6 deletions Tests/GUI/NavigationHistoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void After_SingleHistoryItem_CannotNavigate()
Assert.IsFalse(nav.CanNavigateForward);
}

[Test, ExpectedException(typeof(InvalidOperationException))]
[Test]
public void NavigatingBackward_WhenUnable_ThrowsException()
{
// arrange
Expand All @@ -48,14 +48,14 @@ public void NavigatingBackward_WhenUnable_ThrowsException()

// act

nav.NavigateBackward();
TestDelegate act = () => nav.NavigateBackward();

// assert

Assert.Fail();
Assert.Throws<InvalidOperationException>(act);
}

[Test, ExpectedException(typeof(InvalidOperationException))]
[Test]
public void NavigatingForward_WhenUnable_ThrowsException()
{
// arrange
Expand All @@ -64,11 +64,11 @@ public void NavigatingForward_WhenUnable_ThrowsException()

// act

nav.NavigateForward();
TestDelegate act = () => nav.NavigateForward();

// assert

Assert.Fail();
Assert.Throws<InvalidOperationException>(act);
}

[Test]
Expand Down
8 changes: 4 additions & 4 deletions Tests/NetKAN/SDMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public void SD_Version_Select_214()
}

[Test]
[TestCase("/mod/42/Example/download/1.23", Result="https://spacedock.info/mod/42/Example/download/1.23")]
[TestCase("/mod/42/Example%20With%20Spaces/download/1.23", Result="https://spacedock.info/mod/42/Example%20With%20Spaces/download/1.23")]
[TestCase("/mod/42/Example With Spaces/download/1.23", Result="https://spacedock.info/mod/42/Example%20With%20Spaces/download/1.23")]
[TestCase("/mod/79/Salyut%20Stations%20%26%20Soyuz%20Ferries/download/0.93",Result="https://spacedock.info/mod/79/Salyut%20Stations%20%26%20Soyuz%20Ferries/download/0.93")]
[TestCase("/mod/42/Example/download/1.23", ExpectedResult="https://spacedock.info/mod/42/Example/download/1.23")]
[TestCase("/mod/42/Example%20With%20Spaces/download/1.23", ExpectedResult = "https://spacedock.info/mod/42/Example%20With%20Spaces/download/1.23")]
[TestCase("/mod/42/Example With Spaces/download/1.23", ExpectedResult = "https://spacedock.info/mod/42/Example%20With%20Spaces/download/1.23")]
[TestCase("/mod/79/Salyut%20Stations%20%26%20Soyuz%20Ferries/download/0.93", ExpectedResult = "https://spacedock.info/mod/79/Salyut%20Stations%20%26%20Soyuz%20Ferries/download/0.93")]
// GH #816: Ensure URLs with & are encoded correctly.
public string SD_URL_encode_816(string path)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/NetKAN/Sources/Curse/CurseApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class CurseApiTests
{
private NetFileCache _cache;

[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetup()
{
var tempDirectory = Path.Combine(Path.GetTempPath(), "CKAN", Guid.NewGuid().ToString("N"));
Expand All @@ -24,7 +24,7 @@ public void TestFixtureSetup()
_cache = new NetFileCache(tempDirectory);
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown()
{
Directory.Delete(_cache.GetCachePath(), recursive: true);
Expand Down
4 changes: 2 additions & 2 deletions Tests/NetKAN/Sources/Spacedock/SpacedockApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class SpacedockApiTests
{
private NetFileCache _cache;

[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetup()
{
var tempDirectory = Path.Combine(Path.GetTempPath(), "CKAN", Guid.NewGuid().ToString("N"));
Expand All @@ -24,7 +24,7 @@ public void TestFixtureSetup()
_cache = new NetFileCache(tempDirectory);
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown()
{
Directory.Delete(_cache.GetCachePath(), recursive: true);
Expand Down
2 changes: 1 addition & 1 deletion Tests/NetKAN/Transformers/GeneratedByTransformerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void AddsGeneratedByProperty()
var transformedJson = result.Json();

// Assert
Assert.That((string)transformedJson["x_generated_by"], Is.StringContaining("netkan"),
Assert.That((string)transformedJson["x_generated_by"], Does.Contain("netkan"),
"GeneratedByTransformer should add an x_generated_by property containing the string 'netkan'"
);
}
Expand Down
5 changes: 2 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@
<HintPath>..\_build\lib\nuget\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\_build\lib\nuget\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\_build\lib\nuget\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<package id="log4net" version="2.0.8" targetFramework="net45" />
<package id="Moq" version="4.7.8" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="NUnit" version="3.6.1" targetFramework="net45" />
</packages>
10 changes: 5 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#addin "nuget:?package=Cake.SemVer&version=1.0.14"
#tool "nuget:?package=ILRepack&version=2.0.12"
#tool "nuget:?package=NUnit.Runners&version=2.6.4"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.6.1"

using System.Text.RegularExpressions;
using Semver;
Expand Down Expand Up @@ -112,7 +112,7 @@ Task("Test+Only")
Task("Test-UnitTests+Only")
.Does(() =>
{
var exclude = Argument<string>("exclude", null);
var where = Argument<string>("where", null);
var testFile = outDirectory
.Combine("CKAN.Tests")
Expand All @@ -127,9 +127,9 @@ Task("Test-UnitTests+Only")
CreateDirectory(nunitOutputDirectory);
NUnit(testFile.FullPath, new NUnitSettings {
Exclude = exclude,
ResultsFile = nunitOutputDirectory.CombineWithFilePath("TestResult.xml")
NUnit3(testFile.FullPath, new NUnit3Settings {
Where = where,
Results = nunitOutputDirectory.CombineWithFilePath("TestResult.xml")
});
});

Expand Down

0 comments on commit be1d9a2

Please sign in to comment.