Test GitTag deserialization

This commit is contained in:
John Nye
2013-11-02 07:49:49 +00:00
parent cf9dd7fe95
commit 070980eec5
4 changed files with 22 additions and 14 deletions
+2 -2
View File
@@ -43,10 +43,10 @@ public class TagsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new TagsClient(connection);
client.Create("owner", "repo", new NewTag{Type = NewTagType.Tree});
client.Create("owner", "repo", new NewTag{Type = TaggedType.Tree});
connection.Received().Post<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/tags"),
Arg.Is<NewTag>(nt => nt.Type == NewTagType.Tree));
Arg.Is<NewTag>(nt => nt.Type == TaggedType.Tree));
}
[Fact]
@@ -168,6 +168,11 @@ namespace Octokit.Tests.Http
Assert.Equal("tag-message", response.BodyAsObject.Message);
Assert.Equal("tagger-name", response.BodyAsObject.Tagger.Name);
Assert.Equal("tagger-email", response.BodyAsObject.Tagger.Email);
//Adjust expected date for time zone adjustment
Assert.Equal(new DateTime(2011, 06, 17, 21, 53, 35), response.BodyAsObject.Tagger.Date);
Assert.Equal(TaggedType.Commit, response.BodyAsObject.Object.Type);
Assert.Equal("object-sha", response.BodyAsObject.Object.Sha);
Assert.Equal("object-url", response.BodyAsObject.Object.Url);
}
}
}
+1 -11
View File
@@ -10,17 +10,7 @@ namespace Octokit
public string Object { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods",
Justification = "Property name as defined by web api")]
public NewTagType Type { get; set; }
public TaggedType Type { get; set; }
public Tagger Tagger { get; set; }
}
/// <summary>
/// Represents the type of object being tagged
/// </summary>
public enum NewTagType
{
Commit,
Blob,
Tree
}
}
+14 -1
View File
@@ -2,8 +2,21 @@
{
public class TagObject
{
public string Name { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods",
Justification = "Name defined by web api and required for deserialisation")]
public TaggedType Type { get; set; }
public string Sha { get; set; }
public string Url { get; set; }
}
/// <summary>
/// Represents the type of object being tagged
/// </summary>
public enum TaggedType
{
Commit,
Blob,
Tree
}
}