Пример #1
0
        public void TestFamilyPropagateNewLocation()
        {
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            TCreateTestPartnerData.CreateFamilyWithTwoPersonRecords(MainDS);

            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;

            TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            // now change on partner location. should ask about everyone else
            // it seems, the change must be to PLocation. In Petra 2.3, changes to the PartnerLocation are not propagated
            // MainDS.PPartnerLocation[0].DateGoodUntil = new DateTime(2011, 01, 01);

            Assert.AreEqual(1, MainDS.PLocation.Rows.Count, "there should be only one address for the whole family");

            MainDS.PLocation[0].County = "different";

            ResponseDS = new PartnerEditTDS();

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrInfoNeeded,
                result,
                "should ask if the partner locations of the other members of the family should be changed as well");

            // TODO: simulate the dialog where the user selects which people to propagate the address change for.

            // TODO: what about replacing the whole address?
            // TODO: adding a new location for all members of the family?
        }
Пример #2
0
        public void TestNewPartnerWithLocation0()
        {
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            PPartnerLocationRow PartnerLocationRow = MainDS.PPartnerLocation.NewRowTyped();

            PartnerLocationRow.SiteKey = DomainManager.GSiteKey;
            PartnerLocationRow.PartnerKey = PartnerRow.PartnerKey;
            PartnerLocationRow.LocationKey = 0;
            PartnerLocationRow.TelephoneNumber = PartnerRow.PartnerKey.ToString();
            MainDS.PPartnerLocation.Rows.Add(PartnerLocationRow);

            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;

            TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create a partner with location 0");

            TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS);

            // remove location 0, same is done in csharp\ICT\Petra\Client\MCommon\logic\UC_PartnerAddresses.cs TUCPartnerAddressesLogic::AddRecord
            // Check if record with PartnerLocation.LocationKey = 0 is around > delete it
            DataRow PartnerLocationRecordZero =
                MainDS.PPartnerLocation.Rows.Find(new object[] { PartnerRow.PartnerKey, DomainManager.GSiteKey, 0 });

            if (PartnerLocationRecordZero != null)
            {
                DataRow LocationRecordZero = MainDS.PLocation.Rows.Find(new object[] { DomainManager.GSiteKey, 0 });

                if (LocationRecordZero != null)
                {
                    LocationRecordZero.Delete();
                }

                PartnerLocationRecordZero.Delete();
            }

            ResponseDS = new PartnerEditTDS();
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Replace location 0 of partner");

            Assert.AreEqual(1, MainDS.PPartnerLocation.Rows.Count, "the partner should only have one location in the dataset");

            // get all addresses of the partner
            TDBTransaction ReadTransaction = null;
            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                ref ReadTransaction,
                delegate
                {
                    PPartnerLocationTable testPartnerLocations = PPartnerLocationAccess.LoadViaPPartner(PartnerRow.PartnerKey, ReadTransaction);
                    Assert.AreEqual(1, testPartnerLocations.Rows.Count, "the partner should only have one location");
                    Assert.Greater(testPartnerLocations[0].LocationKey, 0, "TPartnerEditUIConnector SubmitChanges returns valid location key");
                });
        }
Пример #3
0
        public void TestSaveNewPartnerWithExistingLocation()
        {
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS);

            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;

            TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "saving the first partner with a location");

            Int32 LocationKey = MainDS.PLocation[0].LocationKey;

            MainDS = new PartnerEditTDS();

            PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            PPartnerLocationRow PartnerLocationRow = MainDS.PPartnerLocation.NewRowTyped();
            PartnerLocationRow.SiteKey = DomainManager.GSiteKey;
            PartnerLocationRow.PartnerKey = PartnerRow.PartnerKey;
            PartnerLocationRow.LocationKey = LocationKey;
            PartnerLocationRow.TelephoneNumber = PartnerRow.PartnerKey.ToString();
            MainDS.PPartnerLocation.Rows.Add(PartnerLocationRow);

            ResponseDS = new PartnerEditTDS();

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            TDBTransaction ReadTransaction = null;
            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                ref ReadTransaction,
                delegate
                {
                    PPartnerTable PartnerAtAddress = PPartnerAccess.LoadViaPLocation(
                        DomainManager.GSiteKey, LocationKey, ReadTransaction);
                    Assert.AreEqual(2, PartnerAtAddress.Rows.Count, "there should be two partners at this location");
                });
        }
