Пример #1
0
        public static BugTracking.DeveloperBug getBug()
        {
            BugTracking.User user = new BugTracking.User("FirstName", "LastName", "Developer");
            user.Save();
            BugTracking.App app = new BugTracking.App("TestApp1", user);
            app.Save();

            BugTracking.AppForm form = new BugTracking.AppForm("Label Test", "Name Test", true, app.Id);
            form.Save();

            BugTracking.FormControl control = new BugTracking.FormControl("label Test", "Name Test", true, app.Id);
            control.Save();

            BugTracking.Action action = new BugTracking.Action("label Test", "Name Test", app.Id);

            BugTracking.BugLocation location = new BugTracking.BugLocation(app.Id, form.Id, control.Id, action.Name, "Related Method Test", "Related Parameter Test", 1, 99);

            BugTracking.DeveloperBug bug = new BugTracking.DeveloperBug("Test Title", "Test Comment", location, 0, -1, false, "Dummy Code");


            bug.createdByID = user.Id;


            bug.AssignedUserID = user.Id;
            bug.Save();

            return(bug);
        }
Пример #2
0
 public static void deleteAllBug(BugTracking.DeveloperBug deleteBug)
 {
     deleteBug.Location.control.Delete();
     deleteBug.Location.form.Delete();
     deleteBug.Location.application.Delete();
     deleteBug.Location.application.DefaultUser.Delete();
     deleteBug.Location.Delete();
     deleteBug.Delete();
 }
Пример #3
0
        public void TestMinimuInput()
        {
            //Get dummy Bug
            BugTracking.DeveloperBug bug = DeveloperBugSetup.getBug();


            //setup frmCreateBugForm
            BugManager.FrmCreateBug frmCreateBug = new BugManager.FrmCreateBug();
            frmCreateBug.UnitTesting  = true;
            frmCreateBug.LoggedInUser = bug.Location.application.DefaultUser;
            frmCreateBug.BugID        = 0;
            frmCreateBug.Show();
            frmCreateBug.Hide();
            frmCreateBug.cboAssignedUser.SelectedValue = bug.Location.application.DefaultUser.Id;

            //attempt to save without minimul requirements filled in
            frmCreateBug.SaveBug(false);
            Boolean bugPassed = true;

            //if bug hasnt saved then pass
            if (frmCreateBug.BugID != 0)
            {
                bugPassed = false;
            }

            //attempt to save with minimum requirements filled in
            frmCreateBug.txtComment.Text = "Test Comment";

            frmCreateBug.txtTitle.Text = "Test Title";
            frmCreateBug.SaveBug(false);


            //if bug has saved then pass
            if (frmCreateBug.BugID == 0)
            {
                bugPassed = false;
            }

            //check that save was valid
            BugTracking.DeveloperBug checkBug = BugTracking.DeveloperBug.Get(bug.Id);

            //check saved values are correct
            if (checkBug.Title != "Test Title")
            {
                bugPassed = false;
            }

            if (checkBug.Comment != "Test Comment")
            {
                bugPassed = false;
            }

            //delete dummy bug
            DeveloperBugSetup.deleteAllBug(bug);
            Assert.AreEqual(bugPassed, true);
        }
