From b1051546b735ea1218a53bb44494480a4423ecfc Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 29 Jan 2025 07:57:04 +0100 Subject: [PATCH] Fixed test comments --- ENI2/Excel/DakosyUtil.cs | 8 ++++---- ENI2/Excel/ExcelUtil.cs | 12 ++++++------ bsmd.database/IBCPosition.cs | 4 ++++ bsmd.database/IGCPosition.cs | 3 +++ bsmd.database/IMDGPosition.cs | 2 +- bsmd.database/IMSBCPosition.cs | 5 ++++- bsmd.database/MARPOL_Annex_I_Position.cs | 3 +++ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ENI2/Excel/DakosyUtil.cs b/ENI2/Excel/DakosyUtil.cs index f16927b6..fcf3b470 100644 --- a/ENI2/Excel/DakosyUtil.cs +++ b/ENI2/Excel/DakosyUtil.cs @@ -740,7 +740,7 @@ namespace ENI2.Excel pas.PassengerLastName = lastName; pas.PassengerFirstName = reader.ReadCellAsText("passenger departure", string.Format("C{0}", i + 16)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger departure", string.Format("D{0}", i + 16)); - pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16)), out bool canceled); + pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16)), out bool canceled, false); if (canceled) return false; pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger departure", string.Format("F{0}", i + 16)); pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger departure", string.Format("G{0}", i + 16))); @@ -802,7 +802,7 @@ namespace ENI2.Excel pas.PassengerLastName = lastName; pas.PassengerFirstName = reader.ReadCellAsText("passenger arrival", string.Format("C{0}", i + 16)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger arrival", string.Format("D{0}", i + 16)); - pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16)), out bool canceled); + pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16)), out bool canceled, false); if (canceled) return false; pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger arrival", string.Format("F{0}", i + 16)); pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger arrival", string.Format("G{0}", i + 16))); @@ -1207,7 +1207,7 @@ namespace ENI2.Excel crew.CrewMemberLastName = lastName; crew.CrewMemberFirstName = reader.ReadCellAsText("crew departure", string.Format("C{0}", i + 15)); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew departure", string.Format("D{0}", i + 15)); - crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15)), out bool canceled); + crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15)), out bool canceled, false); if (canceled) return false; crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew departure", string.Format("F{0}", i + 15)); string gender = reader.ReadCellAsText("crew departure", string.Format("G{0}", i + 15)); @@ -1257,7 +1257,7 @@ namespace ENI2.Excel crew.CrewMemberLastName = lastName; crew.CrewMemberFirstName = reader.ReadCellAsText("crew arrival", string.Format("C{0}", i + 15)); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew arrival", string.Format("D{0}", i + 15)); - crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15)), out bool canceled); + crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15)), out bool canceled, false); if (canceled) return false; crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew arrival", string.Format("F{0}", i + 15)); string gender = reader.ReadCellAsText("crew arrival", string.Format("G{0}", i + 15)); diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index 9e6f9791..ab7ea69b 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -2133,7 +2133,7 @@ namespace ENI2.Excel crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled); if (canceled) return true; crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100); - crew.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _); + crew.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _, false); crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18)); @@ -2252,7 +2252,7 @@ namespace ENI2.Excel crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled); if (canceled) return true; crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100); - crewd.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _); + crewd.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _, false); crewd.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18)); crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out canceled); @@ -2374,7 +2374,7 @@ namespace ENI2.Excel pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 17)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 17), 100); - pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)), out _); + pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)), out _, false); if (canceled) return true; DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17)); @@ -2515,7 +2515,7 @@ namespace ENI2.Excel pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 18)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 18), 100); - pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out _); + pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out _, false); if (canceled) return true; DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 18)); @@ -2848,12 +2848,12 @@ namespace ENI2.Excel return result; } - public static string ReadNationality(string nationality, out bool canceled) + public static string ReadNationality(string nationality, out bool canceled, bool setPlaceHolder = true) { string result = null; canceled = false; nationality = nationality.Trim(); - if (nationality.IsNullOrEmpty()) + if (nationality.IsNullOrEmpty() && setPlaceHolder) { result = "XX"; } diff --git a/bsmd.database/IBCPosition.cs b/bsmd.database/IBCPosition.cs index 9880923d..ebbb2bcf 100644 --- a/bsmd.database/IBCPosition.cs +++ b/bsmd.database/IBCPosition.cs @@ -266,6 +266,10 @@ namespace bsmd.database public override void Validate(List errors, List violations) { + + if(this.Quantity_KGM >= 1000000000) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value == 2) && this.Flashpoint_CEL.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); diff --git a/bsmd.database/IGCPosition.cs b/bsmd.database/IGCPosition.cs index 23fa5a6e..b8a9d3ed 100644 --- a/bsmd.database/IGCPosition.cs +++ b/bsmd.database/IGCPosition.cs @@ -201,6 +201,9 @@ namespace bsmd.database public override void Validate(List errors, List violations) { + if(this.Quantity_KGM >= 1000000000) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + if (!this.UNNumber.IsNullOrEmpty() && !unNumberRegex.IsMatch(this.UNNumber)) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "UNNumber", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); diff --git a/bsmd.database/IMDGPosition.cs b/bsmd.database/IMDGPosition.cs index 4cd7f97b..7be07593 100644 --- a/bsmd.database/IMDGPosition.cs +++ b/bsmd.database/IMDGPosition.cs @@ -499,7 +499,7 @@ namespace bsmd.database if((this.NetQuantity_KGM >= 1000000000) || (this.GrossQuantity_KGM >= 1000000000) || (this.Volume_MTQ >= 1000000000)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V809, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList) diff --git a/bsmd.database/IMSBCPosition.cs b/bsmd.database/IMSBCPosition.cs index 7af88032..c171e455 100644 --- a/bsmd.database/IMSBCPosition.cs +++ b/bsmd.database/IMSBCPosition.cs @@ -235,7 +235,10 @@ namespace bsmd.database public override void Validate(List errors, List violations) { - if(!MHB ?? false) + if(this.Quantity_KGM >= 1000000000) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + + if (!MHB ?? false) { if(this.UNNumber.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V803, "UNNumber", this.UNNumber, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); diff --git a/bsmd.database/MARPOL_Annex_I_Position.cs b/bsmd.database/MARPOL_Annex_I_Position.cs index 352af5b6..7ef69943 100644 --- a/bsmd.database/MARPOL_Annex_I_Position.cs +++ b/bsmd.database/MARPOL_Annex_I_Position.cs @@ -188,6 +188,9 @@ namespace bsmd.database public override void Validate(List errors, List violations) { + if (this.Quantity_KGM >= 1000000000) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value == 2) && this.Flashpoint_CEL.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier,