forked from ddrilling/AsbCloudServer
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
|
using AsbCloudApp.Data;
|
|||
|
using AsbCloudApp.Services;
|
|||
|
using AsbCloudDb.Model;
|
|||
|
using AsbCloudInfrastructure.Services;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Moq;
|
|||
|
using System.Threading;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Xunit;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace AsbCloudWebApi.Tests.ServicesTests
|
|||
|
{
|
|||
|
public class WellFinalDocumentsServiceTest
|
|||
|
{
|
|||
|
private readonly AsbCloudDbContext context;
|
|||
|
private WellFinalDocumentsService service;
|
|||
|
private readonly Mock<IFileService> fileServiceMock;
|
|||
|
private readonly Mock<IUserService> userServiceMock;
|
|||
|
private readonly Mock<IWellService> wellServiceMock;
|
|||
|
private readonly Mock<IConfiguration> configurationMock;
|
|||
|
private readonly Mock<IEmailService> emailServiceMock;
|
|||
|
|
|||
|
public WellFinalDocumentsServiceTest()
|
|||
|
{
|
|||
|
context = TestHelpter.MakeTestContext();
|
|||
|
context.SaveChanges();
|
|||
|
|
|||
|
fileServiceMock = new Mock<IFileService>();
|
|||
|
userServiceMock = new Mock<IUserService>();
|
|||
|
wellServiceMock = new Mock<IWellService>();
|
|||
|
configurationMock = new Mock<IConfiguration>();
|
|||
|
emailServiceMock = new Mock<IEmailService>();
|
|||
|
|
|||
|
service = new WellFinalDocumentsService(
|
|||
|
context: context,
|
|||
|
fileService: fileServiceMock.Object,
|
|||
|
userService: userServiceMock.Object,
|
|||
|
wellService: wellServiceMock.Object,
|
|||
|
configuration: configurationMock.Object,
|
|||
|
emailService: emailServiceMock.Object);
|
|||
|
}
|
|||
|
|
|||
|
~WellFinalDocumentsServiceTest()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public async Task GetWellFinalDocument_return_collection_rows()
|
|||
|
{
|
|||
|
var data = await service.GetByWellId(90, CancellationToken.None);
|
|||
|
Assert.NotEmpty(data);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public async Task GetListResponsibles_return_cnt_users()
|
|||
|
{
|
|||
|
var data = await service.GetListResponsiblesAsync(90, CancellationToken.None);
|
|||
|
Assert.Empty(data);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public async Task GetHistoryFileByIdCategory_return_data_hitory()
|
|||
|
{
|
|||
|
var data = await service.GetHistoryFileByIdCategory(90, 10018, CancellationToken.None);
|
|||
|
Assert.NotNull(data);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public async Task SaveCategoryFile_return_id_edit_record()
|
|||
|
{
|
|||
|
var stream = new FileStream("D:\\test\\test.txt", FileMode.Open);
|
|||
|
var data = await service.SaveCategoryFile(21, stream, "test.txt", CancellationToken.None);
|
|||
|
Assert.Equal(21, data);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|