1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Common.Test/ConfigFileProviderTest.cs

150 lines
2.9 KiB
C#
Raw Normal View History

2013-05-11 02:53:50 +03:00
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
2011-11-13 10:27:16 +03:00
using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test
{
[TestFixture]
2013-05-11 02:53:50 +03:00
public class ConfigFileProviderTest : TestBase<ConfigFileProvider>
{
[SetUp]
public void SetUp()
{
2011-11-13 10:27:16 +03:00
WithTempAsAppPath();
var configFile = Mocker.Resolve<IAppFolderInfo>().GetConfigPath();
if (File.Exists(configFile))
File.Delete(configFile);
}
[Test]
public void GetValue_Success()
{
const string key = "Port";
const string value = "8989";
2013-05-11 02:53:50 +03:00
var result = Subject.GetValue(key, value);
result.Should().Be(value);
}
[Test]
public void GetInt_Success()
{
const string key = "Port";
const int value = 8989;
2013-05-11 02:53:50 +03:00
var result = Subject.GetValueInt(key, value);
result.Should().Be(value);
}
[Test]
public void GetBool_Success()
{
const string key = "LaunchBrowser";
const bool value = true;
2013-05-11 02:53:50 +03:00
var result = Subject.GetValueBoolean(key, value);
result.Should().BeTrue();
}
[Test]
public void GetLaunchBrowser_Success()
{
2013-05-11 02:53:50 +03:00
var result = Subject.LaunchBrowser;
result.Should().Be(true);
}
[Test]
public void GetPort_Success()
{
const int value = 8989;
2013-05-11 02:53:50 +03:00
var result = Subject.Port;
result.Should().Be(value);
}
[Test]
public void SetValue_bool()
{
const string key = "LaunchBrowser";
const bool value = false;
2013-05-11 02:53:50 +03:00
Subject.SetValue(key, value);
var result = Subject.LaunchBrowser;
result.Should().Be(value);
}
[Test]
public void SetValue_int()
{
const string key = "Port";
const int value = 12345;
2013-05-11 02:53:50 +03:00
Subject.SetValue(key, value);
var result = Subject.Port;
result.Should().Be(value);
}
[Test]
public void GetValue_New_Key()
{
const string key = "Hello";
const string value = "World";
2013-05-11 02:53:50 +03:00
var result = Subject.GetValue(key, value);
result.Should().Be(value);
}
[Test]
public void GetAuthenticationType_No_Existing_Value()
{
2013-07-14 10:00:50 +03:00
var result = Subject.AuthenticationEnabled;
2013-05-11 02:53:50 +03:00
2013-07-14 10:00:50 +03:00
result.Should().Be(false);
}
[Test]
public void SaveDictionary_should_save_proper_value()
{
int port = 20555;
2013-05-11 02:53:50 +03:00
var dic = Subject.GetConfigDictionary();
dic["Port"] = 20555;
2013-05-11 02:53:50 +03:00
Subject.SaveConfigDictionary(dic);
Subject.Port.Should().Be(port);
}
}
}