/// <summary>
        /// Deep load all Trcode children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.TrcodeProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.TrcodeProvider.DeepLoading += new EntityProviderBaseCore <Trcode, TrcodeKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.TrcodeProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("Trcode instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.TrcodeProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
Example #2
0
        ///<summary>
        ///  Update the Typed Trcode Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, Trcode mock)
        {
            TrcodeTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
        /// <summary>
        /// Check the foreign key dal methods.
        /// </summary>
        private void Step_10_FK_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                Trcode entity = CreateMockInstance(tm);
                bool   result = DataRepository.TrcodeProvider.Insert(tm, entity);

                Assert.IsTrue(result, "Could Not Test FK, Insert Failed");
            }
        }
 ///<summary>
 ///  Update the Typed Trcode Entity with modified mock values.
 ///</summary>
 static public void UpdateMockInstance_Generated(TransactionManager tm, Trcode mock)
 {
     mock.TrName       = TestUtility.Instance.RandomString(99, false);;
     mock.Description  = TestUtility.Instance.RandomString(2, false);;
     mock.TrDepart     = TestUtility.Instance.RandomString(1, false);;
     mock.FrmCaption   = TestUtility.Instance.RandomString(24, false);;
     mock.VoucherFile  = TestUtility.Instance.RandomString(9, false);;
     mock.VoucherFile1 = TestUtility.Instance.RandomString(9, false);;
     mock.VoucherFile2 = TestUtility.Instance.RandomString(9, false);;
     mock.Status       = TestUtility.Instance.RandomBoolean();
 }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                Trcode entity = mock.Copy() as Trcode;
                entity = (Trcode)mock.Clone();
                Assert.IsTrue(Trcode.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Example #6
0
        ///<summary>
        ///  Returns a Typed Trcode Entity with mock values.
        ///</summary>
        static public Trcode CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            Trcode mock = TrcodeTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }
        /// <summary>
        /// Serialize the mock Trcode entity into a temporary file.
        /// </summary>
        private void Step_06_SerializeEntity_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_Trcode.xml");

                EntityHelper.SerializeXml(mock, fileName);
                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found");

                System.Console.WriteLine("mock correctly serialized to a temporary file.");
            }
        }
        /// <summary>
        /// Inserts a mock Trcode entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.TrcodeProvider.Insert(tm, mock), "Insert failed");

                System.Console.WriteLine("DataRepository.TrcodeProvider.Insert(mock):");
                System.Console.WriteLine(mock);

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                Trcode mock   = CreateMockInstance(tm);
                bool   result = DataRepository.TrcodeProvider.Insert(tm, mock);

                Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed");

                TrcodeQuery query = new TrcodeQuery();

                query.AppendEquals(TrcodeColumn.TrCode, mock.TrCode.ToString());
                if (mock.TrName != null)
                {
                    query.AppendEquals(TrcodeColumn.TrName, mock.TrName.ToString());
                }
                query.AppendEquals(TrcodeColumn.Description, mock.Description.ToString());
                if (mock.TrDepart != null)
                {
                    query.AppendEquals(TrcodeColumn.TrDepart, mock.TrDepart.ToString());
                }
                if (mock.FrmCaption != null)
                {
                    query.AppendEquals(TrcodeColumn.FrmCaption, mock.FrmCaption.ToString());
                }
                if (mock.VoucherFile != null)
                {
                    query.AppendEquals(TrcodeColumn.VoucherFile, mock.VoucherFile.ToString());
                }
                if (mock.VoucherFile1 != null)
                {
                    query.AppendEquals(TrcodeColumn.VoucherFile1, mock.VoucherFile1.ToString());
                }
                if (mock.VoucherFile2 != null)
                {
                    query.AppendEquals(TrcodeColumn.VoucherFile2, mock.VoucherFile2.ToString());
                }
                if (mock.Status != null)
                {
                    query.AppendEquals(TrcodeColumn.Status, mock.Status.ToString());
                }

                TList <Trcode> results = DataRepository.TrcodeProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
        /// <summary>
        /// Serialize a Trcode collection into a temporary file.
        /// </summary>
        private void Step_08_SerializeCollection_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_TrcodeCollection.xml");

                mock = CreateMockInstance(tm);
                TList <Trcode> mockCollection = new TList <Trcode>();
                mockCollection.Add(mock);

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<Trcode> correctly serialized to a temporary file.");
            }
        }
        ///<summary>
        ///  Returns a Typed Trcode Entity with mock values.
        ///</summary>
        static public Trcode CreateMockInstance_Generated(TransactionManager tm)
        {
            Trcode mock = new Trcode();

            mock.TrCode       = TestUtility.Instance.RandomString(2, false);;
            mock.TrName       = TestUtility.Instance.RandomString(99, false);;
            mock.Description  = TestUtility.Instance.RandomString(2, false);;
            mock.TrDepart     = TestUtility.Instance.RandomString(1, false);;
            mock.FrmCaption   = TestUtility.Instance.RandomString(24, false);;
            mock.VoucherFile  = TestUtility.Instance.RandomString(9, false);;
            mock.VoucherFile1 = TestUtility.Instance.RandomString(9, false);;
            mock.VoucherFile2 = TestUtility.Instance.RandomString(9, false);;
            mock.Status       = TestUtility.Instance.RandomBoolean();


            // create a temporary collection and add the item to it
            TList <Trcode> tempMockCollection = new TList <Trcode>();

            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);


            return((Trcode)mock);
        }
Example #12
0
 /// <summary>
 /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.)
 /// </summary>
 /// <param name="mock">Object to be modified</param>
 static private void SetSpecialTestData(Trcode mock)
 {
     //Code your changes to the data object here.
 }