Exemplo n.º 1
0
        public void TestAcceptanceTransactionLog_DB_NewContactPerson()
        {
            //Test that the transaction log
            //---------------Set up test pack-------------------
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();
            TransactionCommitterDB          tc = new TransactionCommitterDB(DatabaseConnection.CurrentConnection);

            tc.AddBusinessObject(cp);
            string dirtyXML = cp.DirtyXML;

            //---------------Execute Test ----------------------
            tc.CommitTransaction();
            //---------------Test Result -----------------------
            //Test that a transaction Log was created with
            BusinessObjectCollection <TransactionLogBusObj> colTransactions =
                new BusinessObjectCollection <TransactionLogBusObj>();

            colTransactions.LoadAll("TransactionSequenceNo");

            //CRUD = Insert and Dirty XML all properties in DirtyXML.
            Assert.IsTrue(colTransactions.Count > 0);
            TransactionLogBusObj trLog = colTransactions[colTransactions.Count - 1];

            Assert.AreEqual("Created", trLog.CrudAction);
            Assert.AreEqual(dirtyXML, trLog.DirtyXMLLog);
            Assert.AreEqual("ContactPersonTransactionLogging", trLog.BusinessObjectTypeName);
            //Assert.AreEqual(WindowsIdentity.GetCurrent().Name, trLog.WindowsUser);
            Assert.AreEqual(Environment.MachineName, trLog.MachineUpdatedName);
            //Assert.GreaterOrEqual(trLog.DateTimeUpdated, DateTime.Now.AddMinutes(-1));
            Assert.LessOrEqual(trLog.DateTimeUpdated, DateTime.Now.AddSeconds(1));
            Assert.AreEqual(cp.ToString(), trLog.BusinessObjectToString);
            //---------------Tear Down -------------------------
        }
Exemplo n.º 2
0
        public void TestAcceptanceTransactionLog_SaveMultipleTimes()
        {
            //---------------Cleanup databse ------------------
            CleanDB();
            //---------------Set up test pack-------------------
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();

            cp.Save();
            //---------------Execute Test ----------------------
            cp.Surname = Guid.NewGuid().ToString();
            cp.Save();
            cp.Surname = Guid.NewGuid().ToString();
            cp.Save();
            cp.Surname = Guid.NewGuid().ToString();
            cp.Save();
            cp.Surname = Guid.NewGuid().ToString();
            cp.Save();
            cp.MarkForDelete();
            cp.Save();
            BusinessObjectCollection <TransactionLogBusObj> colTransactions =
                new BusinessObjectCollection <TransactionLogBusObj>();

            colTransactions.LoadAll();
            //cp = CreateUnsavedContactPersonTransactionLogging();
            //cp.Save();
            //---------------Test Result -----------------------
            //Test that a transaction Log was created with
            Assert.AreEqual(6, colTransactions.Count);


            //---------------Tear Down -------------------------
        }
Exemplo n.º 3
0
        private static ContactPersonTransactionLogging CreateUnsavedContactPersonTransactionLogging()
        {
            ContactPersonTransactionLogging cp = new ContactPersonTransactionLogging();

            cp.Surname = Guid.NewGuid().ToString();
            return(cp);
        }
Exemplo n.º 4
0
        public void TestAcceptanceTransactionLog_DB_DeleteContactPerson()
        {
            //---------------Set up test pack-------------------
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();
            TransactionCommitterDB          tc = new TransactionCommitterDB(DatabaseConnection.CurrentConnection);

            tc.AddBusinessObject(cp);
            tc.CommitTransaction();
            cp.MarkForDelete();
            tc = new TransactionCommitterDB(DatabaseConnection.CurrentConnection);
            tc.AddBusinessObject(cp);
            //---------------Execute Test ----------------------
            tc.CommitTransaction();
            //---------------Test Result -----------------------
            //Test that a transaction Log was created with
            var colTransactions =
                new BusinessObjectCollection <TransactionLogBusObj>();

            colTransactions.LoadAll("TransactionSequenceNo");

            //CRUD = Insert and Dirty XML all properties in DirtyXML.
            Assert.IsTrue(colTransactions.Count > 0);
            var trLog = colTransactions[colTransactions.Count - 1];

            //CRUD = Deleted
            Assert.AreEqual("Deleted", trLog.CrudAction);

            //---------------Tear Down -------------------------
        }
