Ejemplo n.º 1
0
        public void NewDeterministic_IsValid()
        {
            // Arrange
            var testId = TestId.NewDeterministic(Guid.NewGuid(), Guid.NewGuid().ToString());

            // Assert
            TestId.IsValid(testId.Value).Should().BeTrue(testId.Value);
        }
Ejemplo n.º 2
0
        public void NewDeterministic()
        {
            // Arrange
            var          namespaceId = Guid.Parse("769077C6-F84D-46E3-AD2E-828A576AAAF3");
            const string name        = "fantastic 4";

            // Arrange
            var testId = TestId.NewDeterministic(namespaceId, name);

            // Assert
            testId.Value.Should().Be("test-da7ab6b1-c513-581f-a1a0-7cdf17109deb");
            TestId.IsValid(testId.Value).Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void Aggregates_can_be_hydrated()
        {
            var senderTestId = TestId.NewDeterministic(TestIdNamespace, (DateTime.UtcNow.Day - 1).ToString());
            var senderTest   = new Test(senderTestId);
            var receiver     = TestAggregateId.NewDeterministic(TestIdNamespace, (DateTime.UtcNow.Day + 1).ToString());
            var sender       = TestAggregateId.NewDeterministic(TestIdNamespace, DateTime.UtcNow.Day.ToString());

            RunOn(() =>
            {
                //set up event probe
                // set up sender
                var senderProbe = CreateTestProbe("sender-probe");
                var commandId   = CommandId.New;
                _aggregateProxy.Value.Tell(new CreateTestCommand(sender, commandId), senderProbe);

                senderProbe.ExpectMsg <TestExecutionResult>(
                    x => x.Result.IsSuccess &&
                    x.SourceId.Value == commandId.Value, TimeSpan.FromSeconds(10));


                var nextAggregateCommand = new AddTestCommand(sender, CommandId.New, senderTest);
                _aggregateProxy.Value.Tell(nextAggregateCommand, senderProbe);

                senderProbe.ExpectMsg <TestExecutionResult>(
                    x => x.Result.IsSuccess, TimeSpan.FromSeconds(10));

                // set up receiver
                var receiverProbe = CreateTestProbe("receiver-probe");
                var commandId2    = CommandId.New;
                _aggregateProxy.Value.Tell(new CreateTestCommand(receiver, commandId2), receiverProbe);

                receiverProbe.ExpectMsg <TestExecutionResult>(
                    x => x.Result.IsSuccess &&
                    x.SourceId.Value == commandId2.Value, TimeSpan.FromSeconds(10));
            }, _config.Client);


            EnterBarrier("aggregates-hydrated");

            var eventProbe = CreateTestProbe("event-probe");

            RunOn(() =>
            {
                Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent <TestSaga, TestSagaId, TestSagaStartedEvent>));
                Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent <TestSaga, TestSagaId, TestSagaCompletedEvent>));
                Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent <TestSaga, TestSagaId, TestSagaTransactionCompletedEvent>));
            }, _config.Worker);

            RunOn(() =>
            {
                var senderProbe = CreateTestProbe("saga-starting-probe");

                var nextAggregateCommand = new GiveTestCommand(sender, CommandId.New, receiver, senderTest);
                _aggregateProxy.Value.Tell(nextAggregateCommand, senderProbe);

                senderProbe.ExpectMsg <TestExecutionResult>(
                    x => x.Result.IsSuccess, TimeSpan.FromSeconds(10));
            }, _config.Client);

            RunOn(() =>
            {
                eventProbe.
                ExpectMsg <DomainEvent <TestSaga, TestSagaId, TestSagaStartedEvent> >(
                    x => x.AggregateEvent.Sender.Equals(sender) &&
                    x.AggregateEvent.Receiver.Equals(receiver) &&
                    x.AggregateEvent.SentTest.Equals(senderTest), TimeSpan.FromSeconds(20));

                eventProbe.
                ExpectMsg <DomainEvent <TestSaga, TestSagaId, TestSagaTransactionCompletedEvent> >(TimeSpan.FromSeconds(20));

                eventProbe.
                ExpectMsg <DomainEvent <TestSaga, TestSagaId, TestSagaCompletedEvent> >(TimeSpan.FromSeconds(20));
            }, _config.Worker);


            EnterBarrier("saga-finished");
        }