public void DestroySavedSearch_Invokes_Executor_Execute()
        {
            TwitterContext ctx = InitializeTwitterContextMock();

            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                           exec.PostToTwitter(
                               It.IsAny <string>(),
                               It.IsAny <Dictionary <string, string> >(),
                               It.IsAny <Func <string, SavedSearch> >()))
            .Returns(SavedSearchResponse);
            var parameters = new Dictionary <string, string>();

            SavedSearch search = ctx.DestroySavedSearch(123);

            execMock.Verify(exec =>
                            exec.PostToTwitter(
                                "https://api.twitter.com/1.1/saved_searches/destroy/123.json",
                                parameters,
                                It.IsAny <Func <string, SavedSearch> >()),
                            Times.Once());

            Assert.NotNull(search);
            Assert.Equal("#LinqToTwitter", search.Name);
            Assert.Equal("123", search.ID);
        }
        public void DestroySavedSearch_Throws_On_Invalid_ID()
        {
            TwitterContext ctx = InitializeTwitterContextMock();

            var ex = Assert.Throws <ArgumentException>(() => ctx.DestroySavedSearch(0));

            Assert.Equal("id", ex.ParamName);
        }
Esempio n. 3
0
        /// <summary>
        /// Shows how to delete a saved search
        /// </summary>
        /// <remarks>
        /// Trying to delete a saved search that doesn't exist results
        /// in a TwitterQueryException with HTTP Status 404 (Not Found)
        /// </remarks>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void DestroySavedSearchDemo(TwitterContext twitterCtx)
        {
            var savedSearch = twitterCtx.DestroySavedSearch(167246334);

            Console.WriteLine("ID: {0}, Search: {1}", savedSearch.ID, savedSearch.Name);
        }