Use mapping-style instead of array-style for instances in configuration YAML.pull/151/head
parent
4ae54d8f54
commit
1d604b141b
@ -0,0 +1,50 @@
|
|||||||
|
using Autofac;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NSubstitute;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Recyclarr.Command.Helpers;
|
||||||
|
using Recyclarr.TestLibrary;
|
||||||
|
using TrashLib.Config.Services;
|
||||||
|
|
||||||
|
namespace Recyclarr.Tests.Command.Helpers;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
[Parallelizable(ParallelScope.All)]
|
||||||
|
public class CacheStoragePathTest : IntegrationFixture
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Use_guid_when_empty_name()
|
||||||
|
{
|
||||||
|
var config = Substitute.ForPartsOf<ServiceConfiguration>();
|
||||||
|
config.BaseUrl = "something";
|
||||||
|
config.Name = "";
|
||||||
|
|
||||||
|
using var scope = Container.BeginLifetimeScope(builder =>
|
||||||
|
{
|
||||||
|
builder.RegisterInstance(config).AsImplementedInterfaces();
|
||||||
|
});
|
||||||
|
|
||||||
|
var sut = scope.Resolve<CacheStoragePath>();
|
||||||
|
var result = sut.CalculatePath("obj");
|
||||||
|
|
||||||
|
result.FullName.Should().MatchRegex(@".*[/\\][a-f0-9]+[/\\]obj\.json$");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Use_name_when_not_empty()
|
||||||
|
{
|
||||||
|
var config = Substitute.ForPartsOf<ServiceConfiguration>();
|
||||||
|
config.BaseUrl = "something";
|
||||||
|
config.Name = "thename";
|
||||||
|
|
||||||
|
using var scope = Container.BeginLifetimeScope(builder =>
|
||||||
|
{
|
||||||
|
builder.RegisterInstance(config).AsImplementedInterfaces();
|
||||||
|
});
|
||||||
|
|
||||||
|
var sut = scope.Resolve<CacheStoragePath>();
|
||||||
|
var result = sut.CalculatePath("obj");
|
||||||
|
|
||||||
|
result.FullName.Should().MatchRegex(@".*[/\\]thename[/\\]obj\.json$");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
using TrashLib.Config.Services;
|
||||||
|
|
||||||
|
namespace TrashLib.TestLibrary;
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class TestConfig : ServiceConfiguration
|
||||||
|
{
|
||||||
|
public TestConfig()
|
||||||
|
{
|
||||||
|
Name = "Test";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue