Inheritance: System.Web.UI.Page
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                TransactionHistoryArchive mock = CreateMockInstance(tm);
                bool result = DataRepository.TransactionHistoryArchiveProvider.Insert(tm, mock);

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

                TransactionHistoryArchiveQuery query = new TransactionHistoryArchiveQuery();

                query.AppendEquals(TransactionHistoryArchiveColumn.TransactionId, mock.TransactionId.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.ProductId, mock.ProductId.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.ReferenceOrderId, mock.ReferenceOrderId.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.ReferenceOrderLineId, mock.ReferenceOrderLineId.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.TransactionDate, mock.TransactionDate.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.TransactionType, mock.TransactionType.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.Quantity, mock.Quantity.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.ActualCost, mock.ActualCost.ToString());
                query.AppendEquals(TransactionHistoryArchiveColumn.ModifiedDate, mock.ModifiedDate.ToString());

                TList <TransactionHistoryArchive> results = DataRepository.TransactionHistoryArchiveProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
        /// <summary>
        /// Deep load all TransactionHistoryArchive children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.TransactionHistoryArchiveProvider.GetPaged(tm, 0, 10, out count);

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

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <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(TransactionHistoryArchive mock)
        {
            //Code your changes to the data object here.
            int randomNum = TestUtility.Instance.RandomNumber(1, 3);

            switch (randomNum)
            {
            case 1:
                mock.TransactionType = "P";
                break;

            case 2:
                mock.TransactionType = "S";
                break;

            case 3:
                mock.TransactionType = "W";
                break;

            default:
                mock.TransactionType = "P";
                break;
            }

            //The TransactionID is not an Identity for this table.  So choose a big number
            randomNum          = TestUtility.Instance.RandomNumber(1000000, 2000000);
            mock.TransactionId = randomNum;
        }
        ///<summary>
        ///  Update the Typed TransactionHistoryArchive Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, TransactionHistoryArchive mock)
        {
            TransactionHistoryArchiveTest.UpdateMockInstance_Generated(tm, mock);

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

                Assert.IsTrue(result, "Could Not Test FK, Insert Failed");
            }
        }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                TransactionHistoryArchive entity = mock.Copy() as TransactionHistoryArchive;
                entity = (TransactionHistoryArchive)mock.Clone();
                Assert.IsTrue(TransactionHistoryArchive.ValueEquals(entity, mock), "Clone is not working");
            }
        }
 ///<summary>
 ///  Update the Typed TransactionHistoryArchive Entity with modified mock values.
 ///</summary>
 static public void UpdateMockInstance_Generated(TransactionManager tm, TransactionHistoryArchive mock)
 {
     mock.ProductId            = TestUtility.Instance.RandomNumber();
     mock.ReferenceOrderId     = TestUtility.Instance.RandomNumber();
     mock.ReferenceOrderLineId = TestUtility.Instance.RandomNumber();
     mock.TransactionDate      = TestUtility.Instance.RandomDateTime();
     mock.TransactionType      = TestUtility.Instance.RandomString(1, false);;
     mock.Quantity             = TestUtility.Instance.RandomNumber();
     mock.ActualCost           = TestUtility.Instance.RandomShort();
     mock.ModifiedDate         = TestUtility.Instance.RandomDateTime();
 }
        // PUT api/awbuildversion/5
        public void Put(TransactionHistoryArchive value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.TransactionHistoryArchiveDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.TransactionHistoryArchiveUpdate(value);
            }
        }
        ///<summary>
        ///  Returns a Typed TransactionHistoryArchive Entity with mock values.
        ///</summary>
        static public TransactionHistoryArchive CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            TransactionHistoryArchive mock = TransactionHistoryArchiveTest.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);
        }
        /// <summary>
        /// Serialize the mock TransactionHistoryArchive 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_TransactionHistoryArchive.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.");
            }
        }