Пример #4
0
        /// <summary>
        /// Saves the bug.
        /// </summary>
        /// <param name="messsagebox">if set to <c>true</c> [messsagebox].</param>
        public void SaveBug(Boolean messsagebox)
        {
            long DefaultUserID;

            if (txtComment.Text == "" || txtTitle.Text == "")
            {
                if (messsagebox)
                {
                    MessageBox.Show("A Bug entry must have a Comment and a title in order to commit!");
                }
                return;
            }

            switch (LoggedInUser.UserType)
            {
            case "White Box Tester":

                //create new Developer Bug with limited values
                BugTracking.BugLocation locationWB = new BugTracking.BugLocation((long)cboApplication.SelectedValue, (long)cboFormName.SelectedValue, (long)cboControlName.SelectedValue, (String)cboAction.Text, "", "", (long)Convert.ToDouble(0), (long)Convert.ToDouble(0));

                BugTracking.DeveloperBug BlackBoxBug = new BugTracking.DeveloperBug(BugID, txtTitle.Text, txtComment.Text, locationWB, (long)0, 0, true, Code);

                BlackBoxBug.createdByID = LoggedInUser.Id;

                DefaultUserID = ((BugTracking.App)cboApplication.SelectedItem).DefaultUser.Id;
                BlackBoxBug.AssignedUserID = DefaultUserID;

                BlackBoxBug.Save();

                //repopulates form with saved bug
                BugID = BlackBoxBug.Id;
                populateBugDetails();

                //Bug.createdByID = createdByID;
                //DeveloperBug.AssignedUserID = (long)cboAssignedUser.SelectedValue;
                break;

            case "Black Box Tester":
                if (txtStartLineNumber.Text == "")
                {
                    txtStartLineNumber.Text = "0";
                }
                if (txtEndLineNumber.Text == "")
                {
                    txtEndLineNumber.Text = "0";
                }

                if (Code == null)
                {
                    Code = "";
                }
                //creates new Bug
                BugTracking.BugLocation locationBB = new BugTracking.BugLocation((long)cboApplication.SelectedValue, (long)cboFormName.SelectedValue, (long)cboControlName.SelectedValue, (String)cboAction.Text, txtRelatedMethod.Text, txtParameter.Text, (long)Convert.ToDouble(txtStartLineNumber.Text), (long)Convert.ToDouble(txtEndLineNumber.Text));

                BugTracking.Bug WhiteBoxBug = new BugTracking.Bug(BugID, txtTitle.Text, txtComment.Text);
                WhiteBoxBug.createdByID = LoggedInUser.Id;

                //gets default User for Appliocation selected
                DefaultUserID = ((BugTracking.App)cboApplication.SelectedItem).DefaultUser.Id;
                WhiteBoxBug.AssignedUserID = DefaultUserID;


                WhiteBoxBug.Save();

                //repopulates form with saved bug
                BugID = WhiteBoxBug.Id;
                populateBugDetails();
                break;

            case "Developer":


                if (txtStartLineNumber.Text == "")
                {
                    txtStartLineNumber.Text = "0";
                }
                if (txtEndLineNumber.Text == "")
                {
                    txtEndLineNumber.Text = "0";
                }

                if (Code == null)
                {
                    Code = "";
                }
                if (txtPriority.Text == "")
                {
                    txtPriority.Text = "0";
                }
                //creates Full developer bug
                BugTracking.BugLocation location = new BugTracking.BugLocation((long)cboApplication.SelectedValue, (long)cboFormName.SelectedValue, (long)cboControlName.SelectedValue, (String)cboAction.Text, txtRelatedMethod.Text, txtParameter.Text, (long)Convert.ToDouble(txtStartLineNumber.Text), (long)Convert.ToDouble(txtEndLineNumber.Text));

                BugTracking.DeveloperBug DeveloperBug = new BugTracking.DeveloperBug(BugID, txtTitle.Text, txtComment.Text, location, (long)0, Convert.ToInt64(txtPriority.Text), !chkOpen.Checked, Code);
                DefaultUserID = (long)cboAssignedUser.SelectedValue;

                DeveloperBug.createdByID    = LoggedInUser.Id;
                DeveloperBug.AssignedUserID = DefaultUserID;

                DeveloperBug.Save();
                //repopulates form with saved bug
                BugID = DeveloperBug.Id;
                populateBugDetails();
                break;

            default:


                break;
            }
        }
