public void Setup()
        {
            _test = TestFactory.ForConsumer <ExecuteActivityHost <TestActivity, TestArguments> >()
                    .InSingleBusScenario()
                    .New(x =>
            {
                x.ConstructUsing(
                    () =>
                {
                    var compensateAddress = new Uri("loopback://localhost/mt_server");

                    return
                    (new ExecuteActivityHost <TestActivity, TestArguments>(
                         compensateAddress,
                         new FactoryMethodExecuteActivityFactory
                         <TestActivity, TestArguments>(_ => new TestActivity())));
                });

                var builder = new RoutingSlipBuilder(Guid.NewGuid());
                builder.AddActivity("test", new Uri("loopback://localhost/mt_client"), new
                {
                    Value = "Hello",
                });

                x.Send(builder.Build());
            });

            _test.Execute();
        }
        public void Setup()
        {
            _collection = Database.GetCollection<RoutingSlipDocument>(EventCollectionName);
            _trackingNumber = NewId.NextGuid();
            EventPersister persister = new RoutingSlipEventPersister(_collection);

            Console.WriteLine("Tracking Number: {0}", _trackingNumber);

            _completedTest = TestFactory.ForConsumer<RoutingSlipCompletedConsumer>()
                                        .New(x =>
                                        {
                                            x.ConstructUsing(() => new RoutingSlipCompletedConsumer(persister));

                                            x.Publish(new RoutingSlipCompletedEvent(_trackingNumber, DateTime.UtcNow));
                                        });

            _activityTest = TestFactory.ForConsumer<RoutingSlipActivityCompletedConsumer>()
                                       .New(x =>
                                       {
                                           x.ConstructUsing(
                                               () => new RoutingSlipActivityCompletedConsumer(persister));

                                           x.Publish(new RoutingSlipActivityCompletedEvent(_trackingNumber,
                                               "Prepare",
                                               NewId.NextGuid(), DateTime.UtcNow));
                                           x.Publish(new RoutingSlipActivityCompletedEvent(_trackingNumber, "Send",
                                               NewId.NextGuid(), DateTime.UtcNow));
                                       });

            _completedTest.Execute();
            _activityTest.Execute();
        }
Пример #3
0
        public void A_consumer_is_being_tested()
        {
            _test = TestFactory.ForConsumer <Testsumer>()
                    .New(x =>
            {
                x.ConstructUsing(() => new Testsumer());

                x.Send(new A(), (scenario, context) => context.SendResponseTo(scenario.Bus));
            });

            _test.Execute();
        }
        public void The_new_subscription_system_is_used()
        {
            _test = TestFactory.ForConsumer <Testsumer>()
                    .New(x =>
            {
                x.ConstructUsing(() => new Testsumer());

                x.Publish(new A(), (scenario, context) => context.SendResponseTo(scenario.Bus));
            });

            _unsub = _test.Scenario.Bus.SubscribeHandler <A>(x => { });

            _test.Execute();
        }
Пример #5
0
        public void Should_properly_deserialize()
        {
            ConsumerTest <IBusTestScenario, SmallNumberConsumer> testConsumer = TestFactory
                                                                                .ForConsumer <SmallNumberConsumer>()
                                                                                .New(x =>
            {
                x.ConstructUsing(() => new SmallNumberConsumer());
                x.Send(new SmallNumberMessage {
                    SmallNumber = _smallNumber
                });
            });

            testConsumer.Execute();

            Assert.IsTrue(
                testConsumer.Sent.Any <SmallNumberMessage>(m => m.Context.Message.SmallNumber == _smallNumber),
                "SmallNumberMessage not sent");
            Assert.IsTrue(
                testConsumer.Consumer.Received.Any <SmallNumberMessage>(
                    (c, m) => m.SmallNumber == _smallNumber), "SmallNumberMessage not received");
        }
Пример #6
0
        public void Setup()
        {
            _test = TestFactory
                    .ForConsumer <SaveMemberAddressConsumer>()
                    .InSingleBusScenario()
                    .New(x =>
            {
                x.ConstructUsing(() => new SaveMemberAddressConsumer());
                x.Send(new SaveMemberAddressMessage
                {
                    CommandId = NewId.NextGuid(),
                    Timestamp = DateTime.UtcNow,
                    MemberId  = "Joe",
                    Street    = "123 American Way",
                    City      = "Oakland",
                    State     = "CA",
                    Zip       = "94602"
                });
            });

            _test.Execute();
        }
Пример #7
0
        public void Setup()
        {
            _test = TestFactory
                .ForConsumer<SaveMemberAddressConsumer>()
                .InSingleBusScenario()
                .New(x =>
                    {
                        x.ConstructUsing(() => new SaveMemberAddressConsumer());
                        x.Send(new SaveMemberAddressMessage
                            {
                                CommandId = NewId.NextGuid(),
                                Timestamp = DateTime.UtcNow,
                                MemberId = "Joe",
                                Street = "123 American Way",
                                City = "Oakland",
                                State = "CA",
                                Zip = "94602"
                            });
                    });

            _test.Execute();
        }
        public void Setup()
        {
            _test = TestFactory.ForConsumer<ExecuteActivityHost<TestActivity, TestArguments>>()
                               .InSingleBusScenario()
                               .New(x =>
                                   {
                                       x.ConstructUsing(
                                           () =>
                                               {
                                                   var compensateAddress = new Uri("loopback://localhost/mt_server");

                                                   return
                                                       new ExecuteActivityHost<TestActivity, TestArguments>(
                                                           compensateAddress,
                                                           new FactoryMethodExecuteActivityFactory
                                                               <TestActivity, TestArguments>(_ => new TestActivity()));
                                               });

                                       var builder = new RoutingSlipBuilder(Guid.NewGuid());
                                       builder.AddActivity("test", new Uri("loopback://localhost/mt_client"), new
                                           {
                                               Value = "Hello",
                                           });

                                       x.Send(builder.Build());
                                   });

            _test.Execute();
        }