using Centron.BusinessLogic.Administration.Settings; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket136334; public class Ticket136334Test : EndToEndTest { public Ticket136334Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { // In this ticket the problem was, that some RMA-warehouse-settings were set to NULL // the view cvw_ArticleSearch did not handle this case well, and didn't return any own articles anymore this.CheckArticles("1_Before"); // This is where the problem was, the articles were not there anymore this.UpdateRmaWarehouseSettings(null, 0, 0, 0); this.CheckArticles("2_TestCase1"); this.UpdateRmaWarehouseSettings(0, null, 0, 0); this.CheckArticles("2_TestCase2"); this.UpdateRmaWarehouseSettings(0, 0, null, 0); this.CheckArticles("2_TestCase3"); this.UpdateRmaWarehouseSettings(0, 0, 0, null); this.CheckArticles("2_TestCase4"); // And now everything should work again this.UpdateRmaWarehouseSettings(0, 0, 0, 0); this.CheckArticles("3_SameAsBefore"); } private void CheckArticles(string name) { this.Verifier.VerifySql(name, $"SELECT COUNT(*) FROM dbo.cvw_ArticleSearch WHERE IsExternalArticle = 0"); } private void UpdateRmaWarehouseSettings(int? setting1Value, int? setting2Value, int? setting3Value, int? setting4Value) { this.Sql($"UPDATE dbo.Stammdat SET Wert = {SettingToString(setting1Value)} WHERE I3D = {(int)AppSettingsConst.RMACustomerStorage}"); this.Sql($"UPDATE dbo.Stammdat SET Wert = {SettingToString(setting2Value)} WHERE I3D = {(int)AppSettingsConst.RMAOwnStorage}"); this.Sql($"UPDATE dbo.Stammdat SET Wert = {SettingToString(setting3Value)} WHERE I3D = {(int)AppSettingsConst.RMASendStorage}"); this.Sql($"UPDATE dbo.Stammdat SET Wert = {SettingToString(setting4Value)} WHERE I3D = {(int)AppSettingsConst.RMAOrderStorage}"); static string SettingToString(int? settingValue) { return settingValue is null ? "NULL" : settingValue.Value.ToString(); } } }