public void RejectTest() { var document = CreateDocument() .Bind(doc => AddFile(doc, "123")) .Bind(doc => doc.SendForApproval()) .Bind(doc => RejectReason.Create("Rejected") .Bind(doc.Reject)); document.Match( Succ: doc => Assert.Equal(DocumentStatus.Rejected, doc.Status), Fail: errors => Assert.True(false, "Should never get here")); }
public void RejectEmptyReasonErrorTest() { var document = CreateDocument() .Bind(doc => AddFile(doc, "123")) .Bind(doc => RejectReason.Create(string.Empty) .Bind(doc.Reject)); document.Match( Succ: _ => Assert.True(false, "Should never get here"), Fail: errors => { Assert.True(errors.Count == 1); Assert.True(errors.Head.Equals(new EmptyValueError("Reject reason"))); }); }
public void RejectInvalidDocumentStatusErrorTest() { var document = CreateDocument() .Bind(doc => AddFile(doc, "123")) .Bind(doc => RejectReason.Create("Rejected") .Bind(doc.Reject)); document.Match( Succ: _ => Assert.True(false, "Should never get here"), Fail: errors => { Assert.True(errors.Count == 1); Assert.True(errors.Head.Equals(new InvalidStatusError(DocumentStatus.WaitingForApproval, DocumentStatus.Draft))); }); }
public static Validation <Error, DocumentRejectedEvent> Create(Guid documentId, string reason) => RejectReason.Create(reason) .Map(r => new DocumentRejectedEvent(new DocumentId(documentId), r, DateTime.UtcNow));