Exemplo n.º 5
0
 public void TestFixtureSetup()
 {
     //Code that is executed before any test is run in this class. If multiple tests
     // are executed then it will still only be called once.
     base.SetupDBConnection();
     ClassDef.ClassDefs.Clear();
     ContactPersonTransactionLogging.LoadDefaultClassDef();
     TransactionLogBusObj.LoadClassDef();
 }
Exemplo n.º 6
0
        public void TestDirtyXml()
        {
            ContactPersonTransactionLogging myContact_1 = new ContactPersonTransactionLogging();

            //Edit first object and save
            myContact_1.Surname = "My Surname 1";
            myContact_1.Save(); //

            myContact_1.Surname = "My Surname New";

            Assert.AreEqual(
                "<ContactPersonTransactionLogging ID='" + myContact_1.ID +
                "'><Properties><Surname><PreviousValue>My Surname 1</PreviousValue><NewValue>My Surname New</NewValue></Surname></Properties></ContactPersonTransactionLogging>",
                myContact_1.DirtyXML);
        }
Exemplo n.º 7
0
        public void TestTransactionLogTransactionNotAddedToTransactionCommitter()
        {
            //---------------Set up test pack-------------------
            //Create Mock Business object that implements a stub transaction log.
            ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging();
            TransactionCommitterStub        tc = new TransactionCommitterStub();

            tc.AddBusinessObject(cp);
            Assert.AreEqual(1, tc.OriginalTransactions.Count);
            //---------------Execute Test ----------------------
            //call persist on the object
            tc.CommitTransaction();
            //---------------Test Result -----------------------
            //check that the transaction committer has 1 object
            // i.e. the transaction log object was not added to the transaction.
            Assert.AreEqual(1, tc.ExecutedTransactions.Count);
        }
Exemplo n.º 8
0
        public void TestAcceptanceTransactionLog_DuplicateAlternativeKeyEntries()
        {
            //---------------Cleanup databse ------------------
            CleanDB();
            ClassDef.ClassDefs.Clear();
            ContactPersonTransactionLogging.LoadClassDef_SurnameAlternateKey();
            //---------------Set up test pack-------------------
            ContactPersonTransactionLogging cp1 = CreateUnsavedContactPersonTransactionLogging();
            const string AltSurname             = "TestAltKey";

            cp1.Surname = AltSurname;
            ContactPersonTransactionLogging cp2 = CreateUnsavedContactPersonTransactionLogging();

            cp2.Surname = AltSurname;

            //---------------Execute Test ----------------------
            TransactionCommitterDB tc = new TransactionCommitterDB(DatabaseConnection.CurrentConnection);

            tc.AddBusinessObject(cp1);
            tc.AddBusinessObject(cp2);
            try
            {
                tc.CommitTransaction();
                Assert.Fail(
                    "The transaction should not be committed as there are 2 objects in the transaction with the same alternate key");
            }

            //---------------Test Result -----------------------
            catch (BusObjDuplicateConcurrencyControlException)
            {
            }

            //---------------Tear Down -------------------------
            finally
            {
                const string sql = "DELETE FROM Contact_Person where Surname_field = '" + AltSurname + "'";
                DatabaseConnection.CurrentConnection.ExecuteRawSql(sql);
            }
        }
Exemplo n.º 9
0
 private static ContactPersonTransactionLogging CreateUnsavedContactPersonTransactionLogging()
 {
     ContactPersonTransactionLogging cp = new ContactPersonTransactionLogging();
     cp.Surname = Guid.NewGuid().ToString();
     return cp;
 }
Exemplo n.º 10
0
        public void TestDirtyXml()
        {
            ContactPersonTransactionLogging myContact_1 = new ContactPersonTransactionLogging();
            //Edit first object and save
            myContact_1.Surname = "My Surname 1";
            myContact_1.Save(); //

            myContact_1.Surname = "My Surname New";

            Assert.AreEqual(
                "<ContactPersonTransactionLogging ID='" + myContact_1.ID +
                "'><Properties><Surname><PreviousValue>My Surname 1</PreviousValue><NewValue>My Surname New</NewValue></Surname></Properties></ContactPersonTransactionLogging>",
                myContact_1.DirtyXML);
        }