Пример #5
0
        /// <summary>
        /// populates form with bug details if not new Bug
        /// </summary>
        private void populateBugDetails()
        {
            //if not new bug
            if (BugID != 0)
            {
                BugTracking.DeveloperBug newBug = BugTracking.DeveloperBug.Get(BugID);

                //if developer bug then
                if (newBug != null)
                {
                    //assign bug details
                    txtTitle.Text    = newBug.Title;
                    txtComment.Text  = newBug.Comment;
                    txtPriority.Text = newBug.Priority.ToString();



                    cboApplication.SelectedValue = newBug.Location.application.Id;
                    cboFormName.SelectedValue    = newBug.Location.form.Id;
                    cboControlName.SelectedValue = newBug.Location.control.Id;
                    cboAction.Text        = newBug.Location.action;
                    txtRelatedMethod.Text = newBug.Location.relatedMethod;

                    txtParameter.Text       = newBug.Location.relatedParameter;
                    txtEndLineNumber.Text   = newBug.Location.EndlineNumber.ToString();
                    txtStartLineNumber.Text = newBug.Location.StartlineNumber.ToString();

                    cboAssignedUser.SelectedValue = newBug.AssignedUserID;
                    txtDateCreated.Text           = newBug.CreatedDate.ToShortDateString();



                    //gets any bug history
                    grdBugHistory.DataSource = BugTracking.DeveloperBug.getBugHistory(newBug.Id);


                    //selects current bug from list
                    foreach (DataGridViewRow row in grdBugHistory.Rows)
                    {
                        if ((long)row.Cells["id"].Value == newBug.Id)
                        {
                            row.Selected = true;
                        }
                        else
                        {
                            row.Selected = false;
                        }
                    }

                    Code = newBug.Code;

                    //if there are columns to hide
                    if (grdBugHistory.Columns.Count > 0)
                    {
                        grdBugHistory.Columns["Id"].Visible             = false;
                        grdBugHistory.Columns["previousBugID"].Visible  = false;
                        grdBugHistory.Columns["NextBugID"].Visible      = false;
                        grdBugHistory.Columns["BugOpen"].Visible        = false;
                        grdBugHistory.Columns["AssignedUserID"].Visible = false;
                        grdBugHistory.Columns["createdByID"].Visible    = false;
                    }

                    chkOpen.Checked = !newBug.BugOpen;

                    btnSave.Enabled = newBug.BugOpen;

                    getColourCode();



                    //checks to see if bug already has solution or if not latest in Bug History
                    if ((!newBug.BugOpen) || (newBug.NextBugId > 0))
                    {
                        grpBugdetails.Enabled  = false;
                        grpCodeDetails.Enabled = false;
                        grpManagement.Enabled  = false;
                        btnSave.Enabled        = false;
                    }
                    else
                    {
                        UserFormSettup();
                    }
                }
                else                 //if not developer bug yet
                {
                    BugTracking.Bug bug = new BugTracking.Bug(BugID);

                    if (bug != null)
                    {
                        txtTitle.Text    = bug.Title;
                        txtComment.Text  = bug.Comment;
                        txtPriority.Text = "0";

                        cboApplication.SelectedValue = bug.Location.application.Id;
                        cboFormName.SelectedValue    = bug.Location.form.Id;
                        cboControlName.SelectedValue = bug.Location.control.Id;
                        cboAction.Text = bug.Location.action;


                        txtRelatedMethod.Text = "";

                        txtParameter.Text       = "";
                        txtEndLineNumber.Text   = "";
                        txtStartLineNumber.Text = "";

                        cboAssignedUser.SelectedValue = bug.AssignedUserID;
                        txtDateCreated.Text           = bug.CreatedDate.ToShortDateString();



                        grdBugHistory.DataSource = null;



                        foreach (DataGridViewRow row in grdBugHistory.Rows)
                        {
                            if ((long)row.Cells["id"].Value == bug.Id)
                            {
                                row.Selected = true;
                            }
                            else
                            {
                                row.Selected = false;
                            }
                        }

                        Code = "";

                        //if there are columns to hide
                        if (grdBugHistory.Columns.Count > 0)
                        {
                            grdBugHistory.Columns["Id"].Visible             = false;
                            grdBugHistory.Columns["previousBugID"].Visible  = false;
                            grdBugHistory.Columns["NextBugID"].Visible      = false;
                            grdBugHistory.Columns["BugOpen"].Visible        = false;
                            grdBugHistory.Columns["AssignedUserID"].Visible = false;
                            grdBugHistory.Columns["createdByID"].Visible    = false;
                        }

                        chkOpen.Checked = true;


                        //Black Box testers cannot update a bug
                        if (LoggedInUser.UserType == "Black Box Tester")
                        {
                            btnSave.Enabled = false;
                        }
                        else
                        {
                            btnSave.Enabled = true;
                        }


                        getColourCode();



                        UserFormSettup();
                    }
                }
            }
        }
