public void DeleteProject_BadRequest_NotDeleted(string projectName)
        {
            _mockManager.Setup(x => x.DeleteProject(
                                   It.IsAny <string>())).Returns(false);

            IActionResult result = _sut.DeleteProject(projectName);

            ObjectResult notFoundResult = Assert.IsType <BadRequestObjectResult>(result);
        }
Esempio n. 2
0
        public async void TestDeleteProject()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test5")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var project2 = new Project("user", DateTime.Now, DateTime.Now, 1.00, "test", "test")
                {
                    ProjectId      = 4,
                    UserId         = "2",
                    StartDate      = DateTime.Now,
                    EndDate        = DateTime.Now,
                    PaymentOffered = 1.00,
                    ProjectName    = "test",
                    Description    = "test"
                };

                ProjectsController projectController = new ProjectsController(context);
                await projectController.DeleteProject(4);

                Project res = context.Projects.Find(4);
                Assert.Null(res);
            }
        }
Esempio n. 3
0
        public void DeleteProjectShouldReturnOk()
        {
            // ARRANGE
            _mockProjectRepository.Setup(pr => pr.GetById(1))
            .Returns(new Project {
                ProjectId = 1
            });

            // ACT
            var actionResult  = _projectsController.DeleteProject(1);
            var contentResult = actionResult as OkNegotiatedContentResult <Project>;

            // ASSERT
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(1, contentResult.Content.ProjectId);
        }
Esempio n. 4
0
        public async Task TestDeleteProject()
        {
            var obj = new ProjectsController();
            //var demoProject = GetDemoProjecttoDelete();
            var res = await obj.DeleteProject(13) as OkNegotiatedContentResult <Project>;

            Assert.IsNotNull(res);
            Assert.AreEqual(13, res.Content.ProjectID);
        }
Esempio n. 5
0
        public async void DeleteProjectsWithCorrectIdWillReturnOk()
        {
            _mockedRepository.Setup(x => x.DeleteByIdAsync(It.IsAny <int>())).ReturnsAsync(1);
            var myController = new ProjectsController(_mockedRepository.Object);
            var actionResult = await myController.DeleteProject(It.IsAny <int>());

            Assert.NotNull(actionResult);
            Assert.IsType <OkObjectResult>(actionResult.Result);
        }
        public void DeleteProject()
        {
            // Set up Prerequisites
            var controller = new ProjectsController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            var response = controller.DeleteProject(6);
            var res      = Task.FromResult(response);

            Assert.IsInstanceOf <OkNegotiatedContentResult <DAL.Project> >(response);
        }
        public void DeleteProject_ShouldReturnOK()
        {
            var context = new TestContext();
            var project = GetDemoProject();

            context.Projects.Add(project);

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

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

            context.Projects.Add(item);

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

            Assert.IsNotNull(result);
            Assert.AreEqual(result.GetType(), typeof(NotFoundResult));
        }
        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);
        }
        public void DeleteProjectTest()
        {
            IQueryable <DAL.Project> result = _ProjectsController.GetProjects();

            if (result != null)
            {
                Assert.IsNotNull(result);
                var Task = result.FirstOrDefault();
                IHttpActionResult deleteActionResult = _ProjectsController.DeleteProject(Task.Project_ID);
                Assert.IsNotNull(deleteActionResult);
                var contentResult = ((System.Web.Http.Results.OkNegotiatedContentResult <ProjectManagement.DAL.Project>)deleteActionResult).Content;
                Assert.IsNotNull(contentResult);
            }
        }
        public void DeleteProjectReturnsBadRequestIfModelStateHasErrors()
        {
            var request = new ProjectDeleteRequestDto()
            {
                ProjectId = 1
            };

            ProjectsController controller = this.ProjectsControllerInstance;

            controller.ModelState.AddModelError("error", "error");

            IActionResult result = controller.DeleteProject(request);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Esempio n. 12
0
        public async Task DeleteProject_CallWithMockedIProject_ReturnsOkObjectResult()
        {
            // Arrange
            var mock        = new Mock <IProject>();
            var projectGuid = Guid.NewGuid();
            var projectDto  = new ProjectDto()
            {
                Id   = projectGuid,
                Name = "Project"
            };

            mock.Setup(project => project.DeleteProjectAsync(projectGuid)).Returns(Task.Delay(0));
            var projectsController = new ProjectsController(mock.Object);

            // Act
            var result = await projectsController.DeleteProject(projectGuid);

            var response = (OkResult)result;

            // Assert
            Assert.IsType <OkResult>(result);
        }