Beispiel #1
0
        public async Task can_handle_an_http_request_through_Kestrel()
        {
            var theRuntime = await JasperRuntime.ForAsync <JasperServerApp>();

            var options = theRuntime.Container.GetInstance <DbContextOptions <ApplicationDbContext> >();

            theRuntime.Container.GetInstance <DbContextOptions <ApplicationDbContext> >("options").ShouldNotBeNull();


            try
            {
                // has the message context registered
                ShouldBeNullExtensions.ShouldNotBeNull(theRuntime.Get <IMessageContext>());

                // has the registrations from Jasper
                theRuntime.Get <IFoo>().ShouldBeOfType <Foo>();

                using (var client = new HttpClient())
                {
                    var text = await client.GetStringAsync("http://localhost:5200");

                    text.ShouldContain("Hello from a hybrid Jasper application");
                }
            }
            finally
            {
                await theRuntime.Shutdown();
            }
        }
Beispiel #2
0
        public void does_not_blow_up()
        {
            var chain = Handlers.ChainFor <Message1>();
            var call  = chain.Handlers.First(x => x.HandlerType == typeof(ThingWithInner.InnerHandler));

            ShouldBeNullExtensions.ShouldNotBeNull(call);
        }
 public void determine_resource_type()
 {
     ShouldBeNullExtensions.ShouldBeNull(chainFor(x => x.post_command(null)).ResourceType);
     ShouldBeNullExtensions.ShouldBeNull(chainFor(x => x.post_input()).ResourceType);
     chainFor(x => x.get_resource()).ResourceType.ShouldBe(typeof(Resource1));
     chainFor(x => x.get_resource2()).ResourceType.ShouldBe(typeof(Resource2));
 }
        public void will_build_the_new_table_if_the_configured_table_does_not_match_the_existing_table()
        {
            DocumentTable table1;
            DocumentTable table2;


            theStore.Tenancy.Default.StorageFor(typeof(User));

            theStore.Tenancy.Default.DbObjects.DocumentTables().ShouldContain($"public.mt_doc_user");

            table1 = theStore.TableSchema(typeof(User));
            table1.ShouldNotContain(x => x.Name == "user_name");

            var store = SeparateStore(opts => opts.Schema.For <User>().Duplicate(x => x.UserName));

            store.Tenancy.Default.StorageFor(typeof(User));

            store.Tenancy.Default.DbObjects.DocumentTables().ShouldContain($"public.mt_doc_user");

            table2 = store.TableSchema(typeof(User));

            table2.ShouldNotBe(table1);

            ShouldBeNullExtensions.ShouldNotBeNull(table2.Column("user_name"));
        }
        public void completes_only_when_all_outstanding_work_is_completed()
        {
            var envelope1 = ObjectMother.Envelope();
            var envelope2 = ObjectMother.Envelope();

            history.Start(envelope1, "Envelope");

            watch.IsCompleted.ShouldBeFalse();

            history.Start(envelope2, "Envelope");

            watch.IsCompleted.ShouldBeFalse();

            history.Complete(envelope1, "Envelope");

            watch.IsCompleted.ShouldBeFalse();

            history.Complete(envelope2, "Envelope");

            watch.IsCompleted.ShouldBeTrue();

            var tracks = watch.Result;

            foreach (var messageTrack in tracks)
            {
                messageTrack.Completed.ShouldBeTrue();
                ShouldBeNullExtensions.ShouldNotBeNull(messageTrack.Headers);
                ShouldBeNullExtensions.ShouldBeNull(messageTrack.ExceptionText);
            }
        }
        public void will_build_the_new_table_if_the_configured_table_does_not_match_the_existing_table_on_other_schema()
        {
            DocumentTable table1;
            DocumentTable table2;

            StoreOptions(_ => _.DatabaseSchemaName = "other");

            theStore.Tenancy.Default.EnsureStorageExists(typeof(User));

            theStore.Tenancy.Default.DbObjects.DocumentTables().ShouldContain("other.mt_doc_user");

            table1 = theStore.TableSchema(typeof(User));
            table1.ShouldNotContain(x => x.Name == "user_name");


            var store2 = SeparateStore(_ =>
            {
                _.DatabaseSchemaName = "other";
                _.Schema.For <User>().Duplicate(x => x.UserName);
                _.AutoCreateSchemaObjects = AutoCreate.All;
            });

            store2.Tenancy.Default.EnsureStorageExists(typeof(User));

            store2.Tenancy.Default.DbObjects.DocumentTables().ShouldContain("other.mt_doc_user");

            table2 = store2.TableSchema(typeof(User));


            table2.ShouldNotBe(table1);

            ShouldBeNullExtensions.ShouldNotBeNull(table2.Column("user_name"));
        }
        public void successful_assembly_types()
        {
            var types = new AssemblyTypes(GetType().GetTypeInfo().Assembly);

            types.Record.Name.ShouldBe(GetType().GetTypeInfo().Assembly.FullName);
            ShouldBeNullExtensions.ShouldBeNull(types.Record.LoadException);
        }
