public void BitbucketAuthor_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json"); BitbucketAuthor expectedAuthor = new BitbucketAuthor { Raw = "Henrik Frystyk Nielsen <*****@*****.**>", User = new BitbucketUser { UserType = "user", DisplayName = "HenrikN", UserName = "******", UserId = "{534d978b-53c8-401b-93b7-ee1f98716edd}", } }; expectedAuthor.User.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/HenrikN/" }); expectedAuthor.User.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/account/HenrikN/avatar/32/" }); expectedAuthor.User.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/users/HenrikN" }); // Act BitbucketAuthor actualAuthor = data["push"]["changes"][0]["new"]["target"]["author"].ToObject <BitbucketAuthor>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedAuthor); string actualJson = JsonConvert.SerializeObject(actualAuthor); Assert.Equal(expectedJson, actualJson); }
public void BitbucketTarget_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json"); BitbucketUser expectedUser = new BitbucketUser { UserType = "user", DisplayName = "HenrikN", UserName = "******", UserId = "{534d978b-53c8-401b-93b7-ee1f98716edd}", }; expectedUser.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/HenrikN/" }); expectedUser.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/account/HenrikN/avatar/32/" }); expectedUser.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/users/HenrikN" }); BitbucketAuthor expectedAuthor = new BitbucketAuthor { User = expectedUser, Raw = "Henrik Frystyk Nielsen <*****@*****.**>", }; BitbucketTarget expectedTarget = new BitbucketTarget { Message = "update\n", Operation = "commit", Hash = "8339b7affbd7c70bbacd0276f581d1ca44df0853", Author = expectedAuthor, Date = DateTime.Parse("2015-09-30T18:48:38+00:00").ToUniversalTime(), }; BitbucketParent expectedParent = new BitbucketParent { Operation = "commit", Hash = "b05057cd04921697c0f119ca40fe4a5afa481074", }; expectedParent.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/commits/b05057cd04921697c0f119ca40fe4a5afa481074" }); expectedParent.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01/commit/b05057cd04921697c0f119ca40fe4a5afa481074" }); expectedTarget.Parents.Add(expectedParent); expectedTarget.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/commits/8339b7affbd7c70bbacd0276f581d1ca44df0853" }); expectedTarget.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01/commit/8339b7affbd7c70bbacd0276f581d1ca44df0853" }); // Act BitbucketTarget actualTarget = data["push"]["changes"][0]["new"]["target"].ToObject<BitbucketTarget>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedTarget, _serializerSettings); string actualJson = JsonConvert.SerializeObject(actualTarget, _serializerSettings); Assert.Equal(expectedJson, actualJson); }
public void BitbucketTarget_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json"); BitbucketUser expectedUser = new BitbucketUser { UserType = "user", DisplayName = "HenrikN", UserName = "******", UserId = "{534d978b-53c8-401b-93b7-ee1f98716edd}", }; expectedUser.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/HenrikN/" }); expectedUser.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/account/HenrikN/avatar/32/" }); expectedUser.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/users/HenrikN" }); BitbucketAuthor expectedAuthor = new BitbucketAuthor { User = expectedUser, Raw = "Henrik Frystyk Nielsen <*****@*****.**>", }; BitbucketTarget expectedTarget = new BitbucketTarget { Message = "update\n", Operation = "commit", Hash = "8339b7affbd7c70bbacd0276f581d1ca44df0853", Author = expectedAuthor, Date = DateTime.Parse("2015-09-30T18:48:38+00:00").ToUniversalTime(), }; BitbucketParent expectedParent = new BitbucketParent { Operation = "commit", Hash = "b05057cd04921697c0f119ca40fe4a5afa481074", }; expectedParent.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/commits/b05057cd04921697c0f119ca40fe4a5afa481074" }); expectedParent.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01/commit/b05057cd04921697c0f119ca40fe4a5afa481074" }); expectedTarget.Parents.Add(expectedParent); expectedTarget.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/commits/8339b7affbd7c70bbacd0276f581d1ca44df0853" }); expectedTarget.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01/commit/8339b7affbd7c70bbacd0276f581d1ca44df0853" }); // Act BitbucketTarget actualTarget = data["push"]["changes"][0]["new"]["target"].ToObject <BitbucketTarget>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedTarget, _serializerSettings); string actualJson = JsonConvert.SerializeObject(actualTarget, _serializerSettings); Assert.Equal(expectedJson, actualJson); }