public void TestBatchLoadingRecalculations() { TVerificationResultCollection VerificationResult; Int64 RecipientKey; Int64 RealRecipientLedgerNumber; Int64 FalseRecipientLedgerNumber; const string REALCOSTCENTRECODE = "4300"; const string FALSECOSTCENTRECODE = "3500"; Int32 GiftBatchNumber; // // Arrange: Create all data needed for this test (Gift Detail has a 'fake' RecipientLedgerNumber and CostCentreCode) // TestBatchPostingRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber, out FalseRecipientLedgerNumber, REALCOSTCENTRECODE, FALSECOSTCENTRECODE, out GiftBatchNumber); // // Act: Load the batch // GiftBatchTDS GiftBatchDS = TGiftTransactionWebConnector.LoadAGiftBatchAndRelatedData(FLedgerNumber, GiftBatchNumber); // // Assert // // Initial Assert: Tests that the load returns results Assert.IsNotNull(GiftBatchDS, "TestBatchLoadingRecalculations fail: Loading GiftBatch failed"); Assert.IsNotNull(GiftBatchDS.AGiftDetail, "TestBatchLoadingRecalculations fail: Loading GiftBatch failed"); // Primary Assert: Chaeck that the gift has the correct RecipientLedgerNumber and CostCentreCode TDBTransaction Transaction = null; AGiftDetailRow PositiveGiftDetailRow = null; AGiftDetailRow NegativeGiftDetailRow = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { PositiveGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0]; NegativeGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 2, 1, Transaction)[0]; }); Assert.IsNotNull(PositiveGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining PositiveGiftDetailRow from database failed"); Assert.IsNotNull(NegativeGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining NegativeGiftDetailRow from database failed"); Assert.AreEqual(RealRecipientLedgerNumber, PositiveGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FalseRecipientLedgerNumber, NegativeGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for NegativeGiftDetailRow is incorrect"); Assert.AreEqual(REALCOSTCENTRECODE, PositiveGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FALSECOSTCENTRECODE, NegativeGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for NegativeGiftDetailRow is incorrect"); // Cleanup: Delete test records bool SubmissionOK = true; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, PositiveGiftDetailRow, Transaction); AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, NegativeGiftDetailRow, Transaction); }); TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult); TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult); TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult); }
public void TestRecurringBatchSubmitRecalculations() { TVerificationResultCollection VerificationResult; Int64 RecipientKey; Int64 RealRecipientLedgerNumber; Int64 FalseRecipientLedgerNumber; Int32 RecurringGiftBatchNumber; Int32 GiftBatchNumber = -1; // // Arrange: Create all data needed for this test (Recurring Gift Detail will have 'fake' RecipientLedgerNumber) // TestRecurringBatchSubmitRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber, out FalseRecipientLedgerNumber, out RecurringGiftBatchNumber); // // Act: Submit the batch // Hashtable requestParams = new Hashtable(); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("ABatchNumber", RecurringGiftBatchNumber); requestParams.Add("AEffectiveDate", DateTime.Today); requestParams.Add("AExchangeRateToBase", (decimal)1); requestParams.Add("AExchangeRateIntlToBase", (decimal)1); TGiftTransactionWebConnector.SubmitRecurringGiftBatch(requestParams); // // Assert // // Primary Assert: Chaeck that the RecurringGiftDetail and the newly created GiftDetail have the correct RecipientLedgerNumber TDBTransaction Transaction = null; ARecurringGiftDetailRow RecurringGiftDetailRow = null; AGiftDetailRow GiftDetailRow = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { RecurringGiftDetailRow = ARecurringGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, RecurringGiftBatchNumber, 1, 1, Transaction)[0]; GiftBatchNumber = ALedgerAccess.LoadByPrimaryKey(FLedgerNumber, Transaction)[0].LastGiftBatchNumber; GiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0]; }); Assert.IsNotNull( RecurringGiftDetailRow, "TestRecurringBatchSubmitRecalculations fail: Obtaining RecurringGiftDetailRow from database failed"); Assert.IsNotNull( GiftDetailRow, "TestRecurringBatchSubmitRecalculations fail: Obtaining GiftDetailRow from database failed"); Assert.AreEqual(RealRecipientLedgerNumber, RecurringGiftDetailRow.RecipientLedgerNumber, "TestRecurringBatchSubmitRecalculations fail: RecipientLedgerNumber for RecurringGiftDetailRow is incorrect"); Assert.AreEqual(RealRecipientLedgerNumber, GiftDetailRow.RecipientLedgerNumber, "TestRecurringBatchSubmitRecalculations fail: RecipientLedgerNumber for GiftDetailRow is incorrect"); // Cleanup: Delete test records bool SubmissionOK = true; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, GiftDetailRow, Transaction); ARecurringGiftDetailAccess.DeleteRow(ARecurringGiftDetailTable.TableId, RecurringGiftDetailRow, Transaction); }); TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult); TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult); TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult); }
public void TestBatchPostingRecalculations() { TVerificationResultCollection VerificationResult; Int64 RecipientKey; Int64 RealRecipientLedgerNumber; Int64 FalseRecipientLedgerNumber; const string REALCOSTCENTRECODE = "4300"; const string FALSECOSTCENTRECODE = "3500"; const string ACCOUNTCODE = "0100"; Int32 GiftBatchNumber; // // Arrange: Create all data needed for this test (Gift Details have 'fake' RecipientLedgerNumber and CostCentreCode) // TestBatchPostingRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber, out FalseRecipientLedgerNumber, REALCOSTCENTRECODE, FALSECOSTCENTRECODE, out GiftBatchNumber); // // Act: Post the batch // bool result = TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, GiftBatchNumber, out VerificationResult); // // Assert // // Initial Assert: Tests that the post returns positive Assert.AreEqual(true, result, "TestBatchPostingRecalculations fail: Posting GiftBatch failed: " + VerificationResult.BuildVerificationResultString()); // Primary Assert: Chaeck that the gifts have the correct RecipientLedgerNumber, CostCentreCode and Account TDBTransaction Transaction = null; AGiftDetailRow PositiveGiftDetailRow = null; AGiftDetailRow NegativeGiftDetailRow = null; ATransactionRow TransactionRow = null; Int32 GLBatchNumber = -1; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { PositiveGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0]; NegativeGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 2, 1, Transaction)[0]; GLBatchNumber = ALedgerAccess.LoadByPrimaryKey(FLedgerNumber, Transaction)[0].LastBatchNumber; TransactionRow = ATransactionAccess.LoadByPrimaryKey(FLedgerNumber, GLBatchNumber, 1, 1, Transaction)[0]; }); Assert.IsNotNull(PositiveGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining PositiveGiftDetailRow from database failed"); Assert.IsNotNull(NegativeGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining NegativeGiftDetailRow from database failed"); Assert.IsNotNull(TransactionRow, "TestBatchPostingRecalculations fail: Obtaining Transaction from database failed"); Assert.AreEqual(RealRecipientLedgerNumber, PositiveGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FalseRecipientLedgerNumber, NegativeGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for NegativeGiftDetailRow is incorrect"); Assert.AreEqual(REALCOSTCENTRECODE, PositiveGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FALSECOSTCENTRECODE, NegativeGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for NegativeGiftDetailRow is incorrect"); Assert.AreEqual(ACCOUNTCODE, TransactionRow.AccountCode, "TestBatchPostingRecalculations fail: AccountCode for PositiveGiftDetailRow is incorrect"); // Cleanup: Delete test records bool SubmissionOK = true; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { AProcessedFeeAccess.DeleteUsingTemplate( new TSearchCriteria[] { new TSearchCriteria("a_ledger_number_i", FLedgerNumber), new TSearchCriteria("a_batch_number_i", GiftBatchNumber) }, Transaction); AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, PositiveGiftDetailRow, Transaction); AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, NegativeGiftDetailRow, Transaction); }); TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult); TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult); TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult); }