コード例 #1
0
        public void addMethodOK()
        {
            //create an instance of the class
            clsCustomerCollection collection = new clsCustomerCollection();

            //clear the collection (as collection will contain database records in construction as suggested)
            collection.clear();
            //create item of test data
            clsCustomer customer = new clsCustomer();
            //var to store the customer's ID (primary key from database)
            Int32 PrimaryKey = 0;

            //set its properties
            customer.cusId            = 1000;
            customer.cusName          = "Rodney Dangerfield";
            customer.cusEmail         = "*****@*****.**";
            customer.cusPassword      = "******";
            customer.cusAccountStatus = true;
            customer.cusDateRegister  = DateTime.Now.Date;
            //set ThisCustomer to test data
            collection.ThisCustomer = customer;
            //add the data
            PrimaryKey = collection.Add();
            //set the primary key of the test data
            customer.cusId = PrimaryKey;
            //compare
            Assert.AreEqual(collection.ThisCustomer, customer);
        }
コード例 #2
0
        public void testAddCustomer()
        {
            //create new customer collection
            clsCustomerCollection customerList = new clsCustomerCollection();

            //clear collection
            customerList.clear();
            //add 2 test customers
            clsCustomer tstCustomer1 = new clsCustomer();

            tstCustomer1.cusName = "Tester1";
            clsCustomer tstCustomer2 = new clsCustomer();

            tstCustomer2.cusName = "Tester2";
            //create new test list
            List <clsCustomer> tstList = new List <clsCustomer>();

            //add 2 test customers to test list and customerList
            tstList.Add(tstCustomer1);
            tstList.Add(tstCustomer2);
            customerList.add(tstCustomer1);
            customerList.add(tstCustomer2);
            //compare
            Assert.AreEqual(customerList.customerAtIndex(1), tstList[1]);
        }
コード例 #3
0
        public void customerCollectionCount()
        {
            //create new instance of class
            clsCustomerCollection allCustomers = new clsCustomerCollection();

            //clear class (because it is generated with the SQL db entries
            //in constructor as shown in Lab 23
            allCustomers.clear();
            //make new test customer without properties (it doesn't need them to show count works)
            clsCustomer tstCustomer1 = new clsCustomer();

            //add tst customer
            allCustomers.add(tstCustomer1);
            //compare contents of collection list count to actual count (1)
            Assert.AreEqual(allCustomers.Count, 1);
        }
コード例 #4
0
        public void testClear()
        {
            //create new customer collection
            clsCustomerCollection collection = new clsCustomerCollection();
            //make new test customer without properties (it doesn't need them to show clear works)
            clsCustomer tstCustomer1 = new clsCustomer();

            //add tst customer
            collection.add(tstCustomer1);
            //clear collection
            collection.clear();
            //create new empty list to compare to
            List <clsCustomer> emptyList = new List <clsCustomer>();

            //compare
            Assert.AreEqual(collection.Count, emptyList.Count);
        }