public void ProjectsController_Delete()
        {
            _projectService.Setup(service => service.Delete(It.IsAny <Guid>()));
            LoadRequestInController(_projectController, HttpMethod.Delete, url);

            var response = _projectController.Delete(Guid.NewGuid());

            _projectService.Verify(service => service.Delete(It.IsAny <Guid>()), Times.Once());
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
Esempio n. 2
0
        public void DeleteWhenIdNull()
        {
            // ARRANGE
            // arrange nullable int to pass as an argument
            int?nullId = null;

            // ACT
            var result = _controller.Delete(nullId) as HttpStatusCodeResult;

            // ASSERT
            Assert.AreEqual((int)HttpStatusCode.BadRequest, result.StatusCode);
        }
        public void Project_Delete_With_Error()
        {
            _mockUserContext.Setup(x => x.HasGroupPermission(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            _controller.ModelState.AddModelError("Error", "Error");

            var result = _controller.Delete(FakeViewModels.MakeIdInput());

            Assert.IsInstanceOf <JsonResult>(result);
            var jsonResult = result as JsonResult;

            Assert.IsNotNull(jsonResult);
            Assert.AreEqual(jsonResult.Data, "Failure");
        }
Esempio n. 4
0
        public void WrongDelete(int id)
        {
            var controller = new ProjectsController(context);
            var response   = controller.Delete(id) as StatusCodeResult;

            Assert.AreEqual(404, response.StatusCode);
        }
Esempio n. 5
0
        private ProjectViewModel ConverActionResultToProjectViewModel()
        {
            var result = ProjectsController.Delete(1) as ViewResult;
            var model  = result.Model as ProjectViewModel;

            return(model);
        }
        public void Cannot_Delete_Project_With_Deleted_Status()
        {
            //Arrange

            var model = new Project {
                Id = 1, Status = ProjectStatus.Deleted, Name = "first"
            };

            var tempDataMock = new Mock <ITempDataDictionary>();
            var eventBusMock = new Mock <IEventBus>();

            var projectRepositoryMock = new Mock <IProjectRepository>();

            projectRepositoryMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(model);

            var factoryMock = new Mock <IDeleteProjectFactory>();

            factoryMock.Setup(m => m.Create())
            .Returns(new DeleteProject(projectRepositoryMock.Object, eventBusMock.Object));

            //Act

            var target = new ProjectsController(eventWatcher.Object, logger.Object, eventBus.Object, null, null,
                                                factoryMock.Object,
                                                null, null, null, null, null, null, null);

            target.TempData = tempDataMock.Object;

            var targetResult = target.Delete(1);

            //Assert

            Assert.True(targetResult.StatusCode == HttpStatusCode.InternalServerError);
        }
        public void Test_Delete_Project_Valid(int index)
        {
            // Arrange
            var existingProject    = mockProjectsList[index];
            var expectedTestResult = new OkNegotiatedContentResult <bool>(true, mockController);

            mockProjectsLogic.Setup(api => api.Remove(existingProject.ProjectId)).Returns(true);

            // Act
            var actualResult = mockController.Delete(existingProject.ProjectId);
            var actualData   = ((OkNegotiatedContentResult <bool>)actualResult).Content;

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.IsInstanceOf(typeof(OkNegotiatedContentResult <bool>), actualResult);
            Assert.IsTrue(actualData);
        }
Esempio n. 8
0
        public void ControllerDeleteProjectWithValidID()
        {
            var controller = new ProjectsController();
            var response   = controller.Delete(2);
            var result     = (OkResult)response;

            Assert.IsNotNull(result);
        }
Esempio n. 9
0
        public void ControllerDeleteProjectWithInvalidID()
        {
            var controller = new ProjectsController();

            var response = controller.Delete(1337);
            var result   = (NotFoundResult)response;

            Assert.IsNotNull(result);
        }
        public async Task DeleteProjectWithWrongId()
        {
            var controller = new ProjectsController(unit.Context);
            int id         = 40;//Try to delete the project with id (doesn't exist)

            var response = await controller.Delete(id) as ObjectResult;

            Assert.AreEqual(404, response.StatusCode);
        }
        public void DeleteProject()
        {
            var projectController = new ProjectsController(_projectService, _mapper);
            var result            = projectController.Delete(3);

            var okResult = result as OkObjectResult;

            Assert.That(okResult.StatusCode, Is.EqualTo(200));
        }
Esempio n. 12
0
        //[TestCase(2, Description = "Delete Project", TestName = "Test for Delete a valid Project returns Ok result")]
        public void Test_Delete_Project_Valid()
        {
            // Arrange
            int index              = 2;
            var existingProject    = mockProjectsList[index];
            var expectedTestResult = new OkObjectResult(true);

            mockProjectsLogic.Setup(api => api.Remove(existingProject.ProjectId)).Returns(true);

            // Act
            var actualResult = mockController.Delete(existingProject.ProjectId);
            var actualData   = (bool)((OkObjectResult)actualResult).Value;

            // Assert
            Assert.NotNull(actualResult);
            Assert.IsType <OkObjectResult>(actualResult);
            Assert.True(actualData);
        }
        public async Task DeleteProject()
        {
            var controller = new ProjectsController(unit.Context);
            int id         = 3;//Try to delete the project with id 3

            var response = await controller.Delete(id) as StatusCodeResult;

            Assert.AreEqual(204, response.StatusCode);
        }
Esempio n. 14
0
        public void ProjectControllerDelete()
        {
            var controller = new ProjectsController();

            var response = controller.Delete(4);
            var result   = (OkResult)response;

            Assert.IsNotNull(result);
        }
Esempio n. 15
0
        public void When_DeleteProjectIsCalled_ProjectIsDeletedAndSaved()
        {
            // Act
            var result = _projectsController.Delete(2);

            // Assert
            _mockDbSet.Verify(m => m.Find(It.IsAny <int>()), Times.Once());
            _mockDbSet.Verify(m => m.Remove(It.IsAny <Project>()), Times.Once());
            _mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
        public async Task Delete_given_validID_ReturnsOK()
        {
            projectLogic.Setup(r => r.DeleteAsync(1, 1)).ReturnsAsync(ResponseLogic.SUCCESS);
            userLogic.Setup(u => u.GetIdFromAzureUIdAsync("userid")).ReturnsAsync(1);

            var controller = new ProjectsController(projectLogic.Object, userLogic.Object, sparkLogic.Object)
            {
                GetUserId = () => "userid"
            };

            var response = await controller.Delete(1);

            Assert.IsType <OkResult>(response);
        }
Esempio n. 17
0
        public async Task TestDeleteMethodReturnsExpectedResult()
        {
            //Arrange
            var project = (TestData.GetProjects() as List <Project>).Find(x => x.ProjectId == 115);

            manageProject.Setup(x => x.GetProject(project.ProjectId)).Returns(Task.FromResult <Project>(project));

            //Act
            var result = await projectsController.Delete(project.ProjectId);

            //Assert
            Assert.NotNull(result);

            Assert.Equal(typeof(OkObjectResult), result.GetType());
            Assert.NotNull((result as OkObjectResult).Value);
            Assert.Equal(project.ProjectId, (result as OkObjectResult).Value);
        }
Esempio n. 18
0
        public async Task TestDelete()
        {
            //arrange
            HttpClientHandler handler = new HttpClientHandler();

            handler.UseDefaultCredentials = true;

            ProjectsController controller = new ProjectsController();

            List <Project> projects = controller.Get(1);

            int insertedID = projects[projects.Count - 1].Project_Id;
            //act



            bool succes = controller.Delete(insertedID);



            //assert

            Assert.AreEqual(succes, true);
        }
Esempio n. 19
0
        public void DeleteProjectSuccess()
        {
            Project p = new Project()
            {
                Name          = "Social network",
                BeginDate     = DateTime.Now.AddYears(-1),
                Monogram      = "SN",
                Amount        = 1500,
                Customer      = unit.Customer.Get(2),
                Description   = "Network for companies|",
                Pricing       = Pricing.FixedRate,
                StatusProject = StatusProject.InProgress,
                Team          = unit.Teams.Get("B")
            };

            unit.Projects.Insert(p);
            unit.Save();

            var controller = new ProjectsController();
            var response   = controller.Delete(p.Id);
            var result     = (OkResult)response;

            Assert.IsNotNull(result);
        }
 public void Benchmark_Performance_DeleteProjectElaspedTime()
 {
     _projectsController.Delete(2);
 }
Esempio n. 21
0
        public void WhenTheProjectDoesNotExistTheResultShouldGiveAnError()
        {
            var result = ProjectsController.Delete(1) as HttpNotFoundResult;

            result.StatusDescription.Should().Be("Project does not exist");
        }