Пример #1
0
        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&amp;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&amp;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);
        }
 /// <summary>
 /// Executes the incoming WebHook request for event '<c>tfvc.checkin</c>'.
 /// </summary>
 /// <param name="context">Provides context for the <see cref="IWebHookHandler"/> for further processing the incoming WebHook.</param>
 /// <param name="payload">Strong-typed WebHook payload.</param>
 public virtual Task ExecuteAsync(WebHookHandlerContext context, CodeCheckedInPayload payload)
 {
     return(Task.FromResult(true));
 }
Пример #3
0
 /// <summary>
 /// Executes the incoming WebHook request for event '<c>tfvc.checkin</c>'.
 /// </summary>
 /// <param name="context">Provides context for the <see cref="IWebHookHandler"/> for further processing the incoming WebHook.</param>
 /// <param name="payload">Strong-typed WebHook payload.</param>
 public virtual Task ExecuteAsync(WebHookHandlerContext context, CodeCheckedInPayload payload)
 {
     return Task.FromResult(true);
 }
        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&amp;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&amp;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);
        }