Ejemplo n.º 1
0
        public void DateAddedExtremeMax()
        {
            clsReports AReport = new clsReports();

            //string variable to store the 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;

            //change the date to whatever the date is plus 100 years
            TestDate = TestDate.AddYears(100);

            //convert the date variable to string variable
            String DateAdded = TestDate.ToString();

            //Invoke the method
            Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);

            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 2
0
        public void ValidMethodOK()
        {
            clsReports AReport = new clsReports();

            //String variable to store any error message
            String Error = "";

            //invoke the method
            Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);

            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Ejemplo n.º 3
0
        public void ExpensesPlusOne()
        {
            clsReports AReport = new clsReports();

            //string to store the error message
            String Error = "";

            //set the Expenses to plus 1
            string Total = "1"; //This should pass

            //Invoke the method
            Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);

            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 4
0
        public void DateAddedInvalidData()
        {
            clsReports AReport = new clsReports();

            //string variable to store the error message
            String Error = "";

            //set the DateAdded to non date value
            string DateAdded = "This is not a date!";

            //Invoke the method
            Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);

            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 5
0
        public void EmployeeNameMaxPlusOne()
        {
            clsReports AReport = new clsReports();

            //string variable to store the error message
            String Error = "";

            //create some test data to pass the method
            string EmployeeName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; //this should fail

            //invoking the method
            Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);

            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Ejemplo n.º 6
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsReports AReport = new clsReports();



        //capture employeeName
        string EmployeeName = txtEmployeeName.Text;
        //capture DateAdded
        string DateAdded = txtDateAdded.Text;
        //capture Total
        string Total = txtTotal.Text;
        //capture Expenses
        string Expenses = txtExpenses.Text;
        //variable to store any error messages
        string Error = "";

        //validate the data
        Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);
        if (Error == "")
        {
            //Capture the employee id
            AReport.EmployeeId = EmployeeId;

            //Capture EmployeeName
            AReport.EmployeeName = EmployeeName;
            //capture DateAdded
            AReport.DateAdded = Convert.ToDateTime(DateAdded);
            //capture Total
            AReport.Total = Convert.ToInt32(Total);
            //capture Expenses
            AReport.Expenses = Convert.ToInt32(Expenses);
            //capture Profit
            AReport.ProfitOrLoss = chkProfit.Checked;
            //capture Loss
            AReport.ProfitOrLoss = chkLoss.Checked;

            //create a new instance of the reports collection
            clsReportsCollection ReportList = new clsReportsCollection();

            //if this is a new record i.e. EmployeeId = -1 then add the data
            if (EmployeeId == -1)
            {
                //set the ThisReport property
                ReportList.ThisReport = AReport;

                //add the new record
                ReportList.Add();
            }
            else
            {
                //find the record to update
                ReportList.ThisReport.Find(EmployeeId);

                //set the ThisReport property
                ReportList.ThisReport = AReport;

                //update the record
                ReportList.Update();
            }


            //redirect back to the listpage
            Response.Redirect("5ReportsList.aspx");
        }

        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }