public void Faction_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("faction")); Assert.True(ReferenceEquals(call, call.Faction(1))); Assert.Equal((long)1, call.Parameters["faction"]); }
public void Deputy_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("deputy")); Assert.True(ReferenceEquals(call, call.Deputy(1))); Assert.Equal((long)1, call.Parameters["deputy"]); }
public void To_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("to")); Assert.True(ReferenceEquals(call, call.To(DateTime.MinValue))); Assert.Equal(DateTime.MinValue.RuLawDate(), call.Parameters["to"]); }
public void Deputy_Method() { Assert.Throws<ArgumentNullException>(() => IVotesSearchLawApiCallExtensions.Deputy(null, new Deputy())); Assert.Throws<ArgumentNullException>(() => new VotesSearchLawApiCall().Deputy(null)); var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.Any()); Assert.True(ReferenceEquals(call, call.Deputy(new Deputy { Id = 1 }))); Assert.Equal((long)1, call.Parameters["deputy"]); }
public void Convocation_Method() { Assert.Throws<ArgumentNullException>(() => IVotesSearchLawApiCallExtensions.Convocation(null, new Convocation())); Assert.Throws<ArgumentNullException>(() => new VotesSearchLawApiCall().Convocation(null)); var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.Any()); Assert.True(ReferenceEquals(call, call.Convocation(new Convocation { Id = 1 }))); Assert.Equal((long)1, call.Parameters["convocation"]); }
/// <summary> /// <para>Returns results of votes search.</para> /// </summary> /// <param name="caller">API caller instance to be used.</param> /// <param name="call">Delegate to configure additional parameters of request.</param> /// <returns>Votes search result.</returns> /// <exception cref="ArgumentNullException">If either <paramref name="caller"/> or <paramref name="call"/> is a <c>null</c> reference.</exception> /// <exception cref="RuLawException">If there was an error during processing of web request, or if request was considered as invalid.</exception> /// <seealso cref="http://api.duma.gov.ru/pages/dokumentatsiya/poisk-golosovaniy"/> public static IVotesSearchResult Search(this IVotesApiCaller caller, Action<IVotesSearchLawApiCall> call) { Assertion.NotNull(caller); Assertion.NotNull(call); var api = new VotesSearchLawApiCall(); call(api); return caller.Api.Call<VotesSearchResult>("/{0}/voteSearch".FormatSelf(caller.Api.ApiToken), api.Parameters).Data; }
public void Number_Method() { Assert.Throws<ArgumentNullException>(() => new VotesSearchLawApiCall().Number(null)); Assert.Throws<ArgumentException>(() => new VotesSearchLawApiCall().Number(string.Empty)); var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("number")); Assert.True(ReferenceEquals(call, call.Number("number"))); Assert.Equal("number", call.Parameters["number"]); }
public void Constructors() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.Any()); }
public void Sorting_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("sort")); Assert.True(ReferenceEquals(call, call.Sorting(VotesSorting.DateAscending))); Assert.Equal("date_asc", call.Parameters["sort"]); Assert.Equal("date_desc_true", call.Sorting(VotesSorting.DateDescending).Parameters["sort"]); Assert.Equal("date_desc", call.Sorting(VotesSorting.DateDescendingByDay).Parameters["sort"]); Assert.Equal("result_asc", call.Sorting(VotesSorting.ResultAscending).Parameters["sort"]); Assert.Equal("result_desc", call.Sorting(VotesSorting.ResultDescending).Parameters["sort"]); }
public void Limit_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("limit")); Assert.True(ReferenceEquals(call, call.Limit(PageSize.Five))); Assert.Equal(5, call.Parameters["limit"]); }
public void Page_Method() { var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("page")); Assert.True(ReferenceEquals(call, call.Page(1))); Assert.Equal(1, call.Parameters["page"]); }
public void Keywords_Method() { Assert.Throws<ArgumentNullException>(() => new VotesSearchLawApiCall().Keywords(null)); Assert.Throws<ArgumentException>(() => new VotesSearchLawApiCall().Keywords(string.Empty)); var call = new VotesSearchLawApiCall(); Assert.False(call.Parameters.ContainsKey("keywords")); Assert.True(ReferenceEquals(call, call.Keywords("keywords"))); Assert.Equal("keywords", call.Parameters["keywords"]); }