/// <summary>
/// Test that the data was merged correctly!
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Bank Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Bank Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="ABankingDetailsKey">BankingDetailsKey for the BankingDetails record being tested</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
void TestMergeTwoBanks_SecondaryAsserts(long AFromPartnerKey,
long AToPartnerKey,
int ABankingDetailsKey,
ref TPartnerEditUIConnector AConnector)
{
PartnerEditTDS MainDS = new PartnerEditTDS();
// Read Partners from the database after they have been merged
MainDS.PPartner.Merge(PPartnerAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.PBank.Merge(PBankAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.PBankingDetails.Merge(PBankingDetailsAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
PPartnerMergeTable MergeTable = PPartnerMergeAccess.LoadByPrimaryKey(AFromPartnerKey, DBAccess.GDBAccessObj.Transaction);
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AFromPartnerKey });
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AToPartnerKey });
PBankRow FromBankRow = (PBankRow)MainDS.PBank.Rows.Find(new object[] { AFromPartnerKey });
PBankRow ToBankRow = (PBankRow)MainDS.PBank.Rows.Find(new object[] { AToPartnerKey });
PBankingDetailsRow BankingDetailsRow = (PBankingDetailsRow)MainDS.PBankingDetails.Rows.Find(new object[] { ABankingDetailsKey });
// Check that what we are about to check is there...
Assert.That(MergeTable, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(FromBankRow, Is.Not.Null);
Assert.That(ToBankRow, Is.Not.Null);
Assert.That(BankingDetailsRow, Is.Not.Null);
//
// Check that Partners have been merged correctly
//
// Checking the two Banks
Assert.AreEqual(FromPartnerRow.PartnerKey.ToString() + ", TestBank", ToPartnerRow.PartnerShortName, "merge two Banks");
Assert.AreEqual(FromBankRow.BranchName, ToBankRow.BranchName, "merge two Banks");
Assert.AreEqual(AToPartnerKey, BankingDetailsRow.BankKey, "merge two Banks");
// Checking the MergeTable
Assert.IsNotNull(MergeTable.Rows[0], "merge two Banks");
}
public void TestDeleteOrganisation()
{
DataSet ResponseDS = new PartnerEditTDS();
TVerificationResultCollection VerificationResult;
String TextMessage;
Boolean CanDeletePartner;
PPartnerRow OrganisationPartnerRow;
TSubmitChangesResult result;
Int64 PartnerKey;
TPartnerEditUIConnector connector = new TPartnerEditUIConnector();
PartnerEditTDS MainDS = new PartnerEditTDS();
OrganisationPartnerRow = TCreateTestPartnerData.CreateNewOrganisationPartner(MainDS);
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create organisation record");
// check if organisation partner can be deleted (still needs to be possible at this point)
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(OrganisationPartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(CanDeletePartner);
// now test actual deletion of Organisation partner
PartnerKey = OrganisationPartnerRow.PartnerKey;
Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));
// check that Organisation record is really deleted
Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
}
public void TestDeleteVenue()
{
DataSet ResponseDS = new PartnerEditTDS();
TVerificationResultCollection VerificationResult;
String TextMessage;
Boolean CanDeletePartner;
PPartnerRow VenuePartnerRow;
TSubmitChangesResult result;
Int64 PartnerKey;
TPartnerEditUIConnector connector = new TPartnerEditUIConnector();
PartnerEditTDS MainDS = new PartnerEditTDS();
VenuePartnerRow = TCreateTestPartnerData.CreateNewVenuePartner(MainDS);
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create venue record");
// check if Venue partner can be deleted (still needs to be possible at this point)
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(VenuePartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(CanDeletePartner);
// set up buildings for this venue so deletion is not allowed
PcBuildingTable BuildingTable = new PcBuildingTable();
PcBuildingRow BuildingRow = BuildingTable.NewRowTyped();
BuildingRow.VenueKey = VenuePartnerRow.PartnerKey;
BuildingRow.BuildingCode = "Test";
BuildingTable.Rows.Add(BuildingRow);
PcBuildingAccess.SubmitChanges(BuildingTable, DBAccess.GDBAccessObj.Transaction);
// now deletion must not be possible since a building is linked to the venue
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(VenuePartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(!CanDeletePartner);
// now test actual deletion of venue partner
VenuePartnerRow = TCreateTestPartnerData.CreateNewVenuePartner(MainDS);
PartnerKey = VenuePartnerRow.PartnerKey;
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create venue record for deletion");
// check if Venue record is being deleted
Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));
// check that Venue record is really deleted
Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
}
public void TestDeleteFamily()
{
DataSet ResponseDS = new PartnerEditTDS();
TVerificationResultCollection VerificationResult;
String TextMessage;
Boolean CanDeletePartner;
PPartnerRow FamilyPartnerRow;
PFamilyRow FamilyRow;
PPersonRow PersonRow;
TSubmitChangesResult result;
Int64 PartnerKey;
TPartnerEditUIConnector connector = new TPartnerEditUIConnector();
PartnerEditTDS MainDS = new PartnerEditTDS();
FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create family record");
// check if Family partner can be deleted (still needs to be possible at this point)
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(CanDeletePartner);
// add a person to the family which means the family is not allowed to be deleted any longer
FamilyRow = (PFamilyRow)MainDS.PFamily.Rows[0];
FamilyRow.FamilyMembers = true;
TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create new location");
PartnerEditTDS PersonDS = new PartnerEditTDS();
PersonRow = TCreateTestPartnerData.CreateNewPerson(PersonDS, FamilyPartnerRow.PartnerKey,
MainDS.PLocation[0].LocationKey, "Adam", "Mr", 0);
PersonRow.FamilyKey = FamilyPartnerRow.PartnerKey;
result = connector.SubmitChanges(ref PersonDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create person record");
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(!CanDeletePartner);
// create new family and create subscription given as gift from this family: not allowed to be deleted
FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
PPublicationTable PublicationTable = PPublicationAccess.LoadByPrimaryKey("TESTPUBLICATION", DBAccess.GDBAccessObj.Transaction);
if (PublicationTable.Count == 0)
{
// first check if frequency "Annual" exists and if not then create it
if (!AFrequencyAccess.Exists("Annual", DBAccess.GDBAccessObj.Transaction))
{
// set up details (e.g. bank account) for this Bank so deletion is not allowed
AFrequencyTable FrequencyTable = new AFrequencyTable();
AFrequencyRow FrequencyRow = FrequencyTable.NewRowTyped();
FrequencyRow.FrequencyCode = "Annual";
FrequencyRow.FrequencyDescription = "Annual Frequency";
FrequencyTable.Rows.Add(FrequencyRow);
AFrequencyAccess.SubmitChanges(FrequencyTable, DBAccess.GDBAccessObj.Transaction);
}
// now add the publication "TESTPUBLICATION"
PPublicationRow PublicationRow = PublicationTable.NewRowTyped();
PublicationRow.PublicationCode = "TESTPUBLICATION";
PublicationRow.FrequencyCode = "Annual";
PublicationTable.Rows.Add(PublicationRow);
PPublicationAccess.SubmitChanges(PublicationTable, DBAccess.GDBAccessObj.Transaction);
}
// make sure that "reason subscription given" exists
if (!PReasonSubscriptionGivenAccess.Exists("FREE", DBAccess.GDBAccessObj.Transaction))
{
// set up details (e.g. bank account) for this Bank so deletion is not allowed
PReasonSubscriptionGivenTable ReasonTable = new PReasonSubscriptionGivenTable();
PReasonSubscriptionGivenRow ReasonRow = ReasonTable.NewRowTyped();
ReasonRow.Code = "FREE";
ReasonRow.Description = "Free Subscription";
ReasonTable.Rows.Add(ReasonRow);
PReasonSubscriptionGivenAccess.SubmitChanges(ReasonTable, DBAccess.GDBAccessObj.Transaction);
}
// now add the publication "TESTPUBLICATION" to the first family record and indicate it was a gift from newly created family record
PSubscriptionRow SubscriptionRow = MainDS.PSubscription.NewRowTyped();
SubscriptionRow.PublicationCode = "TESTPUBLICATION";
SubscriptionRow.PartnerKey = FamilyRow.PartnerKey; // link subscription with original family
SubscriptionRow.GiftFromKey = FamilyPartnerRow.PartnerKey; // indicate that subscription is a gift from newly created family
//.........这里部分代码省略.........
public void TestDeleteUnit()
{
DataSet ResponseDS = new PartnerEditTDS();
TVerificationResultCollection VerificationResult;
String TextMessage;
Boolean CanDeletePartner;
PPartnerRow UnitPartnerRow;
PUnitRow UnitRow;
TSubmitChangesResult result;
Int64 PartnerKey;
TPartnerEditUIConnector connector = new TPartnerEditUIConnector();
PartnerEditTDS MainDS = new PartnerEditTDS();
UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
// check if Unit partner can be deleted (still needs to be possible at this point)
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(UnitPartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(CanDeletePartner);
// set unit type to Key Ministry which means it is not allowed to be deleted any longer
UnitRow = (PUnitRow)MainDS.PUnit.Rows[0];
UnitRow.UnitTypeCode = MPartnerConstants.UNIT_TYPE_KEYMIN;
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "set unit type to " + MPartnerConstants.UNIT_TYPE_KEYMIN);
CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(UnitPartnerRow.PartnerKey, out TextMessage);
if (TextMessage.Length > 0)
{
TLogging.Log(TextMessage);
}
Assert.IsTrue(!CanDeletePartner);
// now test actual deletion of Unit partner
UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
PartnerKey = UnitPartnerRow.PartnerKey;
result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit record for deletion");
// check if Unit record is being deleted
Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));
// check that Unit record is really deleted
Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
}
/// <summary>
/// Creates two Person Partners, a Family Partner and AP Info for the From Partner.
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Person Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Person Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="AFamilyPartnerKey">Partner Key of the Family Partner that is in the Partner Merge Test.</param>
/// <param name="AAPDocumentID">Document ID for APDocument that is created for testing.</param>
/// <param name="ALedgerNumber">Ledger Number for the GiftBatch that is created for testing.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
private void TestMergeAPInfo_Arrange(out long AFromPartnerKey, out long AToPartnerKey, out long AFamilyPartnerKey, out int AAPDocumentID,
out int ALedgerNumber, TPartnerEditUIConnector AConnector)
{
TVerificationResultCollection VerificationResult;
TSubmitChangesResult Result;
DataSet ResponseDS;
PartnerEditTDS MainDS = new PartnerEditTDS();
AccountsPayableTDS APDS = new AccountsPayableTDS();
// create two new Person Partners, one family and APInfo for From Partner
TCreateTestPartnerData.CreateFamilyWithTwoPersonRecords(MainDS);
PPartnerRow FamilyPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[0];
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[1];
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[2];
AApDocumentRow APDocumentRow = TCreateTestPartnerData.CreateNewAPInfo(FromPartnerRow.PartnerKey, ref APDS);
// Guard Assertions
Assert.That(FamilyPartnerRow, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(APDocumentRow, Is.Not.Null);
Assert.AreEqual(1, APDS.AApSupplier.Rows.Count);
AFamilyPartnerKey = FamilyPartnerRow.PartnerKey;
AFromPartnerKey = FromPartnerRow.PartnerKey;
AToPartnerKey = ToPartnerRow.PartnerKey;
AAPDocumentID = APDocumentRow.ApDocumentId;
ALedgerNumber = APDocumentRow.LedgerNumber;
// Submit the new records to the database
ResponseDS = new PartnerEditTDS();
Result = AConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for two Persons failed: " + VerificationResult.BuildVerificationResultString());
// Submit the new Supplier record to the database
TSupplierEditUIConnector Connector = new TSupplierEditUIConnector();
Result = Connector.SubmitChanges(ref APDS);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for AP Info failed");
// Submit the new Document record to the database
Result = TAPTransactionWebConnector.SaveAApDocument(ref APDS, out VerificationResult);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for AP Info failed: " + VerificationResult.BuildVerificationResultString());
}
/// <summary>
/// Test that the data was merged correctly!
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Person Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Person Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="AAPDocumentID">Document ID for APDocument that is created for testing.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
void TestMergeAPInfo_SecondaryAsserts(long AFromPartnerKey, long AToPartnerKey, int AAPDocumentID, ref TPartnerEditUIConnector AConnector)
{
PartnerEditTDS MainDS = new PartnerEditTDS();
AccountsPayableTDS APDS = new AccountsPayableTDS();
// Read Partners from the database after they have been merged
MainDS.PPartner.Merge(PPartnerAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.PPerson.Merge(PPersonAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
APDS.AApSupplier.Merge(AApSupplierAccess.LoadViaPPartner(AToPartnerKey, DBAccess.GDBAccessObj.Transaction));
APDS.AApDocument.Merge(AApDocumentAccess.LoadByPrimaryKey(AAPDocumentID, DBAccess.GDBAccessObj.Transaction));
PPartnerMergeTable MergeTable = PPartnerMergeAccess.LoadByPrimaryKey(AFromPartnerKey, DBAccess.GDBAccessObj.Transaction);
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AFromPartnerKey });
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AToPartnerKey });
AApSupplierRow SupplierRow = (AApSupplierRow)APDS.AApSupplier.Rows[0];
AApDocumentRow DocumentRow = (AApDocumentRow)APDS.AApDocument.Rows[0];
// Check that what we are about to check is there...
Assert.That(MergeTable, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(DocumentRow, Is.Not.Null);
//
// Check that Partners have been merged correctly
//
// Checking the two Persons
Assert.AreEqual("MERGED", FromPartnerRow.StatusCode, "merge AP info");
Assert.AreEqual("ACTIVE", ToPartnerRow.StatusCode, "merge AP info");
Assert.AreEqual(AToPartnerKey, DocumentRow.PartnerKey, "AP gift info");
Assert.That(SupplierRow, Is.Not.Null, "Supplier was not correctly merged; it cannot be loaded from the DB as expected");
// Checking the MergeTable
Assert.IsNotNull(MergeTable.Rows[0], "merge AP info");
}
/// <summary>
/// Test that the data was merged correctly!
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Person Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Person Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="ALedgerNumber">Ledger Number for the GiftBatch that is created for testing.</param>
/// <param name="ABatchNumber">Batch Number for the GiftBatch that is created for testing.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
void TestMergeRecurringGiftInfo_SecondaryAsserts(long AFromPartnerKey,
long AToPartnerKey,
int ALedgerNumber,
int ABatchNumber,
ref TPartnerEditUIConnector AConnector)
{
PartnerEditTDS MainDS = new PartnerEditTDS();
GiftBatchTDS GiftDS = new GiftBatchTDS();
// Read Partners from the database after they have been merged
MainDS.PPartner.Merge(PPartnerAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.PPerson.Merge(PPersonAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
GiftDS.ARecurringGift.Merge(ARecurringGiftAccess.LoadViaARecurringGiftBatch(ALedgerNumber, ABatchNumber,
DBAccess.GDBAccessObj.Transaction));
GiftDS.ARecurringGiftDetail.Merge(ARecurringGiftDetailAccess.LoadViaARecurringGiftBatch(ALedgerNumber, ABatchNumber,
DBAccess.GDBAccessObj.Transaction));
PPartnerMergeTable MergeTable = PPartnerMergeAccess.LoadByPrimaryKey(AFromPartnerKey, DBAccess.GDBAccessObj.Transaction);
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AFromPartnerKey });
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AToPartnerKey });
ARecurringGiftRow GiftRow = (ARecurringGiftRow)GiftDS.ARecurringGift.Rows[0];
ARecurringGiftDetailRow GiftDetailRow = (ARecurringGiftDetailRow)GiftDS.ARecurringGiftDetail.Rows[0];
// Check that what we are about to check is there...
Assert.That(MergeTable, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(GiftRow, Is.Not.Null);
Assert.That(GiftDetailRow, Is.Not.Null);
//
// Check that Partners have been merged correctly
//
// Checking the two Persons
Assert.AreEqual("MERGED", FromPartnerRow.StatusCode, "merge gift info");
Assert.AreEqual("ACTIVE", ToPartnerRow.StatusCode, "merge gift info");
Assert.AreEqual(AToPartnerKey, GiftRow.DonorKey, "merge gift info");
Assert.AreEqual(AToPartnerKey, GiftDetailRow.RecipientKey, "merge gift info");
Assert.AreEqual(AToPartnerKey, GiftDetailRow.RecipientLedgerNumber, "merge gift info");
// Checking the MergeTable
Assert.IsNotNull(MergeTable.Rows[0], "merge gift info");
}
public void TestMergeAPInfo()
{
long FromPartnerKey;
long ToPartnerKey;
long FamilyPartnerKey;
int APDocumentID;
int LedgerNumber;
long[] SiteKeys = new long[0];
int[] LocationKeys = new int[0];
TVerificationResultCollection VerificationResult;
TPartnerEditUIConnector UIConnector = new TPartnerEditUIConnector();
//
// Arrange: Create two Person Partners in one Family Partner with one Location
//
TestMergeAPInfo_Arrange(out FromPartnerKey, out ToPartnerKey, out FamilyPartnerKey, out APDocumentID, out LedgerNumber, UIConnector);
//
// Act: Merge the two Person Partners!
//
bool result = TMergePartnersWebConnector.MergeTwoPartners(FromPartnerKey, ToPartnerKey,
TPartnerClass.PERSON, TPartnerClass.PERSON, SiteKeys, LocationKeys, null, -1, FCategories, ref DifferentFamilies);
//
// Assert
//
// Primary Assert: Tests that Partner Merge reports that it was successful!
Assert.AreEqual(true, result, "Merging two Person Partners");
// Secondary Asserts: Test that the data was merged correctly!
TestMergeAPInfo_SecondaryAsserts(FromPartnerKey, ToPartnerKey, APDocumentID, ref UIConnector);
// Cleanup: Delete test records
List <int>DocumentID = new List <int>();
DocumentID.Add(APDocumentID);
TAPTransactionWebConnector.DeleteAPDocuments(LedgerNumber, DocumentID);
AccountsPayableTDS APDS = TAPTransactionWebConnector.LoadAApSupplier(LedgerNumber, ToPartnerKey);
APDS.AApSupplier.Rows[0].Delete();
AApSupplierAccess.SubmitChanges(APDS.AApSupplier, DBAccess.GDBAccessObj.Transaction);
TPartnerWebConnector.DeletePartner(FromPartnerKey, out VerificationResult);
TPartnerWebConnector.DeletePartner(ToPartnerKey, out VerificationResult);
TPartnerWebConnector.DeletePartner(FamilyPartnerKey, out VerificationResult);
}
/// <summary>
/// Creates two Person Partners, a Family Partner and Gift Info for the From Partner.
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Person Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Person Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="AFamilyPartnerKey">Partner Key of the Family Partner that is in the Partner Merge Test.</param>
/// <param name="ALedgerNumber">Ledger Number for the GiftBatch that is created for testing.</param>
/// <param name="ABatchNumber">Batch Number for the GiftBatch that is created for testing.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
private void TestMergeRecurringGiftInfo_Arrange(out long AFromPartnerKey,
out long AToPartnerKey,
out long AFamilyPartnerKey,
out int ALedgerNumber,
out int ABatchNumber,
TPartnerEditUIConnector AConnector)
{
TVerificationResultCollection VerificationResult;
TSubmitChangesResult Result;
DataSet ResponseDS;
PartnerEditTDS MainDS = new PartnerEditTDS();
GiftBatchTDS GiftDS = new GiftBatchTDS();
// create two new Person Partners, one family and GiftInfo for From Partner
TCreateTestPartnerData.CreateFamilyWithTwoPersonRecords(MainDS);
PPartnerRow FamilyPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[0];
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[1];
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[2];
ARecurringGiftBatchRow GiftBatchRow = TCreateTestPartnerData.CreateNewRecurringGiftInfo(FromPartnerRow.PartnerKey, ref GiftDS);
// Guard Assertions
Assert.That(FamilyPartnerRow, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(GiftBatchRow, Is.Not.Null);
Assert.AreEqual(1, GiftDS.ARecurringGift.Rows.Count);
Assert.AreEqual(1, GiftDS.ARecurringGiftDetail.Rows.Count);
AFamilyPartnerKey = FamilyPartnerRow.PartnerKey;
AFromPartnerKey = FromPartnerRow.PartnerKey;
AToPartnerKey = ToPartnerRow.PartnerKey;
ALedgerNumber = GiftBatchRow.LedgerNumber;
ABatchNumber = GiftBatchRow.BatchNumber;
// Submit the new records to the database
ResponseDS = new PartnerEditTDS();
Result = AConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for two Persons failed: " + VerificationResult.BuildVerificationResultString());
// Submit the new Gift Info records to the database
Result = TGiftTransactionWebConnector.SaveGiftBatchTDS(ref GiftDS, out VerificationResult);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for Recurring Gift Info failed: " + VerificationResult.BuildVerificationResultString());
}
public void TestMergeRecurringGiftInfo()
{
long FromPartnerKey;
long ToPartnerKey;
long FamilyPartnerKey;
int LedgerNumber;
int BatchNumber;
long[] SiteKeys = new long[0];
int[] LocationKeys = new int[0];
TVerificationResultCollection VerificationResult;
TPartnerEditUIConnector UIConnector = new TPartnerEditUIConnector();
//
// Arrange: Create two Person Partners in one Family Partner with one Location
//
TestMergeRecurringGiftInfo_Arrange(out FromPartnerKey,
out ToPartnerKey,
out FamilyPartnerKey,
out LedgerNumber,
out BatchNumber,
UIConnector);
//
// Act: Merge the two Person Partners!
//
bool result = TMergePartnersWebConnector.MergeTwoPartners(FromPartnerKey, ToPartnerKey,
TPartnerClass.PERSON, TPartnerClass.PERSON, SiteKeys, LocationKeys, null, -1, FCategories, ref DifferentFamilies);
//
// Assert
//
// Primary Assert: Tests that Partner Merge reports that it was successful!
Assert.AreEqual(true, result, "Merging two Person Partners");
// Secondary Asserts: Test that the data was merged correctly!
TestMergeRecurringGiftInfo_SecondaryAsserts(FromPartnerKey, ToPartnerKey, LedgerNumber, BatchNumber, ref UIConnector);
// Cleanup: Delete test records
GiftBatchTDS GiftDS = TGiftTransactionWebConnector.LoadARecurringGiftBatchAndRelatedData(LedgerNumber, BatchNumber);
GiftDS.ARecurringGiftDetail.Rows[0].Delete();
GiftDS.ARecurringGift.Rows[0].Delete();
GiftDS.ARecurringGiftBatch.Rows[0].Delete();
TGiftTransactionWebConnector.SaveGiftBatchTDS(ref GiftDS, out VerificationResult);
TPartnerWebConnector.DeletePartner(FromPartnerKey, out VerificationResult);
TPartnerWebConnector.DeletePartner(ToPartnerKey, out VerificationResult);
TPartnerWebConnector.DeletePartner(FamilyPartnerKey, out VerificationResult);
}
/// <summary>
/// Creates a Bank Partner a Person Partner and a Family Partner.
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Bank Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Person Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="AToFamilyKey">Partner Key of the Family Partner of the Person Partner.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
private void TestMergeBankToPerson_Arrange(out long AFromPartnerKey,
out long AToPartnerKey,
out long AToFamilyKey,
TPartnerEditUIConnector AConnector)
{
TVerificationResultCollection VerificationResult;
TSubmitChangesResult Result;
DataSet ResponseDS;
PartnerEditTDS MainDS = new PartnerEditTDS();
// Create one new Bank Partner and one new Person Partner
PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
TCreateTestPartnerData.CreateFamilyWithOnePersonRecord(MainDS);
PPersonRow ToPartnerRow = (PPersonRow)MainDS.PPerson.Rows[0];
PFamilyRow ToFamilyRow = (PFamilyRow)MainDS.PFamily.Rows[0];
// Guard Assertions
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(ToFamilyRow, Is.Not.Null);
AFromPartnerKey = FromPartnerRow.PartnerKey;
AToPartnerKey = ToPartnerRow.PartnerKey;
AToFamilyKey = ToFamilyRow.PartnerKey;
// Submit the new Partner records to the database
ResponseDS = new PartnerEditTDS();
Result = AConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
// Guard Assertion
Assert.That(Result, Is.EqualTo(
TSubmitChangesResult.scrOK), "SubmitChanges for bank and person failed: " + VerificationResult.BuildVerificationResultString());
}
/// <summary>
/// Test that the data was merged correctly!
/// </summary>
/// <param name="AFromPartnerKey">Partner Key of the Church Partner that is the 'From' Partner in the Partner Merge Test.</param>
/// <param name="AToPartnerKey">Partner Key of the Organisation Partner that is the 'To' Partner in the Partner Merge Test.</param>
/// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
void TestMergeChurchToOrganisation_SecondaryAsserts(long AFromPartnerKey, long AToPartnerKey, ref TPartnerEditUIConnector AConnector)
{
PartnerEditTDS MainDS = new PartnerEditTDS();
// Read Partners from the database after they have been merged
MainDS.PPartner.Merge(PPartnerAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.PChurch.Merge(PChurchAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
MainDS.POrganisation.Merge(POrganisationAccess.LoadAll(DBAccess.GDBAccessObj.Transaction));
PPartnerMergeTable MergeTable = PPartnerMergeAccess.LoadByPrimaryKey(AFromPartnerKey, DBAccess.GDBAccessObj.Transaction);
PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AFromPartnerKey });
PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows.Find(new object[] { AToPartnerKey });
PChurchRow FromChurchRow = (PChurchRow)MainDS.PChurch.Rows.Find(new object[] { AFromPartnerKey });
POrganisationRow ToOrganisationRow = (POrganisationRow)MainDS.POrganisation.Rows.Find(new object[] { AToPartnerKey });
// Check that what we are about to check is there...
Assert.That(MergeTable, Is.Not.Null);
Assert.That(FromPartnerRow, Is.Not.Null);
Assert.That(ToPartnerRow, Is.Not.Null);
Assert.That(FromChurchRow, Is.Not.Null);
Assert.That(ToOrganisationRow, Is.Not.Null);
//
// Check that Partners have been merged correctly
//
// Checking the church and the Organisation
Assert.AreEqual(FromPartnerRow.PartnerKey.ToString() + ", TestChurch", ToPartnerRow.PartnerShortName, "merge Church to Organisation");
Assert.AreEqual("MERGED", FromPartnerRow.StatusCode, "merge Church to Organisation");
Assert.AreEqual("ACTIVE", ToPartnerRow.StatusCode, "merge Church to Organisation");
Assert.AreEqual(FromChurchRow.ContactPartnerKey, ToOrganisationRow.ContactPartnerKey, "merge Church to Organisation");
// Checking the MergeTable
Assert.IsNotNull(MergeTable.Rows[0], "merge Church to organisation");
}
请发表评论