ConfigFileProvider will now add missing config values automatically, with a default value.

Added Handbrake and AtomicParsley wrappers for iPod video conversion.
This commit is contained in:
Mark McDowall 2011-10-06 21:36:47 -07:00
commit f973c74c87
9 changed files with 376 additions and 20 deletions

View file

@ -2,6 +2,7 @@
using AutoMoq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
@ -32,7 +33,7 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().GetValue(key);
var result = mocker.Resolve<ConfigFileProvider>().GetValue(key, value);
//Assert
result.Should().Be(value);
@ -47,7 +48,7 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().GetValueInt(key);
var result = mocker.Resolve<ConfigFileProvider>().GetValueInt(key, value);
//Assert
result.Should().Be(value);
@ -57,11 +58,12 @@ namespace NzbDrone.Core.Test
public void GetBool_Success()
{
const string key = "LaunchBrowser";
const bool value = true;
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().GetValueBoolean(key);
var result = mocker.Resolve<ConfigFileProvider>().GetValueBoolean(key, value);
//Assert
result.Should().BeTrue();
@ -124,5 +126,60 @@ namespace NzbDrone.Core.Test
var result = mocker.Resolve<ConfigFileProvider>().Port;
result.Should().Be(value);
}
[Test]
public void GetValue_New_Key()
{
const string key = "Hello";
const string value = "World";
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().GetValue(key, value);
//Assert
result.Should().Be(value);
}
[Test]
public void GetValue_New_Key_with_new_parent()
{
const string key = "Hello";
const string value = "World";
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().GetValue(key, value, "Universe");
//Assert
result.Should().Be(value);
}
[Test]
public void GetAuthenticationType_No_Existing_Value()
{
var mocker = new AutoMoqer();
//Act
var result = mocker.Resolve<ConfigFileProvider>().AuthenticationType;
//Assert
result.Should().Be(AuthenticationType.Anonymous);
}
[Test]
public void GetAuthenticationType_Windows()
{
var mocker = new AutoMoqer();
mocker.Resolve<ConfigFileProvider>().SetValue("AuthenticationType", 1);
//Act
var result = mocker.Resolve<ConfigFileProvider>().AuthenticationType;
//Assert
result.Should().Be(AuthenticationType.Windows);
}
}
}