public void AddProject()
        {
            var projectController       = new ProjectsController(_projectService, _mapper);
            Task <IActionResult> result = projectController.Add(_project);

            Assert.That(result.IsCompleted, Is.True);
        }
        public void Can_Add_New_Project()
        {
            //Arrange

            var tempDataMock = new Mock <ITempDataDictionary>();

            var projectRepositoryMock = new Mock <IProjectRepository>();

            var factoryMock = new Mock <IAddProjectFactory>();

            factoryMock.Setup(m => m.Create()).Returns(new AddProject(projectRepositoryMock.Object, eventBus.Object));

            //Act

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

            target.TempData = tempDataMock.Object;

            var targetResult = target.Add("nowy");

            //Assert

            projectRepositoryMock.Verify(m => m.Add(It.IsAny <Project>()));
            Assert.True(targetResult.StatusCode == HttpStatusCode.NoContent);
        }
Beispiel #3
0
        private void UpdateProjectReports(WizardContext wizardContext, FileBasedProject project, AutomaticTask automaticTask)
        {
            if (project == null)
            {
                return;
            }

            try
            {
                _supressProjectControllerEvents = true;

                _projectsController.Close(project);
                _projectSettingsService.UpdateAnalysisTaskReportInfo(project, automaticTask);
                _projectsController.Add(project.FilePath);

                switch (wizardContext.Owner)
                {
                case Enumerators.Controller.Files:
                    _filesController.Activate();
                    break;

                case Enumerators.Controller.Projects:
                    _projectsController.Activate();
                    break;
                }
            }
            finally
            {
                _supressProjectControllerEvents = false;
            }
        }
        public void Cannot_Add_New_Project_With_Empty_Name()
        {
            //Arrange

            var tempDataMock = new Mock <ITempDataDictionary>();

            var projectRepositoryMock = new Mock <IProjectRepository>();

            var factoryMock = new Mock <IAddProjectFactory>();

            factoryMock.Setup(m => m.Create()).Returns(new AddProject(projectRepositoryMock.Object, eventBus.Object));

            //Act

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

            target.TempData = tempDataMock.Object;

            var targetResult = target.Add("");

            //Assert

            Assert.True(targetResult.StatusCode == HttpStatusCode.InternalServerError);
        }