Пример #4
0
        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));
        }
Пример #5
0
        /// <summary>
        /// Creates two Family Partners and a Family Partner.
        /// </summary>
        /// <param name="AFromPartnerKey">Partner Key of the Family Partner that is the 'From' Partner in the Partner Merge Test.</param>
        /// <param name="AToPartnerKey">Partner Key of the Family Partner that is the 'To' Partner in the Partner Merge Test.</param>
        /// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
        private void TestMergeTwoFamilies_Arrange(out long AFromPartnerKey, out long AToPartnerKey, TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // Create two new Family Partners
            PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PPartnerRow ToPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            // Guard Assertions
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);

            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;

            PFamilyRow FromFamilyRow = (PFamilyRow)MainDS.PFamily.Rows.Find(new object[] { AFromPartnerKey });
            PFamilyRow ToFamilyRow = (PFamilyRow)MainDS.PFamily.Rows.Find(new object[] { AToPartnerKey });

            // Guard Assertions
            Assert.That(FromFamilyRow, Is.Not.Null);
            Assert.That(ToFamilyRow, Is.Not.Null);

            // Modify records so that they contain different data
            ToPartnerRow.PartnerShortName = "";
            FromFamilyRow.FirstName = "Chang";
            ToFamilyRow.FirstName = "Eng";
            ToFamilyRow.FamilyName = "";

            // Submit the two new Family 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 two Families failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #6
0
        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));
        }
Пример #7
0
        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));
        }
Пример #8
0
        /// <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());
        }
Пример #9
0
        /// <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="ADataLabelKey">Key for PDataLabel that is created for testing.</param>
        /// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
        private void TestMergePMData_Arrange(out long AFromPartnerKey, out long AToPartnerKey, out long AFamilyPartnerKey,
            out int ADataLabelKey, TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();
            IndividualDataTDS IndividualDS = new IndividualDataTDS();

            // create two new Person Partners, one family and PM Data for both Partners
            TCreateTestPartnerData.CreateFamilyWithTwoPersonRecords(MainDS);
            PPartnerRow FamilyPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[0];
            PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[1];
            PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[2];
            PDataLabelTable DataLabel = TCreateTestPartnerData.CreateNewPMData(FromPartnerRow.PartnerKey, ToPartnerRow.PartnerKey, IndividualDS);

            PmPassportDetailsRow row = (PmPassportDetailsRow)IndividualDS.PmPassportDetails.Rows[0];

            // Guard Assertions
            Assert.That(FamilyPartnerRow, Is.Not.Null);
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);
            Assert.That(DataLabel, Is.Not.Null);
            Assert.AreEqual(1, IndividualDS.PDataLabelValuePartner.Rows.Count);
            Assert.AreEqual(1, IndividualDS.PmPassportDetails.Rows.Count);
            Assert.AreEqual(2, IndividualDS.PmPersonalData.Rows.Count);

            AFamilyPartnerKey = FamilyPartnerRow.PartnerKey;
            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;
            ADataLabelKey = ((PDataLabelRow)DataLabel.Rows[0]).Key;

            // 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 DataLabel record to the database
            PDataLabelAccess.SubmitChanges(DataLabel, DBAccess.GDBAccessObj.Transaction);

            // Submit the new Document record to the database
            MainDS.Merge(IndividualDS);
            Result = TIndividualDataWebConnector.SubmitChangesServerSide(ref IndividualDS,
                ref MainDS,
                DBAccess.GDBAccessObj.Transaction,
                out VerificationResult);

            // Guard Assertion
            Assert.That(Result, Is.EqualTo(
                    TSubmitChangesResult.scrOK), "SubmitChanges for PM Data failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #10
0
        /// <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());
        }
Пример #11
0
        /// <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());
        }
