public void CustomerListOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            List <clsCustomer>    CustomerList = new List <clsCustomer>();
            //create the test customer
            clsCustomer TestCustomer = new clsCustomer();

            //set properties
            TestCustomer.CustomerId  = 1;
            TestCustomer.Name        = "John Snow";
            TestCustomer.Address     = "1 Kings Landing";
            TestCustomer.Postcode    = "KL01 1QL";
            TestCustomer.DoB         = DateTime.Now.Date;
            TestCustomer.GdprRequest = false;
            //add TestCustomer to the CustomerList
            CustomerList.Add(TestCustomer);
            AllCustomers.CustomerList = CustomerList;
            Assert.AreEqual(AllCustomers.CustomerList, CustomerList);
        }
        public void ListAndCountOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            List <clsCustomer>    CustomerList = new List <clsCustomer>();
            //create the test customer
            clsCustomer TestCustomer = new clsCustomer();

            //set properties
            TestCustomer.CustomerId  = 2;
            TestCustomer.Name        = "a";
            TestCustomer.Address     = "ad";
            TestCustomer.Postcode    = "PP112DD";
            TestCustomer.DoB         = DateTime.Now.Date;
            TestCustomer.GdprRequest = false;
            //add TestCustomer to the CustomerList
            CustomerList.Add(TestCustomer);
            AllCustomers.CustomerList = CustomerList;
            Assert.AreEqual(AllCustomers.Count, CustomerList.Count);
        }
        public void ThisCustomerPropertyOK()
        {
            //create an instance of the class we want to create
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create some test data to assign to the property
            clsCustomer TestCustomer = new clsCustomer();

            //set the properties of the test object
            TestCustomer.Active     = true;
            TestCustomer.CustomerId = 1;
            TestCustomer.Username   = "******";
            TestCustomer.Password   = "******";
            TestCustomer.Address    = "some address";
            TestCustomer.DateAdded  = DateTime.Now.Date;
            //assign the data to the property
            AllCustomers.ThisCustomer = TestCustomer;
            //test to see that the two values are the same
            Assert.AreEqual(AllCustomers.ThisCustomer, TestCustomer);
        }
Example #4
0
        public void DateAddedMin()
        {
            //create an instance of the class we want to create
            clsCustomer ACustomer = new clsCustomer();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

            //set the date to todays date
            TestDate = DateTime.Now.Date;
            //convert the date variable to a string variable
            string DateAdded = TestDate.ToString();

            //invoke the method
            Error = ACustomer.Valid(Username, Password, Address, DateAdded);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
        public void AddMethodOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            clsCustomer           TestItem     = new clsCustomer();
            Int32 PrimaryKey = 0;

            TestItem.Name             = "John Smith";
            TestItem.EmailAddress     = "*****@*****.**";
            TestItem.Address          = "Flat 10, Charles street, Leicester";
            TestItem.Password         = "******";
            TestItem.isEmailConfirmed = true;
            TestItem.LoyaltyPoints    = 10.5;
            TestItem.CreatedAt        = DateTime.Now.Date;

            AllCustomers.ThisCustomer = TestItem;
            PrimaryKey          = AllCustomers.Add();
            TestItem.CustomerId = PrimaryKey;
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            Assert.AreEqual(AllCustomers.ThisCustomer, TestItem);
        }
