1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Fixed: Automation/Integration/Unit Tests

This commit is contained in:
Qstick
2019-09-02 22:22:25 -04:00
parent 944f420270
commit 7f221c7834
123 changed files with 1384 additions and 1191 deletions
+36 -5
View File
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using FluentAssertions;
@@ -45,6 +46,7 @@ namespace NzbDrone.Test.Common
{
private static readonly Random _random = new Random();
private static int _nextUid;
private AutoMoqer _mocker;
protected AutoMoqer Mocker
@@ -84,7 +86,21 @@ namespace NzbDrone.Test.Common
}
}
protected string TempFolder { get; private set; }
private string _tempFolder;
protected string TempFolder
{
get
{
if (_tempFolder == null)
{
_tempFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "_temp_" + GetUID());
Directory.CreateDirectory(_tempFolder);
}
return _tempFolder;
}
}
[SetUp]
public void TestBaseSetup()
@@ -93,9 +109,7 @@ namespace NzbDrone.Test.Common
LogManager.ReconfigExistingLoggers();
TempFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "_temp_" + DateTime.Now.Ticks);
Directory.CreateDirectory(TempFolder);
_tempFolder = null;
}
[TearDown]
@@ -103,9 +117,26 @@ namespace NzbDrone.Test.Common
{
_mocker = null;
DeleteTempFolder(_tempFolder);
}
public static string GetUID()
{
return Process.GetCurrentProcess().Id + "_" + DateTime.Now.Ticks + "_" + Interlocked.Increment(ref _nextUid);
}
public static void DeleteTempFolder(string folder)
{
if (folder == null)
{
return;
}
try
{
var tempFolder = new DirectoryInfo(TempFolder);
var tempFolder = new DirectoryInfo(folder);
if (tempFolder.Exists)
{
foreach (var file in tempFolder.GetFiles("*", SearchOption.AllDirectories))