public void TestInsertUser_Success()
        {
            var context = new MockProjectManagerEntities();

            context.Users = new TestDbSet <DAC.User>();

            var user = new Models.User();

            user.FirstName  = "ankita";
            user.LastName   = "ghosh";
            user.EmployeeId = "123456";
            user.UserId     = 123;
            var controller = new UserController(new MockUserBC(context));
            var result     = controller.InsertUserDetails(user) as JSendResponse;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Data, 1);
        }
示例#2
0
        public void TestDeleteProject_NoProjectAsParameter()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "414942",
                First_Name  = "ankita",
                Last_Name   = "ghosh",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users = users;
            Models.Project testProject = null;
            var            controller  = new ProjectController(new MockProjectBC(context));
            var            result      = controller.DeleteProjectDetails(testProject) as JSendResponse;
        }
示例#3
0
        public void TestInsertTasks_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "414942",
                First_Name  = "ankita",
                Last_Name   = "ghosh",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users = users;
            context.Tasks = new TestDbSet <DAC.Task>();

            var task = new PMServer.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  = "ankita",
                    LastName   = "ghosh",
                    EmployeeId = "123456",
                    UserId     = 123
                }
            };

            var controller = new TaskController(new MockTaskBC(context));
            var result     = controller.InsertTaskDetails(task) as JSendResponse;


            Assert.IsNotNull(result);

            Assert.IsNotNull((context.Users.Local[0]).Task_ID);
        }
示例#4
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   = 123456,
                Parent_Task = "PNB"
            });
            context.ParentTasks = parentTasks;
            users.Add(new DAC.User()
            {
                Employee_ID = "414942",
                First_Name  = "ankita",
                Last_Name   = "ghosh",
                User_ID     = 123,
                Task_ID     = 1
            });
            context.Users = users;
            int projectid = 1234;

            tasks.Add(new DAC.Task()
            {
                //Task_ID = 1,
                Task1      = "ASDQW",
                Parent_ID  = 123456,
                Project_ID = 1234,
                Start_Date = DateTime.Now,
                End_Date   = DateTime.Now.AddDays(2),
                Priority   = 10,
                Status     = 0
            });
            context.Tasks = tasks;
            var controller = new TaskController(new MockTaskBC(context));
            var result     = controller.RetrieveTaskByProjectId(projectid) as JSendResponse;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Data, typeof(List <PMServer.Models.Task>));
        }
示例#5
0
        public void TestInsertProjects_Success()
        {
            var context = new MockProjectManagerEntities();
            var users   = new TestDbSet <DAC.User>();

            users.Add(new DAC.User()
            {
                Employee_ID = "414942",
                First_Name  = "ankita",
                Last_Name   = "ghosh",
                User_ID     = 123,
                Task_ID     = 123
            });
            context.Users    = users;
            context.Projects = new TestDbSet <DAC.Project>();

            var testProject = new Models.Project()
            {
                ProjectId          = 12345,
                ProjectName        = "MyProject",
                ProjectStartDate   = DateTime.Now,
                ProjectEndDate     = DateTime.Now.AddDays(5),
                Priority           = 3,
                NoOfCompletedTasks = 3,
                NoOfTasks          = 5,
                User = new User()
                {
                    FirstName  = "ankita",
                    LastName   = "ghosh",
                    EmployeeId = "123456",
                    UserId     = 123
                }
            };
            var controller = new ProjectController(new MockProjectBC(context));
            var result     = controller.InsertProjectDetails(testProject) as JSendResponse;

            Assert.IsNotNull(result);
            Assert.IsNotNull((context.Users.Local[0]).Project_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  = "Prateek",
                Last_Name   = "Gangopadhyay",
                Project_ID  = 123,
                Task_ID     = 123,
                User_ID     = 418220
            });
            users.Add(new DAC.User()
            {
                Employee_ID = "503322",
                First_Name  = "Khushboo",
                Last_Name   = "Jain",
                Project_ID  = 1234,
                Task_ID     = 1234,
                User_ID     = 503322
            });
            context.Users = users;

            var user = new Models.User();

            user.FirstName  = "Khushboo";
            user.LastName   = "Jain";
            user.EmployeeId = "503322";
            user.UserId     = 503322;

            var controller = new UserController(new MockUserBC(context));
            var result     = controller.DeleteUserDetails(user) as JSendResponse;

            Assert.IsNotNull(result);
            Assert.AreEqual(context.Users.Local.Count, 1);
        }
示例#7
0
        public void TestRetrieveParentTasks_Success()
        {
            var context     = new MockProjectManagerEntities();
            var parentTasks = new TestDbSet <DAC.ParentTask>();

            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID   = 12345,
                Parent_Task = "ANB"
            });
            parentTasks.Add(new DAC.ParentTask()
            {
                Parent_ID   = 123456,
                Parent_Task = "PNB"
            });
            context.ParentTasks = parentTasks;

            var controller = new TaskController(new MockTaskBC(context));
            var result     = controller.RetrieveParentTasks() as JSendResponse;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Data, typeof(List <PMServer.Models.ParentTask>));
            Assert.AreEqual((result.Data as List <ParentTask>).Count, 2);
        }
 public MockUserBC(MockProjectManagerEntities mockBd)
 {
     _mockBd = mockBd;
 }