public void If_candidate_has_resigned_temporarily_with_resume_date__then_aggregate_has_HasResignedTemporarily_flag_and_HasResignedEffectively_with_date_after_resuma_date_returns_true() { // Arrange var id = EnrollmentAggregate.EnrollmentId.New; var event1 = new DomainEvent <EnrollmentAggregate, EnrollmentAggregate.EnrollmentId, RecruitmentFormSubmitted>( new RecruitmentFormSubmitted( NodaTime.SystemClock.Instance.GetCurrentInstant(), "Andrzej", "Strzelba", EmailAddress.Parse("*****@*****.**"), Consts.FakePhoneNumber, "ala ma kota", 1, "Wolne Miasto Gdańsk", new[] { "Wadowice" }, new[] { 1 }, true), new Metadata(), DateTimeOffset.Now, id, 1 ); var enrollment = new EnrollmentAggregate(id); enrollment.ApplyEvents(new IDomainEvent[] { event1 }); var recordingCoordinator = new ApplicationUser() { Id = Guid.NewGuid() }; var currentDate = new NodaTime.LocalDate(2020, 06, 30); // Act var result = enrollment.RecordResignation(new RecordResignation.Command() { EnrollmentId = id.GetGuid(), CommunicationChannel = CommunicationChannel.OutgoingEmail, ResignationReason = "brak powodu", AdditionalNotes = "notatka testowa", ResignationType = RecordResignation.ResignationType.Temporary, ResumeDate = currentDate.PlusWeeks(1) }, recordingCoordinator, currentDate.AtStartOfDayInZone(Consts.MainTimezone).ToInstant()); // Assert Assert.True(result.IsSuccess); var uncommittedEvent = Assert.Single(enrollment.UncommittedEvents, e => e.AggregateEvent is CandidateResignedTemporarily); var @event = Assert.IsType <CandidateResignedTemporarily>(uncommittedEvent.AggregateEvent); Assert.Equal(recordingCoordinator.Id, @event.RecordingCoordinatorID); Assert.Equal(CommunicationChannel.OutgoingEmail, @event.CommunicationChannel); Assert.Equal("brak powodu", @event.ResignationReason); Assert.Equal("notatka testowa", @event.AdditionalNotes); Assert.Equal(currentDate.PlusWeeks(1), @event.ResumeDate); enrollment.HasResignedEffectively(currentDate.PlusWeeks(2).AtStartOfDayInZone(Consts.MainTimezone).ToInstant()).Should().BeFalse(); }
/// <summary> /// Add weeks.<br /> /// 添加周数。 /// </summary> /// <param name="ld"></param> /// <param name="weeks"></param> /// <returns></returns> public static LocalDate AddWeeks(this LocalDate ld, int weeks) => ld.PlusWeeks(weeks);