diff --git a/DD.Persistence.App/appsettings.Tests.json b/DD.Persistence.App/appsettings.Tests.json index 72c43d3..9934757 100644 --- a/DD.Persistence.App/appsettings.Tests.json +++ b/DD.Persistence.App/appsettings.Tests.json @@ -1,6 +1,6 @@ { "DbConnection": { - "Host": "postgres", + "Host": "localhost", "Port": 5432, "Database": "persistence", "Username": "postgres", diff --git a/DD.Persistence.Client/SetpointConfigStorage.cs b/DD.Persistence.Client/SetpointConfigStorage.cs index a0b3a17..5cfbabf 100644 --- a/DD.Persistence.Client/SetpointConfigStorage.cs +++ b/DD.Persistence.Client/SetpointConfigStorage.cs @@ -12,4 +12,9 @@ internal class SetpointConfigStorage : ISetpointConfigStorage { return setpointTypeConfigs.TryGetValue(id, out type); } + + public void AddOrReplace(Guid id, Type type) + { + setpointTypeConfigs[id] = type; + } } diff --git a/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs index 27432f3..c27f6cc 100644 --- a/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs @@ -7,12 +7,15 @@ using Xunit; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Client.Clients; using Microsoft.Extensions.Logging; +using System.Text.Json; namespace DD.Persistence.IntegrationTests.Controllers { public class SetpointControllerTest : BaseIntegrationTest { private readonly ISetpointClient setpointClient; + private readonly SetpointConfigStorage configStorage; + private class TestObject { public string? Value1 { get; set; } @@ -26,8 +29,36 @@ namespace DD.Persistence.IntegrationTests.Controllers setpointClient = scope.ServiceProvider .GetRequiredService(); + + configStorage = (SetpointConfigStorage)scope.ServiceProvider.GetRequiredService(); } + + [Fact] + public async Task GetCurrent_returns_correctType() + { + var id = Guid.Parse("e0fcad22-1761-476e-a729-a3c59d51ba41"); + + configStorage.AddOrReplace(id, typeof(float)); + + await setpointClient.Add(id, 48.3f, CancellationToken.None); + + //act + var response = await setpointClient.GetCurrent([id], CancellationToken.None); + + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + Assert.Single(response); + var item = response.First(); + Assert.Equal(item.Key, id); + + Assert.IsNotType(item.Value); + Assert.Equal(item.Value, 48.3f); + } + + + [Fact] public async Task GetCurrent_returns_success() { @@ -39,7 +70,7 @@ namespace DD.Persistence.IntegrationTests.Controllers }; //act - var response = await setpointClient.GetCurrent(setpointKeys, new CancellationToken()); + var response = await setpointClient.GetCurrent(setpointKeys, CancellationToken.None); //assert Assert.NotNull(response); diff --git a/DD.Persistence.sln b/DD.Persistence.sln index 22c99b2..eeb198c 100644 --- a/DD.Persistence.sln +++ b/DD.Persistence.sln @@ -23,6 +23,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DD.Persistence.Models", "DD EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DD.Persistence.Repository.Test", "DD.Persistence.Repository.Test\DD.Persistence.Repository.Test.csproj", "{08B03623-A1C9-482F-B60E-09F293E04999}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{36D591C7-65C7-A0D1-1CBC-10CDE441BDC8}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..cffb4fe --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,15 @@ + + + + + + <_Parameter1>$(AssemblyName).Test + + + <_Parameter1>DD.Persistence.IntegrationTests + + + <_Parameter1>DynamicProxyGenAssembly2 + + + \ No newline at end of file