Newtonsoft.Json.Linq.JToken.ToObject()

Here are the examples of the csharp api Newtonsoft.Json.Linq.JToken.ToObject() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

582 Examples 7

19 View Source File : BitfinexSocketApi.cs
License : MIT License
Project Creator : aabiryukov

private void SocketMessage(object sender, MessageReceivedEventArgs args)
        {
            var dataObject = JToken.Parse(args.Message);
            if(dataObject is JObject)
            {
                Log.Write(LogVerbosity.Info, $"Received object message: {dataObject}");
                var evnt = dataObject["event"].ToString();
                if (evnt == "info")
                    HandleInfoEvent(dataObject.ToObject<BitfinexInfo>());
                else if (evnt == "auth")
                    HandleAuthenticationEvent(dataObject.ToObject<BitfinexAuthenticationResponse>());
                else if (evnt == "subscribed")
                    HandleSubscriptionEvent(dataObject.ToObject<BitfinexSubscriptionResponse>());
                else if (evnt == "error")
                    HandleErrorEvent(dataObject.ToObject<BitfinexSocketError>());                
                else
                    HandleUnhandledEvent((JObject)dataObject);                
            }
            else if(dataObject is JArray)
            {
                Log.Write(LogVerbosity.Info, $"Received array message: {dataObject}");
                if(dataObject[1].ToString() == "hb")
                {
                    // Heartbeat, no need to do anything with that
                    return;
                }

                if (dataObject[0].ToString() == "0")
                    HandleAccountEvent(dataObject.ToObject<BitfinexSocketEvent>());
                else
                    HandleChannelEvent((JArray)dataObject);
            }
        }

19 View Source File : BitfinexSocketApi.cs
License : MIT License
Project Creator : aabiryukov

private void HandleChannelEvent(JArray evnt)
        {
            var eventId = (int)evnt[0];

            BitfinexEventRegistration registration;
            lock (eventListLock)
                registration = eventRegistrations.SingleOrDefault(s => s.ChannelId == eventId);

            if(registration == null)
            {
                Log.Write(LogVerbosity.Warning, $"Received event but have no registration (eventId={eventId})");
                return;
            }

            if (registration is BitfinexTradingPairTickerEventRegistration)
                ((BitfinexTradingPairTickerEventRegistration)registration).Handler(evnt[1].ToObject<BitfinexSocketTradingPairTick>());

            if (registration is BitfinexFundingPairTickerEventRegistration)
                ((BitfinexFundingPairTickerEventRegistration)registration).Handler(evnt[1].ToObject<BitfinexSocketFundingPairTick>());

            if (registration is BitfinexOrderBooksEventRegistration)
            {
                var evnt1 = evnt[1];
                if (evnt1 is JArray)
                {
                    BitfinexSocketOrderBook[] bookArray;
                    if (evnt1[0] is JArray)
                    {
                        bookArray = evnt1.ToObject<BitfinexSocketOrderBook[]>();
                    }
                    else
                    {
                       var book = evnt1.ToObject<BitfinexSocketOrderBook>();
                        bookArray = new BitfinexSocketOrderBook[] { book };
                    }
                    ((BitfinexOrderBooksEventRegistration)registration).Handler(bookArray);
                }
            }

            if (registration is BitfinexTradeEventRegistration)
            {
                if(evnt[1] is JArray)
                    ((BitfinexTradeEventRegistration)registration).Handler(evnt[1].ToObject<BitfinexTradeSimple[]>());
                else
                    ((BitfinexTradeEventRegistration)registration).Handler(new[] { evnt[2].ToObject<BitfinexTradeSimple>() });
            }
        }

19 View Source File : OKCoinAPI.cs
License : MIT License
Project Creator : aabiryukov

public IEnumerable<Order> GetActiveOrders()
		{
			var args = new NameValueCollection
	        {
		        {"symbol", "btc_usd"},
		        {"order_id", "-1"}
	        };

			var response = DoMethod2("order_info", args);
			
			var jsonObject = CheckResult(response);
			var orders = jsonObject["orders"].ToObject<List<Order>>();

			return orders;
		}

19 View Source File : OwnTradesMessage.cs
License : Apache License 2.0
Project Creator : AlexWan

public static OwnTradesMessage CreateFromString(string rawMessage)
        {
            var message = KrakenDataMessageHelper.EnsureRawMessage(rawMessage);
            var trades = message[0]
                .Select(x => (x as JObject)?.ToObject<Dictionary<string, JObject>>())
                .Select(items => items != null && items.Count == 1 ?
                    new
                    {
                        TradeId = items.Keys.ToArray()[0],
                        TradeObject = items.Values.ToArray()[0]
                    } :
                    null)
                .Where(x => x != null)
                .Select(x => TradeObject.CreateFromJObject(x.TradeId, x.TradeObject))
                .ToList();

            return new OwnTradesMessage
            {
                Trades = trades,
                Name = message[1].ToString()
            };

        }

19 View Source File : KrakenApi.cs
License : Apache License 2.0
Project Creator : AlexWan

public async Task<AuthToken> GetWebsocketToken()
        {
            var formContent = new Dictionary<string, string>();

            // generate a 64 bit nonce using a timestamp at tick resolution
            var nonce = DateTime.Now.Ticks;
            formContent.Add("nonce", nonce.ToString());

            var path = $"/{version}/private/GetWebSocketsToken";
            var address = $"{uri}{path}";

            var content = new FormUrlEncodedContent(formContent);
            var request = new HttpRequestMessage(HttpMethod.Post, address)
            {
                Content = content,
                Headers =
                {
                    {"API-Key", apiKey.ToPlainString()},
                    {"API-Sign", Convert.ToBase64String(CalculateSignature(await content.ReadAsByteArrayAsync(), nonce, path)) }
                }
            };

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.SendAsync(request);
                using (var stream = await response.Content.ReadreplacedtreamAsync())
                {
                    using (var jsonReader = new JsonTextReader(new StreamReader(stream)))
                    {
                        var jObject = new JsonSerializer().Deserialize<JObject>(jsonReader);
                        return jObject.Property("result").Value.ToObject<AuthToken>();
                    }
                }
            }
        }

19 View Source File : OpenOrdersMessage.cs
License : Apache License 2.0
Project Creator : AlexWan

internal static OpenOrdersMessage CreateFromString(string rawMessage)
        {
            var message = KrakenDataMessageHelper.EnsureRawMessage(rawMessage);
            var orders = message[0]
                .Select(x => (x as JObject)?.ToObject<Dictionary<string, JObject>>())
                .Select(items => items != null && items.Count == 1 ?
                    new
                    {
                        TradeId = items.Keys.ToArray()[0],
                        TradeObject = items.Values.ToArray()[0]
                    } :
                    null)
                .Where(x => x != null)
                .Select(x => Order.CreateFromJObject(x.TradeId, x.TradeObject))
                .ToList();

            return new OpenOrdersMessage()
            {
                Orders = orders,
                ChannelName = message[1].Value<string>()
            };
        }

19 View Source File : Core.cs
License : MIT License
Project Creator : AliFlux

static object plainifyJson(JToken token)
        {
            if (token.Type == JTokenType.Object)
            {
                IDictionary<string, JToken> dict = token as JObject;
                
                dynamic expandos = dict.Aggregate(new EnhancedExpandoObeject() as IDictionary<string, Object>,
                            (a, p) => { a.Add(p.Key, plainifyJson(p.Value)); return a; });

                return expandos;
            }
            else if (token.Type == JTokenType.Array)
            {
                var array = token as JArray;
                return array.Select(item => plainifyJson(item)).ToList();
            }
            else
            {
                return token.ToObject<object>();
            }
        }

19 View Source File : Style.cs
License : MIT License
Project Creator : AliFlux

object plainifyJson(JToken token)
        {
            if (token.Type == JTokenType.Object)
            {
                IDictionary<string, JToken> dict = token as JObject;
                return dict.Select(pair => new KeyValuePair<string, object>(pair.Key, plainifyJson(pair.Value)))
                        .ToDictionary(key => key.Key, value => value.Value);
            }
            else if (token.Type == JTokenType.Array)
            {
                var array = token as JArray;
                return array.Select(item => plainifyJson(item)).ToArray();
            }
            else
            {
                return token.ToObject<object>();
            }

            return null;
        }

19 View Source File : ToJsonEx.cs
License : MIT License
Project Creator : aprilyush

public static Dictionary<string, object> ToDictionary(this JObject json)
        {
           return new Dictionary<string, object>(json.ToObject<IDictionary<string, object>>(), StringComparer.CurrentCultureIgnoreCase);
        }

19 View Source File : HttpHandler.cs
License : MIT License
Project Creator : Ashesh3

public bool CreateAccount(string email, Captcha.CaptchaSolution captcha, Action<string> updateStatus, ref bool stop)
        {
            if (CreateFailedCount >= 3)
            {
                Logger.Warn("FAILED! Current IP seems to be banned. Endless captcha detected.");
                updateStatus?.Invoke("FAILED! Current IP seems to be banned. Endless captcha detected.");
                stop = true;
                return false;
            }

            if (!(captcha?.Solved ?? false))
            {
                Logger.Warn("Captcha not solved. Cannot create account.");
                return false;
            }

            Logger.Debug("Creating account...");

            //Send request again
            SetConfig(Defaults.Web.STEAM_AJAX_VERIFY_EMAIL_URI, Method.POST);
            _request.AddParameter("captchagid", _captchaGid);
            _request.AddParameter("captcha_text", captcha.Solution);
            _request.AddParameter("email", email);

            var response = _client.Execute(_request);
            if (!response.IsSuccessful)
            {
                Logger.Warn($"HTTP Error: {response.StatusCode}");
                updateStatus($"HTTP Error: {response.StatusCode}");
                return false;
            }

            _request.Parameters.Clear();
            try
            {
                dynamic jsonResponse = JsonConvert.DeserializeObject(response.Content);

                var succesCode = 0;
                try
                {
                    succesCode = (jsonResponse?.success as Newtonsoft.Json.Linq.JValue)?.ToObject<int?>() ?? 0;
                }
                catch (Exception ex)
                {
                    Logger.Error("Cannot get success code.", ex);
                }

                if (jsonResponse.success != 1)
                {
                    switch (succesCode)
                    {
                        case 62:
                            Logger.Warn($"Creating account error: #{jsonResponse.success} / {Error.SIMILIAR_MAIL}");
                            updateStatus(Error.SIMILIAR_MAIL);
                            stop = true;
                            return false;
                        case 13:
                            Logger.Warn($"Creating account error: #{jsonResponse.success} / {Error.INVALID_MAIL}");
                            updateStatus(Error.INVALID_MAIL);
                            stop = true;
                            return false;
                        case 17:
                            Logger.Warn($"Creating account error: #{jsonResponse.success} / {Error.TRASH_MAIL}");
                            updateStatus(Error.TRASH_MAIL);
                            stop = true;
                            return false;
                        case 101: // Please verify your humanity by re-entering the characters below.
                            Logger.Warn("Creating account error: Wrong captcha");
                            updateStatus(Error.WRONG_CAPTCHA);

                            if (captcha.Config != null)
                            {
                                if (captcha.Config.Service == Enums.CaptchaService.RuCaptcha &&
                                    captcha.Config.RuCaptcha.ReportBad)
                                {
                                    TwoCaptchaReport(captcha, false);
                                }
                            }
                            stop = !FormMain.ProxyManager.GetNew();
                            CreateFailedCount++;
                            return false;
                        case 84:
                            {
                                Logger.Warn($"Creating account error: #{jsonResponse.success} / {Error.PROBABLY_IP_BAN}");
                                updateStatus(Error.PROBABLY_IP_BAN);
                                stop = !FormMain.ProxyManager.GetNew();
                                CreateFailedCount++;
                            }
                            return false;
                        default:
                            Logger.Warn($"Creating account error: #{jsonResponse.success} / {Error.UNKNOWN}");
                            updateStatus(Error.UNKNOWN);
                            stop = !FormMain.ProxyManager.GetNew();
                            CreateFailedCount++;
                            break;
                    }
                    return false;
                }

                Logger.Trace($"Creating account, SessionID: {_sessionId}");
                _sessionId = jsonResponse.sessionid;

                Logger.Debug("Creating account: Waiting for email to be verified");
                updateStatus("Waiting for email to be verified");
            }
            catch { }

            return true;
        }

19 View Source File : BitbucketWebHookHandler.cs
License : Apache License 2.0
Project Creator : aspnet

public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
        {
            // For more information about BitBucket WebHook payloads, please see 
            // 'https://confluence.atlreplacedian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push'
            JObject entry = context.GetDataOrDefault<JObject>();

            // Extract the action -- for Bitbucket we have only one.
            string action = context.Actions.First();
            switch (action)
            {
                case "repo:push":
                    // Extract information about the repository
                    var repository = entry["repository"].ToObject<BitbucketRepository>();

                    // Information about the user causing the event
                    var actor = entry["actor"].ToObject<BitbucketUser>();

                    // Information about the specific changes
                    foreach (var change in entry["push"]["changes"])
                    {
                        // The previous commit
                        BitbucketTarget oldTarget = change["old"]["target"].ToObject<BitbucketTarget>();

                        // The new commit
                        BitbucketTarget newTarget = change["new"]["target"].ToObject<BitbucketTarget>();
                    }
                    break;

                default:
                    Trace.WriteLine(entry.ToString());
                    break;
            }

            return Task.FromResult(true);
        }

19 View Source File : WebHookHandlerContextExtensions.cs
License : Apache License 2.0
Project Creator : aspnet

public static T GetDataOrDefault<T>(this WebHookHandlerContext context)
            where T : clreplaced
        {
            if (context == null || context.Data == null)
            {
                return default(T);
            }

            // Do explicit conversion if Data is a JToken subtype and T is not e.g. Data is a JObject and T is
            // one of the strong types for request content.
            //
            // IsreplacedignableFrom(...) check looks odd because return statement effectively replacedigns from Data to T.
            // However, this check avoids useless "conversions" e.g. from a JObject to a JObject without attempting
            // impossible conversions e.g. from a JObject to a JArray. Json.NET does not support semantically-invalid
            // conversions between JToken subtypes.
            //
            // !typeof(T).IsreplacedignableFrom(context.Data.GetType()) may be more precise but is less efficient. That
            // check would not change the (null) outcome in the JObject to JArray case, just adds a first-chance
            // Exception (because the code would attempt the impossible conversion). About the only new cases it
            // handles with a cast instead of ToObject<T>() are extreme corner cases such as when T is
            // IDictionary<string, JToken> or another interface the current Data (e.g. JObject) may implement. Even
            // then, Json.NET can usually perform an explicit conversion.
            if (context.Data is JToken token && !typeof(JToken).IsreplacedignableFrom(typeof(T)))
            {
                try
                {
                    var data = token.ToObject<T>();
                    return data;
                }
                catch (Exception ex)
                {
                    var message = string.Format(
                        CultureInfo.CurrentCulture,
                        ReceiverResources.GetDataOrDefault_Failure,
                        context.Data.GetType(),
                        typeof(T),
                        ex.Message);
                    context.RequestContext.Configuration.DependencyResolver.GetLogger().Error(message, ex);
                    return default(T);
                }
            }

            return context.Data as T;
        }

19 View Source File : AzureAlertConditionTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings);
            string actualJson = JsonConvert.SerializeObject(actual, _serializerSettings);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : KuduNotificationTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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,
                Autreplacedmail = "[email protected]",
                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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected, _serializerSettings);
            string actualJson = JsonConvert.SerializeObject(actual, _serializerSettings);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketLinkTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedLink);
            string actualJson = JsonConvert.SerializeObject(actualLink);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BuildFinishedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void BuildFinishedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.BuildFinishedMessage.json");
            BuildFinishedPayload expected = new BuildFinishedPayload
            {
                Result = "success",
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/"),
                Name = "SampleBuild",
                Branch = "main",
                BuildLogUrl = new Uri("https://www.myget.org/BuildSource/List/sample-feed#d510be3d-7803-43cc-8d15-e327ba999ba7"),
            };
            expected.Packages.Add(new Package
            {
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.Core",
                PackageVersion = "1.0.0-CI00002",
            });
            expected.Packages.Add(new Package
            {
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.MVC4",
                PackageVersion = "1.0.0-CI00002",
            });

            // Act
            BuildFinishedPayload actual = data["Payload"].ToObject<BuildFinishedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BuildQueuedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void BuildQueuedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.BuildQueuedMessage.json");
            BuildQueuedPayload expected = new BuildQueuedPayload
            {
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/"),
                Name = "SampleBuild",
                Branch = "main"
            };

            // Act
            BuildQueuedPayload actual = data["Payload"].ToObject<BuildQueuedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BuildStartedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void BuildStartedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.BuildStartedMessage.json");
            BuildStartedPayload expected = new BuildStartedPayload
            {
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/"),
                Name = "SampleBuild",
                Branch = "main"
            };

            // Act
            BuildStartedPayload actual = data["Payload"].ToObject<BuildStartedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : PackageAddedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void PackageAddedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PackageAddedMessage.json");
            PackageAddedPayload expected = new PackageAddedPayload
            {
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.WP8",
                PackageVersion = "1.0.0-CI00002",
                PackageDetailsUrl = new Uri("https://www.myget.org/feed/sample-feed/package/GooglereplacedyticsTracker.WP8/1.0.0-CI00002"),
                PackageDownloadUrl = new Uri("https://www.myget.org/F/sample-feed/api/v2/package/GooglereplacedyticsTracker.WP8/1.0.0-CI00002"),
                PackageMetadata = new PackageMetadata
                {
                    IconUrl = new Uri("/Content/images/packageDefaultIcon.png", UriKind.Relative),
                    Size = 6158,
                    Authors = "Maarten Balliauw",
                    Description = "GooglereplacedyticsTracker was created to have a means of tracking specific URL's directly from C#. For example, it enables you to log API calls to Google replacedytics.",
                    LicenseUrl = new Uri("http://github.com/maartenba/GooglereplacedyticsTracker/blob/main/LICENSE.md"),
                    LicenseNames = "MS-PL",
                    ProjectUrl = new Uri("http://github.com/maartenba/GooglereplacedyticsTracker"),
                    Tags = "google replacedytics ga wp8 wp7 windows phone windowsphone api rest client tracker stats statistics mango",
                },
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/")
            };
            expected.PackageMetadata.Dependencies.Add(new Package
            {
                PackageIdentifier = "GooglereplacedyticsTracker.Core",
                PackageVersion = "(>= 2.0.5364.25176)",
                TargetFramework = ".NETFramework,Version=v4.0.0.0"
            });

            // Act
            PackageAddedPayload actual = data["Payload"].ToObject<PackageAddedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : PackageDeletedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void PackageDeletedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PackageDeletedMessage.json");
            PackageDeletedPayload expected = new PackageDeletedPayload
            {
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.Core",
                PackageVersion = "1.0.0-CI00002",
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/")
            };

            // Act
            PackageDeletedPayload actual = data["Payload"].ToObject<PackageDeletedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : GitPullRequestUpdatedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GitPullRequestUpdatedPayload_Roundtrips()
        {
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.git.pullrequest.updated.json");
            var expected = new GitPullRequestUpdatedPayload()
            {
                SubscriptionId = "00000000-0000-0000-0000-000000000000",
                NotificationId = 2,
                Id = "af07be1b-f3ad-44c8-a7f1-c4835f2df06b",
                EventType = "git.pullrequest.updated",
                PublisherId = "tfs",
                Message = new PayloadMessage
                {
                    Text = "Jamal Hartnett marked the pull request as completed",
                    Html = "Jamal Hartnett marked the pull request as completed",
                    Markdown = "Jamal Hartnett marked the pull request as completed"
                },
                DetailedMessage = new PayloadMessage
                {
                    Text = "Jamal Hartnett marked the pull request as completed\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 marked the pull request as completed\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 marked the pull request as completed\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 GitPullRequestUpdatedResource
                {
                    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/main",
                        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 = "[email protected]",
                        Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/54d125f7-69f7-4191-904f-c5b96b6261c8"),
                        ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?id=54d125f7-69f7-4191-904f-c5b96b6261c8")
                    },
                    CreationDate = "2014-06-17T16:55:46.589889Z".ToDateTime(),
                    ClosedDate = "2014-06-30T18:59:12.3660573Z".ToDateTime(),
                    replacedle = "my first pull request",
                    Description = " - test2\r\n",
                    SourceRefName = "refs/heads/mytopic",
                    TargetRefName = "refs/heads/main",
                    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 = "2016-06-27T03:29:23.346286Z".ToDateTime()
            };
            expected.Resource.Reviewers.Add(
                new GitReviewer
                {
                    Vote = 0,
                    Id = "2ea2d095-48f9-4cd6-9966-62f6f574096c",
                    DisplayName = "[Mobile]\\Mobile Team",
                    UniqueName = "vstfs:///Clreplacedification/TeamProject/f0811a3b-8c8a-4e43-a3bf-9a049b4835bd\\Mobile Team",
                    Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/2ea2d095-48f9-4cd6-9966-62f6f574096c"),
                    ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : WorkItemCreatedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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- replacedigned 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>replacedigned 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* replacedigned 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",
                        Systemreplacedle = "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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : WorkItemDeletedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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",
                        Systemreplacedle = "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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : WorkItemRestoredPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void WorkItemRestoredPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.workitem.restored.json");
            var expected = new WorkItemRestoredPayload
            {
                SubscriptionId = "00000000-0000-0000-0000-000000000000",
                NotificationId = 7,
                Id = "1ca023d6-6cff-49dd-b3d1-302b69311810",
                EventType = "workitem.restored",
                PublisherId = "tfs",
                Message = new PayloadMessage
                {
                    Text = "Bug #5 (Some great new idea!) restored 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!) restored 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!) restored by Jamal Hartnett."
                },
                DetailedMessage = new PayloadMessage
                {
                    Text = "Bug #5 (Some great new idea!) restored 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- 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!) restored by Jamal Hartnett.<ul>\r\n<li>State: New</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!) restored by Jamal Hartnett.\r\n\r\n* State: New\r\n* Severity: 3 - Medium\r\n"
                },
                Resource = new WorkItemRestoredResource
                {
                    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",
                        Systemreplacedle = "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" },
                        Html = new WorkItemLink { Href = "https://good-company.some.ssl.host/web/wi.aspx?id=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&id=5" },
                        WorkItemHistory = new WorkItemLink { Href = "https://good-company.some.ssl.host/DefaultCollection/_apis/wit/workItems/5/history" }
                    },
                    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:18:15.5707279Z".ToDateTime()
            };

            // Act
            var actual = data.ToObject<WorkItemRestoredPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : WorkItemUpdatedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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"
                        },
                        SystemreplacedignedTo = 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",
                            Systemreplacedle = "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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketAuthorTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void BitbucketAuthor_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketAuthor expectedAuthor = new BitbucketAuthor
            {
                Raw = "Henrik Frystyk Nielsen <[email protected]>",
                User = new BitbucketUser
                {
                    UserType = "user",
                    DisplayName = "HenrikN",
                    UserName = "HenrikN",
                    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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedAuthor);
            string actualJson = JsonConvert.SerializeObject(actualAuthor);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketParentTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedParent);
            string actualJson = JsonConvert.SerializeObject(actualParent);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketRepositoryTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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 = "henrikfrystyknielsen",
                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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedRepository);
            string actualJson = JsonConvert.SerializeObject(actualRepository);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketTargetTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void BitbucketTarget_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PushMessage.json");
            BitbucketUser expectedUser = new BitbucketUser
            {
                UserType = "user",
                DisplayName = "HenrikN",
                UserName = "HenrikN",
                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 <[email protected]>",
            };

            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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedTarget, _serializerSettings);
            string actualJson = JsonConvert.SerializeObject(actualTarget, _serializerSettings);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BitbucketUserTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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 = "henrikfrystyknielsen",
                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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedUser);
            string actualJson = JsonConvert.SerializeObject(actualUser);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : InstagramNotificationCollectionTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void InstagramNotificationCollection_Roundtrips()
        {
            // Arrange
            JArray data = EmbeddedResource.ReadAsJArray("Microsoft.AspNet.WebHooks.Messages.NotificationCollectionMessage.json");
            InstagramNotification[] expected = new InstagramNotification[]
            {
                new InstagramNotification
                {
                    ChangedAspect = "media",
                    Object = "user",
                    UserId = "2174967354",
                    SubscriptionId = "22362655",
                    Data = new InstagramNotificationData
                    {
                        MediaId = "1213184719641169505_2174967354"
                    }
                },
                new InstagramNotification
                {
                    ChangedAspect = "media",
                    Object = "user",
                    UserId = "3174967354",
                    SubscriptionId = "22362655",
                    Data = new InstagramNotificationData
                    {
                        MediaId = "1213184719641169515_3174967354"
                    }
                },
            };

            // Act
            InstagramNotificationCollection actual = data.ToObject<InstagramNotificationCollection>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : PackageListedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void PackageListedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PackageListedMessage.json");
            PackageListedPayload expected = new PackageListedPayload
            {
                Action = "unlisted",
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.Simple",
                PackageVersion = "1.0.0-CI00002",
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/")
            };

            // Act
            PackageListedPayload actual = data["Payload"].ToObject<PackageListedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : PackagePinnedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void PackagePinnedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PackagePinnedMessage.json");
            PackagePinnedPayload expected = new PackagePinnedPayload
            {
                Action = "pinned",
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.Simple",
                PackageVersion = "1.0.0-CI00002",
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/")
            };

            // Act
            PackagePinnedPayload actual = data["Payload"].ToObject<PackagePinnedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : PackagePushedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void PackagePushedPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.PackagePushedMessage.json");
            PackagePushedPayload expected = new PackagePushedPayload
            {
                PackageType = "NuGet",
                PackageIdentifier = "GooglereplacedyticsTracker.Simple",
                PackageVersion = "1.0.0-CI00002",
                PackageDetailsUrl = new Uri("https://www.myget.org/feed/sample-feed/package/GooglereplacedyticsTracker.Simple/1.0.0-CI00002"),
                PackageDownloadUrl = new Uri("https://www.myget.org/F/sample-feed/api/v2/package/GooglereplacedyticsTracker.Simple/1.0.0-CI00002"),
                PackageMetadata = new PackageMetadata
                {
                    IconUrl = new Uri("/Content/images/packageDefaultIcon.png", UriKind.Relative),
                    Size = 5542,
                    Authors = "Maarten Balliauw",
                    Description = "GooglereplacedyticsTracker was created to have a means of tracking specific URL's directly from C#. For example, it enables you to log API calls to Google replacedytics.",
                    LicenseUrl = new Uri("http://github.com/maartenba/GooglereplacedyticsTracker/blob/main/LICENSE.md"),
                    LicenseNames = "MS-PL",
                    ProjectUrl = new Uri("http://github.com/maartenba/GooglereplacedyticsTracker"),
                    Tags = "google replacedytics ga mvc api rest client tracker stats statistics",
                },
                TargetPackageSourceName = "Other Feed",
                TargetPackageSourceUrl = new Uri("https://www.myget.org/F/other-feed/"),
                FeedIdentifier = "sample-feed",
                FeedUrl = new Uri("https://www.myget.org/F/sample-feed/")
            };
            expected.PackageMetadata.Dependencies.Add(new Package
            {
                PackageIdentifier = "GooglereplacedyticsTracker.Core",
                PackageVersion = "(? 2.0.5364.25176)",
                TargetFramework = ".NETFramework,Version=v4.0.0.0"
            });

            // Act
            PackagePushedPayload actual = data["Payload"].ToObject<PackagePushedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : SlackSlashResponseTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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"),
                replacedle = "Slack API Doreplacedentation",
                replacedleLink = 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 preplacedword - https://groove.hq/path/to/ticket/1943",
                Color = "#7CD197",
                Pretext = "New ticket from Andrea Lee",
                replacedle = "Ticket #1943: Can't reset my preplacedword",
                replacedleLink = new Uri("https://groove.hq/path/to/ticket/1943"),
                Text = "Help! I tried to reset my preplacedword 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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : StripeEventTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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,
                RequestData = new StripeRequestData
                {
                    Id = "req_7nbnyKCObIkSXC",
                },
                EventType = "customer.source.created",
            };

            // Act
            StripeEvent actualEvent = data.ToObject<StripeEvent>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expectedEvent);
            string actualJson = JsonConvert.SerializeObject(actualEvent);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : GitPullrequestCreatedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GitPullRequestCreatedPayload_Roundtrips()
        {
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.git.pullrequest.created.json");
            var expected = new GitPullRequestCreatedPayload()
            {
                SubscriptionId = "00000000-0000-0000-0000-000000000000",
                NotificationId = 2,
                Id = "2ab4e3d3-b7a6-425e-92b1-5a9982c1269e",
                EventType = "git.pullrequest.created",
                PublisherId = "tfs",
                Message = new PayloadMessage
                {
                    Text = "Jamal Hartnett created a new pull request",
                    Html = "Jamal Hartnett created a new pull request",
                    Markdown = "Jamal Hartnett created a new pull request"
                },
                DetailedMessage = new PayloadMessage
                {
                    Text = "Jamal Hartnett created a new pull request\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 created a new pull request\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 created a new pull request\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 GitPullRequestResource
                {
                    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/main",
                        RemoteUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam")
                    },
                    PullRequestId = 1,
                    Status = "active",
                    CreatedBy = new GitUser()
                    {
                        Id = "54d125f7-69f7-4191-904f-c5b96b6261c8",
                        DisplayName = "Jamal Hartnett",
                        UniqueName = "[email protected]",
                        Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/54d125f7-69f7-4191-904f-c5b96b6261c8"),
                        ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?id=54d125f7-69f7-4191-904f-c5b96b6261c8")
                    },
                    CreationDate = "2014-06-17T16:55:46.589889Z".ToDateTime(),
                    replacedle = "my first pull request",
                    Description = " - test2\r\n",
                    SourceRefName = "refs/heads/mytopic",
                    TargetRefName = "refs/heads/main",
                    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 = "2016-06-27T01:09:08.3025616Z".ToDateTime()
            };
            expected.Resource.Reviewers.Add(
                new GitReviewer
                {
                    Vote = 0,
                    Id = "2ea2d095-48f9-4cd6-9966-62f6f574096c",
                    DisplayName = "[Mobile]\\Mobile Team",
                    UniqueName = "vstfs:///Clreplacedification/TeamProject/f0811a3b-8c8a-4e43-a3bf-9a049b4835bd\\Mobile Team",
                    Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/2ea2d095-48f9-4cd6-9966-62f6f574096c"),
                    ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?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<GitPullRequestCreatedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : WorkItemCommentedOnPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void WorkItemCommentedOnPayload_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.workitem.commented.json");
            var expected = new WorkItemCommentedOnPayload
            {
                SubscriptionId = "00000000-0000-0000-0000-000000000000",
                NotificationId = 4,
                Id = "fb2617ed-60df-4518-81fa-749faa6c5cd6",
                EventType = "workitem.commented",
                PublisherId = "tfs",
                Message = new PayloadMessage
                {
                    Text = "Bug #5 (Some great new idea!) commented on 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!) commented on 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!) commented on by Jamal Hartnett."
                },
                DetailedMessage = new PayloadMessage
                {
                    Text = "Bug #5 (Some great new idea!) commented on by Jamal Hartnett.\r\n(http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5)\r\nThis is a great new idea",
                    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!) commented on by Jamal Hartnett.<br/>This is a great new idea",
                    Markdown = "[Bug #5](http://good-company.some.ssl.host/web/wi.aspx?id=74e918bf-3376-436d-bd20-8e8c1287f465&id=5) (Some great new idea!) commented on by Jamal Hartnett.\r\nThis is a great new idea"
                },
                Resource = new WorkItemCommentedOnResource
                {
                    Id = 5,
                    RevisionNumber = 4,
                    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",
                        Systemreplacedle = "Some great new idea!",
                        MicrosoftCommonSeverity = "3 - Medium",
                        KanbanColumn = "New",
                        SystemHistory = "This is a great new idea"
                    },
                    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:15:37.4638247Z".ToDateTime()
            };

            // Act
            var actual = data.ToObject<WorkItemCommentedOnPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : ZendeskDeviceTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void ZendeskDevice_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
            ZendeskDevice expected = new ZendeskDevice
            {
                Identifier = "oiuytrdsdfghjk",
                DeviceType = "ios"
            };

            // Act
            ZendeskDevice actual = data["devices"][0].ToObject<ZendeskDevice>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : BuildCompletedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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/main:600c52d2d5b655caa111abfd863e5a9bd304bb0e",
                    LastChangedBy = new ResourceUser
                    {
                        Id = "d6245f20-2af8-44f4-9451-8107cb2767db",
                        DisplayName = "John Smith",
                        UniqueName = "[email protected]",
                        Url = new Uri("https://good-company.some.ssl.host/_apis/Idenreplacedies/d6245f20-2af8-44f4-9451-8107cb2767db"),
                        ImageUrl = new Uri("https://good-company.some.ssl.host/DefaultCollection/_api/_common/idenreplacedyImage?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 = "[email protected]",
                    Url = new Uri("https://good-company.some.ssl.host/_apis/Idenreplacedies/d6245f20-2af8-44f4-9451-8107cb2767db"),
                    ImageUrl = new Uri("https://good-company.some.ssl.host/DefaultCollection/_api/_common/idenreplacedyImage?id=d6245f20-2af8-44f4-9451-8107cb2767db")
                }
            });

            // Act
            var actual = data.ToObject<BuildCompletedPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : CodeCheckedInPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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 = "[email protected]"
                    },
                    CheckedInBy = new ResourceUser
                    {
                        Id = "d6245f20-2af8-44f4-9451-8107cb2767db",
                        DisplayName = "John Smith",
                        UniqueName = "[email protected]"
                    },
                    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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : GitPullRequestMergeCommitCreatedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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/main",
                        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 = "[email protected]",
                        Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/54d125f7-69f7-4191-904f-c5b96b6261c8"),
                        ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?id=54d125f7-69f7-4191-904f-c5b96b6261c8")
                    },
                    CreationDate = "2014-06-17T16:55:46.589889Z".ToDateTime(),
                    ClosedDate = "2014-06-30T18:59:12.3660573Z".ToDateTime(),
                    replacedle = "my first pull request",
                    Description = " - test2\r\n",
                    SourceRefName = "refs/heads/mytopic",
                    TargetRefName = "refs/heads/main",
                    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:///Clreplacedification/TeamProject/f0811a3b-8c8a-4e43-a3bf-9a049b4835bd\\Mobile Team",
                    Url = new Uri("https://fabrikam.vssps.visualstudio.com/_apis/Idenreplacedies/2ea2d095-48f9-4cd6-9966-62f6f574096c"),
                    ImageUrl = new Uri("https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/idenreplacedyImage?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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : GitPushPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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=GBmain\\\">main</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 [main](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmain) 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 main 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=GBmain\\\">main</a> of <a href=\\\"https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/\\\">Project</a>",
                    Markdown = "John Smith pushed updates to branch [main](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmain) of [Project](https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/)",
                    Text = "John Smith pushed updates to branch main of Project\\r\\n(https://good-company.some.ssl.host/tfs/GoodCompany/_git/Project/#version=GBmain)"
                },
                NotificationId = 9,
                PublisherId = "tfs",
                Resource = new GitPushResource()
                {
                    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/Idenreplacedies/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/idenreplacedyImage?id=458616a4-6252-4cd9-accd-38538e7c9c33"),
                        UniqueName = "jsmith",
                        Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/Idenreplacedies/458616a4-6252-4cd9-accd-38538e7c9c33")
                    },
                    PushId = 1168,
                    Repository = new GitRepository()
                    {
                        DefaultBranch = "refs/heads/main",
                        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"
            };
            expected.Resource.Commits.Add(
                new GitCommit()
                {
                    Author = new GitUserInfo()
                    {
                        Date = "2016-06-26T18:10:21Z".ToDateTime(),
                        Email = "[email protected]",
                        Name = "John Smith"
                    },
                    Comment = "A meaningful commit message.",
                    CommitId = "c8e823a60a85381732726d6a9b6a276e71e6ce12",
                    Committer = new GitUserInfo()
                    {
                        Date = "2016-06-26T18:10:21Z".ToDateTime(),
                        Email = "[email protected]",
                        Name = "John Smith"
                    },
                    Url = new Uri("https://good-company.some.ssl.host/tfs/GoodCompany/_apis/git/repositories/7aa31685-abcf-40be-8c18-aaa45067d7bb/commits/c8e823a60a85381732726d6a9b6a276e71e6ce12")
                });
            expected.Resource.RefUpdates.Add(
                new GitRefUpdate()
                {
                    Name = "refs/heads/main",
                    NewObjectId = "c8e823a60a85381732726d6a9b6a276e71e6ce12",
                    OldObjectId = "61b7353aa151d2d7d4e4dac8f701b0d82ff87703"
                });

            // Actual
            var actual = data.ToObject<GitPushPayload>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : TeamRoomMessagePostedPayloadTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        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 = "0[email protected]",
                        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>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : ZendeskNotificationTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void ZendeskNotification_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
            ZendeskNotification expected = new ZendeskNotification
            {
                Body = "Agent replied something something",
                replacedle = "Agent replied",
                TicketId = "5"
            };

            // Act
            ZendeskNotification actual = data["notification"].ToObject<ZendeskNotification>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : ZendeskPostTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void ZendeskPost_Roundtrips()
        {
            // Arrange
            JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
            ZendeskPost expected = new ZendeskPost
            {
                Notification = new ZendeskNotification
                {
                    Body = "Agent replied something something",
                    replacedle = "Agent replied",
                    TicketId = "5"
                }
            };
            expected.Devices.Add(new ZendeskDevice
            {
                Identifier = "oiuytrdsdfghjk",
                DeviceType = "ios"
            });
            expected.Devices.Add(new ZendeskDevice
            {
                Identifier = "iuytfrdcvbnmkl",
                DeviceType = "android"
            });

            // Act
            ZendeskPost actual = data.ToObject<ZendeskPost>();

            // replacedert
            string expectedJson = JsonConvert.SerializeObject(expected);
            string actualJson = JsonConvert.SerializeObject(actual);
            replacedert.Equal(expectedJson, actualJson);
        }

