コード例 #1
0
ファイル: SuppliersTest.cs プロジェクト: jdaigle/nettiers
        ///<summary>
        ///  Update the Typed Suppliers Entity with modified mock values.
        ///</summary>
        public static void UpdateMockInstance(TransactionManager tm, Suppliers mock)
        {
            SuppliersTest.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 Suppliers Entity with mock values.
        ///</summary>
        public static Suppliers CreateMockInstance_Generated(TransactionManager tm)
        {
            Suppliers mock = new Suppliers();

            mock.CompanyName = TestUtility.Instance.RandomString(19, false);;
            mock.ContactName = TestUtility.Instance.RandomString(14, false);;
            mock.ContactTitle = TestUtility.Instance.RandomString(14, false);;
            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.Phone = TestUtility.Instance.RandomString(11, false);;
            mock.Fax = TestUtility.Instance.RandomString(11, false);;
            mock.HomePage = TestUtility.Instance.RandomString(2, false);;

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

               return (Suppliers)mock;
        }
コード例 #3
0
 ///<summary>
 ///  Update the Typed Suppliers Entity with modified mock values.
 ///</summary>
 public static void UpdateMockInstance_Generated(TransactionManager tm, Suppliers mock)
 {
     mock.CompanyName = TestUtility.Instance.RandomString(19, false);;
     mock.ContactName = TestUtility.Instance.RandomString(14, false);;
     mock.ContactTitle = TestUtility.Instance.RandomString(14, false);;
     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.Phone = TestUtility.Instance.RandomString(11, false);;
     mock.Fax = TestUtility.Instance.RandomString(11, false);;
     mock.HomePage = TestUtility.Instance.RandomString(2, false);;
 }
コード例 #4
0
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                Suppliers entity = mock.Copy() as Suppliers;
                entity = (Suppliers)mock.Clone();
                Assert.IsTrue(Suppliers.ValueEquals(entity, mock), "Clone is not working");
            }
        }
コード例 #5
0
        /// <summary>
        /// Serialize a Suppliers 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_SuppliersCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

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

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

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

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

                if (mockCollection.Count > 0)
                {

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
コード例 #9
0
ファイル: SuppliersTest.cs プロジェクト: jdaigle/nettiers
 /// <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(Suppliers mock)
 {
     //Code your changes to the data object here.
 }