public void CreateSavedSearch_Invokes_Executor_Execute() { const string Query = "#LinqToTwitter"; 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> { { "query", Query } }; SavedSearch search = ctx.CreateSavedSearch("#LinqToTwitter"); execMock.Verify(exec => exec.PostToTwitter( "https://api.twitter.com/1.1/saved_searches/create.json", parameters, It.IsAny <Func <string, SavedSearch> >()), Times.Once()); Assert.NotNull(search); Assert.Equal(Query, search.Name); Assert.Equal(Query, search.Query); }
public void CreateSavedSearch_Throws_On_Missing_Query() { TwitterContext ctx = InitializeTwitterContextMock(); var ex = Assert.Throws <ArgumentException>(() => ctx.CreateSavedSearch(null)); Assert.Equal("query", ex.ParamName); }
/// <summary> /// shows how to create a Saved Search /// </summary> /// <param name="twitterCtx">TwitterContext</param> private static void CreateSavedSearchDemo(TwitterContext twitterCtx) { var savedSearch = twitterCtx.CreateSavedSearch("#csharp"); Console.WriteLine("ID: {0}, Search: {1}", savedSearch.IDString, savedSearch.Query); }