public void AddAssignment_Test() { // ARRANGE CreateTestProjectAndProjectType(); var project = uow.Projects.GetAll().First(); var createParam = new AssignmentCreateParam { Name = "TestAssignment", DateDue = DateTime.Now.AddDays(1), DatePlanned = DateTime.Now, Description = "New description", DurationPlannedAsTicks = new TimeSpan(1, 0, 0).Ticks, Project = project }; var assignmentLogic = new AssignmentLogic(); // ACT assignmentLogic.AddAssignment(createParam); assignmentLogic.Dispose(); // ASSERT var assignments = uow.Assignments.GetAll().ToList(); Assert.IsTrue(assignments.Count > 0); Assert.AreEqual("TestAssignment", assignments.First(a => a.Name == "TestAssignment").Name); }
private void btn_AddAssignment_Click(object sender, RoutedEventArgs e) { var assignmentLogic = new AssignmentLogic(); Assignment assignment = null; var durationPlanned = ParseDuration(); if (this.EditMode) { var param = new AssignmentUpdateParam { DateDue = this.dp_AssignmentDue.SelectedDate, DatePlanned = this.dp_Planned.SelectedDate, Description = this.tb_AssignmentDescription.Text, DurationPlannedAsTicks = durationPlanned, Name = this.tb_AssignmentName.Text }; assignmentLogic.UpdateAssignment(this.Assignment.Id, param); assignment = assignmentLogic.GetAssignmentById(this.Assignment.Id); } else { var param = new AssignmentCreateParam { DateDue = this.dp_AssignmentDue.SelectedDate, DatePlanned = this.dp_Planned.SelectedDate, Description = this.tb_AssignmentDescription.Text, DurationPlannedAsTicks = durationPlanned, Name = this.tb_AssignmentName.Text, Project = this.Project }; assignment = assignmentLogic.AddAssignment(param); } assignmentLogic.Dispose(); this.Close(); }