fix tests

This commit is contained in:
ngfrolov 2022-06-17 15:03:14 +05:00
parent 24026f8de8
commit 6d908478dd
4 changed files with 12 additions and 10 deletions

View File

@ -1,7 +1,7 @@
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Repository;
namespace AsbCloudWebApi.Tests.ServicesTests namespace AsbCloudWebApi.Tests.ServicesTests
{ {

View File

@ -6,6 +6,8 @@ using AsbCloudInfrastructure.Services.Cache;
using AsbCloudInfrastructure.Services.DetectOperations; using AsbCloudInfrastructure.Services.DetectOperations;
using Moq; using Moq;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
@ -119,7 +121,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
var timezone = new SimpleTimezoneDto { Hours = 5 }; var timezone = new SimpleTimezoneDto { Hours = 5 };
var wellServiceMock = new Mock<IWellService>(); var wellServiceMock = new Mock<IWellService>();
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone); wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
wellServiceMock.Setup(s => s.GetAsync(It.IsAny<int>(),CancellationToken.None)).Returns(Task.Run(() => wellDto)); wellServiceMock.Setup(s => s.GetOrDefaultAsync(It.IsAny<int>(),CancellationToken.None)).Returns(Task.Run(() => wellDto));
var operationValueService = new OperationValueService(context); var operationValueService = new OperationValueService(context);
var scheduleService = new ScheduleService(context, wellServiceMock.Object); var scheduleService = new ScheduleService(context, wellServiceMock.Object);

View File

@ -115,8 +115,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
public async Task GetDriller_by_workTime_shift1() public async Task GetDriller_by_workTime_shift1()
{ {
var dto = MakeScheduleDto(); var dto = MakeScheduleDto();
dto.ShiftStart = new TimeOnly(8, 00); dto.ShiftStart = new TimeDto(8, 00);
dto.ShiftEnd = new TimeOnly(20, 00); dto.ShiftEnd = new TimeDto(20, 00);
var id = await scheduleService.InsertAsync(dto, CancellationToken.None); var id = await scheduleService.InsertAsync(dto, CancellationToken.None);
var drillerWorkTime = new DateTime( var drillerWorkTime = new DateTime(
dto.DrillStart.Year, dto.DrillStart.Year,
@ -131,8 +131,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
public async Task GetDriller_by_workTime_shift2() public async Task GetDriller_by_workTime_shift2()
{ {
var dto = MakeScheduleDto(); var dto = MakeScheduleDto();
dto.ShiftStart = new TimeOnly(20, 00); dto.ShiftStart = new TimeDto(20, 00);
dto.ShiftEnd = new TimeOnly(8, 00); dto.ShiftEnd = new TimeDto(8, 00);
var id = await scheduleService.InsertAsync(dto, CancellationToken.None); var id = await scheduleService.InsertAsync(dto, CancellationToken.None);
var drillerWorkTime = new DateTime( var drillerWorkTime = new DateTime(
dto.DrillStart.Year, dto.DrillStart.Year,

View File

@ -119,7 +119,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
Permissions = new[] { new PermissionDto { Id = 2_000_001 } }, Permissions = new[] { new PermissionDto { Id = 2_000_001 } },
}; };
var id = await service.InsertAsync(newRole, CancellationToken.None); var id = await service.InsertAsync(newRole, CancellationToken.None);
var entity = await service.GetAsync(id); var entity = await service.GetOrDefaultAsync(id);
Assert.Equal(newRole.Permissions.Count(), entity.Permissions.Count()); Assert.Equal(newRole.Permissions.Count(), entity.Permissions.Count());
} }
@ -134,7 +134,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
Roles = new[] { new UserRoleDto { Id = 1_000_001 } } Roles = new[] { new UserRoleDto { Id = 1_000_001 } }
}; };
var id = await service.InsertAsync(newRole, CancellationToken.None); var id = await service.InsertAsync(newRole, CancellationToken.None);
var entity = await service.GetAsync(id); var entity = await service.GetOrDefaultAsync(id);
Assert.Equal(newRole.Roles.Count, entity.Roles.Count); Assert.Equal(newRole.Roles.Count, entity.Roles.Count);
} }
@ -164,7 +164,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
Permissions = new[] { new PermissionDto { Id = 2_000_001 } }, Permissions = new[] { new PermissionDto { Id = 2_000_001 } },
}; };
var id = await service.UpdateAsync(modRole, CancellationToken.None); var id = await service.UpdateAsync(modRole, CancellationToken.None);
var entity = await service.GetAsync(id); var entity = await service.GetOrDefaultAsync(id);
Assert.Equal(modRole.Permissions.Count(), entity.Permissions.Count()); Assert.Equal(modRole.Permissions.Count(), entity.Permissions.Count());
} }
@ -180,7 +180,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
Roles = new[] { new UserRoleDto { Id = 1_000_001 } } Roles = new[] { new UserRoleDto { Id = 1_000_001 } }
}; };
var id = await service.UpdateAsync(modRole, CancellationToken.None); var id = await service.UpdateAsync(modRole, CancellationToken.None);
var entity = await service.GetAsync(id); var entity = await service.GetOrDefaultAsync(id);
Assert.Equal(modRole.Roles.Count(), entity.Roles.Count()); Assert.Equal(modRole.Roles.Count(), entity.Roles.Count());
} }
} }