30 lines
1014 B
C#
30 lines
1014 B
C#
using Heimdall.Application.Common;
|
|||
|
|
using Heimdall.Application.Settings.Queries.GetSettings;
|
||
|
|
using Heimdall.Application.Tests.Common;
|
||
|
|
using Heimdall.Domain.Entities;
|
||
|
|
using NSubstitute;
|
||
|
|
|
||
|
|
namespace Heimdall.Application.Tests.Handlers.Settings;
|
||
|
|
|
||
|
|
public class GetSettingsHandlerTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public async Task Get_settings_should_return_all_settings_ordered()
|
||
|
|
{
|
||
|
|
var settings = new List<AppSetting>
|
||
|
|
{
|
||
|
|
new("z.key", "z-value", "ZCategory"),
|
||
|
|
new("a.key", "a-value", "ACategory"),
|
||
|
|
new("b.key", "b-value", "ACategory"),
|
||
|
|
};
|
||
|
|
var context = Substitute.For<IApplicationDbContext>();
|
||
|
|
context.AppSettings.Returns(MockDbSetHelper.CreateFor<AppSetting>(settings));
|
||
|
|
var handler = new GetSettingsQueryHandler(context);
|
||
|
|
|
||
|
|
var result = await handler.Handle(new GetSettingsQuery(), CancellationToken.None);
|
||
|
|
|
||
|
|
result.IsSuccess.ShouldBeTrue();
|
||
|
|
result.Data.ShouldNotBeNull();
|
||
|
|
result.Data.Count.ShouldBe(3);
|
||
|
|
}
|
||
|
|
}
|