Example #1
0
        ///<summary>
        ///  Update the Typed Categories Entity with modified mock values.
        ///</summary>
        public static void UpdateMockInstance(TransactionManager tm, Categories mock)
        {
            CategoriesTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
        ///<summary>
        ///  Returns a Typed Categories Entity with mock values.
        ///</summary>
        public static Categories CreateMockInstance_Generated(TransactionManager tm)
        {
            Categories mock = new Categories();

            mock.CategoryName = TestUtility.Instance.RandomString(6, false);;
            mock.Description = TestUtility.Instance.RandomString(2, false);;
            mock.Picture = new byte[] { TestUtility.Instance.RandomByte() };

            // create a temporary collection and add the item to it
            TList<Categories> tempMockCollection = new TList<Categories>();
            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);

               return (Categories)mock;
        }
Example #3
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>
 private static void SetSpecialTestData(Categories mock)
 {
     //Code your changes to the data object here.
 }
 ///<summary>
 ///  Update the Typed Categories Entity with modified mock values.
 ///</summary>
 public static void UpdateMockInstance_Generated(TransactionManager tm, Categories mock)
 {
     mock.CategoryName = TestUtility.Instance.RandomString(6, false);;
     mock.Description = TestUtility.Instance.RandomString(2, false);;
     mock.Picture = new byte[] { TestUtility.Instance.RandomByte() };
 }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                Categories entity = mock.Copy() as Categories;
                entity = (Categories)mock.Clone();
                Assert.IsTrue(Categories.ValueEquals(entity, mock), "Clone is not working");
            }
        }
        /// <summary>
        /// Serialize a Categories 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_CategoriesCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<Categories> correctly serialized to a temporary file.");
            }
        }
        /// <summary>
        /// Serialize the mock Categories 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_Categories.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>
        /// Delete the mock Categories entity into the database.
        /// </summary>
        private void Step_05_Delete_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock =  (Categories)CreateMockInstance(tm);
                DataRepository.CategoriesProvider.Insert(tm, mock);

                Assert.IsTrue(DataRepository.CategoriesProvider.Delete(tm, mock), "Delete failed.");
                System.Console.WriteLine("DataRepository.CategoriesProvider.Delete(mock):");
                System.Console.WriteLine(mock);

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <summary>
        /// Deep load all Categories children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock =  CreateMockInstance(tm);
                mockCollection = DataRepository.CategoriesProvider.GetPaged(tm, 0, 10, out count);

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

                if (mockCollection.Count > 0)
                {

                    DataRepository.CategoriesProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("Categories instance correctly deep loaded at 1 level.");

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }