コード例 #1
0
        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"));
        }
コード例 #2
0
        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")));
            });
        }
コード例 #3
0
        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)));
            });
        }
コード例 #4
0
 public static Validation <Error, DocumentRejectedEvent> Create(Guid documentId, string reason) =>
 RejectReason.Create(reason)
 .Map(r => new DocumentRejectedEvent(new DocumentId(documentId), r, DateTime.UtcNow));