Beispiel #8
0
        public void returns_no_continuation_when_exception_does_not_match()
        {
            var handler = new RespondWithMessageHandler <NotImplementedException>(null);

            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new Exception()));
            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new DivideByZeroException()));
            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new NullReferenceException()));
        }
Beispiel #9
0
        public void do_nothing_if_it_is_not_the_right_exception()
        {
            var handler = new MoveToErrorQueueHandler <NotImplementedException>();

            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new Exception()));
            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new DivideByZeroException()));
            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(null, new NotSupportedException()));
        }
Beispiel #10
0
        public static void ShouldHaveHandler <T>(this HandlerChain chain, Expression <Action <T> > expression)
        {
            ShouldBeNullExtensions.ShouldNotBeNull(chain);

            var method = ReflectionHelper.GetMethod(expression);

            chain.Handlers.Any(x => x.Method.Name == method.Name).ShouldBeTrue();
        }
Beispiel #11
0
        public async Task does_not_blow_up()
        {
            await withAllDefaults();

            var chain = Handlers.ChainFor <Message1>();
            var call  = chain.Handlers.First(x => x.HandlerType == typeof(ThingWithInner.InnerHandler));

            ShouldBeNullExtensions.ShouldNotBeNull(call);
        }
Beispiel #12
0
        public void happily_ignores_nested_field_when_no_data_is_available()
        {
            //var child = theSource.AddChild(nameof(Target.Inner));
            //child.Dictionary.Add(nameof(Child.Name), "Logan");

            var target = binder.Build(theSource);

            ShouldBeNullExtensions.ShouldBeNull(target.InnerField);
        }
Beispiel #13
0
        public async Task bootstraps_the_runtime()
        {
            using (var system = JasperStorytellerHost.Basic())
            {
                await system.Warmup();

                ShouldBeNullExtensions.ShouldNotBeNull(system.Runtime.Get <BusSettings>());
            }
        }
Beispiel #14
0
        public void parent_route()
        {
            ShouldBeNullExtensions.ShouldBeNull(new Node(string.Empty).ParentRoute);

            new Node("a").ParentRoute.ShouldBe(string.Empty);

            new Node("a/*").ParentRoute.ShouldBe("a");
            new Node("a/*/b").ParentRoute.ShouldBe("a/*");
            new Node("a/*/b/c").ParentRoute.ShouldBe("a/*/b");
        }
Beispiel #15
0
        public void can_bind_nested_field()
        {
            var child = theSource.AddChild(nameof(Target.InnerField));

            child.Dictionary.Add(nameof(Child.Name), "Ororo");

            var target = binder.Build(theSource);

            ShouldBeNullExtensions.ShouldNotBeNull(target.InnerField);
            target.InnerField.Name.ShouldBe("Ororo");
        }
Beispiel #16
0
        public void can_bind_nested_property()
        {
            var child = theSource.AddChild(nameof(Target.Inner));

            child.Dictionary.Add(nameof(Child.Name), "Logan");

            var target = binder.Build(theSource);

            ShouldBeNullExtensions.ShouldNotBeNull(target.Inner);
            target.Inner.Name.ShouldBe("Logan");
        }
Beispiel #17
0
        public void create_route_parsing_frame_from_string_argument()
        {
            var arg = new RouteArgument("name", 1);

            arg.ArgType = typeof(string);

            var frame = arg.ToParsingFrame().ShouldBeOfType <StringRouteArgument>();

            ShouldBeNullExtensions.ShouldNotBeNull(frame);
            frame.Position.ShouldBe(1);
            frame.Name.ShouldBe("name");
        }
Beispiel #18
0
        public async Task bootstraps_the_runtime()
        {
            using (var system = JasperStorytellerHost.Basic(x =>
            {
                x.Handlers.DisableConventionalDiscovery();
                x.Http.Actions.DisableConventionalDiscovery();
            }))
            {
                await system.Warmup();

                ShouldBeNullExtensions.ShouldNotBeNull(system.Runtime.Get <BusSettings>());
            }
        }
