public void ProcessResults_ForWebhooks_HandlesSingleResult()
        {
            var accActReqProc = new AccountActivityRequestProcessor <AccountActivity>
            {
                BaseUrl = "https://api.twitter.com/1.1/",
                Type    = AccountActivityType.Webhooks
            };

            List <AccountActivity> accActs = accActReqProc.ProcessResults(WebhooksResponse);

            Assert.IsNotNull(accActs?.SingleOrDefault());

            AccountActivity accAct = accActs.First();

            Assert.IsNotNull(accAct);
            WebhooksValue webhooksVal = accAct.WebhooksValue;

            Assert.IsNotNull(webhooksVal);
            Webhook[] webhooks = webhooksVal.Webhooks;
            Assert.IsNotNull(webhooks);
            Assert.AreEqual(1, webhooks.Length);
            Webhook webhook = webhooks.First();

            Assert.IsNotNull(webhook);
            Assert.AreEqual("920835776169910272", webhook.ID);
            Assert.AreEqual("https://accountactivitydemo.azurewebsites.net/api/accountactivity", webhook.Url);
            Assert.IsTrue(webhook.Valid);
            Assert.AreEqual("2017-10-19 02:15:32 +0000", webhook.CreatedTimestamp);
        }
Example #2
0
        public async Task AddAccountActivityWebhookAsync_WithUrlParameter_ReturnsCreatedAccountActivity()
        {
            const string Url = "https://www.example.com/api/accountactivity";
            var          ctx = InitializeTwitterContext();

            AccountActivity accAct = await ctx.AddAccountActivityWebhookAsync(Url);

            Assert.IsNotNull(accAct);
            WebhooksValue accActVal = accAct.WebhooksValue;

            Assert.IsNotNull(accActVal);
            Webhook[] webhooks = accActVal.Webhooks;
            Assert.IsNotNull(webhooks);
            Assert.AreEqual(1, webhooks.Length);
            Webhook webhook = webhooks[0];

            Assert.IsNotNull(webhook);
            Assert.AreEqual("921246280768151552", webhook.ID);
            Assert.AreEqual("https://accountactivitydemo.azurewebsites.net/api/accountactivity", webhook.Url);
            Assert.IsTrue(webhook.Valid);
            Assert.AreEqual("2017-10-20 05:26:44 +0000", webhook.CreatedTimestamp);
        }