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); }
private HttpContent CreateRequestContent(string payload) { string content = EmbeddedResource.ReadAsString(payload); return(new StringContent(content, Encoding.UTF8, MyGetWebHookReceiver.MediaType)); }
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 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 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); }
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); }
private HttpContent CreateRequestContent(string payload) { string content = EmbeddedResource.ReadAsString(payload); return(new StringContent(content, Encoding.UTF8, "application/json")); }
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 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 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); }