Esempio n. 1
0
        public async Task DestroySavedSearchAsync_Invokes_Executor_Execute()
        {
            TwitterContext ctx = InitializeTwitterContextMock();
            var tcsResponse = new TaskCompletionSource<string>();
            tcsResponse.SetResult(SavedSearchResponse);
            execMock.SetupGet(exec => exec.Authorizer).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostFormUrlEncodedToTwitterAsync<SavedSearch>(
                    HttpMethod.Post.ToString(),
                    It.IsAny<string>(),
                    It.IsAny<IDictionary<string, string>>(),
                    It.IsAny<CancellationToken>()))
                .Returns(tcsResponse.Task);
            var parameters = new Dictionary<string, string>();

            SavedSearch search = await ctx.DestroySavedSearchAsync(123);

            execMock.Verify(exec =>
                exec.PostFormUrlEncodedToTwitterAsync<SavedSearch>(
                    HttpMethod.Post.ToString(),
                    "https://api.twitter.com/1.1/saved_searches/destroy/123.json",
                    parameters,
                    It.IsAny<CancellationToken>()),
                Times.Once());

            Assert.IsNotNull(search);
            Assert.AreEqual("#LinqToTwitter", search.Name);
            Assert.AreEqual(123ul, search.ID);
        }
        public async Task DestroySavedSearch_Throws_On_Invalid_ID()
        {
            TwitterContext ctx = InitializeTwitterContextMock();

            var ex = await L2TAssert.Throws <ArgumentException>(
                async() => await ctx.DestroySavedSearchAsync(0));

            Assert.AreEqual("id", ex.ParamName);
        }
Esempio n. 3
0
        static async Task DestroySavedSearchAsync(TwitterContext twitterCtx)
        {
            ulong savedSearchID = 0;

            SavedSearch savedSearch =
                await twitterCtx.DestroySavedSearchAsync(savedSearchID);

            if (savedSearch != null)
            {
                Console.WriteLine(
                    "ID: {0}, Search: {1}",
                    savedSearch.ID, savedSearch.Name);
            }
        }
        public async Task DestroySavedSearchAsync_WithRawResult_Succeeds()
        {
            TwitterContext ctx         = InitializeTwitterContextMock();
            var            tcsResponse = new TaskCompletionSource <string>();

            tcsResponse.SetResult(SavedSearchResponse);
            execMock.SetupGet(exec => exec.Authorizer).Returns(authMock.Object);
            execMock.Setup(exec =>
                           exec.PostToTwitterAsync <SavedSearch>(
                               It.IsAny <string>(),
                               It.IsAny <IDictionary <string, string> >(),
                               It.IsAny <CancellationToken>()))
            .Returns(tcsResponse.Task);

            await ctx.DestroySavedSearchAsync(123);

            Assert.AreEqual(SavedSearchResponse, ctx.RawResult);
        }