Пример #12
0
        /// <summary>
        /// Creates two Bank Partners and a Bank 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 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>
        private void TestMergeTwoBanks_Arrange(out long AFromPartnerKey,
            out long AToPartnerKey,
            out int ABankingDetailsKey,
            TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // Create two new Bank Partners and a new BankingDetails record
            PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            PPartnerRow ToPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            PartnerEditTDSPBankingDetailsRow BankingDetailsRow = TCreateTestPartnerData.CreateNewBankingRecords(FromPartnerRow.PartnerKey, MainDS);

            // Guard Assertions
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);
            Assert.That(BankingDetailsRow, Is.Not.Null);

            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;
            ABankingDetailsKey = BankingDetailsRow.BankingDetailsKey;

            PBankRow FromBankRow = (PBankRow)MainDS.PBank.Rows.Find(new object[] { AFromPartnerKey });
            PBankRow ToBankRow = (PBankRow)MainDS.PBank.Rows.Find(new object[] { AToPartnerKey });

            // Guard Assertions
            Assert.That(FromBankRow, Is.Not.Null);
            Assert.That(ToBankRow, Is.Not.Null);

            // Modify records so that they contain different data
            ToPartnerRow.PartnerShortName = "";
            ToBankRow.BranchName = "";
            BankingDetailsRow.BankKey = AFromPartnerKey;

            // Submit the two new Bank 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 two Banks failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #13
0
        /// <summary>
        /// Creates two Person Partners and two Family 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 'From' Partner in the Partner Merge Test.</param>
        /// <param name="AFromFamilyPartnerKey">Partner Key of the From Family Partner that is in the Partner Merge Test.</param>
        /// <param name="AToFamilyPartnerKey">Partner Key of the To Family Partner that is in the Partner Merge Test.</param>
        /// <param name="ASiteKey">Site Key of the Location that is in the Partner Merge Test.</param>
        /// <param name="ALocationKey">Location Key of the Location that is in the Partner Merge Test.</param>
        /// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
        private void TestMergeTwoPersonsFromDifferentFamilies_Arrange(out long AFromPartnerKey,
            out long AToPartnerKey,
            out long AFromFamilyPartnerKey,
            out long AToFamilyPartnerKey,
            out long[] ASiteKey,
            out int[] ALocationKey,
            TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // create one new Person Partner, one family and one location
            TCreateTestPartnerData.CreateFamilyWithOnePersonRecord(MainDS);
            PPartnerRow FromFamilyPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[0];
            PPartnerRow FromPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[1];
            PLocationRow LocationRow = (PLocationRow)MainDS.PLocation.Rows[0];

            // Submit the two new Person Partner records to the database (need to this now or will get error when second location is created)
            ResponseDS = new PartnerEditTDS();
            Result = AConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            // create one new Person Partner, one family and one location
            TCreateTestPartnerData.CreateFamilyWithOnePersonRecord(MainDS);
            PPartnerRow ToFamilyPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[2];
            PPartnerRow ToPartnerRow = (PPartnerRow)MainDS.PPartner.Rows[3];

            // Guard Assertions
            Assert.That(FromFamilyPartnerRow, Is.Not.Null);
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToFamilyPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);
            Assert.That(LocationRow, Is.Not.Null);

            AFromFamilyPartnerKey = FromFamilyPartnerRow.PartnerKey;
            AToFamilyPartnerKey = ToFamilyPartnerRow.PartnerKey;
            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;

            PFamilyRow FromFamilyRow = (PFamilyRow)MainDS.PFamily.Rows.Find(new object[] { AFromFamilyPartnerKey });
            PFamilyRow ToFamilyRow = (PFamilyRow)MainDS.PFamily.Rows.Find(new object[] { AToFamilyPartnerKey });
            PPersonRow FromPersonRow = (PPersonRow)MainDS.PPerson.Rows.Find(new object[] { AFromPartnerKey });
            PPersonRow ToPersonRow = (PPersonRow)MainDS.PPerson.Rows.Find(new object[] { AToPartnerKey });

            // location data is needed for the merge
            ASiteKey = new long[1];
            ALocationKey = new int[1];
            ASiteKey[0] = LocationRow.SiteKey;
            ALocationKey[0] = LocationRow.LocationKey;

            // Guard Assertions
            Assert.That(FromFamilyRow, Is.Not.Null);
            Assert.That(ToFamilyRow, Is.Not.Null);
            Assert.That(FromPersonRow, Is.Not.Null);
            Assert.That(ToPersonRow, Is.Not.Null);

            // Modify records so that they contain different data
            ToPartnerRow.PartnerShortName = "";
            ToPersonRow.FirstName = "";
            FromPersonRow.Gender = "MALE";
            ToPersonRow.Gender = "UNKNOWN";

            // Submit the two new Person 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 two Persons from different Families failed: " +
                VerificationResult.BuildVerificationResultString());
        }
