public void GetTask_ShouldReturnNotFound()
        {
            var context = new TestProjectMangerContext();

            context.Tasks.Add(GetDemoTask());
            context.Users.Add(GetDemoUser());

            var controller = new TasksController(context);
            var result     = controller.GetTask(2);

            Assert.AreEqual(0, result.Count);
        }
        public void GetTasks_ShouldReturnAllProjects()
        {
            var context = new TestProjectMangerContext();

            context.Parent_Task.Add(GetDemoParentTask());
            context.Tasks.Add(GetDemoTask());
            var controller = new TasksController(context);
            var result     = controller.GetTasks(1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
        }
        public void GetProject_ShouldReturnNotFound()
        {
            var context = new TestProjectMangerContext();

            context.Projects.Add(GetDemoProject());

            var controller = new ProjectsController(context);
            var result     = controller.GetProject(2);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.GetType(), typeof(NotFoundResult));
        }
        public void GetTask_ShouldReturnProjectWithSameID()
        {
            var context = new TestProjectMangerContext();

            context.Tasks.Add(GetDemoTask());
            context.Users.Add(GetDemoUser());
            var controller = new TasksController(context);
            var result     = controller.GetTask(1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
        }
        public void GetProject_ShouldReturnProjectWithSameID()
        {
            var context = new TestProjectMangerContext();

            context.Projects.Add(GetDemoProject());

            var controller = new ProjectsController(context);
            var result     = controller.GetProject(1) as OkNegotiatedContentResult <Project>;

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Content.Project_Id);
        }
Exemple #6
0
        public void GetUser_ShouldReturnUserWithSameID()
        {
            var context = new TestProjectMangerContext();

            context.Users.Add(GetDemoUser());

            var controller = new UserController(context);
            var result     = controller.GetUser(1) as OkNegotiatedContentResult <User>;

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Content.User_ID);
        }
        public void PutTask_ShouldReturnStatusCode()
        {
            var context = new TestProjectMangerContext();
            var item    = GetDemoTask();

            context.Users.Add(GetDemoUser());
            var controller = new TasksController(context);
            var result     = controller.PutTask(item.Task_ID, item) as StatusCodeResult;

            Assert.IsNotNull(result);
            Assert.AreSame(result.GetType(), typeof(StatusCodeResult));
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
        public void DeleteTask_ShouldReturnNotFound()
        {
            var context = new TestProjectMangerContext();
            var item    = GetDemoTask();

            context.Tasks.Add(item);

            var controller = new TasksController(context);
            var result     = controller.DeleteTask(2);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.GetType(), typeof(NotFoundResult));
        }
        public void DeleteTask_ShouldReturnOK()
        {
            var context = new TestProjectMangerContext();
            var item    = GetDemoTask();

            context.Tasks.Add(item);

            var controller = new TasksController(context);
            var result     = controller.DeleteTask(1) as OkNegotiatedContentResult <Task>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Task_ID, result.Content.Task_ID);
        }
        public void DeleteProject_ShouldReturnOK()
        {
            var context = new TestProjectMangerContext();
            var item    = GetDemoProject();

            context.Projects.Add(item);

            var controller = new ProjectsController(context);
            var result     = controller.DeleteProject(1) as OkNegotiatedContentResult <Project>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Project_Id, result.Content.Project_Id);
        }
Exemple #11
0
        public void GetUser_ShouldReturnNotFound()
        {
            var context = new TestProjectMangerContext();
            var item    = GetDemoUser();

            context.Users.Add(item);

            var controller = new UserController(context);
            var result     = controller.GetUser(2);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.GetType(), typeof(NotFoundResult));
        }
        public void GetProjects_ShouldReturnAllProjects()
        {
            var context = new TestProjectMangerContext();

            context.Projects.Add(new Project {
                Project_Id = 1, Project_Name = "Project1", EndDate = DateTime.Now, StartDate = DateTime.Now, Priority = 15
            });
            context.Users.Add(GetDemoUser());
            var controller = new ProjectsController(context);
            var result     = controller.GetProjects();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
        }
        public void PostTask_ShouldReturnSameProduct()
        {
            var context    = new TestProjectMangerContext();
            var controller = new TasksController(context);

            context.Users.Add(GetDemoUser());

            var item = GetDemoTask();

            var result =
                controller.PostTask(item) as CreatedAtRouteNegotiatedContentResult <Task>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.RouteName, "DefaultApi");
            Assert.AreEqual(result.RouteValues["id"], result.Content.Task_ID);
            Assert.AreEqual(result.Content.Task_Name, item.Task_Name);
        }
        public void GetParentTask_ShouldReturnAllUsers()
        {
            var context = new TestProjectMangerContext();

            context.Parent_Task.Add(new Parent_Task {
                Parent_ID = 1, Parent_Task_Name = "Parent Task 1"
            });
            context.Parent_Task.Add(new Parent_Task {
                Parent_ID = 2, Parent_Task_Name = "Parent Task 2"
            });

            var controller = new ParentTaskController(context);
            var result     = controller.GetParent_Task() as TestParentTaskDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Local.Count);
        }
Exemple #15
0
        public void GetUsers_ShouldReturnAllUsers()
        {
            var context = new TestProjectMangerContext();

            context.Users.Add(new User {
                User_ID = 1, FirstName = "Demo1"
            });
            context.Users.Add(new User {
                User_ID = 2, FirstName = "Demo1"
            });
            context.Users.Add(new User {
                User_ID = 3, FirstName = "Demo1"
            });

            var controller = new UserController(context);
            var result     = controller.GetUsers() as TestUserDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }