예제 #1
0
        private void add_Click(object sender, EventArgs e)
        {
            string      textid   = textBox1.Text;
            CustomerOps customer = new CustomerOps();

            customer.AddCustomer(textid);
        }
예제 #2
0
        public void addCustomer_Test()
        {
            // arrange
            // set up the data access fake
            int    id          = 1;
            string fullName    = "Full Name";
            string address     = "Address";
            string phoneNumber = "12345";
            string email       = "*****@*****.**";
            string city        = "Somewhere";

            Customer.States state    = Customer.States.NSW;
            int             postcode = 2000;

            System.Collections.Generic.List <ITransaction> transactions = null;
            Customer newCustomer             = new Customer(id, fullName, address, phoneNumber, email, city, state, postcode, transactions);
            var      customerDAO             = A.Fake <Model.DataAccessLayer.ICustomerDAO>();
            bool     addCustomerMethodCalled = false;

            A.CallTo(() => customerDAO.addCustomer(newCustomer)).Invokes(() => addCustomerMethodCalled = true);
            // set up the class under test
            this.customerService = new Model.ServiceLayer.CustomerOps(customerDAO);
            // subscribe to the event
            bool eventFired = false;

            this.customerService.GetAllCustomers += (sender, args) => { eventFired = true; };

            // act
            this.customerService.addCustomer(newCustomer);

            // assert
            NUnit.Framework.Assert.IsTrue(eventFired);
            NUnit.Framework.Assert.IsTrue(addCustomerMethodCalled);
        }
예제 #3
0
        private void update_Click(object sender, EventArgs e)
        {
            string      textid   = textBox1.Text;
            string      name     = textBox2.Text;
            CustomerOps customer = new CustomerOps();

            customer.UpdateCustomerName(textid, name);
        }
예제 #4
0
        private void select_Click(object sender, EventArgs e)
        {
            string          textid   = textBox1.Text;
            CustomerOps     customer = new CustomerOps();
            List <Customer> lista    = new List <Customer>();

            lista.Add(customer.GetCustomerByID(textid));
            dataGridView1.DataSource = lista;
        }
예제 #5
0
        static void Main(string[] args)
        {
            IPerson  Alex       = CustomersStruct.Alex;
            IVehicle FordFocus  = CarsStruct.FordFocus;
            IStore   FordStore  = StoresStruct.FordStore;
            IStore   SkodaStore = StoresStruct.SkodaStore;

            CustomerOps.PlaceOrder(Alex, FordStore, FordFocus);
            CustomerOps.PrintOrders(Alex, "Orders after ordering from Ford Store");
            CustomerOps.PlaceOrder(Alex, SkodaStore, FordFocus);
            CustomerOps.PrintOrders(Alex, "Orders after ordering new model from Skoda Store");
            CustomerOps.CancelOrder(Alex, FordStore, FordFocus);
            CustomerOps.PrintOrders(Alex, "Orders after cancelling the order on Ford Store");
            Console.ReadKey();
        }