Пример #14
0
        /// <summary>
        /// Creates two Unit Partners.
        /// </summary>
        /// <param name="AFromPartnerKey">Partner Key of the Unit Partner that is the 'From' Partner in the Partner Merge Test.</param>
        /// <param name="AToPartnerKey">Partner Key of the Unit Partner that is the 'To' Partner in the Partner Merge Test.</param>
        /// <param name="ATestPartnerKey">Partner Key of the auxilary Family Partner.</param>
        /// <param name="AConnector">Instantiated Partner Edit UIConnector.</param>
        private void TestMergeTwoUnits_Arrange(out long AFromPartnerKey,
            out long AToPartnerKey,
            out long ATestPartnerKey,
            TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // Create two new Unit Partners
            PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PPartnerRow ToPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);

            // Guard Assertions
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);

            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;

            PUnitRow FromUnitRow = (PUnitRow)MainDS.PUnit.Rows.Find(new object[] { AFromPartnerKey });
            PUnitRow ToUnitRow = (PUnitRow)MainDS.PUnit.Rows.Find(new object[] { AToPartnerKey });

            // Guard Assertions
            Assert.That(FromUnitRow, Is.Not.Null);
            Assert.That(ToUnitRow, Is.Not.Null);

            // Modify records so that they contain different data
            ToPartnerRow.PartnerShortName = "";
            FromUnitRow.Maximum = 3;
            ToUnitRow.Maximum = 6;

            // Submit the two new Unit 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 two Units failed: " + VerificationResult.BuildVerificationResultString());

            // Create a Family record to be able to test later that the FieldKey (which is referencing p_unit) is changed
            PPartnerRow TestPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            Assert.That(TestPartnerRow, Is.Not.Null);

            ATestPartnerKey = TestPartnerRow.PartnerKey;
            PFamilyRow TestFamilyPartnerRow = (PFamilyRow)MainDS.PFamily.Rows.Find(new object[] { ATestPartnerKey });
            Assert.That(TestFamilyPartnerRow, Is.Not.Null);

            // Submit the new records to database
            ResponseDS = new PartnerEditTDS();
            Result = AConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            // Guard Assertion
            Assert.That(Result, Is.EqualTo(
                    TSubmitChangesResult.scrOK), "SubmitChanges for Family failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #15
0
        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
            SubscriptionRow.ReasonSubsGivenCode = "FREE";
            MainDS.PSubscription.Rows.Add(SubscriptionRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add publication to family record");

            // this should now not be allowed since partner record has a subscription linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Family partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PartnerKey = FamilyPartnerRow.PartnerKey;
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family record");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #16
0
        /// <summary>
        /// Creates a Unit Partner and a Bank Partner.
        /// </summary>
        /// <param name="AFromPartnerKey">Partner Key of the Unit 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="AConnector">Instantiated Partner Edit UIConnector.</param>
        private void TestMergeUnitToBank_Arrange(out long AFromPartnerKey, out long AToPartnerKey, TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // Create one new Unit Partner and one new Bank Partner
            PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PPartnerRow ToPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);

            // Guard Assertions
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);

            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.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 unit and bank failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #17
0
        public void TestDeletePerson()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String TextMessage;
            Boolean CanDeletePartner;
            PPartnerRow FamilyPartnerRow;
            PPartnerRow UnitPartnerRow;
            PPersonRow PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            // create new family, location and person
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                FamilyPartnerRow.PartnerKey,
                MainDS.PLocation[0].LocationKey,
                "Mike",
                "Mr",
                0);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a commitment for the person which means the person is not allowed to be deleted any longer
            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PmStaffDataTable CommitmentTable = new PmStaffDataTable();
            PmStaffDataRow CommitmentRow = CommitmentTable.NewRowTyped();
            CommitmentRow.Key = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_staff_data));
            CommitmentRow.PartnerKey = PersonRow.PartnerKey;
            CommitmentRow.StartOfCommitment = DateTime.Today.Date;
            CommitmentRow.EndOfCommitment = DateTime.Today.AddDays(90).Date;
            CommitmentRow.OfficeRecruitedBy = UnitPartnerRow.PartnerKey;
            CommitmentRow.HomeOffice = UnitPartnerRow.PartnerKey;
            CommitmentRow.ReceivingField = UnitPartnerRow.PartnerKey;
            CommitmentTable.Rows.Add(CommitmentRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit to be used in commitment");
            PmStaffDataAccess.SubmitChanges(CommitmentTable, DBAccess.GDBAccessObj.Transaction);

            // this should now not be allowed since person record has a commitment linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Person partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                FamilyPartnerRow.PartnerKey,
                MainDS.PLocation[0].LocationKey,
                "Mary",
                "Mrs",
                0);
            PartnerKey = PersonRow.PartnerKey;

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record to be deleted");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #18
0
        /// <summary>
        /// Creates a Church Partner and an Organisation Partner.
        /// </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>
        private void TestMergeChurchToOrganisation_Arrange(out long AFromPartnerKey, out long AToPartnerKey, TPartnerEditUIConnector AConnector)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            PartnerEditTDS MainDS = new PartnerEditTDS();

            // Create two new Partners
            PPartnerRow FromPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS);
            PPartnerRow ToPartnerRow = TCreateTestPartnerData.CreateNewOrganisationPartner(MainDS);

            // Guard Assertions
            Assert.That(FromPartnerRow, Is.Not.Null);
            Assert.That(ToPartnerRow, Is.Not.Null);

            AFromPartnerKey = FromPartnerRow.PartnerKey;
            AToPartnerKey = ToPartnerRow.PartnerKey;

            PChurchRow FromChurchRow = (PChurchRow)MainDS.PChurch.Rows.Find(new object[] { AFromPartnerKey });
            POrganisationRow ToOrganisationRow = (POrganisationRow)MainDS.POrganisation.Rows.Find(new object[] { AToPartnerKey });

            // Guard Assertions
            Assert.That(FromChurchRow, Is.Not.Null);
            Assert.That(ToOrganisationRow, Is.Not.Null);

            // Modify records so that they contain different data
            ToPartnerRow.PartnerShortName = "";
            FromChurchRow.ContactPartnerKey = AToPartnerKey;
            ToOrganisationRow.ContactPartnerKey = 0;

            // 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 church and organisation failed: " +
                VerificationResult.BuildVerificationResultString());
        }
