This commit is contained in:
parent
c9405bf64a
commit
21664d1e16
@ -1,23 +1,17 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using DD.Persistence.Client;
|
using DD.Persistence.Client;
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
using System.Net;
|
|
||||||
using Xunit;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Client.Clients;
|
using DD.Persistence.Client.Clients;
|
||||||
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
|
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers
|
namespace DD.Persistence.IntegrationTests.Controllers
|
||||||
{
|
{
|
||||||
public class SetpointControllerTest : BaseIntegrationTest
|
public class SetpointControllerTest : BaseIntegrationTest
|
||||||
{
|
{
|
||||||
private readonly ISetpointClient setpointClient;
|
private readonly ISetpointClient setpointClient;
|
||||||
private class TestObject
|
|
||||||
{
|
|
||||||
public string? Value1 { get; set; }
|
|
||||||
public int? Value2 { get; set; }
|
|
||||||
}
|
|
||||||
public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var refitClientFactory = scope.ServiceProvider
|
||||||
@ -153,7 +147,7 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
|
|
||||||
await Add();
|
await Add();
|
||||||
|
|
||||||
var dateBegin = DateTimeOffset.MinValue;
|
var dateBegin = DateTimeOffset.UtcNow.AddDays(-1);
|
||||||
var take = 1;
|
var take = 1;
|
||||||
var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
@ -164,14 +158,17 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
|
|
||||||
var expectedValue = part!
|
var expectedValue = part!
|
||||||
.FirstOrDefault()!.Created
|
.FirstOrDefault()!.Timestamp
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToUniversalTime()
|
||||||
|
.ToString();
|
||||||
var actualValueFrom = response.From
|
var actualValueFrom = response.From
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToUniversalTime()
|
||||||
|
.ToString();
|
||||||
Assert.Equal(expectedValue, actualValueFrom);
|
Assert.Equal(expectedValue, actualValueFrom);
|
||||||
|
|
||||||
var actualValueTo = response.To
|
var actualValueTo = response.To
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToUniversalTime()
|
||||||
|
.ToString();
|
||||||
Assert.Equal(expectedValue, actualValueTo);
|
Assert.Equal(expectedValue, actualValueTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +213,7 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var setpointKey = Guid.NewGuid();
|
var setpointKey = Guid.NewGuid();
|
||||||
var setpointValue = new TestObject()
|
var setpointValue = new
|
||||||
{
|
{
|
||||||
Value1 = "1",
|
Value1 = "1",
|
||||||
Value2 = 2
|
Value2 = 2
|
||||||
|
@ -8,7 +8,7 @@ public class SetpointLogDto : SetpointValueDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата сохранения уставки
|
/// Дата сохранения уставки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset Created { get; set; }
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ключ пользователя
|
/// Ключ пользователя
|
||||||
|
@ -96,7 +96,7 @@ namespace DD.Persistence.Repository.Repositories
|
|||||||
Key = setpointKey,
|
Key = setpointKey,
|
||||||
Value = newValue,
|
Value = newValue,
|
||||||
IdUser = idUser,
|
IdUser = idUser,
|
||||||
Timestamp = DateTimeOffset.UtcNow
|
Timestamp = DateTimeOffset.UtcNow.ToUniversalTime()
|
||||||
};
|
};
|
||||||
|
|
||||||
await db.Set<Setpoint>().AddAsync(entity, token);
|
await db.Set<Setpoint>().AddAsync(entity, token);
|
||||||
|
Loading…
Reference in New Issue
Block a user