} // PaymentSchemeResult public static void Test(string testName, PaymentSchemeResult paymentSchemeResult) { try { paymentSchemeResult.AddCoverSection(new PaymentCoverSection("COV1", 10.0)); paymentSchemeResult.AddCoverSection(new PaymentCoverSection("COV2", 20.0)); paymentSchemeResult.AddCoverSection(new PaymentCoverSection("COV3", 30.0)); paymentSchemeResult.AddCoverSection(new PaymentCoverSection("COV4", 90.0)); Console.WriteLine(); Console.WriteLine("Scheme {0} : Premium {1}", paymentSchemeResult.Code, paymentSchemeResult.TotalPremium.ToString("F2")); Console.WriteLine(); Console.WriteLine("Primary Cover Section {0} : Full Premium = {1}", paymentSchemeResult.PrimaryPaymentCoverSection.Code, paymentSchemeResult.PrimaryPaymentCoverSection.Premium); foreach (PaymentCoverSection coverSectionOriginal in paymentSchemeResult.AdditionalPaymentCoverSectionContainer) { Console.WriteLine(" Additional Cover Section {0} : Full Premium {1}", coverSectionOriginal.Code, coverSectionOriginal.Premium); } // New Business always has 11 equal payments paymentSchemeResult.Test(testName + " : New Business", true, 11); // Renewals always has 12 equal payments paymentSchemeResult.Test(testName + " : Renewal", false, 12); } catch (ArgumentException eek) { // A Duplicate Cover Section (Code) Exception Console.WriteLine(eek.Message); } catch (Exception eek) { // General Exception Console.WriteLine("Unexpected exception \"{0}\"", eek.Message); } }
static void Main(string[] args) { PaymentSchemeResult paymentSchemeResultWithPrimary = new PaymentSchemeResult("XYZ", new PaymentCoverSection("PRIMARY", 500.0)); Test("Normal Primary Cover Section", paymentSchemeResultWithPrimary); PaymentSchemeResult paymentSchemeResultWithZeroPrimary = new PaymentSchemeResult("TUV", new PaymentCoverSection("PRIMARY", 0.0)); Test("Zero Premium Primary Cover Section", paymentSchemeResultWithZeroPrimary); }