cleaned up test db path for tests.

This commit is contained in:
Keivan Beigi
2013-06-27 18:03:04 -07:00
parent 02c175950b
commit dde91569ac
15 changed files with 123 additions and 133 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using Marr.Data;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Migration.Framework;
@@ -63,9 +64,6 @@ namespace NzbDrone.Core.Test.Framework
public abstract class DbTest : CoreTest
{
private string _dbName;
private ITestDatabase _db;
private IDatabase _database;
@@ -90,15 +88,15 @@ namespace NzbDrone.Core.Test.Framework
}
}
private void WithObjectDb(bool memory = true)
private void WithTestDb()
{
WithTempAsAppPath();
_dbName = DateTime.Now.Ticks.ToString() + ".db";
MapRepository.Instance.EnableTraceLogging = true;
var factory = new DbFactory(new MigrationController(new MigrationLogger(TestLogger)));
_database = factory.Create(_dbName, MigrationType);
var factory = new DbFactory(new MigrationController(new MigrationLogger(TestLogger)), Mocker.GetMock<IAppDirectoryInfo>().Object);
_database = factory.Create(MigrationType);
_db = new TestTestDatabase(_database);
Mocker.SetConstant(_database);
}
@@ -106,27 +104,29 @@ namespace NzbDrone.Core.Test.Framework
[SetUp]
public void SetupReadDb()
{
WithObjectDb();
WithTestDb();
}
[TearDown]
public void TearDown()
{
var files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db");
foreach (var file in files)
if (TestDirectoryInfo != null)
{
try
{
File.Delete(file);
}
catch (Exception)
{
var files = Directory.GetFiles(TestDirectoryInfo.WorkingDirectory);
foreach (var file in files)
{
try
{
File.Delete(file);
}
catch (Exception)
{
}
}
}
}
}

View File

@@ -17,9 +17,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
[SetUp]
public void Setup()
{
//Mocker.SetConstant(new HttpProvider(new IAppDirectoryInfo()));
//Mocker.SetConstant(new DiskProvider());
Mocker.SetConstant(new AppDirectoryInfo());
Mocker.SetConstant<IAppDirectoryInfo>(new AppDirectoryInfo());
}
[Test]

View File

@@ -289,7 +289,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
result.Should().NotBeNull();
result.SeriesId.Should().Be(_fakeSeries.Id);
result.Size.Should().Be(_fileSize);
result.DateAdded.Should().HaveDay(DateTime.Now.Day);
result.DateAdded.Should().HaveDay(DateTime.UtcNow.Day);
Mocker.GetMock<IMediaFileService>().Verify(c => c.Add(result), Times.Once());
}

View File

@@ -5,7 +5,6 @@ using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.TvTests.SeriesRepositoryTests
{