Пример #19
0
        public void TestDeleteChurch()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String TextMessage;
            Boolean CanDeletePartner;
            PPartnerRow ChurchPartnerRow;
            PPartnerRow PartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS);
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record");

            // check if church partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // create family partner and relationship to church partner
            PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PPartnerRelationshipRow RelationshipRow = MainDS.PPartnerRelationship.NewRowTyped();

            RelationshipRow.PartnerKey = ChurchPartnerRow.PartnerKey;
            RelationshipRow.RelationName = "SUPPCHURCH";
            RelationshipRow.RelationKey = PartnerRow.PartnerKey;

            MainDS.PPartnerRelationship.Rows.Add(RelationshipRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add relationship record to church record");

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            // now deletion must not be possible since relationship as SUPPCHURCH exists
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of church partner
            ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS);
            PartnerKey = ChurchPartnerRow.PartnerKey;
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record for deletion");

            // check if church record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that church record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #20
0
        /// <summary>
        /// Creates data needed to test posting recalculations
        /// </summary>
        /// <param name="ARecipientKey">Partner Key of the recipient.</param>
        /// <param name="ARealRecipientLedgerNumber">What the RecipientLedgerNumber should be.</param>
        /// <param name="AFalseRecipientLedgerNumber">What the RecipientLedgerNumber is.</param>
        /// <param name="ARecurringGiftBatchNumber">Batch Number.</param>
        private void TestRecurringBatchSubmitRecalculations_Arrange(out long ARecipientKey,
            out long ARealRecipientLedgerNumber,
            out long AFalseRecipientLedgerNumber,
            out Int32 ARecurringGiftBatchNumber)
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult Result;
            DataSet ResponseDS;
            TPartnerEditUIConnector PartnerEditUIUIConnector = new TPartnerEditUIConnector();

            GiftBatchTDS MainDS = new GiftBatchTDS();
            PartnerEditTDS PartnerEditDS = new PartnerEditTDS();

            // this is a family partner in the test database
            const Int64 DONORKEY = 43005001;


            // create a new recipient
            TCreateTestPartnerData.CreateNewFamilyPartner(PartnerEditDS);
            ARecipientKey = PartnerEditDS.PFamily[0].PartnerKey;

            // create two new Unit partners
            TCreateTestPartnerData.CreateNewUnitPartner(PartnerEditDS);
            TCreateTestPartnerData.CreateNewUnitPartner(PartnerEditDS);
            AFalseRecipientLedgerNumber = PartnerEditDS.PPartner[0].PartnerKey;
            ARealRecipientLedgerNumber = PartnerEditDS.PPartner[1].PartnerKey;

            PPartnerTypeRow PartnerTypeRow = PartnerEditDS.PPartnerType.NewRowTyped();
            PartnerTypeRow.PartnerKey = ARealRecipientLedgerNumber;
            PartnerTypeRow.TypeCode = MPartnerConstants.PARTNERTYPE_COSTCENTRE;
            PartnerEditDS.PPartnerType.Rows.Add(PartnerTypeRow);

            // create a Gift Destination for family
            PPartnerGiftDestinationRow GiftDestination = PartnerEditDS.PPartnerGiftDestination.NewRowTyped(true);

            GiftDestination.Key = TPartnerDataReaderWebConnector.GetNewKeyForPartnerGiftDestination();
            GiftDestination.PartnerKey = ARecipientKey;
            GiftDestination.DateEffective = new DateTime(2011, 01, 01);
            GiftDestination.FieldKey = ARealRecipientLedgerNumber;

            PartnerEditDS.PPartnerGiftDestination.Rows.Add(GiftDestination);

            // Guard Assertions
            Assert.That(PartnerEditDS.PFamily[0], Is.Not.Null);
            Assert.That(PartnerEditDS.PPartner[0], Is.Not.Null);
            Assert.That(PartnerEditDS.PPartner[1], Is.Not.Null);

            // Submit the new PartnerEditTDS records to the database
            ResponseDS = new PartnerEditTDS();
            Result = PartnerEditUIUIConnector.SubmitChanges(ref PartnerEditDS, ref ResponseDS, out VerificationResult);

            // Guard Assertion
            Assert.That(Result, Is.EqualTo(
                    TSubmitChangesResult.scrOK), "SubmitChanges for PartnerEditDS failed: " + VerificationResult.BuildVerificationResultString());

            // link unit to Cost Centre
            DataTable PartnerCostCentreTbl = TGLSetupWebConnector.LoadCostCentrePartnerLinks(FLedgerNumber, 0);
            DataRow PartnerCostCentreRow = PartnerCostCentreTbl.NewRow();
            PartnerCostCentreRow["PartnerKey"] = ARealRecipientLedgerNumber;
            PartnerCostCentreRow["IsLinked"] = 4300;
            PartnerCostCentreTbl.Rows.Add(PartnerCostCentreRow);
            TGLSetupWebConnector.SaveCostCentrePartnerLinks(FLedgerNumber, PartnerCostCentreTbl);

            // create a new Recurring Gift Batch
            MainDS = TGiftTransactionWebConnector.CreateARecurringGiftBatch(FLedgerNumber);
            ARecurringGiftBatchNumber = MainDS.ARecurringGiftBatch[0].BatchNumber;

            // create a new recurring gifts
            ARecurringGiftRow RecurringGiftRow = MainDS.ARecurringGift.NewRowTyped(true);

            RecurringGiftRow.LedgerNumber = FLedgerNumber;
            RecurringGiftRow.BatchNumber = ARecurringGiftBatchNumber;
            RecurringGiftRow.DonorKey = DONORKEY;
            RecurringGiftRow.GiftTransactionNumber = 1;
            RecurringGiftRow.LastDetailNumber = 1;

            MainDS.ARecurringGift.Rows.Add(RecurringGiftRow);

            // create a new RecurringGiftDetail
            ARecurringGiftDetailRow RecurringGiftDetail = MainDS.ARecurringGiftDetail.NewRowTyped(true);

            RecurringGiftDetail.LedgerNumber = FLedgerNumber;
            RecurringGiftDetail.BatchNumber = ARecurringGiftBatchNumber;
            RecurringGiftDetail.GiftTransactionNumber = 1;
            RecurringGiftDetail.DetailNumber = 1;
            RecurringGiftDetail.RecipientLedgerNumber = AFalseRecipientLedgerNumber;
            RecurringGiftDetail.GiftAmount = 100;
            RecurringGiftDetail.MotivationGroupCode = "GIFT";
            RecurringGiftDetail.MotivationDetailCode = "SUPPORT";
            RecurringGiftDetail.RecipientKey = ARecipientKey;

            MainDS.ARecurringGiftDetail.Rows.Add(RecurringGiftDetail);

            // Submit the new GiftBatchTDS records to the database
            Result = TGiftTransactionWebConnector.SaveGiftBatchTDS(ref MainDS, out VerificationResult);

            // Guard Assertion
            Assert.That(Result, Is.EqualTo(
                    TSubmitChangesResult.scrOK), "SaveGiftBatchTDS failed: " + VerificationResult.BuildVerificationResultString());
        }