Ejemplo n.º 11
0
 public bool TransactionHistoryArchiveDelete(TransactionHistoryArchive transactionhistoryarchive)
 {
     return(Execute <bool>(dal =>
     {
         TransactionHistoryArchive transactionhistoryarchiveDelete = dal.TransactionHistoryArchive.Where(x => x.TransactionID == transactionhistoryarchive.TransactionID).FirstOrDefault();
         if (transactionhistoryarchiveDelete != null)
         {
             dal.TransactionHistoryArchive.DeleteOnSubmit(transactionhistoryarchiveDelete);
             dal.SubmitChanges();
             return true;
         }
         return false;
     }));
 }
        public void MapEFToBOList()
        {
            var mapper = new DALTransactionHistoryArchiveMapper();
            TransactionHistoryArchive entity = new TransactionHistoryArchive();

            entity.SetProperties(1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");

            List <BOTransactionHistoryArchive> response = mapper.MapEFToBO(new List <TransactionHistoryArchive>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
        /// <summary>
        /// Inserts a mock TransactionHistoryArchive entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.TransactionHistoryArchiveProvider.Insert(tm, mock), "Insert failed");

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <summary>
        /// Check the indexes dal methods.
        /// </summary>
        private void Step_11_IX_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                TransactionHistoryArchive entity = CreateMockInstance(tm);
                bool result = DataRepository.TransactionHistoryArchiveProvider.Insert(tm, entity);

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


                TList <TransactionHistoryArchive> t0 = DataRepository.TransactionHistoryArchiveProvider.GetByProductId(tm, entity.ProductId);
                TList <TransactionHistoryArchive> t1 = DataRepository.TransactionHistoryArchiveProvider.GetByReferenceOrderIdReferenceOrderLineId(tm, entity.ReferenceOrderId, entity.ReferenceOrderLineId);
                TransactionHistoryArchive         t2 = DataRepository.TransactionHistoryArchiveProvider.GetByTransactionId(tm, entity.TransactionId);
            }
        }
        /// <summary>
        /// Serialize a TransactionHistoryArchive 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_TransactionHistoryArchiveCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<TransactionHistoryArchive> correctly serialized to a temporary file.");
            }
        }
        // PUT api/awbuildversion/5
        public void Put(TransactionHistoryArchive value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                {
                    adventureWorks_BC.TransactionHistoryArchiveDelete(value);
                }
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                {
                    adventureWorks_BC.TransactionHistoryArchiveUpdate(value);
                }
            }
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <ITransactionHistoryArchiveRepository>();
            var record = new TransactionHistoryArchive();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new TransactionHistoryArchiveService(mock.LoggerMock.Object,
                                                               mock.RepositoryMock.Object,
                                                               mock.ModelValidatorMockFactory.TransactionHistoryArchiveModelValidatorMock.Object,
                                                               mock.BOLMapperMockFactory.BOLTransactionHistoryArchiveMapperMock,
                                                               mock.DALMapperMockFactory.DALTransactionHistoryArchiveMapperMock);

            ApiTransactionHistoryArchiveResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public virtual BOTransactionHistoryArchive MapEFToBO(
            TransactionHistoryArchive ef)
        {
            var bo = new BOTransactionHistoryArchive();

            bo.SetProperties(
                ef.TransactionID,
                ef.ActualCost,
                ef.ModifiedDate,
                ef.ProductID,
                ef.Quantity,
                ef.ReferenceOrderID,
                ef.ReferenceOrderLineID,
                ef.TransactionDate,
                ef.TransactionType);
            return(bo);
        }
        public virtual TransactionHistoryArchive MapBOToEF(
            BOTransactionHistoryArchive bo)
        {
            TransactionHistoryArchive efTransactionHistoryArchive = new TransactionHistoryArchive();

            efTransactionHistoryArchive.SetProperties(
                bo.ActualCost,
                bo.ModifiedDate,
                bo.ProductID,
                bo.Quantity,
                bo.ReferenceOrderID,
                bo.ReferenceOrderLineID,
                bo.TransactionDate,
                bo.TransactionID,
                bo.TransactionType);
            return(efTransactionHistoryArchive);
        }
        public void MapEFToBO()
        {
            var mapper = new DALTransactionHistoryArchiveMapper();
            TransactionHistoryArchive entity = new TransactionHistoryArchive();

            entity.SetProperties(1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");

            BOTransactionHistoryArchive response = mapper.MapEFToBO(entity);

            response.ActualCost.Should().Be(1m);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ProductID.Should().Be(1);
            response.Quantity.Should().Be(1);
            response.ReferenceOrderID.Should().Be(1);
            response.ReferenceOrderLineID.Should().Be(1);
            response.TransactionDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TransactionID.Should().Be(1);
            response.TransactionType.Should().Be("A");
        }
Ejemplo n.º 21
0
        public bool TransactionHistoryArchiveUpdate(TransactionHistoryArchive transactionhistoryarchive)
        {
            return(Execute <bool>(dal =>
            {
                TransactionHistoryArchive transactionhistoryarchiveUpdate = dal.TransactionHistoryArchive.Where(x => x.TransactionID == transactionhistoryarchive.TransactionID).FirstOrDefault();
                if (transactionhistoryarchiveUpdate != null)
                {
                    transactionhistoryarchiveUpdate.TransactionID = transactionhistoryarchive.TransactionID;
                    transactionhistoryarchiveUpdate.ProductID = transactionhistoryarchive.ProductID;
                    transactionhistoryarchiveUpdate.ReferenceOrderID = transactionhistoryarchive.ReferenceOrderID;
                    transactionhistoryarchiveUpdate.ReferenceOrderLineID = transactionhistoryarchive.ReferenceOrderLineID;
                    transactionhistoryarchiveUpdate.TransactionDate = transactionhistoryarchive.TransactionDate;
                    transactionhistoryarchiveUpdate.TransactionType = transactionhistoryarchive.TransactionType;
                    transactionhistoryarchiveUpdate.Quantity = transactionhistoryarchive.Quantity;
                    transactionhistoryarchiveUpdate.ActualCost = transactionhistoryarchive.ActualCost;
                    transactionhistoryarchiveUpdate.ModifiedDate = transactionhistoryarchive.ModifiedDate;

                    dal.SubmitChanges();
                    return true;
                }
                return false;
            }));
        }
        ///<summary>
        ///  Returns a Typed TransactionHistoryArchive Entity with mock values.
        ///</summary>
        static public TransactionHistoryArchive CreateMockInstance_Generated(TransactionManager tm)
        {
            TransactionHistoryArchive mock = new TransactionHistoryArchive();

            mock.TransactionId        = TestUtility.Instance.RandomNumber();
            mock.ProductId            = TestUtility.Instance.RandomNumber();
            mock.ReferenceOrderId     = TestUtility.Instance.RandomNumber();
            mock.ReferenceOrderLineId = TestUtility.Instance.RandomNumber();
            mock.TransactionDate      = TestUtility.Instance.RandomDateTime();
            mock.TransactionType      = TestUtility.Instance.RandomString(1, false);;
            mock.Quantity             = TestUtility.Instance.RandomNumber();
            mock.ActualCost           = TestUtility.Instance.RandomShort();
            mock.ModifiedDate         = TestUtility.Instance.RandomDateTime();


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

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


            return((TransactionHistoryArchive)mock);
        }
 // POST api/awbuildversion
 public void Post(TransactionHistoryArchive value)
 {
     adventureWorks_BC.TransactionHistoryArchiveAdd(value);
 }
 /// <summary>
 /// Create a new TransactionHistoryArchive object.
 /// </summary>
 /// <param name="transactionID">Initial value of TransactionID.</param>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="referenceOrderID">Initial value of ReferenceOrderID.</param>
 /// <param name="referenceOrderLineID">Initial value of ReferenceOrderLineID.</param>
 /// <param name="transactionDate">Initial value of TransactionDate.</param>
 /// <param name="transactionType">Initial value of TransactionType.</param>
 /// <param name="quantity">Initial value of Quantity.</param>
 /// <param name="actualCost">Initial value of ActualCost.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static TransactionHistoryArchive CreateTransactionHistoryArchive(int transactionID, int productID, int referenceOrderID, int referenceOrderLineID, global::System.DateTime transactionDate, string transactionType, int quantity, decimal actualCost, global::System.DateTime modifiedDate)
 {
     TransactionHistoryArchive transactionHistoryArchive = new TransactionHistoryArchive();
     transactionHistoryArchive.TransactionID = transactionID;
     transactionHistoryArchive.ProductID = productID;
     transactionHistoryArchive.ReferenceOrderID = referenceOrderID;
     transactionHistoryArchive.ReferenceOrderLineID = referenceOrderLineID;
     transactionHistoryArchive.TransactionDate = transactionDate;
     transactionHistoryArchive.TransactionType = transactionType;
     transactionHistoryArchive.Quantity = quantity;
     transactionHistoryArchive.ActualCost = actualCost;
     transactionHistoryArchive.ModifiedDate = modifiedDate;
     return transactionHistoryArchive;
 }
 // POST api/awbuildversion
 public void Post(TransactionHistoryArchive value)
 {
     adventureWorks_BC.TransactionHistoryArchiveAdd(value);
 }
 /// <summary>
 /// There are no comments for TransactionHistoryArchive in the schema.
 /// </summary>
 public void AddToTransactionHistoryArchive(TransactionHistoryArchive transactionHistoryArchive)
 {
     base.AddObject("TransactionHistoryArchive", transactionHistoryArchive);
 }