AddVariable() public méthode

Add an object variable to the routing slip
public AddVariable ( string key, object value ) : void
key string
value object
Résultat void
        public void Setup()
        {
            var builder = new RoutingSlipBuilder(Guid.NewGuid());

            var fetchAvatarActivity = GetActivityContext<FetchAvatarActivity>();
            builder.AddActivity(fetchAvatarActivity.Name, fetchAvatarActivity.ExecuteUri);

            builder.AddVariable("EmailAddress", "*****@*****.**");
            builder.AddVariable("BookingRequestId", NewId.NextGuid());

            _routingSlip = builder.Build();

            Await(() => Bus.Execute(_routingSlip));
        }
        public void Setup()
        {
            _faulted = SubscribeHandler<RoutingSlipFaulted>();
            _activityCompleted = SubscribeHandler<RoutingSlipActivityCompleted>(x => x.Message.ActivityName.Equals("Test"));
            _activityCompensated = SubscribeHandler<RoutingSlipActivityCompensated>(x => x.Message.ActivityName.Equals("Test"));
            _secondActivityCompleted = SubscribeHandler<RoutingSlipActivityCompleted>(x => x.Message.ActivityName.Equals("SecondTest"));
            _activityFaulted = SubscribeHandler<RoutingSlipActivityFaulted>(x => x.Message.ActivityName.Equals("Faulty"));

            _trackingNumber = NewId.NextGuid();
            var builder = new RoutingSlipBuilder(_trackingNumber);
            builder.AddSubscription(Bus.Address, RoutingSlipEvents.All);

            ActivityTestContext testActivity = GetActivityContext<TestActivity>();
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, new
            {
                Value = "Hello",
            });

            testActivity = GetActivityContext<SecondTestActivity>();
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri);
            testActivity = GetActivityContext<FaultyActivity>();
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri);

            builder.AddVariable("Variable", "Knife");

            Await(() => Bus.Execute(builder.Build()));
        }
Exemple #3
0
        public async Task Consume(ConsumeContext <TRequest> context)
        {
            var builder = new RoutingSlipBuilder(NewId.NextGuid());

            builder.AddSubscription(context.ReceiveContext.InputAddress, RoutingSlipEvents.Completed | RoutingSlipEvents.Faulted);

            builder.AddVariable("RequestId", context.RequestId);
            builder.AddVariable("ResponseAddress", context.ResponseAddress);
            builder.AddVariable("FaultAddress", context.FaultAddress);
            builder.AddVariable("Request", context.Message);

            await BuildRoutingSlip(builder, context);

            var routingSlip = builder.Build();

            await context.Execute(routingSlip).ConfigureAwait(false);
        }
        public async Task Should_work_for_activity_arguments()
        {
            _intValue = 27;
            _stringValue = "Hello, World.";
            _decimalValue = 123.45m;

            Task<ConsumeContext<RoutingSlipCompleted>> completed = SubscribeHandler<RoutingSlipCompleted>();
            Task<ConsumeContext<RoutingSlipFaulted>> faulted = SubscribeHandler<RoutingSlipFaulted>();

            ActivityTestContext testActivity = GetActivityContext<ObjectGraphTestActivity>();
            ActivityTestContext testActivity2 = GetActivityContext<TestActivity>();

            var builder = new RoutingSlipBuilder(Guid.NewGuid());

            var dictionary = new Dictionary<string, object>
            {
                {"Outer", new OuterObjectImpl(_intValue, _stringValue, _decimalValue)},
                {"Names", new[] {"Albert", "Chris"}},
                {"ArgumentsDictionary", _argumentsDictionary}
            };
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, dictionary);
            builder.AddActivity(testActivity2.Name, testActivity2.ExecuteUri, new
            {
                Value = "Howdy!"
            });

            builder.AddVariable("ArgumentsDictionary", new Dictionary<string, string>
            {
                {"good_jpath_key", "val3"},
                {"bad jpath key", "val4"}
            });

            await Bus.Execute(builder.Build());

            await Task.WhenAny(completed, faulted);

            if (faulted.Status == TaskStatus.RanToCompletion)
            {
                Assert.Fail("Failed due to exception {0}", faulted.Result.Message.ActivityExceptions.Any()
                    ? faulted.Result.Message.ActivityExceptions.First()
                        .ExceptionInfo.Message
                    : "VisitUnknownFilter");
            }

            completed.Status.ShouldBe(TaskStatus.RanToCompletion);
        }
        public void Should_publish_the_completed_event()
        {
            _completed = SubscribeHandler<RoutingSlipCompleted>();
            _activityCompleted = SubscribeHandler<RoutingSlipActivityCompleted>();

            _trackingNumber = NewId.NextGuid();
            var builder = new RoutingSlipBuilder(_trackingNumber);
            builder.AddSubscription(Bus.Address, RoutingSlipEvents.All);

            ActivityTestContext testActivity = GetActivityContext<TestActivity>();
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, new
            {
                Value = "Hello",
            });

            builder.AddVariable("Variable", "Knife");

            Await(() => Bus.Execute(builder.Build()));

            Await(() => _completed);
        }
        public async Task Should_publish_the_completed_event()
        {
            _completed = SubscribeHandler<RoutingSlipCompleted>();
            _activityCompleted = SubscribeHandler<RoutingSlipActivityCompleted>();

            _trackingNumber = NewId.NextGuid();
            var builder = new RoutingSlipBuilder(_trackingNumber);
            builder.AddSubscription(Bus.Address, RoutingSlipEvents.All);

            ActivityTestContext testActivity = GetActivityContext<SetVariableActivity>();
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, new
            {
                Key = "Test",
                Value = "Used",
            });

            builder.AddVariable("Value", "Ignored");

            await Bus.Execute(builder.Build());

            await _completed;
        }
