示例#1
0
        public async Task SendAsync_succeeds_and_result_has_error()
        {
            Mock.Get(_instanceFactory)
            .Setup(f => f.Invoke(It.IsAny <Type>()))
            .Returns((Func <Type, object>)_containerFixture.Container.GetInstance);

            var failRequest = new FailRequest();
            var result      = await _sut.SendAsync(failRequest);

            result.Should().NotBeNull();
            result.Match(r => null, e => e.Message).Should().NotBeNull().And.Be("Error");

            Mock.Get(_instanceFactory)
            .Verify(f => f.Invoke(It.Is <Type>(t => t == typeof(IRequestHandler <FailRequest, Unit>))), Times.Once());
        }
        public void GivenAFailureWhenTheAggregateIsNewThenTheFailedChangeIsRemovedAndTheAggregateOtherChangesRemain()
        {
            var context   = new SerializableMessage();
            var aggregate = new SerializableEventCentricAggregateRoot(context);

            SignedVersion original = aggregate.Version.Clone();

            Assert.True(aggregate.HasUncommittedChanges);
            Assert.True(original.IsNew);

            var fail = new FailRequest(context);

            Assert.Equal(original, aggregate.Version);

            _ = Assert.Throws <InvalidOperationException>(() => aggregate.Fail(fail));

            Assert.True(aggregate.HasUncommittedChanges);
            Assert.Equal(original, aggregate.Version);
        }
        public void GivenAFailureWhenTheAggregateWasPersistedThenTheFailedChangeIsRemovedAndTheAggregateRolledBack()
        {
            var         value           = Guid.NewGuid();
            var         context         = new SerializableMessage();
            var         request         = new SetRequest(context, value);
            var         aggregate       = new SerializableEventCentricAggregateRoot(context);
            const ulong ExpectedVersion = 1;

            aggregate.MarkChangesAsCommitted();

            SignedVersion original = aggregate.Version.Clone();

            Assert.False(aggregate.HasUncommittedChanges);
            Assert.Equal(ExpectedVersion, original.Number);

            var fail = new FailRequest(context);

            _ = Assert.Throws <InvalidOperationException>(() => aggregate.Fail(fail));

            Assert.False(aggregate.HasUncommittedChanges);
            Assert.Equal(original, aggregate.Version);
        }
示例#4
0
 public override Task <FailResponse> Fail(FailRequest request, ServerCallContext context)
 {
     throw new RpcException(new Status((StatusCode)request.Code, ""));
 }
 public override Task <FailResponse> Fail(FailRequest request, ServerCallContext context)
 {
     _logger.LogInformation("=> Fail({})", request.Message);
     throw new ApplicationException(request.Message);
 }
示例#6
0
 public FailResponse Fail(FailRequest req, RequestOptions?options = null)
 {
     return(DoRequest("Fail", req, options) as FailResponse);
 }