Exemplo n.º 1
0
        public void InstanceOK()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Test to see that the class exists.
            Assert.IsNotNull(this.staffLogin);
        }
Exemplo n.º 2
0
        public void FindMethodOK()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Variable which stores whether or not the staff member exists in the database.
            Boolean found = this.staffLogin.Find(this.staffUsername, this.staffPassword);

            // Test to see if the staff member exists within the database.
            Assert.IsTrue(found);
        }
Exemplo n.º 3
0
        public void AdminOK()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Set staffLogin's Admin property to the test data.
            this.staffLogin.Admin = this.staffAdmin;

            // Test to see if staffLogin's Admin property is equal to the test data.
            Assert.AreEqual(this.staffLogin.Admin, this.staffAdmin);
        }
Exemplo n.º 4
0
        public void PasswordOK()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Set staffLogin's Password property to the test data.
            this.staffLogin.Password = this.staffPassword;

            // Test to see if staffLogin's Password property is equal to the test data.
            Assert.AreEqual(this.staffLogin.Password, this.staffPassword);
        }
Exemplo n.º 5
0
        public void UsernameOK()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Set staffLogin's Username property to the test data.
            this.staffLogin.Username = this.staffUsername;

            // Test to see if staffLogin's Username property is equal to the test data.
            Assert.AreEqual(this.staffLogin.Username, this.staffUsername);
        }
Exemplo n.º 6
0
        public void TestStaffUsernameFound()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Variable which stores whether or not the staff member's username exists in the database.
            Boolean found = this.staffLogin.Find(this.staffUsername, this.staffPassword);

            Boolean ok = true;

            // Checks to see if staffLogin's Username property is equal to staffUsername.
            if (this.staffLogin.Username != this.staffUsername)
            {
                ok = false;
            }

            // Test to see if the staff member's username exists within the database.
            Assert.IsTrue(ok);
        }
Exemplo n.º 7
0
        public void TestStaffIsAdminFound()
        {
            // Create an instance of clsStaffLogin.
            this.staffLogin = new clsStaffLogin();

            // Variable which stores whether or not the staff member is an admin.
            Boolean found = this.staffLogin.Find(this.staffUsername, this.staffPassword);

            Boolean ok = true;

            // Checks to see if staffLogin's Admin property is true or false.
            if (!this.staffLogin.Admin)
            {
                ok = false;
            }

            // Test to see if the staff member's admin privilege is true or false within the database.
            Assert.IsTrue(ok);
        }
Exemplo n.º 8
0
    // Event handler for the Login button.
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        // Create an instance of clsStaffLogin.
        var staffDetails = new clsStaffLogin();

        // Checks to see if the user data entered exists within the database.
        if (staffDetails.Find(txtStaffUsername.Text.ToLower(), txtStaffPassword.Text.ToLower()))
        {
            // Now set session.
            Session["staffUsername"] = staffDetails.Username;
            Session["staffPassword"] = staffDetails.Password;
            Session["isAdmin"]       = staffDetails.Admin;
            Session["isLoggedIn"]    = true;
            Session["staffID"]       = staffDetails.ID;

            // Redirect to StaffList.
            Response.Redirect("StaffList.aspx");
        }
        else
        {
            // Produce an user-friendly error.
            lblError.Text = "<b>WARNING - THE DETAILS YOU HAVE ENTERED ARE INCORRECT!</b>";
        }
    }