Ejemplo n.º 1
0
 public void GetCustomerTest()
 {
     CustomerCRUD.addCustomer(88, "Joan", "Jett");
     Assert.AreEqual(CustomerCRUD.GetCustomer(88).customer_f_name, "Joan");
     Assert.AreEqual(CustomerCRUD.GetCustomerByLastName("Jett").customer_id, (88));
     Assert.AreEqual(CustomerCRUD.GetCustomerByNames("Joan", "Jett").customer_id, 88);
     CustomerCRUD.deleteCustomer(88);
 }
Ejemplo n.º 2
0
 public void UpdateCustomerTest()
 {
     CustomerCRUD.addCustomer(77, "Ellen", "DeGeneres");
     Assert.IsTrue(CustomerCRUD.updateLastName(77, "Page"));
     Assert.AreEqual(CustomerCRUD.GetCustomer(77).customer_l_name, "Page");
     Assert.IsTrue(CustomerCRUD.updateName(77, "Elliot"));
     Assert.AreEqual(CustomerCRUD.GetCustomerByLastName("Page").customer_f_name, "Elliot");
     CustomerCRUD.deleteCustomer(77);
 }
Ejemplo n.º 3
0
        public void AddCustomerToDatabase()
        {
            Customers c = new Customers()
            {
                id = 101, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
        }
Ejemplo n.º 4
0
        public void DeleteCustomerFromDatabase()
        {
            Customers c = new Customers()
            {
                id = 102, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsTrue(CustomerCRUD.removeCustomer(c.id));
        }
Ejemplo n.º 5
0
        public void UpdateCustomerMoney()
        {
            Customers c = new Customers()
            {
                id = 105, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsTrue(CustomerCRUD.updateMoney(c.id, 300));
            c = CustomerCRUD.getCustomer(c.id);
            Assert.AreEqual(c.money, 400);
        }
Ejemplo n.º 6
0
        public void UpdateCustomerName()
        {
            Customers c = new Customers()
            {
                id = 104, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsTrue(CustomerCRUD.updateName(c.id, "Shawn"));
            c = CustomerCRUD.getCustomer(c.id);
            Assert.AreEqual(c.name, "Shawn");
        }
Ejemplo n.º 7
0
        public void GetCustomer()
        {
            Customers c = new Customers()
            {
                id = 103, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Customers c1 = CustomerCRUD.getCustomer(c.id);

            Assert.AreEqual(c.id, c1.id);
            Assert.AreEqual(c.name, c1.name);
        }
Ejemplo n.º 8
0
        public void BorrowNonExistingBookToCustomerWithMoney()
        {
            Books book = new Books()
            {
                id = 203, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };
            Customers c = new Customers()
            {
                id = 203, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsFalse(BorrowedBookCRUD.borrowBook(103, c.id, book.id));
        }
Ejemplo n.º 9
0
        public void GetCustomersTest()
        {
            CustomerCRUD.addCustomer(19, "Anna", "Kowalska");
            CustomerCRUD.addCustomer(16, "Anna", "Nowak");

            IEnumerable <customer> customers = CustomerCRUD.GetCustomersByName("Anna");

            Assert.AreEqual(customers.Count(), 2);
            Assert.AreEqual(customers.ElementAt(0).customer_l_name, "Nowak");
            Assert.AreEqual(customers.ElementAt(1).customer_id, 19);

            CustomerCRUD.deleteCustomer(19);
            CustomerCRUD.deleteCustomer(16);
        }
Ejemplo n.º 10
0
        public void AddCustomer()
        {
            bool added = CustomerCRUD.addCustomer(newCustomer.customer_id, newCustomer.customer_f_name, newCustomer.customer_l_name);

            if (added)
            {
                actionText = "Customer Added";
            }
            else
            {
                actionText = "Customer with such ID already exists in the database";
            }
            MessageBoxShowDelegate(ActionText);
        }
Ejemplo n.º 11
0
        public void BorrowBorrowedBookToCustomerWithMoney()
        {
            Books book = new Books()
            {
                id = 204, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 0
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Customers c = new Customers()
            {
                id = 204, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsFalse(BorrowedBookCRUD.borrowBook(104, c.id, book.id));
        }
Ejemplo n.º 12
0
        public void BorrowExistingBookToCustomerWithMoney()
        {
            Books book = new Books()
            {
                id = 201, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Customers c = new Customers()
            {
                id = 201, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsTrue(BorrowedBookCRUD.borrowBook(101, c.id, book.id));
            Assert.AreEqual(BookCRUD.getBook(book.id).returnDate, DateTime.Today.AddDays(14));
            Assert.AreEqual(BorrowedBookCRUD.getBorrowedBooks(book.id).customerId, c.id);
        }
Ejemplo n.º 13
0
 public void AddCustomerTest()
 {
     Assert.IsTrue(CustomerCRUD.addCustomer(67, "Michael", "Jackson"));
     Assert.IsTrue(CustomerCRUD.deleteCustomer(67));
 }
Ejemplo n.º 14
0
 private void CustomerSave()
 {
     CustomerCRUD.addCustomer(this.CustomerId, this.Name, this.Money);
 }