public void TestPostGLBatchesArgumentValidation() { TVerificationResultCollection VerificationResult = null; List <Int32> BatchNumbers = new List <int>(); string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatches(-1, BatchNumbers, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Ledger number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch without any batch numbers."; // Post a GL Batch without any batch numbers try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); if ((!VerificationResult.HasCriticalOrNonCriticalErrors) || (!VerificationResult.BuildVerificationResultString().Contains("No GL Batches to post"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; BatchNumbers.Add(-1); // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Batch number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } }
public void TestPostGLBatchesArgumentValidation() { TVerificationResultCollection VerificationResult = null; List <Int32> BatchNumbers = new List <int>(); string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatches(-1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch without any batch numbers."; // Post a GL Batch without any batch numbers try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (ArgumentException e) { Assert.AreEqual("Function:Post GL Batches - The list of GL Batch numbers to post is empty!", e.Message, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; BatchNumbers.Add(-1); // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(1, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } }