private ReadAsJObject ( string name ) : Newtonsoft.Json.Linq.JObject | ||
name | string | |
return | Newtonsoft.Json.Linq.JObject |
public void KuduNotification_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.KuduMessage.json"); KuduNotification expected = new KuduNotification { Id = "ff17489fbcb7e2dda9012ec285811b9b751ebb5e", Status = "success", StatusText = string.Empty, AuthorEmail = "*****@*****.**", Author = "Henrik Frystyk Nielsen", Message = "initial commit\n", Progress = string.Empty, Deployer = "HenrikN", ReceivedTime = DateTime.Parse("2015-09-26T04:26:53.8736751Z"), StartTime = DateTime.Parse("2015-09-26T04:26:54.2486694Z"), EndTime = DateTime.Parse("2015-09-26T04:26:55.6393049Z"), LastSuccessEndTime = DateTime.Parse("2015-09-26T04:26:55.6393049Z"), Complete = true, SiteName = "test", }; // Act KuduNotification actual = data.ToObject <KuduNotification>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings); string actualJson = JsonConvert.SerializeObject(actual, _serializerSettings); Assert.Equal(expectedJson, actualJson); }
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); }
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 StripeEvent_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.StripeEvent.json"); StripeEvent expectedEvent = new StripeEvent { Id = "evt_17Y0a62eZvKYlo2CfDvB2QrJ", Object = "event", ApiVersion = "2015-10-16", Created = _testTime, Data = new StripeEventData { Object = JObject.Parse("{ \"id\": \"12345\", \"object\": \"card\" }"), PreviousAttributes = JObject.Parse("{ \"balance\": null, \"next\": 1340924237, \"closed\": false }") }, LiveMode = true, PendingWebHooks = 10, Request = "req_7nbnyKCObIkSXC", EventType = "customer.source.created", }; // Act StripeEvent actualEvent = data.ToObject <StripeEvent>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedEvent); string actualJson = JsonConvert.SerializeObject(actualEvent); Assert.Equal(expectedJson, actualJson); }
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 SlackSlashResponse_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.SlashResponse.json"); SlackAttachment att1 = new SlackAttachment { Fallback = "Required plain-text summary of the attachment.", Color = "#36a64f", Pretext = "Optional text that appears above the attachment block", AuthorName = "Bobby Tables", AuthorLink = new Uri("http://flickr.com/bobby/"), AuthorIcon = new Uri("http://flickr.com/icons/bobby.jpg"), Title = "Slack API Documentation", TitleLink = new Uri("https://api.slack.com/"), Text = "Optional text that appears within the attachment", ImageLink = new Uri("http://my-website.com/path/to/image.jpg"), ThumbLink = new Uri("http://example.com/path/to/thumb.png"), }; att1.Fields.Add(new SlackField("Priority", "High") { Short = true }); att1.Fields.Add(new SlackField("Importance", "Low") { Short = false }); SlackAttachment att2 = new SlackAttachment { Fallback = "New ticket from Andrea Lee - Ticket #1943: Can't rest my password - https://groove.hq/path/to/ticket/1943", Color = "#7CD197", Pretext = "New ticket from Andrea Lee", Title = "Ticket #1943: Can't reset my password", TitleLink = new Uri("https://groove.hq/path/to/ticket/1943"), Text = "Help! I tried to reset my password but nothing happened!", }; SlackSlashResponse expected = new SlackSlashResponse("It's 80 degrees right now.") { ResponseType = "in_channel" }; expected.Attachments.Add(att1); expected.Attachments.Add(att2); // Act SlackSlashResponse actual = data.ToObject <SlackSlashResponse>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void AlertContext_SubscriptionIdIsRequired() { // Arrange var data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.AlertMessage3.json"); ((JObject)data["context"]).Property("subscriptionId").Remove(); var json = JsonConvert.SerializeObject(data["context"], _serializerSettings); // Act / Assert Assert.Throws <JsonSerializationException>(() => JsonConvert.DeserializeObject <AzureAlertContext>(json)); }
public void AlertContextForWebTest_Roundtrips() { // Arrange var expectedContext = new AzureAlertContext { Condition = new AzureAlertCondition { FailureDetails = string.Empty, MetricName = "Failed Locations", MetricUnit = "locations", MetricValue = "0", Operator = "GreaterThan", Threshold = "3", TimeAggregation = "Sum", WebTestName = "testazuretestaboutpage-azuretest20170922040158", WindowSize = "5", }, ConditionType = "Webtest", Description = string.Empty, Id = "/subscriptions/6e0cb82e-37c4-473b-bb45-8b546cfc01b6/resourceGroups/resources/providers/" + "microsoft.insights/alertrules/testazuretestaboutpage-azuretest20170922040158-47970367-464e-" + "4bf0-b870-b72aa668b591", Name = "testazuretestaboutpage-azuretest20170922040158-47970367-464e-4bf0-b870-b72aa668b591", PortalLink = "https://go.microsoft.com/fwlink/?LinkID=615149&subscriptionId=6e0cb82e-37c4-473b-" + "bb45-8b546cfc01b6&resourceGroup=resources&resourceType=webtests&resourceName=" + "testazuretestaboutpage-azuretest20170922040158&tc=ZAMAAB-LCAAAAAAABADFkltLw0AQhc-fcV8kJdlN2-" + "RRBEH0SQuCb5umN7xEelHw1_vtpNY-FJ8EWWYye-ZyJieJcrrQtR40U6OlOs4TWMR6bIvf4B1xVK6pagXiRhlRVKWSqCQzk" + "idq8LXGRC21cxVU5xpiDbcZGUem004LkJ3xf_Jck5vsuTzVBZU5k7zdSkOGsLnDRvHQ94M0NnmrN-IFaHai6v-" + "mZ4aXRB4NKpTJTJvWciX3wtSsUKrlpPrInDnW0hPJFzbL6QO7AlnpGeZW57pluynIFqzTK9s4bEXujMkR75nU-7_" + "6lgO9w7BBg8ge6f131Cb-AR2dXvZ8HR0bOtbUH2-YkJUp19fdMPv4FFja5A7mALO3-5gzsr0moBVxbT7wzO0dLk_iv-_" + "SZye6N95gOvc8iTXYn_v9dTO8Nx9QPqG9xkNjCfalvB7pcPoC4ncYlWQDAAA1&aadTenantId=h", ResourceGroupName = "resources", ResourceId = "/subscriptions/6e0cb82e-37c4-473b-bb45-8b546cfc01b6/resourceGroups/resources/" + "providers/microsoft.insights/components/AzureTest20170922040158", ResourceName = "AzureTest20170922040158", ResourceType = "components", SubscriptionId = "6e0cb82e-37c4-473b-bb45-8b546cfc01b6", Timestamp = DateTime.Parse("01/01/2017 20:53:57Z"), }; var expectedString = JsonConvert.SerializeObject(expectedContext, _serializerSettings); var json = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.AzureAlert.WebTest.json"); // Act var actualContext = json["context"].ToObject <AzureAlertContext>(); // Assert var actualString = JsonConvert.SerializeObject(actualContext, _serializerSettings); Assert.Equal(expectedString, actualString); }
public void AlertContext_ParsesMessages(string fileName, string expected) { // Arrange string filePath = "Microsoft.AspNet.WebHooks.Messages." + fileName; JObject data = EmbeddedResource.ReadAsJObject(filePath); // Act AzureAlertNotification actual = data.ToObject <AzureAlertNotification>(); // Assert Assert.Equal(expected, actual.Status); }
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 AlertNotification_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.AlertMessage2.json"); AzureAlertNotification expected = new AzureAlertNotification { Status = "Activated", Context = new AzureAlertContext { Id = "/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/WebHookReceivers/providers/microsoft.insights/alertrules/henrikntest01", Name = "henrikntest01", Description = "Requests", ConditionType = "Metric", Condition = new AzureAlertCondition { MetricName = "Http 2xx", MetricUnit = "Count", MetricValue = "8", Threshold = "1", WindowSize = "5", TimeAggregation = "Total", Operator = "GreaterThan", }, SubscriptionId = "aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee", ResourceGroupName = "WebHookReceivers", Timestamp = DateTime.Parse("2015-09-30T03:02:33.4147662Z").ToUniversalTime(), ResourceName = "webhookreceivers", ResourceType = "microsoft.web/sites", ResourceId = "/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/WebHookReceivers/providers/Microsoft.Web/sites/WebHookReceivers", ResourceRegion = "West US", PortalLink = "https://portal.azure.com/#resource/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/WebHookReceivers/providers/Microsoft.Web/sites/WebHookReceivers", } }; expected.Properties.Add("prop1", "value1"); expected.Properties.Add("prop2", 12345.00); // Act AzureAlertNotification actual = data.ToObject <AzureAlertNotification>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings); string actualJson = JsonConvert.SerializeObject(actual, _serializerSettings); Assert.Equal(expectedJson, actualJson); }
public void BitbucketLink_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json"); BitbucketLink expectedLink = new BitbucketLink { Reference = "https://bitbucket.org/henrikfrystyknielsen/henrikntest01" }; // Act BitbucketLink actualLink = data["repository"]["links"]["html"].ToObject <BitbucketLink>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedLink); string actualJson = JsonConvert.SerializeObject(actualLink); Assert.Equal(expectedJson, actualJson); }
public void InstagramSubscription_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.SubscriptionMessage.json"); InstagramSubscription expectedSubscription = new InstagramSubscription { Id = "19985884", Object = "tag", ObjectId = "mytag", Callback = new Uri("http://requestb.in/18jwdvk1"), }; // Act InstagramSubscription actualPost = data.ToObject <InstagramSubscription>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedSubscription); string actualJson = JsonConvert.SerializeObject(actualPost); Assert.Equal(expectedJson, actualJson); }
public void AlertContext_Roundtrips() { // Arrange var data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.AlertMessage1.json"); var expected = new AzureAlertContext { Id = "/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/tests123/providers/microsoft.insights/alertrules/HenriknTest02", Name = "HenriknTest02", Description = "Test", ConditionType = "Metric", Condition = new AzureAlertCondition { MetricName = "CPU percentage", MetricUnit = "Count", MetricValue = "2.716631", Threshold = "10", WindowSize = "5", TimeAggregation = "Average", Operator = "LessThan", }, SubscriptionId = "aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee", ResourceGroupName = "tests123", Timestamp = DateTime.Parse("2015-09-30T03:55:30.7037012Z").ToUniversalTime(), ResourceName = "testmachine", ResourceType = "microsoft.classiccompute/virtualmachines", ResourceRegion = "West US", ResourceId = "/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/tests123/providers/Microsoft.ClassicCompute/virtualMachines/testmachine", PortalLink = "https://portal.azure.com/#resource/subscriptions/aaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeeee/resourceGroups/tests123/providers/Microsoft.ClassicCompute/virtualMachines/testmachine", }; // Act var actual = data["context"].ToObject <AzureAlertContext>(); // Assert var expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings); var actualJson = JsonConvert.SerializeObject(actual, _serializerSettings); Assert.Equal(expectedJson, actualJson); }
public void AlertCondition_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.AlertMessage1.json"); AzureAlertCondition expected = new AzureAlertCondition { MetricName = "CPU percentage", MetricUnit = "Count", MetricValue = "2.716631", Threshold = "10", WindowSize = "5", TimeAggregation = "Average", Operator = "LessThan", }; // Act AzureAlertCondition actual = data["context"]["condition"].ToObject <AzureAlertCondition>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings); string actualJson = JsonConvert.SerializeObject(actual, _serializerSettings); Assert.Equal(expectedJson, actualJson); }
public void GitPushPayload_Roundtrips() { JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.git.push.json"); var expected = new GitPushPayload { CreatedDate = "2016-06-26T18:10:31.3603573Z".ToDateTime(), DetailedMessage = new PayloadMessage() { Html = "John Smith pushed 1 commit to branch <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmaster\\\">master</a> of <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/\\\">Project</a>\\r\\n<ul>\\r\\n<li>A meaningful commit message. <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/commit/c8e823a60a85381732726d6a9b6a276e71e6ce12\\\">c8e823a6</a></li>\\r\\n</ul>", Markdown = "John Smith pushed 1 commit to branch [master](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmaster) of [Project](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/)\\r\\n* A meaningful commit message. [c8e823a6](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/commit/c8e823a60a85381732726d6a9b6a276e71e6ce12)", Text = "John Smith pushed 1 commit to branch master of Project\\r\\n - A meaningful commit message. c8e823a6 (https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/commit/c8e823a60a85381732726d6a9b6a276e71e6ce12)" }, EventType = "git.push", Id = "cd159468-0509-48d9-960d-6f3ba627fd06", Message = new PayloadMessage() { Html = "John Smith pushed updates to branch <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmaster\\\">master</a> of <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/\\\">Project</a>", Markdown = "John Smith pushed updates to branch [master](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmaster) of [Project](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/)", Text = "John Smith pushed updates to branch master of Project\\r\\n(https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmaster)" }, NotificationId = 9, PublisherId = "tfs", Resource = new GitPushResource() { Commits = new List <GitCommit>() { new GitCommit() { Author = new GitUserInfo() { Date = "2016-06-26T18:10:21Z".ToDateTime(), Email = "*****@*****.**", Name = "John Smith" }, Comment = "A meaningful commit message.", CommitId = "c8e823a60a85381732726d6a9b6a276e71e6ce12", Committer = new GitUserInfo() { Date = "2016-06-26T18:10:21Z".ToDateTime(), Email = "*****@*****.**", Name = "John Smith" }, Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/commits/c8e823a60a85381732726d6a9b6a276e71e6ce12") } }, Date = "2016-06-26T18:10:30.065511Z".ToDateTime(), Links = new GitPushLinks() { Commits = new GitLink() { Href = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/pushes/1168/commits") }, Pusher = new GitLink() { Href = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/Identities/458616a4-6252-4cd9-accd-38538e7c9c33") }, Refs = new GitLink() { Href = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/refs") }, Repository = new GitLink() { Href = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb") }, Self = new GitLink() { Href = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/pushes/1168") } }, PushedBy = new GitUser() { DisplayName = "John Smith", Id = "458616a4-6252-4cd9-accd-38538e7c9c33", ImageUrl = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_api/_common/identityImage?id=458616a4-6252-4cd9-accd-38538e7c9c33"), UniqueName = "jsmith", Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/Identities/458616a4-6252-4cd9-accd-38538e7c9c33") }, PushId = 1168, RefUpdates = new List <GitRefUpdate>() { new GitRefUpdate() { Name = "refs/heads/master", NewObjectId = "c8e823a60a85381732726d6a9b6a276e71e6ce12", OldObjectId = "61b7353aa151d2d7d4e4dac8f701b0d82ff87703" } }, Repository = new GitRepository() { DefaultBranch = "refs/heads/master", Id = "7aa31685-abcf-40be-8c18-aaa45067d7bb", Name = "Project", Project = new GitProject() { Id = "65e40c52-3c5d-487c-8a45-6b852de287a8", Name = "Project", State = "wellFormed", Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/projects/65e40c52-3c5d-487c-8a45-6b852de287a8") }, RemoteUrl = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project"), Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb") }, Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/pushes/1168") }, ResourceContainers = new PayloadResourceContainers() { Collection = new PayloadResourceContainer() { Id = "d11e28a5-859e-4fd6-841d-a3ee54815568" }, Project = new PayloadResourceContainer() { Id = "65e40c52-3c5d-487c-8a45-6b852de287a8" } }, ResourceVersion = "1.0", SubscriptionId = "00000000-0000-0000-0000-000000000000" }; // Actual var actual = data.ToObject <GitPushPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void CodeCheckedInPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.tfvc.checkin.json"); var expected = new CodeCheckedInPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 2, Id = "f9b4c23e-88dd-4516-b04d-849787304e32", EventType = "tfvc.checkin", PublisherId = "tfs", Message = new PayloadMessage { Text = "John Smith checked in changeset 18: Dropping in new Java sample", Html = "John Smith checked in changeset <a href=\"https://good-company.some.ssl.host/web/cs.aspx?id=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&cs=18\">18</a>: Dropping in new Java sample", Markdown = "John Smith checked in changeset [18](https://good-company.some.ssl.host/web/cs.aspx?id=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&cs=18): Dropping in new Java sample" }, DetailedMessage = new PayloadMessage { Text = "John Smith checked in changeset 18: Dropping in new Java sample", Html = "John Smith checked in changeset <a href=\"https://good-company.some.ssl.host/web/cs.aspx?id=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&cs=18\">18</a>: Dropping in new Java sample", Markdown = "John Smith checked in changeset [18](https://good-company.some.ssl.host/web/cs.aspx?id=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&cs=18): Dropping in new Java sample" }, Resource = new CodeCheckedInResource { ChangesetId = 18, Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/_apis/tfvc/changesets/18"), Author = new ResourceUser { Id = "d6245f20-2af8-44f4-9451-8107cb2767db", DisplayName = "John Smith", UniqueName = "*****@*****.**" }, CheckedInBy = new ResourceUser { Id = "d6245f20-2af8-44f4-9451-8107cb2767db", DisplayName = "John Smith", UniqueName = "*****@*****.**" }, CreatedDate = "2014-05-12T22:41:16Z".ToDateTime(), Comment = "Dropping in new Java sample" }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:01:11.7056821Z".ToDateTime() }; // Act var actual = data.ToObject <CodeCheckedInPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void TeamRoomMessagePostedPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.message.posted.json"); var expected = new TeamRoomMessagePostedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 3, Id = "daae438c-296b-4512-b08e-571910874e9b", EventType = "message.posted", PublisherId = "tfs", Message = new PayloadMessage { Text = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room\r\nHello", Html = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room\r\nHello", Markdown = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room\r\nHello" }, DetailedMessage = new PayloadMessage { Text = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room\r\nHello", Html = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room<p>Hello</p>", Markdown = "Jamal Hartnett posted a message to Northward-Fiber-Git Team Room\r\nHello" }, Resource = new TeamRoomMessagePostedResource { Id = 0, Content = "Hello", MessageType = "normal", PostedTime = "2014-05-02T19:17:13.3309587Z".ToDateTime(), PostedRoomId = 1, PostedBy = new ResourceUser { Id = "*****@*****.**", DisplayName = "Jamal Hartnett", UniqueName = "Windows Live ID\\[email protected]" } }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:13:40.8417653Z".ToDateTime() }; // Act var actual = data.ToObject <TeamRoomMessagePostedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); 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 BuildCompletedPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.build.complete.json"); var expected = new BuildCompletedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 1, Id = "4a5d99d6-1c75-4e53-91b9-ee80057d4ce3", EventType = "build.complete", PublisherId = "tfs", Message = new PayloadMessage { Text = "Build ConsumerAddressModule_20150407.2 succeeded", Html = "Build <a href=\"https://good-company.some.ssl.host/web/build.aspx?id=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3\">ConsumerAddressModule_20150407.2</a> succeeded", Markdown = "Build [ConsumerAddressModule_20150407.2](https://good-company.some.ssl.host/web/build.aspx?id=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3) succeeded" }, DetailedMessage = new PayloadMessage { Text = "Build ConsumerAddressModule_20150407.2 succeeded", Html = "Build <a href=\"https://good-company.some.ssl.host/web/build.aspx?id=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3\">ConsumerAddressModule_20150407.2</a> succeeded", Markdown = "Build [ConsumerAddressModule_20150407.2](https://good-company.some.ssl.host/web/build.aspx?id=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3) succeeded" }, Resource = new BuildCompletedResource { Uri = new Uri("vstfs:///Build/Build/2"), Id = 2, BuildNumber = "ConsumerAddressModule_20150407.1", Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Builds/2"), StartTime = "2015-04-07T18:04:06.83Z".ToDateTime(), FinishTime = "2015-04-07T18:06:10.69Z".ToDateTime(), Reason = "manual", Status = "succeeded", DropLocation = "#/3/drop", Drop = new BuildCompletedDrop { Location = "#/3/drop", DropType = "container", Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/_apis/resources/Containers/3/drop"), DownloadUrl = new Uri("https://good-company.some.ssl.host/DefaultCollection/_apis/resources/Containers/3/drop?api-version=1.0&$format=zip&downloadFileName=ConsumerAddressModule_20150407.1_drop") }, Log = new BuildCompletedLog { LogType = "container", Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/_apis/resources/Containers/3/logs"), DownloadUrl = new Uri("https://good-company.some.ssl.host/_apis/resources/Containers/3/logs?api-version=1.0&$format=zip&downloadFileName=ConsumerAddressModule_20150407.1_logs") }, SourceGetVersion = "LG:refs/heads/master:600c52d2d5b655caa111abfd863e5a9bd304bb0e", LastChangedBy = new ResourceUser { Id = "d6245f20-2af8-44f4-9451-8107cb2767db", DisplayName = "John Smith", UniqueName = "*****@*****.**", Url = new Uri("https://good-company.some.ssl.host/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db"), ImageUrl = new Uri("https://good-company.some.ssl.host/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db") }, RetainIndefinitely = false, HasDiagnostics = true, Definition = new BuildCompletedDefinition { BatchSize = 1, TriggerType = "none", DefinitionType = "xaml", Id = 2, Name = "ConsumerAddressModule", Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Definitions/2") }, Queue = new BuildCompletedQueueDefinition { QueueType = "buildController", Id = 4, Name = "Hosted Build Controller", Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/_apis/build/Queues/4") } }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:00:39.5893296Z".ToDateTime() }; expected.Resource.Requests.Add(new BuildCompletedRequest { Id = 1, Url = new Uri("https://good-company.some.ssl.host/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Requests/1"), RequestedFor = new ResourceUser { Id = "d6245f20-2af8-44f4-9451-8107cb2767db", DisplayName = "John Smith", UniqueName = "*****@*****.**", Url = new Uri("https://good-company.some.ssl.host/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db"), ImageUrl = new Uri("https://good-company.some.ssl.host/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db") } }); // Act var actual = data.ToObject <BuildCompletedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void WorkItemCreatedPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.workitem.created.json"); var expected = new WorkItemCreatedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 5, Id = "d2d46fb1-dba5-403c-9373-427583f19e8c", EventType = "workitem.created", PublisherId = "tfs", Message = new PayloadMessage { Text = "Bug #5 (Some great new idea!) created by Jamal Hartnett.\r\n(http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5)", Html = "<a href=\"http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5\">Bug #5</a> (Some great new idea!) created by Jamal Hartnett.", Markdown = "[Bug #5](http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5) (Some great new idea!) created by Jamal Hartnett." }, DetailedMessage = new PayloadMessage { Text = "Bug #5 (Some great new idea!) created by Jamal Hartnett.\r\n(http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5)\r\n\r\n- State: New\r\n- Assigned to: \r\n- Comment: \r\n- Severity: 3 - Medium\r\n", Html = "<a href=\"http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5\">Bug #5</a> (Some great new idea!) created by Jamal Hartnett.<ul>\r\n<li>State: New</li>\r\n<li>Assigned to: </li>\r\n<li>Comment: </li>\r\n<li>Severity: 3 - Medium</li></ul>", Markdown = "[Bug #5](http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5) (Some great new idea!) created by Jamal Hartnett.\r\n\r\n* State: New\r\n* Assigned to: \r\n* Comment: \r\n* Severity: 3 - Medium\r\n" }, Resource = new WorkItemCreatedResource { Id = 5, RevisionNumber = 1, Fields = new WorkItemFields { SystemAreaPath = "GoodCompanyCloud", SystemTeamProject = "GoodCompanyCloud", SystemIterationPath = "GoodCompanyCloud\\Release 1\\Sprint 1", SystemWorkItemType = "Bug", SystemState = "New", SystemReason = "New defect reported", SystemCreatedDate = "2014-07-15T17:42:44.663Z".ToDateTime(), SystemCreatedBy = "Jamal Hartnett", SystemChangedDate = "2014-07-15T17:42:44.663Z".ToDateTime(), SystemChangedBy = "Jamal Hartnett", SystemTitle = "Some great new idea!", MicrosoftCommonSeverity = "3 - Medium", KanbanColumn = "New" }, Links = new WorkItemLinks { Self = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5" }, WorkItemUpdates = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/updates" }, WorkItemRevisions = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/revisions" }, WorkItemType = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/ea830882-2a3c-4095-a53f-972f9a376f6e/workItemTypes/Bug" }, Fields = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/fields" } }, Url = new Uri("http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5") }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:16:25.6251162Z".ToDateTime() }; // Act var actual = data.ToObject <WorkItemCreatedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void GitPullRequestMergeCommitCreatedPayload_Roundtrips() { JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.git.pullrequest.merged.json"); var expected = new GitPullRequestMergeCommitCreatedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 9, Id = "6872ee8c-b333-4eff-bfb9-0d5274943566", EventType = "git.pullrequest.merged", PublisherId = "tfs", Message = new PayloadMessage { Text = "Jamal Hartnett has created a pull request merge commit", Html = "Jamal Hartnett has created a pull request merge commit", Markdown = "Jamal Hartnett has created a pull request merge commit" }, DetailedMessage = new PayloadMessage { Text = "Jamal Hartnett has created a pull request merge commit\r\n\r\n- Merge status: Succeeded\r\n- Merge commit: eef717(https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/eef717f69257a6333f221566c1c987dc94cc0d72)\r\n", Html = "Jamal Hartnett has created a pull request merge commit\r\n<ul>\r\n<li>Merge status: Succeeded</li>\r\n<li>Merge commit: <a href=\"https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/eef717f69257a6333f221566c1c987dc94cc0d72\">eef717</a></li>\r\n</ul>", Markdown = "Jamal Hartnett has created a pull request merge commit\r\n\r\n+ Merge status: Succeeded\r\n+ Merge commit: [eef717](https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/eef717f69257a6333f221566c1c987dc94cc0d72)\r\n" }, Resource = new GitPullRequestMergeCommitCreatedResource { Repository = new GitRepository { Id = "4bc14d40-c903-45e2-872e-0462c7748079", Name = "Fabrikam", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079"), Project = new GitProject { Id = "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c", Name = "Fabrikam", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"), State = "wellFormed" }, DefaultBranch = "refs/heads/master", RemoteUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam") }, PullRequestId = 1, Status = "completed", CreatedBy = new GitUser() { Id = "54d125f7-69f7-4191-904f-c5b96b6261c8", DisplayName = "Jamal Hartnett", UniqueName = "*****@*****.**", Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Identities/54d125f7-69f7-4191-904f-c5b96b6261c8"), ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=54d125f7-69f7-4191-904f-c5b96b6261c8") }, CreationDate = "2014-06-17T16:55:46.589889Z".ToDateTime(), ClosedDate = "2014-06-30T18:59:12.3660573Z".ToDateTime(), Title = "my first pull request", Description = " - test2\r\n", SourceRefName = "refs/heads/mytopic", TargetRefName = "refs/heads/master", MergeStatus = "succeeded", MergeId = "a10bb228-6ba6-4362-abd7-49ea21333dbd", LastMergeSourceCommit = new GitMergeCommit { CommitId = "53d54ac915144006c2c9e90d2c7d3880920db49c", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/53d54ac915144006c2c9e90d2c7d3880920db49c") }, LastMergeTargetCommit = new GitMergeCommit { CommitId = "a511f535b1ea495ee0c903badb68fbc83772c882", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/a511f535b1ea495ee0c903badb68fbc83772c882") }, LastMergeCommit = new GitMergeCommit { CommitId = "eef717f69257a6333f221566c1c987dc94cc0d72", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/eef717f69257a6333f221566c1c987dc94cc0d72") }, Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/pullRequests/1") }, CreatedDate = "2017-08-30T14:21:16.8515903Z".ToDateTime() }; expected.Resource.Reviewers.Add( new GitReviewer { Vote = 0, Id = "2ea2d095-48f9-4cd6-9966-62f6f574096c", DisplayName = "[Mobile]\\Mobile Team", UniqueName = "vstfs:///Classification/TeamProject/f0811a3b-8c8a-4e43-a3bf-9a049b4835bd\\Mobile Team", Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Identities/2ea2d095-48f9-4cd6-9966-62f6f574096c"), ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=2ea2d095-48f9-4cd6-9966-62f6f574096c"), IsContainer = true }); expected.Resource.Commits.Add( new GitCommit { CommitId = "53d54ac915144006c2c9e90d2c7d3880920db49c", Url = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/4bc14d40-c903-45e2-872e-0462c7748079/commits/53d54ac915144006c2c9e90d2c7d3880920db49c") }); // Actual var actual = data.ToObject <GitPullRequestUpdatedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void WorkItemUpdatedPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.workitem.updated.json"); var expected = new WorkItemUpdatedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 8, Id = "27646e0e-b520-4d2b-9411-bba7524947cd", EventType = "workitem.updated", PublisherId = "tfs", Message = new PayloadMessage { Text = "Bug #5 (Some great new idea!) updated by Jamal Hartnett.\r\n(http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5)", Html = "<a href=\"http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5\">Bug #5</a> (Some great new idea!) updated by Jamal Hartnett.", Markdown = "[Bug #5](http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5) (Some great new idea!) updated by Jamal Hartnett." }, DetailedMessage = new PayloadMessage { Text = "Bug #5 (Some great new idea!) updated by Jamal Hartnett.\r\n(http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5)\r\n\r\n- New State: Approved\r\n", Html = "<a href=\"http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5\">Bug #5</a> (Some great new idea!) updated by Jamal Hartnett.<ul>\r\n<li>New State: Approved</li></ul>", Markdown = "[Bug #5](http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5) (Some great new idea!) updated by Jamal Hartnett.\r\n\r\n* New State: Approved\r\n" }, Resource = new WorkItemUpdatedResource { Id = 2, WorkItemId = 0, RevisionNumber = 2, RevisedBy = null, RevisedDate = "0001-01-01T00:00:00".ToDateTime(), Fields = new WorkItemUpdatedFields { SystemRev = new WorkItemUpdatedFieldValue <string> { OldValue = "1", NewValue = "2" }, SystemAuthorizedDate = new WorkItemUpdatedFieldValue <DateTime> { OldValue = "2014-07-15T16:48:44.663Z".ToDateTime(), NewValue = "2014-07-15T17:42:44.663Z".ToDateTime() }, SystemRevisedDate = new WorkItemUpdatedFieldValue <DateTime> { OldValue = "2014-07-15T17:42:44.663Z".ToDateTime(), NewValue = "9999-01-01T00:00:00Z".ToDateTime() }, SystemState = new WorkItemUpdatedFieldValue <string> { OldValue = "New", NewValue = "Approved" }, SystemReason = new WorkItemUpdatedFieldValue <string> { OldValue = "New defect reported", NewValue = "Approved by the Product Owner" }, SystemAssignedTo = new WorkItemUpdatedFieldValue <string> { NewValue = "Jamal Hartnet" }, SystemChangedDate = new WorkItemUpdatedFieldValue <DateTime> { OldValue = "2014-07-15T16:48:44.663Z".ToDateTime(), NewValue = "2014-07-15T17:42:44.663Z".ToDateTime() }, SystemWatermark = new WorkItemUpdatedFieldValue <string> { OldValue = "2", NewValue = "5" }, MicrosoftCommonSeverity = new WorkItemUpdatedFieldValue <string> { OldValue = "3 - Medium", NewValue = "2 - High" } }, Links = new WorkItemLinks { Self = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/updates/2" }, Parent = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5" }, WorkItemUpdates = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/updates" } }, Url = new Uri("http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/updates/2"), Revision = new WorkItemUpdatedRevision { Id = 5, Rev = 2, Fields = new WorkItemFields { SystemAreaPath = "GoodCompanyCloud", SystemTeamProject = "GoodCompanyCloud", SystemIterationPath = "GoodCompanyCloud\\Release 1\\Sprint 1", SystemWorkItemType = "Bug", SystemState = "New", SystemReason = "New defect reported", SystemCreatedDate = "2014-07-15T16:48:44.663Z".ToDateTime(), SystemCreatedBy = "Jamal Hartnett", SystemChangedDate = "2014-07-15T16:48:44.663Z".ToDateTime(), SystemChangedBy = "Jamal Hartnett", SystemTitle = "Some great new idea!", MicrosoftCommonSeverity = "3 - Medium", KanbanColumn = "New" }, Url = new Uri("http://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/revisions/2") } }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:19:12.8836446Z".ToDateTime() }; // Act var actual = data.ToObject <WorkItemUpdatedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }
public void InstagramPost_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PostMessage.json"); InstagramPost expectedPost = new InstagramPost { Id = "1077852647225486162_194771465", Link = new Uri("https://instagram.com/p/3sFga24da/"), CreatedTime = _testTime, MediaType = "video", Location = new InstagramLocation { Id = 225623404, Name = "Equinox At The High Line", Latitude = 40.7437744, Longitude = -74.0068283 }, Images = new InstagramImages { Thumbnail = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/Thumbnail.jpg"), Width = 150, Height = 150, }, LowResolution = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/LowRes.jpg"), Width = 320, Height = 320 }, StandardResolution = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/StdRes.jpg"), Width = 640, Height = 640 } }, Videos = new InstagramVideos { LowBandwidth = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/LowBw.mp4"), Width = 480, Height = 270, }, LowResolution = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/LowRes.mp4"), Width = 480, Height = 270 }, StandardResolution = new InstagramMedia { Address = new Uri("https://scontent.cdninstagram.com/StdRes.mp4"), Width = 640, Height = 360 } }, Caption = new InstagramCaption { CreatedTime = _testTime, Id = "1077852735856538330", Text = "#handstand #drill #compilation", From = new InstagramUser { UserName = "******", ProfilePicture = new Uri("https://scontent.cdninstagram.com/userprofile.jpg"), FullName = "Some User", Id = "194771423" } }, User = new InstagramUser { Id = "194771423", FullName = "Some User", UserName = "******", ProfilePicture = new Uri("https://scontent.cdninstagram.com/userprofile.jpg"), } }; expectedPost.Tags.Add("compilation"); expectedPost.Tags.Add("handstand"); expectedPost.Tags.Add("drill"); // Act InstagramPost actualPost = data.ToObject <InstagramPost>(); // Assert string expectedJson = JsonConvert.SerializeObject(expectedPost); string actualJson = JsonConvert.SerializeObject(actualPost); Assert.Equal(expectedJson, actualJson); }
public void WorkItemDeletedPayload_Roundtrips() { // Arrange JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.workitem.deleted.json"); var expected = new WorkItemDeletedPayload { SubscriptionId = "00000000-0000-0000-0000-000000000000", NotificationId = 6, Id = "72da0ade-0709-40ee-beb7-104287bf7e84", EventType = "workitem.deleted", PublisherId = "tfs", Message = new PayloadMessage { Text = "Bug #5 (Some great new idea!) deleted by Jamal Hartnett.", Html = "Bug #5 (Some great new idea!) deleted by Jamal Hartnett.", Markdown = "[Bug #5] (Some great new idea!) deleted by Jamal Hartnett." }, DetailedMessage = new PayloadMessage { Text = "Bug #5 (Some great new idea!) deleted by Jamal Hartnett.\r\n\r\n- State: New\r\n", Html = "Bug #5 (Some great new idea!) deleted by Jamal Hartnett.<ul>\r\n<li>State: New</li></ul>", Markdown = "[Bug #5] (Some great new idea!) deleted by Jamal Hartnett.\r\n\r\n* State: New\r\n" }, Resource = new WorkItemDeletedResource { Id = 5, RevisionNumber = 1, Fields = new WorkItemFields { SystemAreaPath = "GoodCompanyCloud", SystemTeamProject = "GoodCompanyCloud", SystemIterationPath = "GoodCompanyCloud\\Release 1\\Sprint 1", SystemWorkItemType = "Bug", SystemState = "New", SystemReason = "New defect reported", SystemCreatedDate = "2014-07-15T17:42:44.663Z".ToDateTime(), SystemCreatedBy = "Jamal Hartnett", SystemChangedDate = "2014-07-15T17:42:44.663Z".ToDateTime(), SystemChangedBy = "Jamal Hartnett", SystemTitle = "Some great new idea!", MicrosoftCommonSeverity = "3 - Medium", KanbanColumn = "New" }, Links = new WorkItemLinks { Self = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/recyclebin/5" }, WorkItemType = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/ea830882-2a3c-4095-a53f-972f9a376f6e/workItemTypes/Bug" }, Fields = new WorkItemLink { Href = "http://good-company.some.ssl.host/DefaultCollection/_apis/wit/fields" } }, Url = new Uri("http://good-company.some.ssl.host/DefaultCollection/_apis/wit/recyclebin/5") }, ResourceVersion = "1.0", ResourceContainers = new PayloadResourceContainers { Collection = new PayloadResourceContainer { Id = "c12d0eb8-e382-443b-9f9c-c52cba5014c2" }, Account = new PayloadResourceContainer { Id = "f844ec47-a9db-4511-8281-8b63f4eaf94e" }, Project = new PayloadResourceContainer { Id = "be9b3917-87e6-42a4-a549-2bc06a7a878f" } }, CreatedDate = "2016-05-02T19:17:28.3644564Z".ToDateTime() }; // Act var actual = data.ToObject <WorkItemDeletedPayload>(); // Assert string expectedJson = JsonConvert.SerializeObject(expected); string actualJson = JsonConvert.SerializeObject(actual); Assert.Equal(expectedJson, actualJson); }