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

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

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
示例#2
0
        ///<summary>
        ///  Update the Typed MofSys Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, MofSys mock)
        {
            MofSysTest.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())
            {
                MofSys entity = CreateMockInstance(tm);
                bool   result = DataRepository.MofSysProvider.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);

                MofSys entity = mock.Copy() as MofSys;
                entity = (MofSys)mock.Clone();
                Assert.IsTrue(MofSys.ValueEquals(entity, mock), "Clone is not working");
            }
        }
 ///<summary>
 ///  Update the Typed MofSys Entity with modified mock values.
 ///</summary>
 static public void UpdateMockInstance_Generated(TransactionManager tm, MofSys mock)
 {
     mock.MofGl     = TestUtility.Instance.RandomString(4, false);;
     mock.MofName   = TestUtility.Instance.RandomString(126, false);;
     mock.MofNameb  = TestUtility.Instance.RandomString(99, false);;
     mock.AcType    = TestUtility.Instance.RandomString(1, false);;
     mock.Negative  = TestUtility.Instance.RandomString(1, false);;
     mock.Master    = TestUtility.Instance.RandomBoolean();
     mock.Glevel    = TestUtility.Instance.RandomNumber();
     mock.LastLevel = TestUtility.Instance.RandomBoolean();
     mock.OtherEqui = TestUtility.Instance.RandomString(126, false);;
 }
示例#6
0
        ///<summary>
        ///  Returns a Typed MofSys Entity with mock values.
        ///</summary>
        static public MofSys CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            MofSys mock = MofSysTest.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 MofSys 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_MofSys.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>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                MofSys mock   = CreateMockInstance(tm);
                bool   result = DataRepository.MofSysProvider.Insert(tm, mock);

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

                MofSysQuery query = new MofSysQuery();

                query.AppendEquals(MofSysColumn.Id, mock.Id.ToString());
                query.AppendEquals(MofSysColumn.MofGl, mock.MofGl.ToString());
                if (mock.MofName != null)
                {
                    query.AppendEquals(MofSysColumn.MofName, mock.MofName.ToString());
                }
                if (mock.MofNameb != null)
                {
                    query.AppendEquals(MofSysColumn.MofNameb, mock.MofNameb.ToString());
                }
                if (mock.AcType != null)
                {
                    query.AppendEquals(MofSysColumn.AcType, mock.AcType.ToString());
                }
                if (mock.Negative != null)
                {
                    query.AppendEquals(MofSysColumn.Negative, mock.Negative.ToString());
                }
                if (mock.Master != null)
                {
                    query.AppendEquals(MofSysColumn.Master, mock.Master.ToString());
                }
                if (mock.Glevel != null)
                {
                    query.AppendEquals(MofSysColumn.Glevel, mock.Glevel.ToString());
                }
                query.AppendEquals(MofSysColumn.LastLevel, mock.LastLevel.ToString());
                if (mock.OtherEqui != null)
                {
                    query.AppendEquals(MofSysColumn.OtherEqui, mock.OtherEqui.ToString());
                }

                TList <MofSys> results = DataRepository.MofSysProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
        /// <summary>
        /// Inserts a mock MofSys entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.MofSysProvider.Insert(tm, mock), "Insert failed");

                System.Console.WriteLine("DataRepository.MofSysProvider.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 MofSys 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_MofSysCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

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

            mock.MofGl     = TestUtility.Instance.RandomString(4, false);;
            mock.MofName   = TestUtility.Instance.RandomString(126, false);;
            mock.MofNameb  = TestUtility.Instance.RandomString(99, false);;
            mock.AcType    = TestUtility.Instance.RandomString(1, false);;
            mock.Negative  = TestUtility.Instance.RandomString(1, false);;
            mock.Master    = TestUtility.Instance.RandomBoolean();
            mock.Glevel    = TestUtility.Instance.RandomNumber();
            mock.LastLevel = TestUtility.Instance.RandomBoolean();
            mock.OtherEqui = TestUtility.Instance.RandomString(126, false);;


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

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


            return((MofSys)mock);
        }
示例#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(MofSys mock)
 {
     //Code your changes to the data object here.
 }