public void TestDeleteProject_NoProjectAsParameter()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "136600",
                First_Name  = "Sachin",
                Last_Name   = "Kumar",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users = users;
            Models.Project testProject = null;
            var            controller  = new ProjectController(new BusLayer.ProjectBL(context));
            var            result      = controller.DeleteProjectDetails(testProject) as JsonResponse;
        }
Beispiel #2
0
        public void TestRetrieveTasks_Success()
        {
            var context     = new MockProjectManagerEntities();
            var tasks       = new TestDbSet <DAC.Task>();
            var users       = new TestDbSet <DAC.User>();
            var parentTasks = new TestDbSet <DAC.ParentTask>();

            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID        = 789,
                Parent_Task_Name = "PNB"
            });
            context.ParentTasks = parentTasks;
            users.Add(new DAC.User()
            {
                Employee_ID = "136600",
                First_Name  = "Sachin",
                Last_Name   = "Kumar",
                User_ID     = 123,
                Task_ID     = 1
            });
            context.Users = users;
            int projectid = 4567;

            tasks.Add(new DAC.Task()
            {
                Task_ID    = 1,
                Task_Name  = "ASDQW",
                Parent_ID  = 789,
                Project_ID = 4567,
                Start_Date = DateTime.Now,
                End_Date   = DateTime.Now.AddDays(2),
                Priority   = 10,
                Status     = 0
            });
            context.Tasks = tasks;
            var controller = new TaskController(new BusLayer.TaskBL(context));
            var result     = controller.RetrieveTaskByProjectId(projectid) as JsonResponse;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Data, typeof(List <ProjectManagerAPI.Models.Task>));
        }
Beispiel #3
0
        public void TestInsertTasks_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "136600",
                First_Name  = "Sachin",
                Last_Name   = "Kumar",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users = users;
            var task = new ProjectManagerAPI.Models.Task()
            {
                Task_Name  = "ASDQW",
                Parent_ID  = 123674,
                Project_ID = 34856,
                Start_Date = DateTime.Now,
                End_Date   = DateTime.Now.AddDays(2),
                Priority   = 10,
                Status     = 0,
                User       = new User()
                {
                    FirstName  = "Sachin",
                    LastName   = "Kumar",
                    EmployeeId = "789",
                    UserId     = 123
                }
            };

            var controller = new TaskController(new BusLayer.TaskBL(context));
            var result     = controller.InsertTaskDetails(task) as JsonResponse;


            Assert.IsNotNull(result);

            Assert.IsNotNull((context.Users.Local[0]).Task_ID);
        }
        public void TestDeleteUser_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "418220",
                First_Name  = "Rahul",
                Last_Name   = "Dravid",
                Project_ID  = 123,
                Task_ID     = 123,
                User_ID     = 418220
            });
            users.Add(new DAC.User()
            {
                Employee_ID = "136601",
                First_Name  = "Rana",
                Last_Name   = "Pratap",
                Project_ID  = 4567,
                Task_ID     = 4567,
                User_ID     = 136601
            });
            context.Users = users;

            var user = new Models.User();

            user.FirstName  = "Rana";
            user.LastName   = "Pratap";
            user.EmployeeId = "136601";
            user.UserId     = 136601;

            var controller = new UserController(new BusLayer.UserBL(context));
            var result     = controller.DeleteUserDetails(user) as JsonResponse;

            Assert.IsNotNull(result);
            Assert.AreEqual(context.Users.Local.Count, 1);
        }
        public void TestInsertProjects_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "136600",
                First_Name  = "Sachin",
                Last_Name   = "Kumar",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users = users;
            var testProject = new Models.Project()
            {
                ProjectId          = 45675,
                ProjectName        = "MyProject",
                ProjectStartDate   = DateTime.Now,
                ProjectEndDate     = DateTime.Now.AddDays(5),
                Priority           = 3,
                NoOfCompletedTasks = 3,
                NoOfTasks          = 5,
                User = new User()
                {
                    FirstName  = "Sachin",
                    LastName   = "Kumar",
                    EmployeeId = "789",
                    UserId     = 123
                }
            };
            var controller = new ProjectController(new BusLayer.ProjectBL(context));
            var result     = controller.InsertProjectDetails(testProject) as JsonResponse;

            Assert.IsNotNull(result);
            Assert.IsNotNull((context.Users.Local[0]).Project_ID);
        }
Beispiel #6
0
        public void TestRetrieveParentTasks_Success()
        {
            var context     = new MockProjectManagerEntities();
            var parentTasks = new TestDbSet <DAC.ParentTask>();

            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID        = 45675,
                Parent_Task_Name = "ANB"
            });
            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID        = 789,
                Parent_Task_Name = "PNB"
            });
            context.ParentTasks = parentTasks;

            var controller = new TaskController(new BusLayer.TaskBL(context));
            var result     = controller.RetrieveParentTasks() as JsonResponse;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Data, typeof(List <ProjectManagerAPI.Models.ParentTask>));
            Assert.AreEqual((result.Data as List <ParentTask>).Count, 2);
        }