using Centron.BusinessLogic;
using Centron.BusinessLogic.WebServices.ReportEngine;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using FastReport.Export.Pdf;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.ReportEngine
{
///
/// End-to-end tests for PDF export settings API.
/// Validates both standard and PDF-A/3 export profiles with their properties.
///
public class PdfExportSettingsTests : EndToEndTest
{
///
/// Initializes a new instance of the class.
///
/// The test output helper.
public PdfExportSettingsTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
// Uncomment to update expected files during test development
// Verifier.OverrideExpectedFiles = true;
}
///
/// The main test execution entry point.
///
public override void Execute()
{
using (var session = new BLSession())
{
// Test the PDF export settings API
TestGetAndSavePdfExportSettings(session);
}
}
///
/// Tests getting and saving PDF export settings through the WebServiceBL.
///
/// The BLSession instance.
private void TestGetAndSavePdfExportSettings(BLSession session)
{
// Get the initial settings
var webServiceBL = session.GetBL();
var initialSettings = webServiceBL.GetPdfExportSettings();
// Verify the result is successful
Assert.True(initialSettings.Status == ResultStatus.Success);
Assert.NotNull(initialSettings.Data);
// Verify the initial settings values
Verifier.Verify("PdfExportSettings_Initial", initialSettings.Data);
// Modify settings with test values
var modifiedSettings = initialSettings.Data;
// Standard profile settings
modifiedSettings.StandardEmbeddingFonts = !modifiedSettings.StandardEmbeddingFonts;
modifiedSettings.StandardCompliance = (int)PDFExport.PdfStandard.PdfA_3b;
modifiedSettings.StandardColorSpace = (int)PDFExport.PdfColorSpace.CMYK;
modifiedSettings.StandardJpegCompression = !modifiedSettings.StandardJpegCompression;
modifiedSettings.StandardCompression = !modifiedSettings.StandardCompression;
modifiedSettings.StandardTransparentImages = !modifiedSettings.StandardTransparentImages;
modifiedSettings.StandardPrintOptimized = !modifiedSettings.StandardPrintOptimized;
// PDF-A/3 profile settings - these should be modified but preserved when applied
modifiedSettings.PdfA3JpegCompression = !modifiedSettings.PdfA3JpegCompression;
modifiedSettings.PdfA3Compression = !modifiedSettings.PdfA3Compression;
modifiedSettings.PdfA3TransparentImages = !modifiedSettings.PdfA3TransparentImages;
modifiedSettings.PdfA3PrintOptimized = !modifiedSettings.PdfA3PrintOptimized;
modifiedSettings.PdfA3ColorSpace = (int)PDFExport.PdfColorSpace.CMYK;
// Save the modified settings
var saveResult = webServiceBL.SavePdfExportSettings(modifiedSettings);
// Verify the save was successful
Assert.True(saveResult.Status == ResultStatus.Success);
// Retrieve the settings again to verify they were saved correctly
var retrievedSettings = webServiceBL.GetPdfExportSettings();
// Verify the settings were updated correctly
Verifier.Verify("PdfExportSettings_Modified", retrievedSettings);
// Restore the original settings
webServiceBL.SavePdfExportSettings(initialSettings.Data);
}
}
}