protected override void When(object @event) { switch (@event) { case ApplicationEvents.Submitted e: Id = new ApplicationId(e.Id); ApplicantId = new ApplicantId(e.ApplicantId); VisaId = new VisaId(e.VisaId); SubmissionDate = SubmissionDate.FromDateTimeOffset(e.SubmissionDate); Status = ApplicationStatus.Submitted; break; case ApplicationEvents.AssignedToReviewer e: ReviewerId = new EmbassyEmployeeId(e.ReviewerId); Status = ApplicationStatus.PendingForReview; break; case ApplicationEvents.DocumentAdded e: var document = new Uri(e.DocumentUrl); Documents.Add(document); break; case ApplicationEvents.ChangesRequested _: Status = ApplicationStatus.ChangesRequested; break; case ApplicationEvents.Approved _: Status = ApplicationStatus.Approved; break; } }
protected override void When(object @event) { switch (@event) { case RequirementEvents.AddedToVisa e: ParentId = new VisaId(e.VisaId); Id = new RequirementId(e.RequirementId); Name = new RequirementName(e.Name); Description = new RequirementDescription(e.Description); Example = new RequirementExample(e.Example); break; case RequirementEvents.NameChanged e: Name = new RequirementName(e.Name); break; case RequirementEvents.ExampleChanged e: Example = new RequirementExample(e.Example); break; case RequirementEvents.DescriptionChanged e: Description = new RequirementDescription(e.Description); break; } }
public Application(ApplicantId applicantId, VisaId visaId, SubmissionDate submissionDate) { Documents = new List <Uri>(); Apply(new ApplicationEvents.Submitted { Id = Guid.NewGuid(), ApplicantId = applicantId, VisaId = visaId, SubmissionDate = submissionDate ?? DateTimeOffset.Now }); }
public void ThrowException_CalledWithoutSettingTheReviewer() { // Arrange var applicantId = new ApplicantId(Guid.NewGuid()); var visaId = new VisaId(Guid.NewGuid()); var submissionDate = SubmissionDate.FromDateTimeOffset(DateTimeOffset.Now.AddDays(-7)); var application = new Application(applicantId, visaId, submissionDate); var documentUrl = new Uri("https://www.streamscheme.com/wp-content/uploads/2020/04/pepega.png"); application.AddDocument(documentUrl); // Act & Assert Assert.Throws <Exceptions.InvalidEntityState>(() => application.Approve()); }
public void AddDocument_Called() { // Arrange var applicantId = new ApplicantId(Guid.NewGuid()); var visaId = new VisaId(Guid.NewGuid()); var submissionDate = SubmissionDate.FromDateTimeOffset(DateTimeOffset.Now.AddDays(-7)); var application = new Application(applicantId, visaId, submissionDate); var documentUrl = new Uri("https://www.streamscheme.com/wp-content/uploads/2020/04/pepega.png"); // Act application.AddDocument(documentUrl); // Assert Assert.NotEmpty(application.Documents); }
public void Create_Called() { // Arrange var applicantId = new ApplicantId(Guid.NewGuid()); var visaId = new VisaId(Guid.NewGuid()); var submissionDate = SubmissionDate.FromDateTimeOffset(DateTimeOffset.Now.AddDays(-7)); // Act var application = new Application(applicantId, visaId, submissionDate); // Assert Assert.NotNull(application.Id); Assert.NotNull(application.Documents); Assert.Equal(applicantId, application.ApplicantId); Assert.Equal(visaId, application.VisaId); Assert.Equal(submissionDate, application.SubmissionDate); }
public void ChangeStatusToApprove_Called() { // Arrange var applicantId = new ApplicantId(Guid.NewGuid()); var visaId = new VisaId(Guid.NewGuid()); var submissionDate = SubmissionDate.FromDateTimeOffset(DateTimeOffset.Now.AddDays(-7)); var application = new Application(applicantId, visaId, submissionDate); var documentUrl = new Uri("https://www.streamscheme.com/wp-content/uploads/2020/04/pepega.png"); application.AddDocument(documentUrl); var reviewerId = new EmbassyEmployeeId(Guid.NewGuid()); application.AssignToReviewer(reviewerId); // Act application.Approve(); // Assert Assert.Equal(ApplicationStatus.Approved, application.Status); }