Exemple #7
0
        public async Task Should_handle_the_failed_to_compensate_event()
        {
            Task<ConsumeContext<RoutingSlipActivityCompensationFailed>> handledCompensationFailure =
                SubscribeHandler<RoutingSlipActivityCompensationFailed>();
            Task<ConsumeContext<RoutingSlipCompensationFailed>> handledRoutingSlipFailure =
                SubscribeHandler<RoutingSlipCompensationFailed>();

            ActivityTestContext testActivity = GetActivityContext<TestActivity>();
            ActivityTestContext faultyCompensateActivity = GetActivityContext<FaultyCompensateActivity>();
            ActivityTestContext faultActivity = GetActivityContext<FaultyActivity>();

            var builder = new RoutingSlipBuilder(Guid.NewGuid());
            builder.AddVariable("Value", "Hello");
            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri);
            builder.AddActivity(faultyCompensateActivity.Name, faultyCompensateActivity.ExecuteUri);
            builder.AddActivity(faultActivity.Name, faultActivity.ExecuteUri);

            await Bus.Execute(builder.Build());

            await handledRoutingSlipFailure;

            await handledCompensationFailure;
        }
        public async Task Setup()
        {
            ActivityTestContext testActivity = GetActivityContext<TestActivity>();
            ActivityTestContext secondActivity = GetActivityContext<SecondTestActivity>();

            _completed = SubscribeHandler<RoutingSlipCompleted>();
            _firstActivityCompleted =
                SubscribeHandler<RoutingSlipActivityCompleted>(context => context.Message.ActivityName.Equals(testActivity.Name));
            _secondActivityCompleted =
                SubscribeHandler<RoutingSlipActivityCompleted>(context => context.Message.ActivityName.Equals(secondActivity.Name));

            var builder = new RoutingSlipBuilder(Guid.NewGuid());

            builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, new
            {
                Value = "Hello",
                NullValue = (string)null,
            });

            builder.AddActivity(secondActivity.Name, secondActivity.ExecuteUri);

            builder.AddVariable("Variable", "Knife");
            builder.AddVariable("Nothing", null);
            builder.AddVariable("ToBeRemoved", "Existing");

            _routingSlip = builder.Build();

            await Bus.Execute(_routingSlip);
        }