public void BuyerExceptionTest()
        {
            //Variables
            var buyer = new Buyer();

            // Try Catch block to test the fail condition
            try
            {
                // Call CreateOrder method
                buyer.CreateOrder(new Contract());
            }
            catch (Exception e)
            {
                // Assert that test threw exception and succeeded
                Assert.AreEqual("Invalid Contract", e.Message);
            }

            // Try Catch block to test the fail condition
            try
            {
                // Call GenerateInvoice method
                buyer.GenerateInvoice(new Order());
            }
            catch (Exception e)
            {
                // Assert that test threw exception and succeeded
                Assert.AreEqual("Invalid Order", e.Message);
            }
        }
        public void BuyerFunctionalTest()
        {
            //Variables
            var buyer = new Buyer();

            // Try Catch block to test the fail condition
            try
            {
                // Call CreateOrder method
                buyer.CreateOrder(new Contract());
            }
            catch (Exception e)
            {
                // Assert that test failed
                throw new AssertFailedException();
            }

            // Try Catch block to test the fail condition
            try
            {
                // Call GenerateInvoice method
                buyer.GenerateInvoice(new Order());
            }
            catch (Exception e)
            {
                // Assert that test failed
                throw new AssertFailedException();
            }
        }
Example #3
0
        private void acceptButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (NewContractsDataGrid.SelectedItem != null)
                {
                    DataRowView rows = (DataRowView)NewContractsDataGrid.SelectedItems[0];

                    // get values from selected row
                    string clientName  = (string)rows.Row.ItemArray[0];
                    int    jobType     = (int)rows.Row.ItemArray[1];
                    int    quantity    = (int)rows.Row.ItemArray[2];
                    string origin      = (string)rows.Row.ItemArray[3];
                    string destination = (string)rows.Row.ItemArray[4];
                    int    vanType     = (int)rows.Row.ItemArray[5];

                    // create order from it
                    Order newOrder = CurrentBuyer.CreateOrder(clientName, jobType, quantity, origin, destination, vanType);

                    // insert the new contract into the database for record, getting contract ID
                    DataAccess dal        = new DataAccess();
                    int        contractID = dal.InsertNewContract(clientName, jobType, quantity, origin, destination, vanType);

                    dal.InsertNewOrder(contractID);
                }
            }
            catch (Exception ex)
            {
                Logger.LogToFile("Error accepting contract - " + ex.Message);
            }
        }