예제 #1
0
        public async Task Should_bind_reader_result_with_the_first_matching_reader()
        {
            var requestGraph = RequestGraph
                               .CreateFor <Handler>(h => h.Get(null))
                               .WithRequestParameter("request")
                               .AddRequestReader1(x => "reader1".ToTaskResult <object>())
                               .AddRequestReader2(x => "reader2".ToTaskResult <object>());
            var binder = new ReaderBinder(requestGraph.RequestReaders, requestGraph.Configuration);
            var requestReaderContext = requestGraph.GetRequestBinderContext();

            await binder.Bind(requestReaderContext);

            requestGraph.ActionArguments.ShouldOnlyContain("reader1");

            requestGraph.RequestReader1.AppliesToCalled.ShouldBeTrue();
            requestGraph.RequestReader1.AppliesToContext.RequestContext
            .ShouldEqual(requestReaderContext.RequestContext);
            requestGraph.RequestReader1.ReadCalled.ShouldBeTrue();
            requestGraph.RequestReader1.ReadContext.RequestContext
            .ShouldEqual(requestReaderContext.RequestContext);

            requestGraph.RequestReader2.AppliesToCalled.ShouldBeTrue();
            requestGraph.RequestReader2.AppliesToContext.RequestContext
            .ShouldEqual(requestReaderContext.RequestContext);
            requestGraph.RequestReader2.ReadCalled.ShouldBeFalse();
        }
예제 #2
0
        public void Should_not_bind_reader_if_route_does_not_have_a_request()
        {
            var requestGraph = RequestGraph
                               .CreateFor <Handler>(h => h.Get(null));
            var binder = new ReaderBinder(requestGraph.RequestReaders, requestGraph.Configuration);

            binder.AppliesTo(requestGraph.GetRequestBinderContext()).ShouldBeFalse();
        }
예제 #3
0
        public async Task Should_not_bind_if_no_reader_found()
        {
            var requestGraph = RequestGraph
                               .CreateFor <Handler>(h => h.Get(null))
                               .WithRequestParameter("request")
                               .AddValueMapper1(x => $"{x.Values.First()}mapper");
            var binder = new ReaderBinder(requestGraph.RequestReaders, requestGraph.Configuration);

            await binder.Bind(requestGraph.GetRequestBinderContext());

            requestGraph.ActionArguments.ShouldOnlyContain(null);

            requestGraph.ValueMapper1.MapCalled.ShouldBeFalse();
        }
예제 #4
0
        public async Task Should_not_bind_with_reader_instance_that_does_not_apply()
        {
            var requestGraph = RequestGraph
                               .CreateFor <Handler>(h => h.Get(null))
                               .WithRequestParameter("request")
                               .AddRequestReader1(x => "reader1".ToTaskResult <object>(),
                                                  instanceAppliesTo: x => false)
                               .AddRequestReader2(x => "reader2".ToTaskResult <object>())
                               .AddValueMapper1(x => x.Values.First());

            var binder = new ReaderBinder(requestGraph.RequestReaders, requestGraph.Configuration);

            await binder.Bind(requestGraph.GetRequestBinderContext());

            requestGraph.ActionArguments.ShouldOnlyContain("reader2");

            requestGraph.RequestReader1.AppliesToCalled.ShouldBeTrue();
            requestGraph.RequestReader1.ReadCalled.ShouldBeFalse();

            requestGraph.RequestReader2.AppliesToCalled.ShouldBeTrue();
            requestGraph.RequestReader2.ReadCalled.ShouldBeTrue();
        }
 public void SetUp()
 {
     binder = new ReaderBinder(ObjectResolver.Basic(), new InMemoryServiceLocator());
 }
예제 #6
0
        public void SetUp()
        {
            var container = new Container(new AppSettingProviderRegistry());

            binder = container.GetInstance<ReaderBinder>();
        }
예제 #7
0
 public void SetUp()
 {
     binder = new ReaderBinder(StandardModelBinder.Basic(), new StubServiceLocator());
 }
예제 #8
0
 public void SetUp()
 {
     binder = new ReaderBinder(ObjectResolver.Basic(), new InMemoryServiceLocator());
 }
예제 #9
0
        public void SetUp()
        {
            var container = new Container(new AppSettingProviderRegistry());

            binder = container.GetInstance <ReaderBinder>();
        }
예제 #10
0
 public void SetUp()
 {
     binder = new ReaderBinder(StandardModelBinder.Basic(), new StubServiceLocator());
 }