Esempio n. 1
0
 public void can_determine_the_application_assembly()
 {
     using (var runtime = JasperRuntime.Basic())
     {
         runtime.ApplicationAssembly.ShouldBe(GetType().GetAssembly());
     }
 }
Esempio n. 2
0
        public static void Go()
        {
            // SAMPLE: Bootstrapping-Basic
            using (var runtime = JasperRuntime.Basic())
            {
                // do stuff
            }
            // ENDSAMPLE

            // SAMPLE: Bootstrapping-Basic2
            using (var runtime = JasperRuntime.For(new JasperRegistry()))
            {
                // do stuff
            }
            // ENDSAMPLE

            // SAMPLE: Bootstrapping-Basic3
            using (var runtime = JasperRuntime.For(_ =>
            {
                _.Transports.ListenForMessagesFrom("tcp://localhost:2001");
            }))
            {
                // do stuff
            }

            // ENDSAMPLE
        }
Esempio n. 3
0
 public void try_out_resolver_cache()
 {
     using (var runtime = JasperRuntime.Basic())
     {
         runtime.Container.Model.ExportResolverCode <JasperResolverSet>("../../../../Jasper/Internal/Resolvers");
     }
 }
        public void settings_policy_registers_settings()
        {
            var runtime   = JasperRuntime.Basic();
            var registry  = runtime.Registry;
            var container = new Container(registry.Services);
            var settings  = container.GetInstance <MySettings>();

            settings.SomeSetting.ShouldBe(0);
        }
Esempio n. 5
0
 public async Task sample_alba_spec()
 {
     using (var runtime = JasperRuntime.Basic())
     {
         await runtime.Scenario(x =>
         {
             x.Get.Url("/salutations");
             x.StatusCodeShouldBeOk();
             x.ContentShouldBe("Greetings and salutations");
             x.ContentTypeShouldBe("text/plain");
         });
     }
 }
Esempio n. 6
0
        public void transport_endpoints_are_not_enabled_by_default()
        {
            using (var runtime = JasperRuntime.Basic())
            {
                var routes = runtime.Get <RouteGraph>();

                routes.ChainForAction <TransportEndpoint>(x => x.put__messages(null, null, null))
                .ShouldBeNull();

                routes.ChainForAction <TransportEndpoint>(x => x.put__messages_durable(null, null, null))
                .ShouldBeNull();
            }
        }
        public void deliver_by_mechanics()
        {
            using (var runtime = JasperRuntime.Basic())
            {
                var root     = runtime.Get <IMessagingRoot>();
                var envelope = new Envelope
                {
                    Message = new MySpecialMessage()
                };

                root.ApplyMessageTypeSpecificRules(envelope);

                envelope.DeliverBy.Value.ShouldBeGreaterThan(DateTimeOffset.UtcNow);
            }
        }
        public void apply_message_type_rules_from_attributes()
        {
            using (var runtime = JasperRuntime.Basic())
            {
                var root     = runtime.Get <IMessagingRoot>();
                var envelope = new Envelope
                {
                    Message = new MySpecialMessage()
                };

                root.ApplyMessageTypeSpecificRules(envelope);

                envelope.Headers["special"].ShouldBe("true");
            }
        }
Esempio n. 9
0
        public void see_registrations()
        {
            using (var runtime = JasperRuntime.Basic())
            {
                var singletons =
                    runtime.Container.Model.AllInstances;
                //.Where(x => x.Lifetime == ServiceLifetime.Singleton)
                //.Where(x => !x.ServiceType.IsOpenGeneric())
                //.Where(x => x.Instance is GeneratedInstance);

                foreach (var singleton in singletons)
                {
                    _output.WriteLine($"{singleton.ServiceType.GetTypeFullName()} --> {singleton.ImplementationType.FullNameInCode()} --> {singleton.Instance.GetType().Name}");
                }
            }
        }
        public async Task see_the_customizations_happen_inside_of_message_context()
        {
            using (var runtime = JasperRuntime.Basic())
            {
                var context = runtime.Get <IMessageContext>();

                // Just to force the message context to pool up the envelope instead
                // of sending it out
                await context.EnlistInTransaction(new InMemoryEnvelopeTransaction());

                var mySpecialMessage = new MySpecialMessage();

                await context.Send("tcp://localhost:2001".ToUri(), mySpecialMessage);

                var outgoing = context.As <MessageContext>().Outstanding.Single();

                outgoing.Headers["special"].ShouldBe("true");
            }
        }
Esempio n. 11
0
 public ApplicationFixture()
 {
     // Your application setup here would probably
     // refer to a JasperRegistry for your application
     Runtime = JasperRuntime.Basic();
 }