public void InsertProject_Test() { // ARRANGE CreateProjectType(); var projectType = this.uow.ProjectTypes.GetAll().First(); var projectCreateParam = new ProjectCreateParam { Description = "Test description", Name = "Test project", ProjectType = projectType }; var projectLogic = new ProjectLogic(); // ACT projectLogic.InsertProject(projectCreateParam); projectLogic.Dispose(); this.uow.Dispose(); this.uow = new UnitOfWork(); // ASSERT var createdProject = this.uow.Projects.GetAll().First(); Assert.IsNotNull(createdProject); Assert.AreEqual(EnumDefinition.ProjectStatus.Active, createdProject.ProjectStatus); }
public void UpdateProject_Test() { // ARRANGE CreateProject(); var projectToUpdate = this.uow.Projects.GetAll().First(); var updateParam = new ProjectUpdateParam { Description = "Test description updated", Name = "Test project updated" }; var projectLogic = new ProjectLogic(); // ACT projectLogic.UpdateProject(updateParam, projectToUpdate.Id); projectLogic.Dispose(); this.uow.Dispose(); this.uow = new UnitOfWork(); // ASSERT var updatedProject = this.uow.Projects.Get(projectToUpdate.Id); Assert.IsNotNull(updatedProject); Assert.AreNotEqual(projectToUpdate.Name, updatedProject.Name); Assert.AreEqual(updateParam.Name, updatedProject.Name); Assert.AreEqual(updateParam.Description, updatedProject.Description); }
private void btn_DeleteProject_Click(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show( string.Format("{0}{1}", ResourceStringManager.GetResourceByKey("ConfirmDeleteMessageBoxMessage"), this.SelectedProject.Name), ResourceStringManager.GetResourceByKey("ConfirmDeleteMessageBoxTitle"), System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { var projectLogic = new ProjectLogic(); try { projectLogic.DeleteProject(this.SelectedProject.Id); } catch (Exception ex) { Logger.LogException(ex); MessageBox.Show(ResourceStringManager.GetResourceByKey("DeleteProjectFailedTitle"), ResourceStringManager.GetResourceByKey("DeleteProjectFailedMessage"), MessageBoxButton.OK, MessageBoxImage.Error); } projectLogic.Dispose(); this.lv_Projects.SelectedItem = null; this.Load(); this.RefreshBindings(this.PagingManager.CurrentPage); } }
public void CreateEntry() { var projectLogic = new ProjectLogic(); var project = projectLogic.GetProjectById(project_id); projectLogic.Dispose(); var subtaskLogic = new SubtaskLogic(); var subtask = subtaskLogic.GetById(this.SelectedSubtask.Id); ChangeParentAssignmentToInProgress(subtask); var entryCreateViewModel = new EntryCreateViewModel { Comment = this.tb_Description.Text, Date = DateTime.Now, Name = this.tb_Name.Text, Project = project, Subtask = subtask, DurationAsTicks = this.DurationElapsed.Ticks, Ended = this.stopped, Started = this.started }; subtaskLogic.AddEntry(this.SelectedSubtask.Id, entryCreateViewModel, this.chebo_FinishesSubtask.IsChecked.Value); subtaskLogic.Dispose(); this.Close(); }
private void btn_ToggleStatus_Click(object sender, RoutedEventArgs e) { var projectLogic = new ProjectLogic(); projectLogic.ToggleProjectStatus(this.SelectedProject.Id); projectLogic.Dispose(); this.Load(); }
private void LoadProjects() { var projectLogic = new ProjectLogic(); this.ProjectViewModels = projectLogic.GetAllProjects().Where(p => p.ProjectStatus != EnumDefinition.ProjectStatus.Archived) .Select(p => new ProjectViewModel(p)) .ToList(); projectLogic.Dispose(); this.ProjectViewModels.Add(new ProjectViewModel { Id = 0, Name = ResourceStringManager.GetResourceByKey("All") }); }
public AddAssignment(int assignment_id, int project_id) { InitializeComponent(); var assignmentLogic = new AssignmentLogic(); var projectLogic = new ProjectLogic(); this.Assignment = assignmentLogic.GetAssignmentById(assignment_id); this.Project = projectLogic.GetProjectById(project_id); assignmentLogic.Dispose(); projectLogic.Dispose(); this.EditMode = true; Load(); }
public void GetAllProjects_Test() { // ARRANGE CreateProjects(); var projectLogic = new ProjectLogic(); // ACT var foundProjects = projectLogic.GetAllProjects(); projectLogic.Dispose(); // ASSERT Assert.IsNotNull(foundProjects); Assert.AreEqual(3, foundProjects.Count()); }
public void GetProjectById_Test() { // ARRANGE CreateProject(); var project = this.uow.Projects.GetAll().First(); var projectLogic = new ProjectLogic(); // ACT var foundProject = projectLogic.GetProjectById(project.Id); projectLogic.Dispose(); // ASSERT Assert.IsNotNull(foundProject); Assert.AreEqual("Test project", foundProject.Name); }
public void RetrieveWorkingTime_Test() { // ARRANGE CreateProjectWithEntries(); var projectWithEntries = this.uow.Projects.GetAll().First(); var projectLogic = new ProjectLogic(); // ACT var workingTime = projectLogic.RetrieveWorkingTime(projectWithEntries.Id); projectLogic.Dispose(); // ASSERT var expected = new TimeSpan(3, 0, 0); Assert.IsTrue(expected <= workingTime); }
public void DeleteProject_TestFail() { // ARRANGE CreateProject(); var toBeDeleted = this.uow.Projects.GetAll().First(); var projectLogic = new ProjectLogic(); // ACT projectLogic.DeleteProject(toBeDeleted.Id); projectLogic.Dispose(); this.uow.Dispose(); this.uow = new UnitOfWork(); // ASSERT var deleted = this.uow.Projects.Get(toBeDeleted.Id); Assert.IsNull(deleted); }
public void DeleteProject_TestSuccess() { // ARRANGE CreateProject(); var toBeDeleted = this.uow.Projects.GetAll().First(); var projectLogic = new ProjectLogic(); // ACT projectLogic.SetStatus(toBeDeleted.Id, EnumDefinition.ProjectStatus.Archived); projectLogic.DeleteProject(toBeDeleted.Id); projectLogic.Dispose(); this.uow.Dispose(); this.uow = new UnitOfWork(); // ASSERT var deleted = this.uow.Projects.Get(toBeDeleted.Id); Assert.IsNull(deleted); }
public void SetStatus_Test() { // ARRANGE CreateProject(); var projectToUpdate = this.uow.Projects.GetAll().First(); var projectLogic = new ProjectLogic(); // ACT projectLogic.SetStatus(projectToUpdate.Id, EnumDefinition.ProjectStatus.Archived); projectLogic.Dispose(); this.uow.Dispose(); this.uow = new UnitOfWork(); // ASSERT var updatedProject = this.uow.Projects.Get(projectToUpdate.Id); Assert.IsNotNull(updatedProject); Assert.AreEqual(EnumDefinition.ProjectStatus.Archived, updatedProject.ProjectStatus); }
private void btn_AddProject_Click(object sender, RoutedEventArgs e) { if (this.SelectedProjectType != null && this.CanCreateProject && !editMode && !string.IsNullOrWhiteSpace(this.tb_projectDesignation.Text)) { var bllProjectTypes = new ProjectTypeLogic(); var bllProjects = new ProjectLogic(); var projectType = bllProjectTypes.GetProjectType(this.SelectedProjectType.Id); var viewModel = new ProjectCreateViewModel { Description = tb_projectDescription.Text, Name = tb_projectDesignation.Text, ProjectType = projectType }; bllProjects.InsertProject(viewModel); bllProjects.Dispose(); bllProjectTypes.Dispose(); this.Close(); } else if (this.SelectedProjectType != null && this.CanCreateProject && editMode) { var bllProjectTypes = new ProjectTypeLogic(); var bllProjects = new ProjectLogic(); var projectType = bllProjectTypes.GetProjectType(this.SelectedProjectType.Id); var viewModel = new ProjectUpdateViewModel { Description = this.tb_projectDescription.Text, Name = this.tb_projectDesignation.Text }; bllProjects.UpdateProject(viewModel, projectId); bllProjects.Dispose(); bllProjectTypes.Dispose(); this.Close(); } }
private void ShowAddAssignmentDialog(bool editMode) { AddAssignment addAssignmentWindow = null; var projectLogic = new ProjectLogic(); int? projectId = null; if (this.SelectedProject != null) { projectId = this.SelectedProject.Id; } else if (this.SelectedAssignment != null) { projectId = this.SelectedAssignment.ProjectId; } if (projectId.HasValue) { var project = projectLogic.GetProjectById(projectId.Value); projectLogic.Dispose(); if (editMode) { var assignmentLogic = new AssignmentLogic(); var selectedAssignment = assignmentLogic.GetAssignmentById(this.SelectedAssignment.Id); assignmentLogic.Dispose(); addAssignmentWindow = new AddAssignment(selectedAssignment.Id, selectedAssignment.Project_Id.Value); } else { addAssignmentWindow = new AddAssignment(project.Id); } addAssignmentWindow.ShowDialog(); this.Load(); this.RefreshBindings(this.PagingManager.CurrentPage); } }