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

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

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
 ///<summary>
 ///  Update the Typed ModePayment Entity with modified mock values.
 ///</summary>
 static public void UpdateMockInstance_Generated(TransactionManager tm, ModePayment mock)
 {
     mock.Description = TestUtility.Instance.RandomString(49, false);;
     mock.ForexRate   = (decimal)TestUtility.Instance.RandomShort();
     mock.Iscard      = TestUtility.Instance.RandomString(1, false);;
     mock.Status      = TestUtility.Instance.RandomBoolean();
 }
Пример #3
0
        ///<summary>
        ///  Update the Typed ModePayment Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, ModePayment mock)
        {
            ModePaymentTest.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())
            {
                ModePayment entity = CreateMockInstance(tm);
                bool        result = DataRepository.ModePaymentProvider.Insert(tm, entity);

                Assert.IsTrue(result, "Could Not Test FK, Insert Failed");
            }
        }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                ModePayment entity = mock.Copy() as ModePayment;
                entity = (ModePayment)mock.Clone();
                Assert.IsTrue(ModePayment.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Пример #6
0
        ///<summary>
        ///  Returns a Typed ModePayment Entity with mock values.
        ///</summary>
        static public ModePayment CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            ModePayment mock = ModePaymentTest.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>
        /// Check the indexes dal methods.
        /// </summary>
        private void Step_11_IX_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                ModePayment entity = CreateMockInstance(tm);
                bool        result = DataRepository.ModePaymentProvider.Insert(tm, entity);

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


                ModePayment t0 = DataRepository.ModePaymentProvider.GetByPmtModeForex(tm, entity.PmtMode, entity.Forex);
            }
        }
        /// <summary>
        /// Serialize the mock ModePayment 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_ModePayment.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 ModePayment entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.ModePaymentProvider.Insert(tm, mock), "Insert failed");

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <summary>
        /// Serialize a ModePayment 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_ModePaymentCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

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

            mock.PmtMode     = TestUtility.Instance.RandomString(10, false);;
            mock.Description = TestUtility.Instance.RandomString(49, false);;
            mock.Forex       = TestUtility.Instance.RandomString(3, false);;
            mock.ForexRate   = (decimal)TestUtility.Instance.RandomShort();
            mock.Iscard      = TestUtility.Instance.RandomString(1, false);;
            mock.Status      = TestUtility.Instance.RandomBoolean();


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

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


            return((ModePayment)mock);
        }
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                ModePayment mock   = CreateMockInstance(tm);
                bool        result = DataRepository.ModePaymentProvider.Insert(tm, mock);

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

                ModePaymentQuery query = new ModePaymentQuery();

                query.AppendEquals(ModePaymentColumn.PmtMode, mock.PmtMode.ToString());
                if (mock.Description != null)
                {
                    query.AppendEquals(ModePaymentColumn.Description, mock.Description.ToString());
                }
                query.AppendEquals(ModePaymentColumn.Forex, mock.Forex.ToString());
                if (mock.ForexRate != null)
                {
                    query.AppendEquals(ModePaymentColumn.ForexRate, mock.ForexRate.ToString());
                }
                if (mock.Iscard != null)
                {
                    query.AppendEquals(ModePaymentColumn.Iscard, mock.Iscard.ToString());
                }
                if (mock.Status != null)
                {
                    query.AppendEquals(ModePaymentColumn.Status, mock.Status.ToString());
                }

                TList <ModePayment> results = DataRepository.ModePaymentProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
Пример #13
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(ModePayment mock)
 {
     //Code your changes to the data object here.
 }