mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed tests.
This commit is contained in:
parent
958153be55
commit
c38973cce4
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Marr.Data;
|
using Marr.Data;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Instrumentation;
|
using NzbDrone.Common.Instrumentation;
|
||||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
using NzbDrone.Core.MediaFiles;
|
|
||||||
using NzbDrone.Core.Instrumentation;
|
using NzbDrone.Core.Instrumentation;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.Categories;
|
using NzbDrone.Test.Common.Categories;
|
||||||
@ -35,7 +36,6 @@ public void Setup()
|
|||||||
|
|
||||||
LogManager.ReconfigExistingLoggers();
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
|
||||||
|
|
||||||
_logger = NzbDroneLogger.GetLogger(this);
|
_logger = NzbDroneLogger.GetLogger(this);
|
||||||
|
|
||||||
_uniqueMessage = "Unique message: " + Guid.NewGuid();
|
_uniqueMessage = "Unique message: " + Guid.NewGuid();
|
||||||
@ -46,6 +46,8 @@ public void write_log()
|
|||||||
{
|
{
|
||||||
_logger.Info(_uniqueMessage);
|
_logger.Info(_uniqueMessage);
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
StoredModel.Message.Should().Be(_uniqueMessage);
|
StoredModel.Message.Should().Be(_uniqueMessage);
|
||||||
VerifyLog(StoredModel, LogLevel.Info);
|
VerifyLog(StoredModel, LogLevel.Info);
|
||||||
}
|
}
|
||||||
@ -61,6 +63,8 @@ public void write_long_log()
|
|||||||
|
|
||||||
_logger.Info(message);
|
_logger.Info(message);
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
StoredModel.Message.Should().HaveLength(message.Length);
|
StoredModel.Message.Should().HaveLength(message.Length);
|
||||||
StoredModel.Message.Should().Be(message);
|
StoredModel.Message.Should().Be(message);
|
||||||
VerifyLog(StoredModel, LogLevel.Info);
|
VerifyLog(StoredModel, LogLevel.Info);
|
||||||
@ -77,6 +81,9 @@ public void perf_test()
|
|||||||
{
|
{
|
||||||
_logger.Info(Guid.NewGuid());
|
_logger.Info(Guid.NewGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
MapRepository.Instance.EnableTraceLogging = true;
|
MapRepository.Instance.EnableTraceLogging = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +94,7 @@ public void write_log_exception()
|
|||||||
|
|
||||||
_logger.Error(ex, _uniqueMessage);
|
_logger.Error(ex, _uniqueMessage);
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
VerifyLog(StoredModel, LogLevel.Error);
|
VerifyLog(StoredModel, LogLevel.Error);
|
||||||
StoredModel.Message.Should().Be(_uniqueMessage + ": " + ex.Message);
|
StoredModel.Message.Should().Be(_uniqueMessage + ": " + ex.Message);
|
||||||
@ -99,13 +107,13 @@ public void write_log_exception()
|
|||||||
[Test]
|
[Test]
|
||||||
public void exception_log_with_no_message_should_use_exceptions_message()
|
public void exception_log_with_no_message_should_use_exceptions_message()
|
||||||
{
|
{
|
||||||
|
|
||||||
var ex = new InvalidOperationException("Fake Exception");
|
var ex = new InvalidOperationException("Fake Exception");
|
||||||
_uniqueMessage = string.Empty;
|
_uniqueMessage = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
_logger.Error(ex, _uniqueMessage);
|
_logger.Error(ex, _uniqueMessage);
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
StoredModel.Message.Should().Be(ex.Message);
|
StoredModel.Message.Should().Be(ex.Message);
|
||||||
|
|
||||||
VerifyLog(StoredModel, LogLevel.Error);
|
VerifyLog(StoredModel, LogLevel.Error);
|
||||||
@ -119,6 +127,8 @@ public void null_string_as_arg_should_not_fail()
|
|||||||
var epFile = new EpisodeFile();
|
var epFile = new EpisodeFile();
|
||||||
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
||||||
|
|
||||||
|
Thread.Sleep(600);
|
||||||
|
|
||||||
epFile.RelativePath.Should().BeNull();
|
epFile.RelativePath.Should().BeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user