예제 #6
0
        public void getCustomer_Test()
        {
            // should return either a null or a customer object

            // arrange
            // set up the data access fake
            int    id          = 1;
            string fullName    = "Full Name";
            string address     = "Address";
            string phoneNumber = "12345";
            string email       = "*****@*****.**";
            string city        = "Somewhere";

            Customer.States state    = Customer.States.NSW;
            int             postcode = 2000;

            System.Collections.Generic.List <ITransaction> transactions = null;
            var customerDAO = A.Fake <Model.DataAccessLayer.ICustomerDAO>();

            A.CallTo(() => customerDAO.getCustomer(1)).Returns(new Customer(id, fullName, address, phoneNumber, email, city, state, postcode, transactions));
            A.CallTo(() => customerDAO.getCustomer(0)).Returns(null);
            // set up the class under test
            this.customerService = new Model.ServiceLayer.CustomerOps(customerDAO);

            // act
            ICustomer customerThatExists       = this.customerService.getCustomer(1);
            ICustomer customerThatDoesNotExist = this.customerService.getCustomer(0);

            // assert
            NUnit.Framework.Assert.IsNull(customerThatDoesNotExist);
            NUnit.Framework.Assert.AreEqual(id, customerThatExists.CustomerID);
            NUnit.Framework.Assert.AreEqual(fullName, customerThatExists.FullName);
            NUnit.Framework.Assert.AreEqual(address, customerThatExists.Address);
            NUnit.Framework.Assert.AreEqual(phoneNumber, customerThatExists.PhoneNumber);
            NUnit.Framework.Assert.AreEqual(email, customerThatExists.Email);
            NUnit.Framework.Assert.AreEqual(city, customerThatExists.City);
            NUnit.Framework.Assert.AreEqual(state, customerThatExists.state);
            NUnit.Framework.Assert.AreEqual(postcode, customerThatExists.Postcode);
            NUnit.Framework.Assert.AreEqual(transactions, customerThatExists.Transactions);
        }
예제 #7
0
        public void deleteCustomer_Test()
        {
            // arrange
            // set up the data access fake
            int  id          = 1;
            var  customerDAO = A.Fake <Model.DataAccessLayer.ICustomerDAO>();
            bool deleteCustomerMethodCalled = false;

            A.CallTo(() => customerDAO.deleteCustomer(id)).Invokes(() => deleteCustomerMethodCalled = true);
            // set up the class under test
            this.customerService = new Model.ServiceLayer.CustomerOps(customerDAO);
            // subscribe to the event
            bool eventFired = false;

            this.customerService.GetAllCustomers += (sender, args) => { eventFired = true; };

            // act
            this.customerService.deleteCustomer(id);

            // assert
            NUnit.Framework.Assert.IsTrue(eventFired);
            NUnit.Framework.Assert.IsTrue(deleteCustomerMethodCalled);
        }
예제 #8
0
        public void getAllCustomers_Test()
        {
            // arrange
            // set up the data access fake
            int    id          = 1;
            string fullName    = "Full Name";
            string address     = "Address";
            string phoneNumber = "12345";
            string email       = "*****@*****.**";
            string city        = "Somewhere";

            Customer.States state    = Customer.States.NSW;
            int             postcode = 2000;

            System.Collections.Generic.List <ITransaction> transactions = null;
            var customerDAO = A.Fake <Model.DataAccessLayer.ICustomerDAO>();

            A.CallTo(() => customerDAO.getAllCustomers()).Returns(new System.Collections.Generic.List <ICustomer> {
                new Customer(id, fullName, address, phoneNumber, email, city, state, postcode, transactions)
            });
            // set up the class under test
            this.customerService = new Model.ServiceLayer.CustomerOps(customerDAO);
            // subscribe to the event
            bool eventFired = false;

            this.customerService.GetAllCustomers += (sender, args) => { eventFired = true; };

            // act
            IEnumerable <ICustomer> collectionOfCustomers = this.customerService.getAllCustomers();

            // assert
            NUnit.Framework.Assert.IsTrue(eventFired);
            foreach (ICustomer customer in collectionOfCustomers)
            {
                NUnit.Framework.Assert.AreEqual(id, customer.CustomerID);
            }
        }
예제 #9
0
 public CustomerViewModel SemdEmail(string CustomerId, string CategoryId, string TemplateId)
 {
     return(CustomerOps.SendEmail(CustomerId, CategoryId, TemplateId));
 }
예제 #10
0
 public CustomerViewModel GetCategoryList()
 {
     return(CustomerOps.GetCategoryList());
 }
예제 #11
0
 public CustomerViewModel ImportCustomer(string FilePath)
 {
     return(CustomerOps.ImportCustomer(FilePath));
 }
예제 #12
0
 public CustomerViewModel GetCustomerSummaryList(int CustomerId)
 {
     return(CustomerOps.GetCustomerSummaryList(CustomerId));
 }