Example #6
0
        public void TestActiveFound()
        {
            //create an instance of the class we want to create
            clsCustomer theCustomer = new clsCustomer();
            //Boolean variable to store the results of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with method
            Int32 CustomerId = 4;

            //invoke the method
            Found = theCustomer.Find(CustomerId);
            //check the customer activity
            if (theCustomer.Active != true)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Example #7
0
        public void TestCustomerRegisteredDateFound()
        {
            //create an instance of the class we want to create
            clsCustomer theCustomer = new clsCustomer();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            Int32 CustomerId = 4;

            //invoke the method
            Found = theCustomer.Find(CustomerId);
            //check the registered date
            if (theCustomer.CustomerRegisteredDate != Convert.ToDateTime("06/05/2021"))
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
        public void ListAndCountOK()
        {
            clsCustomerCollection allCustomers = new clsCustomerCollection();

            List <clsCustomer> TestList = new List <clsCustomer>();

            clsCustomer TestItem = new clsCustomer();

            TestItem.Active                 = true;
            TestItem.CustomerId             = 4;
            TestItem.Name                   = "Zeynep Tugce";
            TestItem.CustomerRegisteredDate = DateTime.Now.Date;
            TestItem.ProductId              = 40;
            TestItem.Point                  = 0;

            TestList.Add(TestItem);

            allCustomers.CustomerList = TestList;

            Assert.AreEqual(allCustomers.Count, TestList.Count);
        }
Example #9
0
        public void TestCustomerIdFound()
        {
            //create an instance of the class we want to create
            clsCustomer ACustomer = new clsCustomer();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is ok
            Boolean OK = true;
            //create some test data to use with the method
            Int16 CustomerId = 1;

            //invoke the method
            Found = ACustomer.Find(CustomerId);
            //check the customer id
            if (ACustomer.CustomerId != 1)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Example #10
0
        public void TestActiveFound()
        {
            //create an instance of the class we want to create
            clsCustomer AnCustomer = new clsCustomer();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            int CustomerNo = 21;

            //invoke the method
            Found = AnCustomer.Find(CustomerNo);
            //check the property
            if (AnCustomer.Active != true)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Example #11
0
        public void RegisteredDateInvalidData()

        {
            //create an instance of the class we want to create

            clsCustomer theCustomer = new clsCustomer();

            //string variable to store any error message

            String Error = "";

            string CustomerRegisteredDate = "this is not a date";

            //invoke the method

            Error = theCustomer.Valid(CustomerRegisteredDate, Name, Point, ProductId);

            //test to see that the result is correct

            Assert.AreNotEqual(Error, "");
        }
        public void AddMethodOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create the test customer
            clsCustomer TestCustomer = new clsCustomer();
            Int32       PrimaryKey   = 0;

            //set properties
            TestCustomer.CustomerId   = 5;
            TestCustomer.Name         = "Bruce Lee";
            TestCustomer.Address      = "Turbo Road";
            TestCustomer.Postcode     = "PE10 1AB";
            TestCustomer.DoB          = DateTime.Now.Date;
            TestCustomer.GdprRequest  = true;
            AllCustomers.ThisCustomer = TestCustomer;
            //add customer to key
            PrimaryKey = AllCustomers.Add();
            //set key
            TestCustomer.CustomerId = PrimaryKey;
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            Assert.AreEqual(AllCustomers.ThisCustomer, TestCustomer);
        }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create the item of test data
            clsCustomer TestItem = new clsCustomer();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Active     = true;
            TestItem.CustomerId = 1;
            TestItem.Username   = "******";
            TestItem.DateAdded  = DateTime.Now.Date;
            TestItem.Address    = "an address";
            TestItem.Password   = "******";
            //set ThisCustomer to the test data
            AllCustomers.ThisCustomer = TestItem;
            //add the record
            PrimaryKey = AllCustomers.Add();
            //set the primary key of the test data
            TestItem.CustomerId = PrimaryKey;
            //modify the test data
            TestItem.Active     = false;
            TestItem.CustomerId = 3;
            TestItem.Username   = "******";
            TestItem.DateAdded  = DateTime.Now.Date;
            TestItem.Address    = "an address2";
            TestItem.Password   = "******";
            //set the record based on the new test data
            AllCustomers.ThisCustomer = TestItem;
            //update the record
            AllCustomers.Update();
            //find the record
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            //test to see ThisCustomer matches the test data
            Assert.AreEqual(AllCustomers.ThisCustomer, TestItem);
        }
Example #14
0
        public void ProductIdMinPlusOne()

        {
            //create an instance of the class we want to create

            clsCustomer theCustomer = new clsCustomer();

            //string variable to store any error message

            String Error = "";

            //create some test data to pass to the method

            string ProductId = "2"; //this should be ok

            //invoke the method

            Error = theCustomer.Valid(CustomerRegisteredDate, Name, Point, ProductId);

            //test to see that the result is correct

            Assert.AreEqual(Error, "");
        }
        public void DeleteMethodOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create the test customer
            clsCustomer TestCustomer = new clsCustomer();
            Int32       PrimaryKey   = 0;

            //set properties
            TestCustomer.Name         = "John Barry";
            TestCustomer.Address      = "The Road";
            TestCustomer.Postcode     = "N111FF";
            TestCustomer.DoB          = DateTime.Now.Date;
            TestCustomer.GdprRequest  = false;
            AllCustomers.ThisCustomer = TestCustomer;
            //add customer to key
            PrimaryKey = AllCustomers.Add();
            TestCustomer.CustomerId = PrimaryKey;
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            AllCustomers.Delete();
            Boolean found = AllCustomers.ThisCustomer.Find(PrimaryKey);

            Assert.IsFalse(found);
        }
Example #16
0
        void PopulateArray(clsDataConnection DB)
        {
            Int32 Index       = 0;
            Int32 RecordCount = 0;

            RecordCount   = DB.Count;
            mCustomerList = new List <clsCustomer>();
            while (Index < RecordCount)
            {
                clsCustomer ACustomer = new clsCustomer();

                ACustomer.CustomerId       = Convert.ToInt32(DB.DataTable.Rows[Index]["CustomerId"]);
                ACustomer.Name             = Convert.ToString(DB.DataTable.Rows[Index]["Name"]);
                ACustomer.EmailAddress     = Convert.ToString(DB.DataTable.Rows[Index]["EmailAddress"]);
                ACustomer.Address          = Convert.ToString(DB.DataTable.Rows[Index]["Address"]);
                ACustomer.Password         = Convert.ToString(DB.DataTable.Rows[Index]["Password"]);
                ACustomer.isEmailConfirmed = Convert.ToBoolean(DB.DataTable.Rows[Index]["IsEmailConfirmed"]);
                ACustomer.LoyaltyPoints    = Convert.ToDouble(DB.DataTable.Rows[Index]["LoyaltyPoints"]);
                ACustomer.CreatedAt        = Convert.ToDateTime(DB.DataTable.Rows[Index]["CreatedAt"]);

                mCustomerList.Add(ACustomer);
                Index++;
            }
        }
Example #17
0
        public void InstanceOK()
        {
            clsCustomer ACustomer = new clsCustomer();

            Assert.IsNotNull(ACustomer);
        }