mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 19:50:15 -07:00
Added support to Error/Warning/Fatal verification in text projects
This commit is contained in:
parent
d6ae21506c
commit
6d085d5340
28 changed files with 240 additions and 313 deletions
62
NzbDrone.Core.Test/ConfigProviderTest.cs
Normal file
62
NzbDrone.Core.Test/ConfigProviderTest.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using AutoMoq;
|
||||
using MbUnit.Framework;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using SubSonic.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ConfigProviderTest : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void Overwrite_existing_value()
|
||||
{
|
||||
const string key = "MY_KEY";
|
||||
const string value = "MY_VALUE";
|
||||
|
||||
//Arrange
|
||||
var config = new Config {Key = key, Value = value};
|
||||
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.GetMock<IRepository>()
|
||||
.Setup(r => r.Single<Config>(key))
|
||||
.Returns(config);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<ConfigProvider>().SetValue(key, value);
|
||||
|
||||
//Assert
|
||||
mocker.GetMock<IRepository>().Verify(c => c.Update(config));
|
||||
mocker.GetMock<IRepository>().Verify(c => c.Add(It.IsAny<Config>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_new_value()
|
||||
{
|
||||
const string key = "MY_KEY";
|
||||
const string value = "MY_VALUE";
|
||||
|
||||
//Arrange
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.GetMock<IRepository>()
|
||||
.Setup(r => r.Single<Config>(It.IsAny<string>()))
|
||||
.Returns<Config>(null)
|
||||
.Verifiable();
|
||||
|
||||
//Act
|
||||
mocker.Resolve<ConfigProvider>().SetValue(key, value);
|
||||
|
||||
//Assert
|
||||
mocker.GetMock<IRepository>().Verify();
|
||||
mocker.GetMock<IRepository>().Verify(r => r.Update(It.IsAny<Config>()), Times.Never());
|
||||
mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)),
|
||||
Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue