Ejemplo n.º 1
0
 private void ConfigureLinkBehaviour()
 {
     _linkFactory.SetHandler <HomeLink>(new ActionResponseHandler(HandleHomeLinkResponse));
     _linkFactory.SetHandler <UserLink>(new ActionResponseHandler(HandleUserLinkResponse));
     _linkFactory.SetHandler <CodeSearchLink>(new ActionResponseHandler(HandleStandardDocumentResponse));
     _linkFactory.SetHandler <EmojisLink>(new ActionResponseHandler(HandleStandardDocumentResponse));
     _linkFactory.SetHandler <FollowingLink>(new ActionResponseHandler(HandleStandardDocumentResponse));
     _linkFactory.SetHandler <FollowersLink>(new ActionResponseHandler(HandleStandardDocumentResponse));
     _linkFactory.SetHandler <GistsLink>(new ActionResponseHandler(HandleStandardDocumentResponse));
     _linkFactory.SetHandler <ItemLink>(new ActionResponseHandler(HandleItemResponse));
 }
Ejemplo n.º 2
0
        public void SpecifyHandlerForAboutLink()
        {
            var foo = false;

            var registry = new LinkFactory();
            registry.SetHandler<AboutLink>(new ActionResponseHandler((hrm) => foo = true));

            var link = registry.CreateLink<AboutLink>();

            Assert.IsType<ActionResponseHandler>(link.HttpResponseHandler);
        }
Ejemplo n.º 3
0
        public Task SpecifyHandlerChainForAboutLink()
        {
            var foo = false;
            var bar = false;
            var baz = false;

            var registry = new LinkFactory();
            var grh = new ActionResponseHandler((hrm) => baz = true,
                new ActionResponseHandler((hrm) => foo = true,
                    new ActionResponseHandler((hrm) => bar = true)));

            registry.SetHandler<AboutLink>(grh);

            var link = registry.CreateLink<AboutLink>();
            link.Target = new Uri("http://example.org");
            var httpClient = new HttpClient(new FakeHandler() { Response = new HttpResponseMessage()});

            return httpClient.FollowLinkAsync(link).ContinueWith(t =>
                {
                    Assert.True(foo);
                    Assert.True(bar);
                    Assert.True(baz);
                });
        }