diff --git a/GpioController/Models/FilterSettings.cs b/GpioController/Models/FilterSettings.cs index e5e44d2..ab12427 100644 --- a/GpioController/Models/FilterSettings.cs +++ b/GpioController/Models/FilterSettings.cs @@ -2,6 +2,12 @@ namespace GpioController.Models; public class FilterSettings { - public required List AllowOnlyTheseChipsets { get; set; } - public required List AllowOnlyTheseGpios { get; set; } + public FilterSettings() + { + AllowOnlyTheseChipsets = new(); + AllowOnlyTheseGpios = new(); + } + + public List AllowOnlyTheseChipsets { get; set; } + public List AllowOnlyTheseGpios { get; set; } } \ No newline at end of file diff --git a/GpioController/appsettings.json b/GpioController/appsettings.json index 67ed923..e66372b 100644 --- a/GpioController/appsettings.json +++ b/GpioController/appsettings.json @@ -7,7 +7,7 @@ } }, "Authorization": { - "Enabled": true, + "Enabled": false, "AuthorizedEmails": [ "yourEmail@gmail.com" ], diff --git a/GpioControllerTests/Services/GpioServiceTests.cs b/GpioControllerTests/Services/GpioServiceTests.cs index 8e2d124..f67fcd2 100644 --- a/GpioControllerTests/Services/GpioServiceTests.cs +++ b/GpioControllerTests/Services/GpioServiceTests.cs @@ -73,7 +73,7 @@ public void GetGpios_ShouldReturnResult_WhenFactoryAdCommandFound() } [Fact] - public void OrderResultsByFilter_ShouldSortResults_WhenFilterIsPresent() + public void OrderResultsByFilter_WhenFilterIsPresent_ShouldSortResults() { var sut = GetSystemUnderTest(); @@ -111,4 +111,44 @@ public void OrderResultsByFilter_ShouldSortResults_WhenFilterIsPresent() result[1].Id.Should().Be(95); result[2].Id.Should().Be(80); } + + [Fact] + public void OrderResultsByFilter_WhenNoFilterIsPresent_ShouldStillReturnOriginalResults() + { + var sut = GetSystemUnderTest(); + + A.CallTo(() => filterSettings.Value).Returns(new FilterSettings + { + AllowOnlyTheseChipsets = [], + AllowOnlyTheseGpios = [] + }); + + var data = new List + { + new() + { + Chipset = 1, + Id = 95, + Name = "Gpio 95" + }, + new() + { + Chipset = 1, + Id = 80, + Name = "Gpio 80" + }, + new() + { + Chipset = 1, + Id = 81, + Name = "Gpio 81" + } + }; + + var result = sut.OrderResultsByFilter(data).ToArray(); + + result[0].Id.Should().Be(95); + result[1].Id.Should().Be(80); + result[2].Id.Should().Be(81); + } } \ No newline at end of file