Exemple #1
0
        public void GetAllTasks()
        {
            var db = new mitoden_dbgr13Entities();
            var ser = new Service1();
            var tasksProcedure = new List<TaskDTO>();
            tasksProcedure = ser.GetAllTasks();

            var tasksEntityFramework = db.Task.ToList();

            Assert.AreEqual(tasksProcedure.Count, tasksEntityFramework.Count);
        }
Exemple #2
0
        public void UpdateTaskStatus()
        {
            var db = new mitoden_dbgr13Entities();
            var ser = new Service1();

            ser.CreateTask("Unit Test", "norb0102", 1, DateTime.Now);
            var taskcreated = db.Task.LastOrDefault();
            ser.UpdateTaskStatus(taskcreated.TaskID, "Testing");

            var task = db.Task.Where(m => m.Feedback == "Testing").FirstOrDefault();
            Assert.AreEqual(task.TaskID, taskcreated.TaskID);
        }
Exemple #3
0
        public void GetAllTasksFromWorker()
        {
            var db = new mitoden_dbgr13Entities();
            var ser = new Service1();
            var tasksProcedure = new List<TaskDTO>();
            tasksProcedure = ser.GetAllTasksFromWorker("hohn");

            var tasksEntityFramework = db.Task.Where(m => m.FK_Username == "hohn").ToList();

            Assert.AreEqual(tasksProcedure[0].TaskID, tasksEntityFramework[0].TaskID);
            Assert.AreEqual(tasksProcedure.Count, tasksEntityFramework.Count);
        }
Exemple #4
0
        public void Login()
        {
            var db = new mitoden_dbgr13Entities();

            var user1 = db.Worker.FirstOrDefault(u => u.Username == "norb0102" && u.Password == "password");
            Assert.IsNotNull(user1);

            bool act1 = true;
            bool exp1 = user1.IsSuperviser.Value;
            Assert.AreEqual(exp1, act1);

            var user2 = db.Worker.FirstOrDefault(u => u.Username == "hohn" && u.Password == "password");
            Assert.IsNotNull(user2);

            bool act2 = false;
            bool exp2 = user2.IsSuperviser.Value;
            Assert.AreEqual(exp2, act2);

            var user3 = db.Worker.FirstOrDefault(u => u.Username == "lalala" && u.Password == "lalala");
            Assert.IsNull(user3);
        }
        protected void Button1_Click1(object sender, EventArgs e)
        {
            var db = new mitoden_dbgr13Entities();

            try
            {
                var myUser = db.Worker.FirstOrDefault
                (u => u.Username == (string)usernameBox.Text && u.Password == (string)passwordBox.Text);

                if (myUser != null)
                {
                    if (myUser.IsSuperviser == true)
                    {
                        Session["Supervisor"] = (string)usernameBox.Text;
                        Response.Redirect("Supervisor.aspx");
                        return;

                    }

                    if (myUser.IsSuperviser == false)
                    {
                        Session["Worker"] = (string)usernameBox.Text;
                        Response.Redirect("Worker.aspx");
                        return;
                    }
                }
                else
                {
                    Label1.Text = "Incorrect Username or Password. Try again.";
                    Label1.ForeColor = System.Drawing.Color.DarkRed;
                }

            }
            catch (Exception)
            {

            }
        }