Fix up the Test style

This commit is contained in:
Paul Betts
2014-08-21 16:38:41 -07:00
parent 94fdd387cf
commit e2c734e31e
4 changed files with 13 additions and 25 deletions

View File

@@ -26,8 +26,7 @@ namespace Squirrel.Tests.Core
var existingTypes = GetContentTypes(expected); var existingTypes = GetContentTypes(expected);
try try {
{
File.Copy(inputFile, tempFile); File.Copy(inputFile, tempFile);
var actual = new XmlDocument(); var actual = new XmlDocument();
@@ -38,9 +37,7 @@ namespace Squirrel.Tests.Core
var actualTypes = GetContentTypes(actual); var actualTypes = GetContentTypes(actual);
Assert.Equal(existingTypes, actualTypes); Assert.Equal(existingTypes, actualTypes);
} } finally {
finally
{
File.Delete(tempFile); File.Delete(tempFile);
} }
} }

View File

@@ -205,8 +205,7 @@ namespace Squirrel.Tests.Core
var assemblyName = AssemblyName.GetAssemblyName(outputFile); var assemblyName = AssemblyName.GetAssemblyName(outputFile);
Assert.Equal(1, assemblyName.Version.Major); Assert.Equal(1, assemblyName.Version.Major);
Assert.Equal(5, assemblyName.Version.Minor); Assert.Equal(5, assemblyName.Version.Minor);
} } finally {
finally {
File.Delete(outputPackage); File.Delete(outputPackage);
File.Delete(outputFile); File.Delete(outputFile);
} }
@@ -242,8 +241,7 @@ namespace Squirrel.Tests.Core
var fixture = new ReleasePackage(inputPackage); var fixture = new ReleasePackage(inputPackage);
(new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue(); (new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();
try try {
{
fixture.CreateReleasePackage(outputPackage, sourceDir); fixture.CreateReleasePackage(outputPackage, sourceDir);
this.Log().Info("Resulting package is at {0}", outputPackage); this.Log().Info("Resulting package is at {0}", outputPackage);
@@ -264,9 +262,7 @@ namespace Squirrel.Tests.Core
Assert.Contains("dir\\item-in-subdirectory.txt", contentFilePaths); Assert.Contains("dir\\item-in-subdirectory.txt", contentFilePaths);
Assert.Equal(1, pkg.GetLibFiles().Count()); Assert.Equal(1, pkg.GetLibFiles().Count());
} } finally {
finally
{
File.Delete(outputPackage); File.Delete(outputPackage);
} }
} }
@@ -281,8 +277,7 @@ namespace Squirrel.Tests.Core
var rightPackage = "Caliburn.Micro.1.5.2.nupkg"; var rightPackage = "Caliburn.Micro.1.5.2.nupkg";
var rightPackagePath = IntegrationTestHelper.GetPath("fixtures", rightPackage); var rightPackagePath = IntegrationTestHelper.GetPath("fixtures", rightPackage);
try try {
{
var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages"); var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");
(new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue(); (new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();
@@ -298,9 +293,7 @@ namespace Squirrel.Tests.Core
.FirstOrDefault(f => f.TargetFramework == FrameworkTargetVersion.Net45); .FirstOrDefault(f => f.TargetFramework == FrameworkTargetVersion.Net45);
Assert.NotNull(dependency); Assert.NotNull(dependency);
} } finally {
finally
{
File.Delete(outputPackage); File.Delete(outputPackage);
} }
} }

View File

@@ -85,8 +85,7 @@ namespace Squirrel.Tests
"Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.0.0.0-full.nupkg",
"Squirrel.Core.1.1.0.0-delta.nupkg", "Squirrel.Core.1.1.0.0-delta.nupkg",
"Squirrel.Core.1.1.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg",
}.ForEach(x => }.ForEach(x => {
{
var path = IntegrationTestHelper.GetPath("fixtures", x); var path = IntegrationTestHelper.GetPath("fixtures", x);
File.Copy(path, Path.Combine(localPackages, x)); File.Copy(path, Path.Combine(localPackages, x));
File.Copy(path, Path.Combine(remotePackages, x)); File.Copy(path, Path.Combine(remotePackages, x));
@@ -125,8 +124,7 @@ namespace Squirrel.Tests
"Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.0.0.0-full.nupkg",
"Squirrel.Core.1.1.0.0-delta.nupkg", "Squirrel.Core.1.1.0.0-delta.nupkg",
"Squirrel.Core.1.1.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg",
}.ForEach(x => }.ForEach(x => {
{
var path = IntegrationTestHelper.GetPath("fixtures", x); var path = IntegrationTestHelper.GetPath("fixtures", x);
File.Copy(path, Path.Combine(localPackages, x)); File.Copy(path, Path.Combine(localPackages, x));
}); });
@@ -134,8 +132,7 @@ namespace Squirrel.Tests
new[] { new[] {
"Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.0.0.0-full.nupkg",
"Squirrel.Core.1.1.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg",
}.ForEach(x => }.ForEach(x => {
{
var path = IntegrationTestHelper.GetPath("fixtures", x); var path = IntegrationTestHelper.GetPath("fixtures", x);
File.Copy(path, Path.Combine(remotePackages, x)); File.Copy(path, Path.Combine(remotePackages, x));
}); });

View File

@@ -30,7 +30,6 @@ namespace Squirrel.Tests.Core
{ {
string tempDir; string tempDir;
using (Utility.WithTempDirectory(out tempDir)) { using (Utility.WithTempDirectory(out tempDir)) {
for (var i = 0; i < 50; i++) { for (var i = 0; i < 50; i++) {
var directory = Path.Combine(tempDir, newId()); var directory = Path.Combine(tempDir, newId());
CreateSampleDirectory(directory); CreateSampleDirectory(directory);
@@ -64,6 +63,7 @@ namespace Squirrel.Tests.Core
static void CreateSampleDirectory(string directory) static void CreateSampleDirectory(string directory)
{ {
Random prng = new Random();
while (true) { while (true) {
Directory.CreateDirectory(directory); Directory.CreateDirectory(directory);
@@ -73,12 +73,13 @@ namespace Squirrel.Tests.Core
File.WriteAllText(file, Guid.NewGuid().ToString()); File.WriteAllText(file, Guid.NewGuid().ToString());
} }
if (new Random().NextDouble() > 0.5) { if (prng.NextDouble() > 0.5) {
var childDirectory = Path.Combine(directory, newId()); var childDirectory = Path.Combine(directory, newId());
if (childDirectory.Length > 248) return; if (childDirectory.Length > 248) return;
directory = childDirectory; directory = childDirectory;
continue; continue;
} }
break; break;
} }
} }