19 View Source File : CompletionItemExtensions.cs
License : Apache License 2.0
Project Creator : aspnet

public static bool TryGetRazorCompletionKind(this CompletionItem completion, out RazorCompletionItemKind completionItemKind)
        {
            if (completion is null)
            {
                throw new ArgumentNullException(nameof(completion));
            }

            if (completion.Data is JObject data && data.ContainsKey(RazorCompletionItemKind))
            {
                completionItemKind = data[RazorCompletionItemKind].ToObject<RazorCompletionItemKind>();
                return true;
            }

            completionItemKind = default;
            return false;
        }

19 View Source File : CompletionItemExtensions.cs
License : Apache License 2.0
Project Creator : aspnet

public static ElementDescriptionInfo GetElementDescriptionInfo(this CompletionItem completion)
        {
            if (completion.Data is JObject data && data.ContainsKey(TagHelperElementDataKey))
            {
                var descriptionInfo = data[TagHelperElementDataKey].ToObject<ElementDescriptionInfo>();
                return descriptionInfo;
            }

            return ElementDescriptionInfo.Default;
        }

19 View Source File : CompletionItemExtensions.cs
License : Apache License 2.0
Project Creator : aspnet

public static AttributeDescriptionInfo GetTagHelperAttributeDescriptionInfo(this CompletionItem completion)
        {
            if (completion.Data is JObject data && data.ContainsKey(TagHelperAttributeDataKey))
            {
                var descriptionInfo = data[TagHelperAttributeDataKey].ToObject<AttributeDescriptionInfo>();
                return descriptionInfo;
            }

            return AttributeDescriptionInfo.Default;
        }

19 View Source File : CompletionItemExtensions.cs
License : Apache License 2.0
Project Creator : aspnet

public static AttributeCompletionDescription GetAttributeDescriptionInfo(this CompletionItem completion)
        {
            if (completion is null)
            {
                throw new ArgumentNullException(nameof(completion));
            }

            if (completion.Data is JObject data && data.ContainsKey(AttributeCompletionDataKey))
            {
                var descriptionInfo = data[AttributeCompletionDataKey].ToObject<AttributeCompletionDescription>();
                return descriptionInfo;
            }

            return null;
        }

See More Examples