Пример #6
0
        public void TestListDeveloperBugCreate()
        {
            //public BugLocation(long applicationID, long formID, long controlID, string action, string relatedMethod, string relatedParameter, long startLineNumber, long endlineNumber)
            //list of Created Bug Ids
            List <long> IDlist = new List <long>();



            //first in List
            BugTracking.DeveloperBug bug = DeveloperBugSetup.getBug();


            IDlist.Add(bug.Id);

            //Second In List
            bug.Title = "Test Title Change";
            bug.Save();
            IDlist.Add(bug.Id);

            //third In List
            bug.Comment = "Test Comment Change";
            bug.Save();
            IDlist.Add(bug.Id);
            //forth In List
            bug.Code = "Dummy Code Change";
            bug.Save();
            IDlist.Add(bug.Id);
            //fith In List
            bug.Location.relatedMethod = "Related Method Test Change";
            bug.Save();
            IDlist.Add(bug.Id);
            //sixth In List
            bug.Location.StartlineNumber = 97;
            bug.Location.EndlineNumber   = 98;
            bug.Save();
            IDlist.Add(bug.Id);



            Boolean AllFound = true;

            //Get Bug History
            List <BugTracking.DeveloperBug> BugHistoryList = BugTracking.DeveloperBug.getBugHistory(IDlist[3]);

            int listPosition = BugHistoryList.Count - 1;



            foreach (BugTracking.DeveloperBug newBug in BugHistoryList)
            {
                if (newBug.Id != IDlist[listPosition])
                {
                    AllFound = false;
                }
                else
                {
                    //Test that each change was kept from previous to next Bug
                    switch (listPosition)
                    {
                    case 5:
                        if (newBug.Location.StartlineNumber != 97)
                        {
                            AllFound = false;
                        }
                        if (newBug.Location.EndlineNumber != 98)
                        {
                            AllFound = false;
                        }

                        break;

                    case 4:
                        if (newBug.Location.relatedMethod != "Related Method Test Change")
                        {
                            AllFound = false;
                        }

                        if (newBug.Location.StartlineNumber != 1)
                        {
                            AllFound = false;
                        }

                        if (newBug.Location.EndlineNumber != 99)
                        {
                            AllFound = false;
                        }

                        break;

                    case 3:
                        if (newBug.Location.relatedMethod != "Related Method Test")
                        {
                            AllFound = false;
                        }

                        if (newBug.Code != "Dummy Code Change")
                        {
                            AllFound = false;
                        }

                        break;

                    case 2:
                        if (newBug.Code != "Dummy Code")
                        {
                            AllFound = false;
                        }
                        ;
                        if (newBug.Comment != "Test Comment Change")
                        {
                            AllFound = false;
                        }

                        break;

                    case 1:
                        if (newBug.Title != "Test Title Change")
                        {
                            AllFound = false;
                        }

                        if (newBug.Comment != "Test Comment")
                        {
                            AllFound = false;
                        }

                        break;

                    case 0:
                        if (newBug.Title != "Test Title")
                        {
                            AllFound = false;
                        }

                        break;
                    }
                }
                //delete bug once checked
                newBug.Delete();
                listPosition -= 1;
            }

            //delete left overs
            DeveloperBugSetup.deleteAllBug(bug);



            Assert.AreEqual(AllFound, true);
        }
Пример #7
0
        public void TestDeveloperBugCreate()
        {
            //public BugLocation(long applicationID, long formID, long controlID, string action, string relatedMethod, string relatedParameter, long startLineNumber, long endlineNumber)

            //create dummy controls
            BugTracking.User user = new BugTracking.User("FirstName", "LastName", "Developer");
            user.Save();
            BugTracking.App app = new BugTracking.App("TestApp1", user);
            app.Save();

            BugTracking.AppForm form = new BugTracking.AppForm("Label Test", "Name Test", true, app.Id);
            form.Save();

            BugTracking.FormControl control = new BugTracking.FormControl("label Test", "Name Test", true, app.Id);
            control.Save();

            BugTracking.Action action = new BugTracking.Action("label Test", "Name Test", app.Id);

            BugTracking.BugLocation location = new BugTracking.BugLocation(app.Id, form.Id, control.Id, action.Name, "Related Method Test", "Related Parameter Test", 1, 99);

            BugTracking.DeveloperBug bug = new BugTracking.DeveloperBug("Test Title", "Test Comment", location, 0, -1, false, "Dummy Code");


            bug.createdByID = user.Id;


            bug.AssignedUserID = user.Id;
            bug.Save();

            BugTracking.Bug commitedBug = new BugTracking.Bug(bug.Id);


            Boolean AllFound = true;

            if (user.Id != commitedBug.AssignedUserID)
            {
                //app retreived

                AllFound = false;
            }
            if (user.Id != commitedBug.createdByID)
            {
                //app retreived

                AllFound = false;
            }
            if (app.Id != commitedBug.Location.application.Id)
            {
                //app retreived

                AllFound = false;
            }
            if (form.Id != commitedBug.Location.form.Id)
            {
                //form retreived
                AllFound = false;
            }
            if (control.Id != commitedBug.Location.control.Id)
            {
                //control retreived
                AllFound = false;
            }
            if (action.Name != commitedBug.Location.action)
            {
                //action retreived

                AllFound = false;
            }
            if (location.Id != commitedBug.Location.Id)
            {
                //location retreived

                AllFound = false;
            }
            if (bug.Id != commitedBug.Id)
            {
                //app retreived

                AllFound = false;
            }



            user.Delete();
            control.Delete();
            form.Delete();
            app.Delete();
            location.Delete();
            bug.Delete();

            Assert.AreEqual(AllFound, true);
        }