2013-02-24 19:18:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-03-02 18:25:39 +00:00
|
|
|
|
|
2013-02-24 19:18:48 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Configuration
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ConfigCachingFixture : CoreTest<ConfigService>
|
|
|
|
|
{
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IConfigRepository>().Setup(c => c.All())
|
2013-03-24 10:09:32 +00:00
|
|
|
|
.Returns(new List<Config> { new Config { Key = "key1", Value = "Value1" } });
|
2013-02-24 19:18:48 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void getting_value_more_than_once_should_hit_db_once()
|
|
|
|
|
{
|
|
|
|
|
Subject.GetValue("Key1", null).Should().Be("Value1");
|
|
|
|
|
Subject.GetValue("Key1", null).Should().Be("Value1");
|
|
|
|
|
Subject.GetValue("Key1", null).Should().Be("Value1");
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IConfigRepository>().Verify(c => c.All(), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|