Beispiel #19
0
        public void if_nothing_matches_do_not_return_a_continuation()
        {
            var exception = new Exception();
            var envelope  = ObjectMother.Envelope();

            var conditionThatDoesNotMatch = Substitute.For <IExceptionMatch>();


            var handler = new ErrorHandler();

            handler.AddCondition(conditionThatDoesNotMatch);

            ShouldBeNullExtensions.ShouldBeNull(handler.DetermineContinuation(envelope, exception));
        }
Beispiel #20
0
        public void create_route_parsing_from_int_argument()
        {
            var arg = new RouteArgument("age", 3)
            {
                ArgType = typeof(int)
            };

            var frame = arg.ToParsingFrame().ShouldBeOfType <ParsedRouteArgument>();

            ShouldBeNullExtensions.ShouldNotBeNull(frame);
            frame.Position.ShouldBe(3);
            frame.Variable.Usage.ShouldBe("age");

            frame.Variable.VariableType.ShouldBe(typeof(int));
        }
Beispiel #21
0
        public static void ShouldHaveTheSameElementKeysAs <ELEMENT, KEY>(this IEnumerable <ELEMENT> actual,
                                                                         IEnumerable expected,
                                                                         Func <ELEMENT, KEY> keySelector)
        {
            ShouldBeNullExtensions.ShouldNotBeNull(actual);
            ShouldBeNullExtensions.ShouldNotBeNull(expected);

            var actualArray   = actual.ToArray();
            var expectedArray = expected.Cast <object>().ToArray();

            actualArray.Length.ShouldBe(expectedArray.Length);

            for (var i = 0; i < actual.Count(); i++)
            {
                keySelector(actualArray[i]).ShouldBe(expectedArray[i]);
            }
        }
        public async Task adds_the_core_service_provider_abstractions()
        {
            var registry = new JasperRegistry();

            registry.Services.AddTransient <IService, FooService>();

            var runtime = await JasperRuntime.ForAsync(registry);

            try
            {
                ShouldBeNullExtensions.ShouldNotBeNull(runtime.Get <IServiceProvider>());
                ShouldBeNullExtensions.ShouldNotBeNull(runtime.Get <IServiceScopeFactory>());
            }
            finally
            {
                await runtime.Shutdown();
            }
        }
Beispiel #23
0
        public static void ShouldHaveTheSameElementsAs(this IList actual, IList expected)
        {
            try
            {
                ShouldBeNullExtensions.ShouldNotBeNull(actual);
                ShouldBeNullExtensions.ShouldNotBeNull(expected);

                actual.Count.ShouldBe(expected.Count);

                for (var i = 0; i < actual.Count; i++)
                {
                    actual[i].ShouldBe(expected[i]);
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Actual values were:");
                actual.Each(x => Debug.WriteLine(x));
                throw;
            }
        }
        public void if_original_envelope_is_ack_requested_send_ack_back()
        {
            var original = new Envelope
            {
                ReplyUri     = "foo://bar".ToUri(),
                AckRequested = true,
            };

            ClassUnderTest.SendOutgoingMessages(original, new object[0]);


            var envelope = MockFor <IEnvelopeSender>().ReceivedCalls().First().GetArguments()[0].As <Envelope>();

            ShouldBeNullExtensions.ShouldNotBeNull(envelope);

            envelope.ResponseId.ShouldBe(original.Id);
            envelope.Destination.ShouldBe(original.ReplyUri);
            envelope.Message.ShouldBe(new Acknowledgement {
                CorrelationId = original.Id
            });
            envelope.ParentId.ShouldBe(original.Id);
        }
Beispiel #25
0
        public async Task finds_actions_on_saga_state_start_methods()
        {
            await _fixture.withRuntime();

            ShouldBeNullExtensions.ShouldNotBeNull(chainFor <SagaStarter>());
        }
Beispiel #26
0
        public void no_input_type_if_none()
        {
            var route = RouteBuilder.Build <SomeEndpoint>(x => x.delete_something(null));

            ShouldBeNullExtensions.ShouldBeNull(route.InputType);
        }
Beispiel #27
0
 public void can_build_a_binder()
 {
     ShouldBeNullExtensions.ShouldNotBeNull(binder);
 }
Beispiel #28
0
 public void do_nothing_with_a_missing_string_field_value()
 {
     ShouldBeNullExtensions.ShouldBeNull(binder.Build(theSource)
                                         .StringField);
 }
Beispiel #29
0
 public void should_have_sent_a_failure_ack()
 {
     ShouldBeNullExtensions.ShouldNotBeNull(theAck);
 }
Beispiel #30
0
 protected override void beforeAll()
 {
     ShouldBeNullExtensions.ShouldNotBeNull(Host);
     BeforeAllWasCalled = true;
 }