Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/WordPressSharp/Models/MediaFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

namespace WordPressSharp.Models
{
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaFilter : FilterBase
{
[XmlRpcMember("offset")]
public string Offset { get; set; }
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaFilter : FilterBase
{
[XmlRpcMember("offset")]
public int Offset { get; set; }

[XmlRpcMember("parent_id")]
public string ParentId { get; set; }
[XmlRpcMember("number")]
public int Number { get; set; }

[XmlRpcMember("mime_type")]
public string MimeType { get; set; }
}
[XmlRpcMember("parent_id")]
public int ParentId { get; set; }

[XmlRpcMember("mime_type")]
public string MimeType { get; set; }
}
}
49 changes: 26 additions & 23 deletions src/WordPressSharp/Models/MediaItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,37 @@

namespace WordPressSharp.Models
{
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaItem
{
[XmlRpcMember("attachment_id")]
public string Id { get; set; }
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaItem
{
[XmlRpcMember("attachment_id")]
public string Id { get; set; }

[XmlRpcMember("date_created_gmt")]
public DateTime DateCreated { get; set; }
[XmlRpcMember("date_created_gmt")]
public DateTime DateCreated { get; set; }

[XmlRpcMember("parent")]
public int Parent { get; set; }
[XmlRpcMember("parent")]
public int Parent { get; set; }

[XmlRpcMember("link")]
public string Link { get; set; }
[XmlRpcMember("link")]
public string Link { get; set; }

[XmlRpcMember("title")]
public string Title { get; set; }
[XmlRpcMember("thumbnail")]
public string Thumbnail { get; set; }

[XmlRpcMember("caption")]
public string Caption { get; set; }
[XmlRpcMember("title")]
public string Title { get; set; }

[XmlRpcMember("description")]
public string Description { get; set; }
[XmlRpcMember("caption")]
public string Caption { get; set; }

[XmlRpcMember("metadata")]
public MediaItemMetadata metadata { get; set; }

[XmlRpcMember("thumbnail")]
public string Thumbnail { get; set; }
}
[XmlRpcMember("description")]
public string Description { get; set; }

[XmlRpcMember("metadata")]
public MediaItemMetadata metadata { get; set; }

[XmlRpcMember("image_meta")]
public PostThumbnailImageMeta Imagemeta { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/WordPressSharp/Models/MediaItemMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class MediaItemMetadata
public string File { get; set; }

[XmlRpcMember("sizes")]
public MediaItemSizes Sizes { get; set; }
public MediaItemSizes[] Sizes { get; set; }
}
}
32 changes: 16 additions & 16 deletions src/WordPressSharp/Models/MediaItemSizes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

namespace WordPressSharp.Models
{
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaItemSizes
{
[XmlRpcMember("medium")]
public MediaItemSize Medium { get; set; }
[XmlRpcMissingMapping(MappingAction.Ignore)]
public class MediaItemSizes
{
[XmlRpcMember("thumbnail")]
public MediaItemSize Thumbnail { get; set; }

[XmlRpcMember("large")]
public MediaItemSize Large { get; set; }
[XmlRpcMember("medium")]
public MediaItemSize Medium { get; set; }

[XmlRpcMember("thumbnail")]
public MediaItemSize Thumbnail { get; set; }
[XmlRpcMember("large")]
public MediaItemSize Large { get; set; }

[XmlRpcMember("post-thumbnail")]
public MediaItemSize PostThumbnail { get; set; }
[XmlRpcMember("post-thumbnail")]
public MediaItemSize PostThumbnail { get; set; }

[XmlRpcMember("listing")]
public MediaItemSize Listing { get; set; }
[XmlRpcMember("listing")]
public MediaItemSize Listing { get; set; }

[XmlRpcMember("listing_small")]
public MediaItemSize ListingSmall { get; set; }
}
[XmlRpcMember("listing_small")]
public MediaItemSize ListingSmall { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/WordPressSharp/Models/MediamItemSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public class MediaItemSize
public string File { get; set; }

[XmlRpcMember("width")]
public int Width { get; set; }
public string Width { get; set; }

[XmlRpcMember("height")]
public int Height { get; set; }
public string Height { get; set; }

[XmlRpcMember("mime_type")]
[XmlRpcMember("mime-type")]
public string MimeType { get; set; }
}
}
38 changes: 38 additions & 0 deletions src/WordPressSharp/Models/PostThumbnailImageMeta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using CookComputing.XmlRpc;


namespace WordPressSharp.Models
{
public class PostThumbnailImageMeta
{
[XmlRpcMember("aperture")]
public int Aperture { get; set; }

[XmlRpcMember("credit")]
public string Credit { get; set; }

[XmlRpcMember("camera")]
public string Camera { get; set; }

[XmlRpcMember("caption")]
public string Caption { get; set; }

[XmlRpcMember("created_timestamp")]
public int CreatedTimestamp { get; set; }

[XmlRpcMember("copyright")]
public string Copyright { get; set; }

[XmlRpcMember("focal_length")]
public int FocalLength { get; set; }

[XmlRpcMember("iso")]
public int Iso { get; set; }

[XmlRpcMember("shutter_speed")]
public int ShutterSpeed { get; set; }

[XmlRpcMember("title")]
public string Title { get; set; }
}
}
37 changes: 0 additions & 37 deletions src/WordPressSharp/Models/PostThumnailImageMeta.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/WordPressSharp/WordPressSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<Compile Include="Models\Post.cs" />
<Compile Include="Models\PostCommentCount.cs" />
<Compile Include="Models\PostFilter.cs" />
<Compile Include="Models\PostThumnailImageMeta.cs" />
<Compile Include="Models\PostThumbnailImageMeta.cs" />
<Compile Include="Models\PostType.cs" />
<Compile Include="Models\Post_Put.cs" />
<Compile Include="Models\Taxonomy.cs" />
Expand Down
121 changes: 67 additions & 54 deletions src/WordPressSharpTest/WordPressClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,76 @@

namespace WordPressSharpTest
{
[TestClass]
public class WordPressClientTest
{
/// <summary>
/// Creates the default client.
/// </summary>
/// <returns></returns>
private static WordPressClient CreateDefaultClient()
{
return new WordPressClient();
}
[TestClass]
public class WordPressClientTest
{
/// <summary>
/// Creates the default client.
/// </summary>
/// <returns></returns>
private static WordPressClient CreateDefaultClient()
{
return new WordPressClient();
}

/// <summary>
/// Tests the default configuration. Note: settings must be present is App.config.
/// </summary>
[TestMethod]
public void TestDefaultConfiguration()
{
//if settings are wrong - CreateDefaultClient will throw an error
using (var client = CreateDefaultClient())
{
Assert.IsNotNull(client.WordPressService, "WordPressService is null.");
}
}
/// <summary>
/// Tests the default configuration. Note: settings must be present is App.config.
/// </summary>
[TestMethod]
public void TestDefaultConfiguration()
{
//if settings are wrong - CreateDefaultClient will throw an error
using (var client = CreateDefaultClient())
{
Assert.IsNotNull(client.WordPressService, "WordPressService is null.");
}
}

/// <summary>
/// Tests the get posts.
/// </summary>
[TestMethod]
public void TestGetPosts()
{
using (var client = CreateDefaultClient())
{
//if something is wrong - GetPosts will throw an error
var posts = client.GetPosts(new PostFilter());
}
}
/// <summary>
/// Tests the get posts.
/// </summary>
[TestMethod]
public void TestGetPosts()
{
using (var client = CreateDefaultClient())
{
//if something is wrong - GetPosts will throw an error
var posts = client.GetPosts(new PostFilter());
}
}

/// <summary>
/// Test Create Post
/// </summary>
[TestMethod]
public void CreatePost()
/// <summary>
/// Tests the get medias.
/// </summary>
[TestMethod]
public void TestGetMedias()
{
using (var client = CreateDefaultClient())
{
//if something is wrong - GetPosts will throw an error
var mediaItems = client.GetMediaItems(new MediaFilter());
}
}

/// <summary>
/// Test Create Post
/// </summary>
[TestMethod]
public void CreatePost()
{
using (var client = CreateDefaultClient())
{
var post = new Post
{
using (var client = CreateDefaultClient())
{
var post = new Post
{
PostType = "post", // "post" or "page"
Title = "Test Title",
Content = "Test",
PublishDateTime = DateTime.Now,
Status = "publish" // "draft" or "publish"
};
PostType = "post", // "post" or "page"
Title = "Test Title",
Content = "Test",
PublishDateTime = DateTime.Now,
Status = "publish" // "draft" or "publish"
};

client.NewPost(post);
}
}
}
client.NewPost(post);
}
}
}
}