public void After_submitting_recruitment_form_candidate_can_be_invited_to_training() { // Arrange var id = EnrollmentAggregate.EnrollmentId.New; var selectedTraining = BuildScheduledTraining(1, CreateOffsetDateTimeDaysInTheFuture(14), CreateOffsetDateTimeDaysInTheFuture(15)); selectedTraining.Campaign = new Campaign(CreateOffsetDateTimeDaysInTheFuture(-7), CreateOffsetDateTimeDaysInTheFuture(+7), 1, "kampania testowa"); selectedTraining.Campaign.GetType().GetProperty(nameof(selectedTraining.Campaign.Id)).SetValue(selectedTraining.Campaign, 1); var now = NodaTime.SystemClock.Instance.GetCurrentInstant(); var enrollment = new EnrollmentAggregate(id); // Act var result = enrollment.SubmitRecruitmentForm(new SubmitRecruitmentForm.Command() { FirstName = "Andrzej", LastName = "Strzelba", Email = EmailAddress.Parse("*****@*****.**"), PhoneNumber = Consts.FakePhoneNumber, AboutMe = "ala ma kota", Region = "Wolne Miasto Gdańsk", PreferredLecturingCities = new[] { "Wadowice" }, PreferredTrainingIds = new[] { 1 }, GdprConsentGiven = true }, new[] { selectedTraining }, now); // Assert Assert.True(result.IsSuccess); Assert.True(enrollment.CanAcceptTrainingInvitation(new[] { selectedTraining }, now).IsSuccess); }
public void All_specified_trainings_must_be_held_in_the_future() { // Arrange var id = EnrollmentAggregate.EnrollmentId.New; var selectedTraining = BuildScheduledTraining(1, CreateOffsetDateTimeDaysInTheFuture(-3), CreateOffsetDateTimeDaysInTheFuture(-2)); selectedTraining.Campaign = new Campaign(CreateOffsetDateTimeDaysInTheFuture(-7), CreateOffsetDateTimeDaysInTheFuture(+7), 1, "kampania testowa"); selectedTraining.Campaign.GetType().GetProperty(nameof(selectedTraining.Campaign.Id)).SetValue(selectedTraining.Campaign, 1); var enrollment = new EnrollmentAggregate(id); // Act var result = enrollment.SubmitRecruitmentForm(new SubmitRecruitmentForm.Command() { FirstName = "Andrzej", LastName = "Strzelba", Email = EmailAddress.Parse("*****@*****.**"), PhoneNumber = Consts.FakePhoneNumber, AboutMe = "ala ma kota", Region = "Wolne Miasto Gdańsk", PreferredLecturingCities = new[] { "Wadowice" }, PreferredTrainingIds = new[] { 1 }, GdprConsentGiven = true }, new[] { selectedTraining }, NodaTime.SystemClock.Instance.GetCurrentInstant()); // Assert Assert.False(result.IsSuccess); var error = Assert.IsType <Error.DomainError>(result.Error); Assert.Equal(SubmitRecruitmentForm_ErrorMessages.PreferredTrainingsMustOccurInTheFuture, error.Message); }
public void After_executing_command__aggregate_contains_name_email_phone_region_cities_trainings_and_campaign() { // Arrange var now = NodaTime.SystemClock.Instance.GetOffsetDateTime(); var command = new SubmitRecruitmentForm.Command() { FirstName = "Andrzej", LastName = "Strzelba", Email = EmailAddress.Parse("*****@*****.**"), PhoneNumber = Consts.FakePhoneNumber, AboutMe = "ala ma kota", Region = "małopolskie", PreferredLecturingCities = new[] { "Wadowice" }, PreferredTrainingIds = new[] { 1 }, GdprConsentGiven = true }; var enrollment = new EnrollmentAggregate(EnrollmentAggregate.EnrollmentId.New); var campaign = new Campaign( startDateTime: now.Minus(Duration.FromDays(3)), endDateTime: now.Plus(Duration.FromDays(3)), editionId: 1, name: "kampania testowa"); campaign.GetType().GetProperty(nameof(campaign.Id)).SetValue(campaign, 1); var training = new Training( address: "Papieska 21/37", city: "Wadowice", startDateTime: now.Plus(Duration.FromDays(7)), endDateTime: now.Plus(Duration.FromDays(7) + Duration.FromHours(4)), coordinatorId: Guid.NewGuid()); training.GetType().GetProperty(nameof(training.ID)).SetValue(training, 1); campaign.ScheduleTraining(training); var trainings = new[] { training }; // Act var result = enrollment.SubmitRecruitmentForm(command, trainings, now.ToInstant()); // Assert result.IsSuccess.Should().BeTrue(); enrollment.FirstName.Should().Be("Andrzej"); enrollment.LastName.Should().Be("Strzelba"); enrollment.FullName.Should().Be("Andrzej Strzelba"); enrollment.Email.ToString().Should().Be("*****@*****.**"); enrollment.PhoneNumber.Should().Be(Consts.FakePhoneNumber); enrollment.Region.Should().Be("małopolskie"); enrollment.PreferredLecturingCities.Should().BeEquivalentTo(new[] { "Wadowice" }); enrollment.PreferredTrainingIds.Should().BeEquivalentTo(new[] { 1 }); enrollment.CampaignId.Should().Be(1); }