-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a1aab5
commit ac05c89
Showing
19 changed files
with
784 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<Playlist Version="1.0"><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_listing_articles::should_list_articles" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_counting_articles::should_count_articles" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_creating_an_article::should_create_an_article" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_updating_an_article::should_update_an_article" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_listing_tags::should_list_tags" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_listing_tags_for_a_blog::should_list_tags_for_a_blog" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_deleting_an_article::should_delete_an_article" /><Add Test="ShopifySharp.Tests.ShopifyArticleService_Tests.When_listing_authors::should_list_authors" /></Playlist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
static class ArticleUtils | ||
{ | ||
public static ShopifyArticleService Service = new ShopifyArticleService(Utils.MyShopifyUrl, Utils.AccessToken); | ||
|
||
public static string Title = "My new Article title - "; | ||
|
||
public static string Author = "John Smith"; | ||
|
||
public static string Tags = "This Post, Has Been Tagged"; | ||
|
||
public static string BodyHtml = "<h1>I like articles</h1>\n<p><strong>Yea</strong>, I like posting them through <span class=\"caps\">REST</span>.</p>"; | ||
|
||
static long? BlogId; | ||
|
||
public static long GetBlogId() | ||
{ | ||
if (BlogId.HasValue) | ||
{ | ||
return BlogId.Value; | ||
} | ||
|
||
var service = new ShopifyBlogService(Utils.MyShopifyUrl, Utils.AccessToken); | ||
var blogs = service.ListAsync().Result; | ||
|
||
BlogId = blogs.First().Id; | ||
|
||
return BlogId.Value; | ||
} | ||
|
||
public static ShopifyArticle CreateArticle() | ||
{ | ||
return new ShopifyArticle() | ||
{ | ||
Title = Title + Guid.NewGuid(), | ||
Author = Author, | ||
Tags = Tags, | ||
BodyHtml = BodyHtml, | ||
Image = new ShopifyArticleImage() | ||
{ | ||
Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" | ||
} | ||
}; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
ShopifySharp.Tests/ShopifyArticleService Tests/When_counting_articles.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Machine.Specifications; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_counting_articles | ||
{ | ||
Establish context = () => | ||
{ | ||
CreatedId = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await().AsTask.Result.Id; | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Count = ArticleUtils.Service.CountAsync(ArticleUtils.GetBlogId()).Await(); | ||
}; | ||
|
||
It should_count_articles = () => | ||
{ | ||
Count.HasValue.ShouldBeTrue(); | ||
Count.Value.ShouldBeGreaterThanOrEqualTo(1); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (CreatedId.HasValue) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), CreatedId.Value).Await(); | ||
} | ||
}; | ||
|
||
static int? Count; | ||
|
||
static long? CreatedId; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
ShopifySharp.Tests/ShopifyArticleService Tests/When_creating_an_article.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Machine.Specifications; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_creating_an_article | ||
{ | ||
Establish context = () => | ||
{ | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Article = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await(); | ||
}; | ||
|
||
It should_create_an_article = () => | ||
{ | ||
Article.Id.HasValue.ShouldBeTrue(); | ||
Article.Author.ShouldEqual(ArticleUtils.Author); | ||
Article.BodyHtml.ShouldEqual(ArticleUtils.BodyHtml); | ||
Article.BlogId.ShouldEqual(ArticleUtils.GetBlogId()); | ||
Article.Title.ShouldContain(ArticleUtils.Title); | ||
Article.Handle.ShouldNotBeEmpty(); | ||
Article.Tags.ShouldNotBeEmpty(); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (Article != null) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), Article.Id.Value).Await(); | ||
} | ||
}; | ||
|
||
static ShopifyArticle Article; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
ShopifySharp.Tests/ShopifyArticleService Tests/When_deleting_an_article.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Machine.Specifications; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_deleting_an_article | ||
{ | ||
Establish context = () => | ||
{ | ||
Id = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await().AsTask.Result.Id.Value; | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
ex = Catch.Exception(() => ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), Id).Await()); | ||
}; | ||
|
||
It should_delete_an_article = () => | ||
{ | ||
ex.ShouldBeNull(); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
}; | ||
|
||
static long Id; | ||
|
||
static Exception ex; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ShopifySharp.Tests/ShopifyArticleService Tests/When_listing_articles.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Machine.Specifications; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_listing_articles | ||
{ | ||
Establish context = () => | ||
{ | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Articles = ArticleUtils.Service.ListAsync(ArticleUtils.GetBlogId()).Await().AsTask.Result.ToList(); | ||
}; | ||
|
||
It should_list_articles = () => | ||
{ | ||
Articles.ShouldNotBeNull(); | ||
Articles.Count().ShouldBeGreaterThanOrEqualTo(0); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
}; | ||
|
||
static IEnumerable<ShopifyArticle> Articles; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
ShopifySharp.Tests/ShopifyArticleService Tests/When_listing_authors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Machine.Specifications; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_listing_authors | ||
{ | ||
Establish context = () => | ||
{ | ||
CreatedId = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await().AsTask.Result.Id; | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Authors = ArticleUtils.Service.ListAuthorsAsync().Await().AsTask.Result; | ||
}; | ||
|
||
It should_list_authors = () => | ||
{ | ||
Authors.ShouldNotBeNull(); | ||
Authors.Any(a => a == ArticleUtils.Author).ShouldBeTrue(); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (CreatedId.HasValue) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), CreatedId.Value).Await(); | ||
} | ||
}; | ||
|
||
static long? CreatedId; | ||
|
||
static IEnumerable<string> Authors; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
ShopifySharp.Tests/ShopifyArticleService Tests/When_listing_tags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Machine.Specifications; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_listing_tags | ||
{ | ||
Establish context = () => | ||
{ | ||
CreatedId = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await().AsTask.Result.Id; | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Tags = ArticleUtils.Service.ListTagsAsync().Await().AsTask.Result; | ||
}; | ||
|
||
It should_list_tags = () => | ||
{ | ||
Tags.ShouldNotBeNull(); | ||
Tags.Count().ShouldBeGreaterThanOrEqualTo(1); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (CreatedId.HasValue) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), CreatedId.Value).Await(); | ||
} | ||
}; | ||
|
||
static long? CreatedId; | ||
|
||
static IEnumerable<string> Tags; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
ShopifySharp.Tests/ShopifyArticleService Tests/When_listing_tags_for_a_blog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Machine.Specifications; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_listing_tags_for_a_blog | ||
{ | ||
Establish context = () => | ||
{ | ||
CreatedId = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await().AsTask.Result.Id; | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Tags = ArticleUtils.Service.ListTagsForBlogAsync(ArticleUtils.GetBlogId()).Await().AsTask.Result; | ||
}; | ||
|
||
It should_list_tags_for_a_blog = () => | ||
{ | ||
Tags.ShouldNotBeNull(); | ||
Tags.Count().ShouldBeGreaterThanOrEqualTo(1); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (CreatedId.HasValue) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), CreatedId.Value).Await(); | ||
} | ||
}; | ||
|
||
static long? CreatedId; | ||
|
||
static IEnumerable<string> Tags; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
ShopifySharp.Tests/ShopifyArticleService Tests/When_updating_an_article.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Machine.Specifications; | ||
|
||
namespace ShopifySharp.Tests.ShopifyArticleService_Tests | ||
{ | ||
[Subject(typeof(ShopifyArticleService))] | ||
class When_updating_an_article | ||
{ | ||
Establish context = () => | ||
{ | ||
Article = ArticleUtils.Service.CreateAsync(ArticleUtils.GetBlogId(), ArticleUtils.CreateArticle()).Await(); | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
Article.BodyHtml = Html; | ||
Article = ArticleUtils.Service.UpdateAsync(ArticleUtils.GetBlogId(), Article).Await(); | ||
}; | ||
|
||
It should_update_an_article = () => | ||
{ | ||
Article.Id.HasValue.ShouldBeTrue(); | ||
Article.BodyHtml.ShouldEqual(Html); | ||
Article.Author.ShouldEqual(ArticleUtils.Author); | ||
Article.BlogId.ShouldEqual(ArticleUtils.GetBlogId()); | ||
Article.Title.ShouldContain(ArticleUtils.Title); | ||
Article.Handle.ShouldNotBeEmpty(); | ||
Article.Tags.ShouldNotBeEmpty(); | ||
}; | ||
|
||
Cleanup after = () => | ||
{ | ||
if (Article != null) | ||
{ | ||
ArticleUtils.Service.DeleteAsync(ArticleUtils.GetBlogId(), Article.Id.Value).Await(); | ||
} | ||
}; | ||
|
||
static ShopifyArticle Article; | ||
|
||
static string Html = "<h1>Updated!</h1>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.