Esempio n. 1
0
        public void BitbucketParent_Roundtrips()
        {
            // Arrange
            JObject         data           = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            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"
            });

            // Act
            BitbucketParent actualParent = data["push"]["changes"][0]["new"]["target"]["parents"][0].ToObject <BitbucketParent>();

            // Assert
            string expectedJson = JsonConvert.SerializeObject(expectedParent);
            string actualJson   = JsonConvert.SerializeObject(actualParent);

            Assert.Equal(expectedJson, actualJson);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void BitbucketParent_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            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" });

            // Act
            BitbucketParent actualParent = data["push"]["changes"][0]["new"]["target"]["parents"][0].ToObject<BitbucketParent>();

            // Assert
            string expectedJson = JsonConvert.SerializeObject(expectedParent);
            string actualJson = JsonConvert.SerializeObject(actualParent);
            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);
        }