Exemplo n.º 1
0
        public void Technician_Update_Default_Should_Pass()
        {
            // Arrange
            var myController = new TechnicianController();

            // Act
            var result = myController.Update("abc");

            // Assert
            Assert.IsNotNull(result);
        }
        public bool Schedule(ServiceRequest sr)
        {
            TechnicianController techCtr = new TechnicianController();

            List <Package>    packages = sr.ServiceContract.Packages;
            List <Technician> techs    = techCtr.Read();

            Technician     techMin = null;
            Service        serMin  = null;
            RequestAgent   reqAgent;
            List <Service> skills;

            foreach (Package i in packages)
            {
                foreach (Technician j in techs)
                {
                    skills = j.Skills;

                    foreach (Service k in skills)
                    {
                        if (k.Equals(i.Service))
                        {
                            int queueDuration    = GetQueueDuration(j);
                            int queueDurationMin = GetQueueDuration(j);
                            if (techMin != null)
                            {
                                queueDurationMin = GetQueueDuration(techMin);
                            }

                            if (queueDuration <= queueDurationMin)
                            {
                                techMin = j;
                                serMin  = k;
                            }
                        }
                    }
                }

                if (techMin == null)
                {
                    return(false);
                }

                techMin.EmploymentStatus = "Working";
                techCtr.Update(techMin);
                reqAgent = new RequestAgent(serMin, techMin);
                rqCtr.Add(reqAgent, sr);

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public void Technician_Update_Get_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new TechnicianController();
            var myData       = BiliWeb.Backend.TechnicianBackend.Instance.Index().FirstOrDefault();

            // Act
            var result = myController.Update(myData.ID) as ViewResult;

            // Assert
            Assert.IsNotNull(result.Model);
        }
Exemplo n.º 4
0
        public void Technician_Update_Get_InValid_ID_Bogus_Should_Fail()
        {
            // Arrange
            var myController = new TechnicianController();

            // Act
            var result = myController.Update("abc");

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
        public void EditTechnician(Technician tech, List <Service> newSkills, List <Service> oldSkills)
        {
            techCtr.Update(tech);

            foreach (Service i in genLogic.GetAddedItems(oldSkills, newSkills))
            {
                techCtr.Add(i, tech);
            }

            foreach (Service i in genLogic.GetRemovedItems(oldSkills, newSkills))
            {
                techCtr.Remove(i, tech);
            }
        }
Exemplo n.º 6
0
        public void Technician_Update_Post_Default_Should_Pass()
        {
            // Arrange
            var myController = new TechnicianController();
            var myData       = new TechnicianModel();

            // Act
            var result = myController.Update(myData);

            // Reset

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 7
0
        public void Technician_Update_Post_Invalid_Model_Should_Send_Back_For_Edit()
        {
            // Arrange
            var controller = new TechnicianController();
            var data       = new TechnicianModel();

            // Make ModelState Invalid
            controller.ModelState.AddModelError("test", "test");

            // Act
            var result = controller.Update(data) as NotFoundResult;

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
Exemplo n.º 8
0
        private void btnComplete_Click(object sender, EventArgs e)
        {
            currentServiceRequest.Status = "Resolved";
            RequestController rqCtr = new RequestController();

            rqCtr.Update(currentServiceRequest);

            if (sdLogic.GetQueueDuration(tech) == 0)
            {
                tech.EmploymentStatus = "Open";
                TechnicianController techCtr = new TechnicianController();
                techCtr.Update(tech);
            }

            LoadData();
        }
Exemplo n.º 9
0
        public void Technician_Update_Post_Valid_Data_Should_Pass()
        {
            // Arrange
            var myController = new TechnicianController();
            var myData       = BiliWeb.Backend.TechnicianBackend.Instance.Index().FirstOrDefault();
            var resultData   = new TechnicianModel(myData)
            {
                FirstName = "New",
                ID        = myData.ID
            };

            // Act
            var result = myController.Update(resultData) as RedirectToActionResult;

            //Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.AreEqual("Index", result.ActionName);
        }