Пример #1
0
        ///<summary>
        ///  Update the Typed Employees Entity with modified mock values.
        ///</summary>
        public static void UpdateMockInstance(TransactionManager tm, Employees mock)
        {
            EmployeesTest.UpdateMockInstance_Generated(tm, mock);

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

            mock.LastName = TestUtility.Instance.RandomString(9, false);;
            mock.FirstName = TestUtility.Instance.RandomString(10, false);;
            mock.Title = TestUtility.Instance.RandomString(14, false);;
            mock.TitleOfCourtesy = TestUtility.Instance.RandomString(11, false);;
            mock.BirthDate = TestUtility.Instance.RandomDateTime();
            mock.HireDate = TestUtility.Instance.RandomDateTime();
            mock.Address = TestUtility.Instance.RandomString(29, false);;
            mock.City = TestUtility.Instance.RandomString(6, false);;
            mock.Region = TestUtility.Instance.RandomString(6, false);;
            mock.PostalCode = TestUtility.Instance.RandomString(10, false);;
            mock.Country = TestUtility.Instance.RandomString(6, false);;
            mock.HomePhone = TestUtility.Instance.RandomString(11, false);;
            mock.Extension = TestUtility.Instance.RandomString(4, false);;
            mock.Photo = new byte[] { TestUtility.Instance.RandomByte() };
            mock.Notes = TestUtility.Instance.RandomString(2, false);;
            mock.PhotoPath = TestUtility.Instance.RandomString(126, false);;

            int count0 = 0;
            TList<Employees> _collection0 = DataRepository.EmployeesProvider.GetPaged(tm, 0, 10, out count0);
            //_collection0.Shuffle();
            if (_collection0.Count > 0)
            {
                mock.ReportsTo = _collection0[0].EmployeeId;

            }

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

               return (Employees)mock;
        }
Пример #3
0
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                Employees entity = mock.Copy() as Employees;
                entity = (Employees)mock.Clone();
                Assert.IsTrue(Employees.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Пример #4
0
        /// <summary>
        /// Serialize a Employees 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_EmployeesCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<Employees> correctly serialized to a temporary file.");
            }
        }
Пример #5
0
        /// <summary>
        /// Serialize the mock Employees 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_Employees.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.");
            }
        }
Пример #6
0
        /// <summary>
        /// Delete the mock Employees entity into the database.
        /// </summary>
        private void Step_05_Delete_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock =  (Employees)CreateMockInstance(tm);
                DataRepository.EmployeesProvider.Insert(tm, mock);

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

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

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

                if (mockCollection.Count > 0)
                {

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
Пример #8
0
        ///<summary>
        ///  Update the Typed Employees Entity with modified mock values.
        ///</summary>
        public static void UpdateMockInstance_Generated(TransactionManager tm, Employees mock)
        {
            mock.LastName = TestUtility.Instance.RandomString(9, false);;
            mock.FirstName = TestUtility.Instance.RandomString(10, false);;
            mock.Title = TestUtility.Instance.RandomString(14, false);;
            mock.TitleOfCourtesy = TestUtility.Instance.RandomString(11, false);;
            mock.BirthDate = TestUtility.Instance.RandomDateTime();
            mock.HireDate = TestUtility.Instance.RandomDateTime();
            mock.Address = TestUtility.Instance.RandomString(29, false);;
            mock.City = TestUtility.Instance.RandomString(6, false);;
            mock.Region = TestUtility.Instance.RandomString(6, false);;
            mock.PostalCode = TestUtility.Instance.RandomString(10, false);;
            mock.Country = TestUtility.Instance.RandomString(6, false);;
            mock.HomePhone = TestUtility.Instance.RandomString(11, false);;
            mock.Extension = TestUtility.Instance.RandomString(4, false);;
            mock.Photo = new byte[] { TestUtility.Instance.RandomByte() };
            mock.Notes = TestUtility.Instance.RandomString(2, false);;
            mock.PhotoPath = TestUtility.Instance.RandomString(126, false);;

            int count0 = 0;
            TList<Employees> _collection0 = DataRepository.EmployeesProvider.GetPaged(tm, 0, 10, out count0);
            //_collection0.Shuffle();
            if (_collection0.Count > 0)
            {
                mock.ReportsTo = _collection0[0].EmployeeId;
            }
        }
Пример #9
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(Employees mock)
 {
     //Code your changes to the data object here.
 }