Пример #21
0
        public void TestDeleteBank()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String TextMessage;
            Boolean CanDeletePartner;
            PPartnerRow BankPartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank record");

            // check if Bank partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // set up details (e.g. bank account) for this Bank so deletion is not allowed
            PBankingDetailsTable BankingDetailsTable = new PBankingDetailsTable();
            PBankingDetailsRow BankingDetailsRow = BankingDetailsTable.NewRowTyped();
            BankingDetailsRow.BankKey = BankPartnerRow.PartnerKey;
            BankingDetailsRow.BankingType = 0;
            BankingDetailsRow.BankingDetailsKey = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_bank_details));
            BankingDetailsTable.Rows.Add(BankingDetailsRow);

            PBankingDetailsAccess.SubmitChanges(BankingDetailsTable, DBAccess.GDBAccessObj.Transaction);

            // now deletion must not be possible since a bank account is set up for the bank
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of venue partner
            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            PartnerKey = BankPartnerRow.PartnerKey;
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank partner for deletion");

            // check if Venue record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Bank record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
        private Int64 CreateNewPartnerKeyWithUnit()
        {
            TVerificationResultCollection VerificationResult;
            TSubmitChangesResult result;
            DataSet ResponseDS = new PartnerEditTDS();
            Int64 retVal = 0;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            PPartnerRow UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartnerWithTypeCode(MainDS, "KEY-MIN");

            if (UnitPartnerRow != null)
            {
                result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

                if (result == TSubmitChangesResult.scrOK)
                {
                    retVal = UnitPartnerRow.PartnerKey;
                }
            }

            return retVal;
        }
