Пример #1
0
        public void Bitbucket_Roundtrips()
        {
            // Arrange
            JObject       data         = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketUser expectedUser = new BitbucketUser
            {
                UserType    = "user",
                DisplayName = "Henrik Nielsen",
                UserName    = "******",
                UserId      = "{73498d6a-711f-4d29-90cd-a13281674474}",
            };

            expectedUser.Links.Add("html", new BitbucketLink {
                Reference = "https://bitbucket.org/henrikfrystyknielsen/"
            });
            expectedUser.Links.Add("avatar", new BitbucketLink {
                Reference = "https://bitbucket.org/account/henrikfrystyknielsen/avatar/32/"
            });
            expectedUser.Links.Add("self", new BitbucketLink {
                Reference = "https://api.bitbucket.org/2.0/users/henrikfrystyknielsen"
            });

            // Act
            BitbucketUser actualUser = data["actor"].ToObject <BitbucketUser>();

            // Assert
            string expectedJson = JsonConvert.SerializeObject(expectedUser);
            string actualJson   = JsonConvert.SerializeObject(actualUser);

            Assert.Equal(expectedJson, actualJson);
        }
Пример #2
0
        public void BitbucketRepository_Roundtrips()
        {
            // Arrange
            JObject       data         = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketUser expectedUser = new BitbucketUser
            {
                UserType    = "user",
                DisplayName = "Henrik Nielsen",
                UserName    = "******",
                UserId      = "{73498d6a-711f-4d29-90cd-a13281674474}",
            };

            expectedUser.Links.Add("html", new BitbucketLink {
                Reference = "https://bitbucket.org/henrikfrystyknielsen/"
            });
            expectedUser.Links.Add("avatar", new BitbucketLink {
                Reference = "https://bitbucket.org/account/henrikfrystyknielsen/avatar/32/"
            });
            expectedUser.Links.Add("self", new BitbucketLink {
                Reference = "https://api.bitbucket.org/2.0/users/henrikfrystyknielsen"
            });

            BitbucketRepository expectedRepository = new BitbucketRepository
            {
                FullName       = "henrikfrystyknielsen/henrikntest01",
                Name           = "henrikntest01",
                IsPrivate      = true,
                ItemType       = "repository",
                RepositoryType = "git",
                RepositoryId   = "{d9898aea-edda-4f50-8f5f-5a8bfc819ab8}",
                Owner          = expectedUser
            };

            expectedRepository.Links.Add("html", new BitbucketLink {
                Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01"
            });
            expectedRepository.Links.Add("avatar", new BitbucketLink {
                Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/avatar/16/"
            });
            expectedRepository.Links.Add("self", new BitbucketLink {
                Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01"
            });

            // Act
            BitbucketRepository actualRepository = data["repository"].ToObject <BitbucketRepository>();

            // Assert
            string expectedJson = JsonConvert.SerializeObject(expectedRepository);
            string actualJson   = JsonConvert.SerializeObject(actualRepository);

            Assert.Equal(expectedJson, actualJson);
        }
Пример #3
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);
        }
Пример #4
0
        public void Bitbucket_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketUser expectedUser = new BitbucketUser
            {
                UserType = "user",
                DisplayName = "Henrik Nielsen",
                UserName = "******",
                UserId = "{73498d6a-711f-4d29-90cd-a13281674474}",
            };
            expectedUser.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/" });
            expectedUser.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/account/henrikfrystyknielsen/avatar/32/" });
            expectedUser.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/users/henrikfrystyknielsen" });

            // Act
            BitbucketUser actualUser = data["actor"].ToObject<BitbucketUser>();

            // Assert
            string expectedJson = JsonConvert.SerializeObject(expectedUser);
            string actualJson = JsonConvert.SerializeObject(actualUser);
            Assert.Equal(expectedJson, actualJson);
        }
Пример #5
0
        public void BitbucketRepository_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketUser expectedUser = new BitbucketUser
            {
                UserType = "user",
                DisplayName = "Henrik Nielsen",
                UserName = "******",
                UserId = "{73498d6a-711f-4d29-90cd-a13281674474}",
            };
            expectedUser.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/" });
            expectedUser.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/account/henrikfrystyknielsen/avatar/32/" });
            expectedUser.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/users/henrikfrystyknielsen" });

            BitbucketRepository expectedRepository = new BitbucketRepository
            {
                FullName = "henrikfrystyknielsen/henrikntest01",
                Name = "henrikntest01",
                IsPrivate = true,
                ItemType = "repository",
                RepositoryType = "git",
                RepositoryId = "{d9898aea-edda-4f50-8f5f-5a8bfc819ab8}",
                Owner = expectedUser
            };
            expectedRepository.Links.Add("html", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01" });
            expectedRepository.Links.Add("avatar", new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01/avatar/16/" });
            expectedRepository.Links.Add("self", new BitbucketLink { Reference = "https://api.bitbucket.org/2.0/repositories/henrikfrystyknielsen/henrikntest01" });

            // Act
            BitbucketRepository actualRepository = data["repository"].ToObject<BitbucketRepository>();

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