diff --git a/Core/API/Gist.cs b/Core/API/Gist.cs index 3f847f5..6c0c0ce 100644 --- a/Core/API/Gist.cs +++ b/Core/API/Gist.cs @@ -14,7 +14,7 @@ public Gist( cacheProvider, authProvider) { } - public IEnumerable UserGists(string username) + public IEnumerable List(string username) { return base.Get>( string.Format( @@ -22,7 +22,7 @@ public Gist( username), "GET").Result; } - public IEnumerable CurrentUserGists() + public IEnumerable List() { return base.Get>( string.Format( @@ -31,14 +31,14 @@ public Gist( "GET").Result; } - public IEnumerable PublicGists() + public IEnumerable Public() { return base.Get>( "gists/public", "GET").Result; } - public IEnumerable StarredGists() + public IEnumerable Starred() { return base.Get>( "gists/starred", @@ -72,7 +72,7 @@ public Models.Gist Edit(string id, Models.GistToCreateOrEdit gist) gist).Result; } - public void StarGist(string id) + public void Star(string id) { base.Get( string.Format( @@ -81,7 +81,7 @@ public void StarGist(string id) "PUT"); } - public void UnstarGist(string id) + public void Unstar(string id) { base.Get( string.Format( @@ -90,7 +90,7 @@ public void UnstarGist(string id) "DELETE"); } - public bool IsGistStarred(string id) + public bool HasStar(string id) { return base.Get( string.Format( diff --git a/NOTES b/NOTES index 2be026f..8f8a0ff 100644 --- a/NOTES +++ b/NOTES @@ -2,4 +2,6 @@ Add pagination defaults to base api class Continue to implement models to understand the needs of the base api class Add attribute for an api method that needs authentication? Add a simple parameterized string format for methods? -Add raw url helper methods - with content types? \ No newline at end of file +Add raw url helper methods - with content types? + +Check if 404 causes an exception.. \ No newline at end of file diff --git a/Tests/CoreTests/GistModelTest.cs b/Tests/CoreTests/GistModelTest.cs index 74f53cd..5832fd6 100755 --- a/Tests/CoreTests/GistModelTest.cs +++ b/Tests/CoreTests/GistModelTest.cs @@ -48,6 +48,63 @@ public void TestCreateEditAndDelete() gistModel.Delete(editedGist.id); } + + [Test] + public void PublicGistsTest() + { + var gistModel = new GithubSharp.Core.API.Gist( + new GithubSharp.Plugins.LogProviders.NullLogger.NullLogger(true), + new GithubSharp.Plugins.CacheProviders.NullCacher.NullCacher(), + new GithubSharp.Plugins.AuthProviders.UserPasswordAuthProvider.UserPasswordAuthProvider + (TestSettings.Username, TestSettings.Password)); + + var publicGists = gistModel.Public(); + + Assert.IsNotNull(publicGists); + Assert.IsTrue(new List(publicGists).Count > 0); + } + + [Test] + public void GistStarTest() + { + var gistModel = new GithubSharp.Core.API.Gist( + new GithubSharp.Plugins.LogProviders.NullLogger.NullLogger(true), + new GithubSharp.Plugins.CacheProviders.NullCacher.NullCacher(), + new GithubSharp.Plugins.AuthProviders.UserPasswordAuthProvider.UserPasswordAuthProvider + (TestSettings.Username, TestSettings.Password)); + + + var gistFiles = new Dictionary(); + gistFiles.Add( + "fileName.txt", + new GithubSharp.Core.Models.GistFileForCreation + { + content = System.Guid.NewGuid().ToString() + }); + + + var toCreate = new GithubSharp.Core.Models.GistToCreateOrEdit + { + description = "test gist", + @public = false, + files = gistFiles + }; + + var createdGist = gistModel.Create(toCreate); + + Assert.IsFalse(gistModel.HasStar(createdGist.id)); + + gistModel.Star(createdGist.id); + + Assert.IsTrue(gistModel.HasStar(createdGist.id)); + + gistModel.Unstar(createdGist.id); + + Assert.IsFalse(gistModel.HasStar(createdGist.id)); + + gistModel.Delete(createdGist.id); + } + } }