using System.Data; using Centron.BusinessLogic; using Centron.BusinessLogic.ReportEngine; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.ReportVariables; public class ReportVariablesTest : CentronTest { public ReportVariablesTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } [Fact] public void Execute() { var parameterTable = new DataTable(); parameterTable.Columns.Add("Kurz"); parameterTable.Columns.Add("Wert"); parameterTable.Rows.Add("@Anlageart", "Rechnung"); parameterTable.Rows.Add("@AnlageI3D", "123"); // Should replace variables ignoring the casing this.Test("@Anlageart @AnlageI3D", parameterTable, "Rechnung 123"); this.Test("@anlageart @anlagei3d", parameterTable, "Rechnung 123"); this.Test("@anlageArt @anlageI3D", parameterTable, "Rechnung 123"); this.Test("@AnLaGeArT @aNlAgEi3D", parameterTable, "Rechnung 123"); // Should not replace the variable, if it's part of a word this.Test("@AnlageartBla", parameterTable, "@AnlageartBla"); this.Test("@AnlageartA", parameterTable, "@AnlageartA"); this.Test("@Anlageart_Test", parameterTable, "@Anlageart_Test"); this.Test("@Anlagearten", parameterTable, "@Anlagearten"); // But these should still get replaced this.Test("(@Anlageart)", parameterTable, "(Rechnung)"); this.Test("@Anlageart-12", parameterTable, "Rechnung-12"); this.Test("@Anlageart.Jetzt", parameterTable, "Rechnung.Jetzt"); } private void Test(string input, DataTable table, string expected) { var result = ReportDataBL.ReplaceLocalVariables(input, table); Assert.Equal(expected, result); } }