Inheritance: System.Web.UI.Page
Exemple #1
0
        /// <summary>
        /// Deep load all NullFkeyParent children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.NullFkeyParentProvider.GetPaged(tm, 0, 10, out count);

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

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

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

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

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

                Assert.IsTrue(result, "Could Not Test FK, Insert Failed");
            }
        }
        ///<summary>
        ///  Update the Typed NullFkeyChild Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance_Generated(TransactionManager tm, NullFkeyChild mock)
        {
            mock.SomeText = TestUtility.Instance.RandomString(24, false);;

            //OneToOneRelationship
            NullFkeyParent mockNullFkeyParentByNullFkeyParentId = NullFkeyParentTest.CreateMockInstance(tm);

            DataRepository.NullFkeyParentProvider.Insert(tm, mockNullFkeyParentByNullFkeyParentId);
            mock.NullFkeyParentId = mockNullFkeyParentByNullFkeyParentId.NullFkeyParentId;
        }
Exemple #5
0
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                NullFkeyParent entity = mock.Copy() as NullFkeyParent;
                entity = (NullFkeyParent)mock.Clone();
                Assert.IsTrue(NullFkeyParent.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Exemple #6
0
        ///<summary>
        ///  Returns a Typed NullFkeyParent Entity with mock values.
        ///</summary>
        static public NullFkeyParent CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            NullFkeyParent mock = NullFkeyParentTest.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);
        }
Exemple #7
0
        /// <summary>
        /// Serialize the mock NullFkeyParent 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_NullFkeyParent.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.");
            }
        }
Exemple #8
0
        /// <summary>
        /// Inserts a mock NullFkeyParent entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.NullFkeyParentProvider.Insert(tm, mock), "Insert failed");

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

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

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

                EntityHelper.SerializeXml(mockCollection, fileName);

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

            mock.NullFkeyParentId = TestUtility.Instance.RandomNumber();
            mock.SomeText         = TestUtility.Instance.RandomString(24, false);;


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

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


            return((NullFkeyParent)mock);
        }
Exemple #11
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.NullFkeyChild"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.NullFkeyChild Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.NullFkeyChild entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region NullFkeyParentIdSource
            if (CanDeepLoad(entity, "NullFkeyParent|NullFkeyParentIdSource", deepLoadType, innerList) &&
                entity.NullFkeyParentIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.NullFkeyParentId ?? (int)0);
                NullFkeyParent tmpEntity = EntityManager.LocateEntity <NullFkeyParent>(EntityLocator.ConstructKeyFromPkItems(typeof(NullFkeyParent), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.NullFkeyParentIdSource = tmpEntity;
                }
                else
                {
                    entity.NullFkeyParentIdSource = DataRepository.NullFkeyParentProvider.GetByNullFkeyParentId(transactionManager, (entity.NullFkeyParentId ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'NullFkeyParentIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.NullFkeyParentIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.NullFkeyParentProvider.DeepLoad(transactionManager, entity.NullFkeyParentIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion NullFkeyParentIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        ///<summary>
        ///  Returns a Typed NullFkeyChild Entity with mock values.
        ///</summary>
        static public NullFkeyChild CreateMockInstance_Generated(TransactionManager tm)
        {
            NullFkeyChild mock = new NullFkeyChild();

            mock.NullFkeyChildId = TestUtility.Instance.RandomNumber();
            mock.SomeText        = TestUtility.Instance.RandomString(24, false);;

            //OneToOneRelationship
            NullFkeyParent mockNullFkeyParentByNullFkeyParentId = NullFkeyParentTest.CreateMockInstance(tm);

            DataRepository.NullFkeyParentProvider.Insert(tm, mockNullFkeyParentByNullFkeyParentId);
            mock.NullFkeyParentId = mockNullFkeyParentByNullFkeyParentId.NullFkeyParentId;

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

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


            return((NullFkeyChild)mock);
        }
Exemple #13
0
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                NullFkeyParent mock   = CreateMockInstance(tm);
                bool           result = DataRepository.NullFkeyParentProvider.Insert(tm, mock);

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

                NullFkeyParentQuery query = new NullFkeyParentQuery();

                query.AppendEquals(NullFkeyParentColumn.NullFkeyParentId, mock.NullFkeyParentId.ToString());
                if (mock.SomeText != null)
                {
                    query.AppendEquals(NullFkeyParentColumn.SomeText, mock.SomeText.ToString());
                }

                TList <NullFkeyParent> results = DataRepository.NullFkeyParentProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
Exemple #14
0
 ///<summary>
 ///  Update the Typed NullFkeyParent Entity with modified mock values.
 ///</summary>
 static public void UpdateMockInstance_Generated(TransactionManager tm, NullFkeyParent mock)
 {
     mock.SomeText = TestUtility.Instance.RandomString(24, false);;
 }
Exemple #15
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(NullFkeyParent mock)
 {
     //Code your changes to the data object here.
 }