Browse Source

fix(exporter): fix unit tests

pull/1249/head
colin 1 year ago
parent
commit
e817431fe7
  1. 5
      aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf.LibreOffice/LINGYUN/Abp/Exporter/Pdf/LibreOffice/AbpExporterPdfLibreOfficeModule.cs
  2. 4
      aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf.LibreOffice/LINGYUN/Abp/Exporter/Pdf/LibreOffice/LibreOfficeTestEnvironment.cs
  3. 5
      aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf/LINGYUN/Abp/Exporter/Pdf/OriginalExcelToPdfProvider.cs

5
aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf.LibreOffice/LINGYUN/Abp/Exporter/Pdf/LibreOffice/AbpExporterPdfLibreOfficeModule.cs

@ -8,6 +8,11 @@ public class AbpExporterPdfLibreOfficeModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
// 解决单元测试问题
if (context.Services.IsAdded<LibreOfficeTestEnvironment>())
{
return;
}
if (!LibreOfficeCommands.IsLibreOffliceInstalled()) if (!LibreOfficeCommands.IsLibreOffliceInstalled())
{ {
throw new Volo.Abp.AbpInitializationException("Libreoffice not installed in the current operation environment of the host, please refer to the document after installation using ` AbpExporterPdfLibreOfficeModule ` module."); throw new Volo.Abp.AbpInitializationException("Libreoffice not installed in the current operation environment of the host, please refer to the document after installation using ` AbpExporterPdfLibreOfficeModule ` module.");

4
aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf.LibreOffice/LINGYUN/Abp/Exporter/Pdf/LibreOffice/LibreOfficeTestEnvironment.cs

@ -0,0 +1,4 @@
namespace LINGYUN.Abp.Exporter.Pdf.LibreOffice;
public class LibreOfficeTestEnvironment
{
}

5
aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf/LINGYUN/Abp/Exporter/Pdf/NullExcelToPdfProvider.cs → aspnet-core/framework/exporter/LINGYUN.Abp.Exporter.Pdf/LINGYUN/Abp/Exporter/Pdf/OriginalExcelToPdfProvider.cs

@ -6,11 +6,10 @@ using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Exporter.Pdf; namespace LINGYUN.Abp.Exporter.Pdf;
[Dependency(TryRegister = true)] [Dependency(TryRegister = true)]
public class NullExcelToPdfProvider : IExcelToPdfProvider, ISingletonDependency public class OriginalExcelToPdfProvider : IExcelToPdfProvider, ISingletonDependency
{ {
private readonly static Stream _nullStreamCache = Stream.Null;
public virtual Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default) public virtual Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default)
{ {
return Task.FromResult(_nullStreamCache); return Task.FromResult(excelStream);
} }
} }
Loading…
Cancel
Save