Пример #1
0
        public void PingReturnsSuccessIfTrackbackFound()
        {
            FakePostService postService = new FakePostService();

            postService.AddedPosts.Add(new Oxite.Models.Post()
            {
                Slug = "test", Trackbacks = new List <Trackback>(new[] { new Trackback()
                                                                         {
                                                                             Url = "http://test.com/foo"
                                                                         } })
            });

            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            string result = service.Ping("http://test.com/foo", "http://foo.com/test/area");

            Assert.Null(postService.AddedTrackback);
        }
Пример #2
0
        public void PingCreatesNewTrackbackForNotFoundTrackback()
        {
            FakePostService postService = new FakePostService();

            postService.AddedPosts.Add(new Oxite.Model.Post()
            {
                Slug = "test", Trackbacks = new List <Trackback>()
            });

            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            string result = service.Ping("http://test.com/foo", "http://foo.com/test/area");

            Assert.NotNull(result);
            Assert.NotNull(postService.AddedTrackback);
            Assert.Equal("http://test.com/foo", postService.AddedTrackback.Url);
        }
Пример #3
0
        public void PingFaultsForNotFoundPost()
        {
            FakePostService postService = new FakePostService();
            RouteCollection routes      = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            Assert.Throws <ArgumentException>(() => service.Ping("http://test.com/foo", "http://foo.com/test/area"));
        }
Пример #4
0
        public void PingFaultsForNullTargetUri()
        {
            PingbackService service = new PingbackService(null, null);

            Assert.Throws <ArgumentNullException>(() => service.Ping("http://test", null));
        }
Пример #5
0
        public void PingFaultsForNullSourceUri()
        {
            PingbackService service = new PingbackService(null, null);

            Assert.Throws <ArgumentNullException>(() => service.Ping(null, null));
        }