Пример #23
0
        public void TestSaveNewPartnerWithLocation()
        {
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS);

            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;

            TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "TPartnerEditUIConnector SubmitChanges return value");

            // check the location key for this partner. should not be negative
            Assert.AreEqual(1, MainDS.PPartnerLocation.Rows.Count, "TPartnerEditUIConnector SubmitChanges returns one location");
            Assert.Greater(MainDS.PPartnerLocation[0].LocationKey, 0, "TPartnerEditUIConnector SubmitChanges returns valid location key");
        }
        public void TestBankingDetails()
        {
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);

            TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS);

            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;

            TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving:");

            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "TPartnerEditUIConnector SubmitChanges return value");

            connector = new TPartnerEditUIConnector(PartnerRow.PartnerKey);

            // add a banking detail
            PartnerEditTDSPBankingDetailsRow bankingDetailsRow = MainDS.PBankingDetails.NewRowTyped(true);
            bankingDetailsRow.AccountName = "account of " + PartnerRow.PartnerShortName;
            bankingDetailsRow.BankAccountNumber = new Random().Next().ToString();
            bankingDetailsRow.BankingDetailsKey = (MainDS.PBankingDetails.Count + 1) * -1;
            bankingDetailsRow.BankKey = 43005004;
            bankingDetailsRow.MainAccount = true;
            bankingDetailsRow.BankingType = MPartnerConstants.BANKINGTYPE_BANKACCOUNT;
            MainDS.PBankingDetails.Rows.Add(bankingDetailsRow);

            PPartnerBankingDetailsRow partnerBankingDetails = MainDS.PPartnerBankingDetails.NewRowTyped(true);
            partnerBankingDetails.PartnerKey = PartnerRow.PartnerKey;
            partnerBankingDetails.BankingDetailsKey = bankingDetailsRow.BankingDetailsKey;
            MainDS.PPartnerBankingDetails.Rows.Add(partnerBankingDetails);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving 2:");

            foreach (DataTable t in MainDS.Tables)
            {
                if ((t == MainDS.PBankingDetails)
                    || (t == MainDS.PPartnerBankingDetails)
                    || (t == MainDS.PDataLabelValuePartner))
                {
                    int NumRows = t.Rows.Count;

                    for (int RowIndex = NumRows - 1; RowIndex >= 0; RowIndex -= 1)
                    {
                        DataRow InspectDR = t.Rows[RowIndex];

                        // delete all added Rows.
                        if (InspectDR.RowState == DataRowState.Added)
                        {
                            InspectDR.Delete();
                        }
                    }
                }
            }

            MainDS.AcceptChanges();

            Assert.AreEqual(1, PBankingDetailsUsageAccess.CountViaPPartner(PartnerRow.PartnerKey, null), "count of main accounts for partner");

            // add another account
            bankingDetailsRow = MainDS.PBankingDetails.NewRowTyped(true);
            bankingDetailsRow.AccountName = "2nd account of " + PartnerRow.PartnerShortName;
            bankingDetailsRow.BankAccountNumber = new Random().Next().ToString();
            bankingDetailsRow.BankingDetailsKey = (MainDS.PBankingDetails.Count + 1) * -1;
            bankingDetailsRow.BankKey = 43005004;
            bankingDetailsRow.MainAccount = false;
            bankingDetailsRow.BankingType = MPartnerConstants.BANKINGTYPE_BANKACCOUNT;
            MainDS.PBankingDetails.Rows.Add(bankingDetailsRow);

            partnerBankingDetails = MainDS.PPartnerBankingDetails.NewRowTyped(true);
            partnerBankingDetails.PartnerKey = PartnerRow.PartnerKey;
            partnerBankingDetails.BankingDetailsKey = bankingDetailsRow.BankingDetailsKey;
            MainDS.PPartnerBankingDetails.Rows.Add(partnerBankingDetails);

            PartnerEditTDS ChangedDS = MainDS.GetChangesTyped(true);
            result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult);
            MainDS.Merge(ChangedDS);

            foreach (DataTable t in MainDS.Tables)
            {
                if ((t == MainDS.PBankingDetails)
                    || (t == MainDS.PPartnerBankingDetails)
                    || (t == MainDS.PDataLabelValuePartner))
                {
                    int NumRows = t.Rows.Count;

                    for (int RowIndex = NumRows - 1; RowIndex >= 0; RowIndex -= 1)
                    {
                        DataRow InspectDR = t.Rows[RowIndex];

                        // delete all added Rows.
                        if (InspectDR.RowState == DataRowState.Added)
                        {
                            InspectDR.Delete();
                        }
                    }
                }
            }

            MainDS.AcceptChanges();

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving 3:");

            // now delete the main bank account
            PartnerEditTDSPBankingDetailsRow toDelete = null;

            foreach (PartnerEditTDSPBankingDetailsRow row in MainDS.PBankingDetails.Rows)
            {
                if (row.MainAccount)
                {
                    toDelete = row;
                    break;
                }
            }

            Assert.IsNotNull(toDelete, "cannot find main account");
            Assert.AreEqual(true, toDelete.MainAccount, "should be the main account");
            MainDS.PPartnerBankingDetails.Rows.Find(new object[] { PartnerRow.PartnerKey, toDelete.BankingDetailsKey }).Delete();
            toDelete.Delete();

            ChangedDS = MainDS.GetChangesTyped(true);
            result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult);

            Assert.AreEqual(1, VerificationResult.Count, "should fail because we have no main account anymore");
            Assert.AreEqual(
                "One Bank Account of a Partner must be set as the 'Main Account'. Please select the record that should become the 'Main Account' and choose 'Set Main Account'.",
                VerificationResult[0].ResultText,
                "should fail because we have no main account anymore");

            PartnerEditTDSPBankingDetailsRow otherAccount = null;

            foreach (PartnerEditTDSPBankingDetailsRow row in MainDS.PBankingDetails.Rows)
            {
                if ((row.RowState != DataRowState.Deleted) && !row.MainAccount)
                {
                    otherAccount = row;
                    break;
                }
            }

            otherAccount.MainAccount = true;

            ChangedDS = MainDS.GetChangesTyped(true);
            result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult);

            MainDS.Merge(ChangedDS);
            MainDS.AcceptChanges();

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving 4:");

            // now delete the last remaining bank account
            toDelete = MainDS.PBankingDetails[0];
            Assert.AreEqual(true, toDelete.MainAccount);
            MainDS.PPartnerBankingDetails.Rows.Find(new object[] { PartnerRow.PartnerKey, toDelete.BankingDetailsKey }).Delete();
            toDelete.Delete();
            ChangedDS = MainDS.GetChangesTyped(true);
            result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult);
            MainDS.Merge(ChangedDS);
            MainDS.AcceptChanges();

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                "There was a critical error when saving 5:");
        }