Ejemplo n.º 1
0
        public void UpdateProject()
        {
            //Arrange
            var context        = new TestProjectManagerContext();
            var testController = new TestProjectController();

            testController.Projects().ForEach(x =>
            {
                context.Projects.Add(x);
            });

            var project = new Project()
            {
                ProjectId = 2, Project_Name = "Test Project 2", Priority = 25, Start_Date = new DateTime(2018, 10, 1), End_Date = new DateTime(2018, 10, 2)
            };

            //Act
            var     controller = new ProjectController(context);
            dynamic result     = controller.UpdateProject(project);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, context.Projects.Find(2).ProjectId);
            Assert.AreEqual(project.Project_Name, context.Projects.Find(2).Project_Name);
            Assert.AreEqual(project.Priority, context.Projects.Find(2).Priority);
        }
Ejemplo n.º 2
0
        public void DeleteProject()
        {
            //Arrange
            var context        = new TestProjectManagerContext();
            var testController = new TestProjectController();

            testController.Projects().ForEach(x =>
            {
                context.Projects.Add(x);
            });

            var project = new Project()
            {
                ProjectId = 1
            };

            //Act
            var controller = new ProjectController(context);

            Assert.AreEqual(2, context.Projects.Count());
            dynamic result = controller.DeleteProject(project.ProjectId);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, context.Projects.Count());
        }
Ejemplo n.º 3
0
        public void GetProjectById_ReturnProject()
        {
            //Arrange
            var context        = new TestProjectManagerContext();
            var testController = new TestProjectController();

            testController.Projects().ForEach(x =>
            {
                context.Projects.Add(x);
            });


            //Act
            var     controller = new ProjectController(context);
            dynamic result     = controller.GetProjectById(1);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(1, result.Content.ProjectId);
        }
Ejemplo n.º 4
0
        public void AddProject()
        {
            //Arrange
            var context        = new TestProjectManagerContext();
            var testController = new TestProjectController();

            testController.Projects().ForEach(x =>
            {
                context.Projects.Add(x);
            });

            var task = new Project()
            {
                ProjectId = 3, Project_Name = "Test 3", Priority = 5, Start_Date = new DateTime(2018, 10, 1), End_Date = new DateTime(2018, 10, 2)
            };

            //Act
            var     controller = new ProjectController(context);
            dynamic result     = controller.AddProject(task);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, context.Projects.Find(3).ProjectId);
        }