public void GetPostFaultsOnBadID()
        {
            FakePostService postService = new FakePostService();
            FakeUserService userService = new FakeUserService();

            MetaWeblogAPI service = new MetaWeblogAPI(postService, null, userService, null, null);

            Assert.Throws <ArgumentOutOfRangeException>(() => service.GetPost(Guid.NewGuid().ToString(), "test", "test"));
        }
        public void GetPostReturnsPost()
        {
            FakePostService postService = new FakePostService();
            FakeUserService userService = new FakeUserService();

            DateTime now = DateTime.Now;

            Oxite.Models.Post fakePost = new Oxite.Models.Post()
            {
                Title     = "Title",
                Body      = "Body",
                Created   = DateTime.Now,
                Published = DateTime.Now,
                ID        = Guid.NewGuid(),
                Creator   = new Oxite.Models.User()
                {
                    DisplayName = "Test User", Name = "user"
                },
                BodyShort = "Excerpt",
                Slug      = "Slug"
            };
            fakePost.Area = new Oxite.Models.Area()
            {
                ID = Guid.NewGuid(), Name = "Blog1", DisplayName = "Blog One"
            };
            fakePost.Tags =
                new List <Oxite.Models.Tag>(new[]
            {
                new Oxite.Models.Tag()
                {
                    ID = Guid.NewGuid(), Name = "Tag1"
                },
                new Oxite.Models.Tag()
                {
                    ID = Guid.NewGuid(), Name = "Tag2"
                }
            });

            postService.AddedPosts.Add(fakePost);

            MetaWeblogAPI service = new MetaWeblogAPI(postService, null, userService, null, null);

            Post post = service.GetPost(fakePost.ID.ToString(), "test", "test");

            Assert.NotNull(post);
            Assert.Equal(fakePost.Title, post.title);
            Assert.Equal(fakePost.Body, post.description);
            Assert.Equal(fakePost.Created, post.dateCreated);
            Assert.Equal(fakePost.Creator.ID, new Guid(post.userid));
            Assert.Equal(fakePost.BodyShort, post.mt_excerpt);
            Assert.Equal(fakePost.Slug, post.mt_basename);
            foreach (string category in post.categories)
            {
                Assert.Contains <string>(category, fakePost.Tags.Select(t => t.Name));
            }
        }
        public void GetPostFaultsOnNullUser()
        {
            MetaWeblogAPI service = new MetaWeblogAPI(null, null, null, null, null);

            Assert.Throws <ArgumentException>(() => service.GetPost(Guid.NewGuid().ToString(), null, null));
        }