Добавлен тест на проверку типов клиента
Some checks failed
Unit tests / test (push) Failing after 2m10s
Some checks failed
Unit tests / test (push) Failing after 2m10s
This commit is contained in:
parent
5350febaba
commit
90ca38a741
@ -1,6 +1,6 @@
|
||||
{
|
||||
"DbConnection": {
|
||||
"Host": "postgres",
|
||||
"Host": "localhost",
|
||||
"Port": 5432,
|
||||
"Database": "persistence",
|
||||
"Username": "postgres",
|
||||
|
@ -12,4 +12,9 @@ internal class SetpointConfigStorage : ISetpointConfigStorage
|
||||
{
|
||||
return setpointTypeConfigs.TryGetValue(id, out type);
|
||||
}
|
||||
|
||||
public void AddOrReplace(Guid id, Type type)
|
||||
{
|
||||
setpointTypeConfigs[id] = type;
|
||||
}
|
||||
}
|
||||
|
@ -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<ISetpointClient>();
|
||||
|
||||
configStorage = (SetpointConfigStorage)scope.ServiceProvider.GetRequiredService<ISetpointConfigStorage>();
|
||||
}
|
||||
|
||||
|
||||
[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<JsonElement>(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);
|
||||
|
@ -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
|
||||
|
15
Directory.Build.props
Normal file
15
Directory.Build.props
Normal file
@ -0,0 +1,15 @@
|
||||
<Project>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>$(AssemblyName).Test</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>DD.Persistence.IntegrationTests</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||
<_Parameter1>DynamicProxyGenAssembly2</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user