Ejemplo n.º 1
0
        public async void ArchiveProject_ReturnsNoContent()
        {
            _projectService.Setup(s => s.ArchiveProject(It.IsAny <int>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            var controller = new ProjectController(_projectService.Object, _mapper, _logger.Object);

            var result = await controller.ArchiveProject(1);

            Assert.IsType <NoContentResult>(result);
        }
Ejemplo n.º 2
0
        public async Task ArchiveProject()
        {
            var createResult = await projectController.CreateProject(new ProjectCreateDTO()
            {
                ClientName  = "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
                Description = "This project must be archived!",
                ProjectName = "Test Name",
                Tags        = new List <string>()
                {
                    "PLEASE ARCHIVE"
                }
            });

            Assert.IsTrue(createResult.Success);

            await projectController.ArchiveProject(new ArchiveProjectDTO()
            {
                Archive   = true,
                ProjectId = createResult.Data
            });

            var projectUpdated = await projectController.GetProjectById(createResult.Data);

            // This test will fail if it starts on one day and ends on another
            // I think the chances of that would be like winning the lottery though so we ok
            Assert.IsTrue(projectUpdated.Data.ArchivedDate.Value.Date == DateTime.UtcNow.Date);

            await projectController.ArchiveProject(new ArchiveProjectDTO()
            {
                Archive   = false,
                ProjectId = createResult.Data
            });

            projectUpdated = await projectController.GetProjectById(createResult.Data);

            Assert.IsNull(projectUpdated.Data.ArchivedDate);
        }