Esempio n. 1
0
        public void MakeCustomerDeposit_AmountBiggerTanProducts_ExceptionThrown()
        {
            // arrange
            var product = Product.MakeProduct("Test product", "Test product", 15, Dimensions.MakeDimensions(11, 12, 13));

            product.UpdateAmount(15);
            var customer      = Customer.MakeCustomer("Julio", "05908990078", DateTime.Now);
            var customerOrder = CustomerOrder.MakeCustomerOrder(5, customer);

            customerOrder.AddItem(product, 5);

            // act
            Assert.Throws <ArgumentException>(() => CustomerDeposit.MakeCustomerDeposit(customerOrder.CustomerOrderItems.First(), 20, DepositMovement.Out));
        }
Esempio n. 2
0
        public void DeleteCustomerDeposit_ValidParameters_ExceptionThrown()
        {
            // arrange
            var product = Product.MakeProduct("Test product", "Test product", 15, Dimensions.MakeDimensions(11, 12, 13));

            product.UpdateAmount(15);
            var customer      = Customer.MakeCustomer("Julio", "05908990078", DateTime.Now);
            var customerOrder = CustomerOrder.MakeCustomerOrder(5, customer);

            customerOrder.AddItem(product, 5);
            var customerDeposit = CustomerDeposit.MakeCustomerDeposit(customerOrder.CustomerOrderItems.First(), 5, DepositMovement.Out);

            // act
            Assert.Throws <InvalidOperationException>(() => customerDeposit.Delete());
        }
Esempio n. 3
0
        public void MakeCustomerDeposit_ValidParameters_DepositCreated()
        {
            // arrange
            var product = Product.MakeProduct("Test product", "Test product", 15, Dimensions.MakeDimensions(11, 12, 13));

            product.UpdateAmount(15);
            var customer      = Customer.MakeCustomer("Julio", "05908990078", DateTime.Now);
            var customerOrder = CustomerOrder.MakeCustomerOrder(5, customer);

            customerOrder.AddItem(product, 5);

            // act
            var customerDeposit = CustomerDeposit.MakeCustomerDeposit(customerOrder.CustomerOrderItems.First(), 5, DepositMovement.Out);

            // assert
            Assert.Equal(customerDeposit.Amount, 5);
            Assert.Equal(customerDeposit.Sku, product.Sku);
        }
        protected override OpResult _Store(CustomerDeposit _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "CustomerDeposit object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.CustomerDepositID == null)
            {
                _obj.CustomerDepositID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
Esempio n. 5
0
 public void MakeCustomerDeposit_NullCustomerOrderItem_ExceptionThrown()
 {
     // act
     Assert.Throws <ArgumentNullException>(() => CustomerDeposit.MakeCustomerDeposit(null, 5, DepositMovement.Out));
 }
 private DbUpdateStatement GetQuery_UpdateQuery(CustomerDeposit _obj)
 {
     return(DbMgr.CreateUpdateClause("CustomerDeposits", GetFields(_obj), "CustomerDepositID", _obj.CustomerDepositID));
 }
        private DbInsertStatement GetQuery_InsertQuery(CustomerDeposit _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("CustomerDeposits", fields));
        }