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

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

            mock.UnitPrice = TestUtility.Instance.RandomShort();
            mock.Quantity = TestUtility.Instance.RandomShort();
            mock.Discount = (float)TestUtility.Instance.RandomNumber();

            //OneToOneRelationship
            Orders mockOrdersByOrderId = OrdersTest.CreateMockInstance(tm);
            DataRepository.OrdersProvider.Insert(tm, mockOrdersByOrderId);
            mock.OrderId = mockOrdersByOrderId.OrderId;
            //OneToOneRelationship
            Products mockProductsByProductId = ProductsTest.CreateMockInstance(tm);
            DataRepository.ProductsProvider.Insert(tm, mockProductsByProductId);
            mock.ProductId = mockProductsByProductId.ProductId;

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

               return (OrderDetails)mock;
        }
Exemple #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(OrderDetails mock)
 {
     //Code your changes to the data object here.
 }
        ///<summary>
        ///  Update the Typed OrderDetails Entity with modified mock values.
        ///</summary>
        public static void UpdateMockInstance_Generated(TransactionManager tm, OrderDetails mock)
        {
            mock.UnitPrice = TestUtility.Instance.RandomShort();
            mock.Quantity = TestUtility.Instance.RandomShort();
            mock.Discount = (float)TestUtility.Instance.RandomNumber();

            //OneToOneRelationship
            Orders mockOrdersByOrderId = OrdersTest.CreateMockInstance(tm);
            DataRepository.OrdersProvider.Insert(tm, mockOrdersByOrderId);
            mock.OrderId = mockOrdersByOrderId.OrderId;

            //OneToOneRelationship
            Products mockProductsByProductId = ProductsTest.CreateMockInstance(tm);
            DataRepository.ProductsProvider.Insert(tm, mockProductsByProductId);
            mock.ProductId = mockProductsByProductId.ProductId;
        }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

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

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

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<OrderDetails> correctly serialized to a temporary file.");
            }
        }
        /// <summary>
        /// Serialize the mock OrderDetails 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_OrderDetails.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>
        /// Deep load all OrderDetails children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock =  CreateMockInstance(tm);
                mockCollection = DataRepository.OrderDetailsProvider.GetPaged(tm, 0, 10, out count);

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

                if (mockCollection.Count > 0)
                {

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

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

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