You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.4 KiB
C#

using System.IO;
using System.Reflection;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NPOI.HPSF;
using Org.BouncyCastle.Ocsp;
using SharpCompress.Common;
using SqlSugar;
using SqlSugar.IOC;
using Xunit;
namespace Ds.WMS.Test;
public class OpTest
{
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
private readonly ISaasDbService saasService;
private readonly IClientCommonService _formSetService;
private readonly IOpCommonService _commonSetService;
//private readonly ICommonService _commonService;
public OpTest(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
_formSetService = _serviceProvider.GetRequiredService<IClientCommonService>();
_commonSetService = _serviceProvider.GetRequiredService<IOpCommonService>();
//_commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
[Fact]
public async void OpTest1()
{
//var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
var data = await _formSetService.GetFormSetCreateInfoAsync("1750335377144680448");
Assert.True(true);
}
/// <summary>
/// ×⻧Óû§ÊÚȨÊý
/// </summary>
[Fact]
public void OpTest2()
{
//var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
//var data = _commonSetService.GetSequenceNext<SeaExport>();
var str = EncrypteHelper.EncryptData("300", "ba31a8758af1c6b7");
Assert.True(true);
}
[Fact]
public void FileRead()
{
//var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
//var data = _commonSetService.GetSequenceNext<SeaExport>();
var path = "D:\\Code\\DS\\ds8-solution\\ds-wms-service\\DS.WMS.MainApi\\wwwroot\\LinkAttach\\1800846562843299840.txt";
//var temp = new FileStream("D:\\Code\\DS\\ds8-solution\\ds-wms-service\\DS.WMS.MainApi\\wwwroot\\LinkAttach\\1800846562843299840.txt", FileMode.Open);
try
{
var temp1 = File.ReadAllBytes(path);
var stream = new MemoryStream(temp1);
//using (var stream1= System.IO.File.Create(path))
//{
// await file.CopyToAsync(stream);
//}
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
{
// ½«×Ö·û´®×ª»»Îª×Ö½ÚÊý×é
byte[] data = System.Text.Encoding.UTF8.GetBytes("ÕâÀïÊÇÄÚÈÝ11232");
// дÈëÊý¾Ýµ½Îļþ
fs.Write(data, 0, data.Length);
}
//var result = new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = "1800846562843299840.txt" };
}
catch (Exception ex)
{
// ¼Ç¼»ò´¦ÀíÒì³£
Console.WriteLine(ex.Message);
throw;
}
Assert.True(true);
}
}