Esempio n. 1
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                PingId.ToBytes(),
                DisconnectDelay.ToBytes()));
 }
Esempio n. 2
0
        public async Task PublishingStartAndCompleteWithPingsResultInCorrectMessages()
        {
            // Arrange
            var thingyId = A <ThingyId>();

            // Act
            var pingsWithNewSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false);

            await CommandBus.PublishAsync(new ThingyRequestSagaStartCommand(thingyId), CancellationToken.None).ConfigureAwait(false);

            var pingsWithRunningSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false);

            await CommandBus.PublishAsync(new ThingyRequestSagaCompleteCommand(thingyId), CancellationToken.None).ConfigureAwait(false);

            var pingsWithCompletedSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false);

            // Assert - saga
            var thingySaga = await LoadSagaAsync(thingyId).ConfigureAwait(false);

            thingySaga.State.Should().Be(SagaState.Completed);
            thingySaga.PingIdsSinceStarted.ShouldAllBeEquivalentTo(pingsWithRunningSaga);

            // Assert - aggregate
            var thingyAggregate = await LoadAggregateAsync(thingyId).ConfigureAwait(false);

            thingyAggregate.PingsReceived.ShouldAllBeEquivalentTo(
                pingsWithNewSaga.Concat(pingsWithRunningSaga).Concat(pingsWithCompletedSaga));
            var receivedSagaPingIds = thingyAggregate.Messages
                                      .Select(m => PingId.With(m.Message))
                                      .ToList();

            receivedSagaPingIds.Should().HaveCount(3);
            receivedSagaPingIds.ShouldAllBeEquivalentTo(pingsWithRunningSaga);
        }
Esempio n. 3
0
 public IExecutionResult PingMaybe(PingId pingId, bool isSuccess)
 {
     Emit(new ThingyPingEvent(pingId));
     return(isSuccess
         ? ExecutionResult.Success()
         : ExecutionResult.Failed());
 }
        public void ValidateTestAggregate()
        {
            // Act
            var testAggregate = _eventStore.LoadAggregate <ThingyAggregate, ThingyId>(_thingyId, CancellationToken.None);

            // Assert
            testAggregate.Version.Should().Be(2);
            testAggregate.PingsReceived.Should().Contain(PingId.With("95433aa0-11f7-4128-bd5f-18e0ecc4d7c1"));
            testAggregate.PingsReceived.Should().Contain(PingId.With("2352d09b-4712-48cc-bb4f-5560d7c52558"));
        }
Esempio n. 5
0
 public ThingyAddMessageAndPingCommand(
     ThingyId aggregateId,
     ThingyMessage thingyMessage,
     PingId pingId,
     bool pingFirst)
     : base(aggregateId)
 {
     ThingyMessage = thingyMessage;
     PingId        = pingId;
     PingFirst     = pingFirst;
 }
Esempio n. 6
0
 public ThingyPingCommand(ThingyId aggregateId, SourceId sourceId, PingId pingId)
     : base(aggregateId, sourceId)
 {
     PingId = pingId;
 }
Esempio n. 7
0
 public ThingyPingCommand(ThingyId aggregateId, PingId pingId)
     : this(aggregateId, CommandId.New, pingId)
 {
 }
Esempio n. 8
0
 public PingCommand(TestId aggregateId, SourceId sourceId, PingId pingId)
     : base(aggregateId, sourceId)
 {
     PingId = pingId;
 }
Esempio n. 9
0
 public PingCommand(TestId aggregateId, PingId pingId)
     : this(aggregateId, CommandId.New, pingId)
 {
 }
 public ThingySagaPingReceivedEvent(
     PingId pingId)
 {
     PingId = pingId;
 }
Esempio n. 11
0
 public PingCommand(TestId id, PingId pingId) : base(id)
 {
     PingId = pingId;
 }
Esempio n. 12
0
 public ThingyPingEvent(PingId pingId)
 {
     PingId = pingId;
 }
Esempio n. 13
0
 public void Apply(IReadModelContext context, IDomainEvent <TestAggregate, TestId, PingEvent> domainEvent)
 {
     Id = domainEvent.AggregateEvent.PingId;
 }
Esempio n. 14
0
 public void Ping(PingId pingId)
 {
     Emit(new ThingyPingEvent(pingId));
 }
Esempio n. 15
0
 public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyPingEvent> domainEvent)
 {
     Id = domainEvent.AggregateEvent.PingId;
 }
 public ThingyMaybePingCommand(ThingyId aggregateId, PingId pingId, bool isSuccess)
     : base(aggregateId, CommandId.New)
 {
     PingId    = pingId;
     IsSuccess = isSuccess;
 }
Esempio n. 17
0
 public PingEvent(PingId pingId)
 {
     PingId = pingId;
 }