本文整理汇总了C#中Mock.FakeGET方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.FakeGET方法的具体用法?C# Mock.FakeGET怎么用?C# Mock.FakeGET使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.FakeGET方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Answer_tags_test
public void Answer_tags_test()
{
var mock20 = new Mock<StacManClient>(null, "2.0");
var mock21 = new Mock<StacManClient>(null, "2.1");
//http://api.stackexchange.com/2.0/answers?pagesize=1&order=desc&sort=activity&site=stackoverflow&filter=!9hnGsz84b
mock20.FakeGET(response: @"{""items"":[{""question_id"":17127032,""answer_id"":17127341,""creation_date"":1371325907,""last_activity_date"":1371325907,""score"":0,""is_accepted"":false,""owner"":{""user_id"":2486415,""display_name"":""user2486415"",""reputation"":10,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/8d5eb93a89200d4f7900f46dc2c26d3b?d=identicon&r=PG"",""link"":""http://stackoverflow.com/users/2486415/user2486415""}}],""quota_remaining"":98,""quota_max"":300,""has_more"":true}");
//http://api.stackexchange.com/2.1/answers?pagesize=1&order=desc&sort=activity&site=stackoverflow&filter=!9hnGsz84b
mock21.FakeGET(response: @"{""items"":[{""question_id"":17127032,""answer_id"":17127341,""creation_date"":1371325907,""last_activity_date"":1371325907,""score"":0,""is_accepted"":false,""owner"":{""user_id"":2486415,""display_name"":""user2486415"",""reputation"":10,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/8d5eb93a89200d4f7900f46dc2c26d3b?d=identicon&r=PG"",""link"":""http://stackoverflow.com/users/2486415/user2486415""},""tags"":[""javascript"",""jquery"",""css""]}],""quota_remaining"":97,""quota_max"":300,""has_more"":true}");
var client20 = mock20.Object;
var client21 = mock21.Object;
var result20 = client20.Answers.GetAll("stackoverflow.com", pagesize: 1, order: Order.Desc, sort: Answers.Sort.Activity, filter: "!9hnGsz84b").Result;
var result21 = client21.Answers.GetAll("stackoverflow.com", pagesize: 1, order: Order.Desc, sort: Answers.Sort.Activity, filter: "!9hnGsz84b").Result;
Assert.IsTrue(result20.Success);
Assert.IsTrue(result21.Success);
var answer20 = result20.Data.Items.Single();
var answer21 = result21.Data.Items.Single();
Assert.IsNull(answer20.Tags);
Assert.IsNotNull(answer21.Tags);
Assert.AreEqual(3, answer21.Tags.Length);
}
示例2: Users_get_associated_test
public void Users_get_associated_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/users/1998/associated?pagesize=2
mock.FakeGET(response: @"{""items"":[{""site_name"":""Stack Overflow"",""site_url"":""http://stackoverflow.com"",""user_id"":2749,""reputation"":4365,""account_id"":1998,""creation_date"":1219613204,""badge_counts"":{""gold"":1,""silver"":13,""bronze"":26},""last_access_date"":1334611626,""answer_count"":144,""question_count"":20},{""site_name"":""Server Fault"",""site_url"":""http://serverfault.com"",""user_id"":31532,""reputation"":101,""account_id"":1998,""creation_date"":1263334764,""badge_counts"":{""gold"":0,""silver"":0,""bronze"":3},""last_access_date"":1334610908,""answer_count"":0,""question_count"":0}],""quota_remaining"":-212787,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Users.GetAssociated(new int[] { 1998 }, pagesize: 2).Result;
Assert.IsTrue(result.Success);
var networkUser = result.Data.Items.First();
Assert.AreEqual("Stack Overflow", networkUser.SiteName);
Assert.AreEqual("http://stackoverflow.com", networkUser.SiteUrl);
Assert.AreEqual(2749, networkUser.UserId);
Assert.AreEqual(4365, networkUser.Reputation);
Assert.AreEqual(1998, networkUser.AccountId);
Assert.AreEqual(1219613204L.ToDateTime(), networkUser.CreationDate);
Assert.AreEqual(1, networkUser.BadgeCounts.Gold);
Assert.AreEqual(13, networkUser.BadgeCounts.Silver);
Assert.AreEqual(26, networkUser.BadgeCounts.Bronze);
Assert.AreEqual(1334611626L.ToDateTime(), networkUser.LastAccessDate);
Assert.AreEqual(144, networkUser.AnswerCount);
Assert.AreEqual(20, networkUser.QuestionCount);
Assert.AreEqual(default(StackExchange.StacMan.Users.UserType), networkUser.UserType);
}
示例3: Questions_get_all_test
public void Questions_get_all_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/questions?pagesize=1&fromdate=1328054400&order=desc&sort=activity&tagged=starcraft-2&site=gaming
mock.FakeGET(response: @"{""items"":[{""question_id"":62531,""last_edit_date"":1334545016,""creation_date"":1334446664,""last_activity_date"":1334566818,""score"":1,""answer_count"":2,""title"":""Why does the 'favored' rating change from start of game to end of game in Starcraft 2?"",""tags"":[""starcraft-2"",""multiplayer""],""view_count"":96,""owner"":{""user_id"":2030,""display_name"":""Kelsey"",""reputation"":273,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/395b66642a372ee82bbc821bdc2697a4?d=identicon&r=PG"",""link"":""http://gaming.stackexchange.com/users/2030/kelsey""},""link"":""http://gaming.stackexchange.com/questions/62531/why-does-the-favored-rating-change-from-start-of-game-to-end-of-game-in-starcr"",""is_answered"":true}],""quota_remaining"":-81147,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Questions.GetAll("gaming", pagesize: 1, fromdate: new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), order: Order.Desc, sort: Questions.AllSort.Activity, tagged: "starcraft-2").Result;
Assert.IsTrue(result.Success);
var question = result.Data.Items.Single();
Assert.AreEqual(1334545016L.ToDateTime(), question.LastEditDate);
Assert.AreEqual(1334446664L.ToDateTime(), question.CreationDate);
Assert.AreEqual(1334566818L.ToDateTime(), question.LastActivityDate);
Assert.AreEqual(1, question.Score);
Assert.AreEqual(2, question.AnswerCount);
Assert.AreEqual("Why does the 'favored' rating change from start of game to end of game in Starcraft 2?", question.Title);
Assert.AreEqual(2, question.Tags.Length);
Assert.AreEqual("starcraft-2", question.Tags.First());
Assert.AreEqual(96, question.ViewCount);
Assert.AreEqual(2030, question.Owner.UserId);
Assert.AreEqual("Kelsey", question.Owner.DisplayName);
Assert.AreEqual(273, question.Owner.Reputation);
Assert.AreEqual(Users.UserType.Registered, question.Owner.UserType);
Assert.AreEqual("http://www.gravatar.com/avatar/395b66642a372ee82bbc821bdc2697a4?d=identicon&r=PG", question.Owner.ProfileImage);
Assert.AreEqual("http://gaming.stackexchange.com/users/2030/kelsey", question.Owner.Link);
Assert.AreEqual("http://gaming.stackexchange.com/questions/62531/why-does-the-favored-rating-change-from-start-of-game-to-end-of-game-in-starcr", question.Link);
Assert.IsTrue(question.IsAnswered);
}
示例4: Backoff_test
public void Backoff_test()
{
var mockSlow = new Mock<StacManClient>(null, null);
var mockFast = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/users?pagesize=1&site=stackoverflow
mockSlow.FakeGET(response: @"{""backoff"":1,""items"":[{""user_id"":22656,""user_type"":""registered"",""creation_date"":1222430705,""display_name"":""Jon Skeet"",""profile_image"":""http://www.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?d=identicon&r=PG"",""reputation"":431980,""reputation_change_day"":365,""reputation_change_week"":2286,""reputation_change_month"":9666,""reputation_change_quarter"":9666,""reputation_change_year"":44922,""age"":35,""last_access_date"":1335550327,""last_modified_date"":1335533187,""is_employee"":false,""link"":""http://stackoverflow.com/users/22656/jon-skeet"",""website_url"":""http://csharpindepth.com"",""location"":""Reading, United Kingdom"",""account_id"":11683,""badge_counts"":{""gold"":124,""silver"":1896,""bronze"":3221},""accept_rate"":95}],""quota_remaining"":109,""quota_max"":300,""has_more"":true}");
mockFast.FakeGET(response: @"{""items"":[{""user_id"":22656,""user_type"":""registered"",""creation_date"":1222430705,""display_name"":""Jon Skeet"",""profile_image"":""http://www.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?d=identicon&r=PG"",""reputation"":431980,""reputation_change_day"":365,""reputation_change_week"":2286,""reputation_change_month"":9666,""reputation_change_quarter"":9666,""reputation_change_year"":44922,""age"":35,""last_access_date"":1335550327,""last_modified_date"":1335533187,""is_employee"":false,""link"":""http://stackoverflow.com/users/22656/jon-skeet"",""website_url"":""http://csharpindepth.com"",""location"":""Reading, United Kingdom"",""account_id"":11683,""badge_counts"":{""gold"":124,""silver"":1896,""bronze"":3221},""accept_rate"":95}],""quota_remaining"":109,""quota_max"":300,""has_more"":true}");
var clientSlow = mockSlow.Object;
var clientFast = mockFast.Object;
Action<StacManClient, Action<long>> measure = (client, verifyElapsedMs) =>
{
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
var result = client.Users.GetAll("stackoverflow", pagesize: 1).Result;
var result2 = client.Users.GetAll("stackoverflow", pagesize: 1).Result;
verifyElapsedMs(stopwatch.ElapsedMilliseconds);
};
measure(clientSlow, elapsedMs => Assert.IsTrue(elapsedMs >= 1000));
measure(clientFast, elapsedMs => Assert.IsTrue(elapsedMs < 1000));
clientSlow.RespectBackoffs = false;
measure(clientSlow, elapsedMs => Assert.IsTrue(elapsedMs < 1000));
}
示例5: Info_get_test
public void Info_get_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/info?site=english
mock.FakeGET(response: @"{""items"":[{""total_questions"":14647,""total_unanswered"":15,""total_accepted"":10674,""total_answers"":41975,""questions_per_minute"":0.01,""answers_per_minute"":0.02,""total_comments"":112674,""total_votes"":251459,""total_badges"":41800,""badges_per_minute"":0.02,""total_users"":17118,""new_active_users"":1,""api_revision"":""2012.4.12.2100""}],""quota_remaining"":291,""quota_max"":300,""has_more"":false}");
var client = mock.Object;
var result = client.Info.Get("english").Result;
Assert.IsTrue(result.Success);
var info = result.Data.Items.Single();
Assert.AreEqual(14647, info.TotalQuestions);
Assert.AreEqual(15, info.TotalUnanswered);
Assert.AreEqual(10674, info.TotalAccepted);
Assert.AreEqual(41975, info.TotalAnswers);
Assert.AreEqual(.01m, info.QuestionsPerMinute);
Assert.AreEqual(.02m, info.AnswersPerMinute);
Assert.AreEqual(112674, info.TotalComments);
Assert.AreEqual(251459, info.TotalVotes);
Assert.AreEqual(41800, info.TotalBadges);
Assert.AreEqual(.02m, info.BadgesPerMinute);
Assert.AreEqual(17118, info.TotalUsers);
Assert.AreEqual(1, info.NewActiveUsers);
Assert.AreEqual("2012.4.12.2100", info.ApiRevision);
Assert.IsNull(info.Site);
}
示例6: Questions_by_id_test
public void Questions_by_id_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/questions/13332?order=desc&sort=activity&site=gaming
mock.FakeGET(response: @"{""items"":[{""question_id"":13332,""last_edit_date"":1296990699,""creation_date"":1278527266,""last_activity_date"":1296990699,""score"":1,""answer_count"":1,""migrated_from"":{""question_id"":161024,""other_site"":{""site_type"":""main_site"",""name"":""Super User"",""logo_url"":""http://cdn.sstatic.net/superuser/img/logo.png"",""api_site_parameter"":""superuser"",""site_url"":""http://superuser.com"",""audience"":""computer enthusiasts and power users"",""icon_url"":""http://cdn.sstatic.net/superuser/img/apple-touch-icon.png"",""site_state"":""normal"",""styling"":{""link_color"":""#1086A4"",""tag_foreground_color"":""#1087A4"",""tag_background_color"":""#FFFFFF""},""launch_date"":1250553600,""favicon_url"":""http://cdn.sstatic.net/superuser/img/favicon.ico"",""related_sites"":[{""name"":""Meta Super User"",""site_url"":""http://meta.superuser.com"",""relation"":""meta"",""api_site_parameter"":""meta.superuser""},{""name"":""Chat Stack Exchange"",""site_url"":""http://chat.stackexchange.com"",""relation"":""chat""}],""twitter_account"":""StackSuper_User""},""on_date"":1293296833},""title"":""How do I run Worms: World Party on Ubuntu?"",""tags"":[""linux"",""unix"",""ubuntu""],""view_count"":845,""owner"":{""display_name"":""gcc"",""user_type"":""does_not_exist""},""link"":""http://gaming.stackexchange.com/questions/13332/how-do-i-run-worms-world-party-on-ubuntu"",""is_answered"":true}],""quota_remaining"":-89970,""quota_max"":300,""has_more"":false}");
var client = mock.Object;
var result = client.Questions.GetByIds("gaming", new int[] { 13332 }, order: Order.Desc, sort: Questions.Sort.Activity).Result;
Assert.IsTrue(result.Success);
var question = result.Data.Items.Single();
Assert.AreEqual(13332, question.QuestionId);
Assert.IsNull(question.AcceptedAnswerId);
Assert.AreEqual(161024, question.MigratedFrom.QuestionId);
Assert.AreEqual("Super User", question.MigratedFrom.OtherSite.Name);
Assert.AreEqual("#1086A4", question.MigratedFrom.OtherSite.Styling.LinkColor);
Assert.AreEqual(2, question.MigratedFrom.OtherSite.RelatedSites.Length);
Assert.AreEqual(question.Tags.Length, 3);
Assert.AreEqual("gcc", question.Owner.DisplayName);
Assert.AreEqual(Users.UserType.DoesNotExist, question.Owner.UserType);
Assert.IsNull(question.Owner.UserId);
Assert.IsNull(question.Owner.Reputation);
}
示例7: Sites_get_all_test
public void Sites_get_all_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/sites?page=1&pagesize=1
mock.FakeGET(response: @"{""items"":[{""site_type"":""main_site"",""name"":""Stack Overflow"",""logo_url"":""http://cdn.sstatic.net/stackoverflow/img/logo.png"",""api_site_parameter"":""stackoverflow"",""site_url"":""http://stackoverflow.com"",""audience"":""professional and enthusiast programmers"",""icon_url"":""http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png"",""aliases"":[""http://www.stackoverflow.com""],""site_state"":""normal"",""styling"":{""link_color"":""#0077CC"",""tag_foreground_color"":""#3E6D8E"",""tag_background_color"":""#E0EAF1""},""launch_date"":1221436800,""favicon_url"":""http://cdn.sstatic.net/stackoverflow/img/favicon.ico"",""related_sites"":[{""name"":""Stack Overflow Chat"",""site_url"":""http://chat.stackoverflow.com"",""relation"":""chat""}],""markdown_extensions"":[""Prettify""]}],""quota_remaining"":-50833,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Sites.GetAll(filter: "default", page: 1, pagesize: 1).Result;
Assert.IsTrue(result.Success);
var site = result.Data.Items.Single();
Assert.AreEqual("main_site", site.SiteType);
Assert.AreEqual("Stack Overflow", site.Name);
Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/logo.png", site.LogoUrl);
Assert.AreEqual("stackoverflow", site.ApiSiteParameter);
Assert.AreEqual("http://stackoverflow.com", site.SiteUrl);
Assert.AreEqual("professional and enthusiast programmers", site.Audience);
Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png", site.IconUrl);
Assert.AreEqual("http://www.stackoverflow.com", site.Aliases.Single());
Assert.AreEqual(StacMan.Sites.SiteState.Normal, site.SiteState);
Assert.AreEqual("#0077CC", site.Styling.LinkColor);
Assert.AreEqual("#3E6D8E", site.Styling.TagForegroundColor);
Assert.AreEqual("#E0EAF1", site.Styling.TagBackgroundColor);
Assert.AreEqual(1221436800L.ToDateTime(), site.LaunchDate);
Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/favicon.ico", site.FaviconUrl);
Assert.AreEqual("Stack Overflow Chat", site.RelatedSites.Single().Name);
Assert.AreEqual("http://chat.stackoverflow.com", site.RelatedSites.Single().SiteUrl);
Assert.AreEqual("chat", site.RelatedSites.Single().Relation);
Assert.AreEqual("Prettify", site.MarkdownExtensions.Single());
}
示例8: Test_response_debugging_properties
public void Test_response_debugging_properties()
{
var mock = new Mock<StacManClient>("myappkey", null);
//http://api.stackexchange.com/2.0/suggested-edits?pagesize=2&site=superuser
mock.FakeGET(response: @"{""items"":[{""suggested_edit_id"":10345,""post_id"":410422,""post_type"":""question"",""comment"":""Removed unnecessary greetings"",""creation_date"":1333996736,""proposing_user"":{""user_id"":111438,""display_name"":""dnbrv"",""reputation"":348,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/0299470f4dcad8b4d79fd01c5dc7be4a?d=identicon&r=PG"",""link"":""http://superuser.com/users/111438/dnbrv""}},{""suggested_edit_id"":10344,""post_id"":410423,""post_type"":""question"",""comment"":""updated info"",""creation_date"":1333995585,""approval_date"":1333997046,""proposing_user"":{""user_id"":127397,""display_name"":""James Wilson"",""reputation"":3,""user_type"":""unregistered"",""profile_image"":""http://www.gravatar.com/avatar/ace280d5491b40c2645d856bf20337a3?d=identicon&r=PG"",""link"":""http://superuser.com/users/127397/james-wilson""}}],""quota_remaining"":262,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var response = client.SuggestedEdits.GetAll("superuser", pagesize: 2).Result;
Assert.IsTrue(response.ApiUrl.Contains("site=superuser"));
Assert.IsTrue(response.ApiUrl.Contains("pagesize=2"));
Assert.IsTrue(response.ApiUrl.Contains("key=myappkey"));
Assert.IsNotNull(response.RawData);
}
示例9: Api_web_exception_response
public void Api_web_exception_response()
{
var mock = new Mock<StacManClient>(null, null);
var client = mock.Object;
mock.FakeGET(throws: new System.Net.WebException("timeout"));
var response = client.Users.GetAll("gaming.stackexchange.com").Result;
Assert.IsFalse(response.Success);
Assert.IsNull(response.Data);
Assert.IsInstanceOfType(response.Error, typeof(System.Net.WebException));
Assert.IsFalse(response.ReceivedApiResponse);
Assert.IsNotNull(response.ApiUrl);
Assert.IsNull(response.RawData);
}
示例10: Tags_get_all_test
public void Tags_get_all_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/tags?page=3&pagesize=2&order=desc&sort=popular&site=gaming
mock.FakeGET(response: @"{""items"":[{""name"":""league-of-legends"",""count"":768,""is_required"":false,""is_moderator_only"":false,""has_synonyms"":true},{""name"":""pc"",""count"":607,""is_required"":false,""is_moderator_only"":false,""has_synonyms"":false}],""quota_remaining"":-47478,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Tags.GetAll("gaming", page: 3, pagesize: 2, order: Order.Desc, sort: Tags.Sort.Popular).Result;
Assert.IsTrue(result.Success);
var tag = result.Data.Items.Skip(1).First();
Assert.AreEqual("pc", tag.Name);
Assert.AreEqual(607, tag.Count);
Assert.IsFalse(tag.IsRequired);
Assert.IsFalse(tag.IsModeratorOnly);
Assert.IsFalse(tag.HasSynonyms);
Assert.IsNull(tag.UserId);
Assert.IsNull(tag.LastActivityDate);
}
示例11: Stack_Exchange_API_Exception_response
public void Stack_Exchange_API_Exception_response()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/inbox?access_token=foo
mock.FakeGET(response: @"{""error_id"":405,""error_name"":""key_required"",""error_message"":""`key` is required when `access_token` is passed.""}");
var client = mock.Object;
var response = client.Inbox.Get("foo").Result;
Assert.IsFalse(response.Success);
Assert.IsTrue(response.ReceivedApiResponse);
Assert.IsNotNull(response.RawData);
Assert.IsInstanceOfType(response.Error, typeof(Exceptions.StackExchangeApiException));
Assert.AreEqual(405, ((Exceptions.StackExchangeApiException)response.Error).ErrorId);
Assert.AreEqual("key_required", ((Exceptions.StackExchangeApiException)response.Error).ErrorName);
Assert.AreEqual("`key` is required when `access_token` is passed.", ((Exceptions.StackExchangeApiException)response.Error).ErrorMessage);
Assert.IsNull(response.Data.Items);
Assert.AreEqual(405, response.Data.ErrorId);
Assert.AreEqual("key_required", response.Data.ErrorName);
Assert.AreEqual("`key` is required when `access_token` is passed.", response.Data.ErrorMessage);
}
示例12: Users_get_all_test
public void Users_get_all_test()
{
var mock = new Mock<StacManClient>(null, null);
//http://api.stackexchange.com/2.0/users?pagesize=1&order=desc&min=1&max=1000&sort=reputation&inname=doug&site=webapps
mock.FakeGET(response: @"{""items"":[{""user_id"":183,""user_type"":""registered"",""creation_date"":1277932837,""display_name"":""Doug Harris"",""profile_image"":""http://www.gravatar.com/avatar/731e7de87c241fce562d03b23770b5cf?d=identicon&r=PG"",""reputation"":545,""reputation_change_day"":0,""reputation_change_week"":0,""reputation_change_month"":0,""reputation_change_quarter"":0,""reputation_change_year"":15,""age"":92,""last_access_date"":1332536617,""last_modified_date"":1332297406,""is_employee"":false,""link"":""http://webapps.stackexchange.com/users/183/doug-harris"",""website_url"":""http://delicious.com/dharris"",""location"":""Washington, DC"",""account_id"":46903,""badge_counts"":{""gold"":1,""silver"":4,""bronze"":8},""accept_rate"":25}],""quota_remaining"":-210785,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Users.GetAll("webapps", pagesize: 1, order: Order.Desc, min: 1, max: 1000, sort: Users.Sort.Reputation, inname: "doug").Result;
Assert.IsTrue(result.Success);
var user = result.Data.Items.Single();
Assert.AreEqual(183, user.UserId);
Assert.AreEqual(Users.UserType.Registered, user.UserType);
Assert.AreEqual("Doug Harris", user.DisplayName);
Assert.AreEqual("http://www.gravatar.com/avatar/731e7de87c241fce562d03b23770b5cf?d=identicon&r=PG", user.ProfileImage);
Assert.AreEqual(545, user.Reputation);
Assert.AreEqual(0, user.ReputationChangeDay);
Assert.AreEqual(0, user.ReputationChangeWeek);
Assert.AreEqual(0, user.ReputationChangeMonth);
Assert.AreEqual(0, user.ReputationChangeQuarter);
Assert.AreEqual(15, user.ReputationChangeYear);
Assert.AreEqual(92, user.Age);
Assert.AreEqual(1332536617L.ToDateTime(), user.LastAccessDate);
Assert.AreEqual(1332297406L.ToDateTime(), user.LastModifiedDate);
Assert.IsFalse(user.IsEmployee);
Assert.AreEqual("http://webapps.stackexchange.com/users/183/doug-harris", user.Link);
Assert.AreEqual("http://delicious.com/dharris", user.WebsiteUrl);
Assert.AreEqual("Washington, DC", user.Location);
Assert.AreEqual(46903, user.AccountId);
Assert.AreEqual(1, user.BadgeCounts.Gold);
Assert.AreEqual(4, user.BadgeCounts.Silver);
Assert.AreEqual(8, user.BadgeCounts.Bronze);
Assert.AreEqual(25, user.AcceptRate);
Assert.IsNull(user.TimedPenaltyDate);
}
示例13: Merge_get_test
public void Merge_get_test()
{
var mock = new Mock<StacManClient>(null, "2.1");
//http://api.stackexchange.com/2.1/users/1450259/merges
mock.FakeGET(response: @"{""items"":[{""old_account_id"":2885329,""new_account_id"":1450259,""merge_date"":1371139987}],""quota_remaining"":89,""quota_max"":300,""has_more"":false}");
var client = mock.Object;
var result = client.Users.GetMerges(new int[] { 1450259 }).Result;
Assert.IsTrue(result.Success);
var merge = result.Data.Items.Single();
Assert.AreEqual(2885329, merge.OldAccountId);
Assert.AreEqual(1450259, merge.NewAccountId);
Assert.AreEqual(1371139987L.ToDateTime(), merge.MergeDate);
}
示例14: Reputation_history_test
public void Reputation_history_test()
{
var mock = new Mock<StacManClient>(null, "2.1");
//http://api.stackexchange.com/2.1/users/2749/reputation-history?pagesize=3&site=stackoverflow
mock.FakeGET(response: @"{""items"":[{""user_id"":2749,""creation_date"":1370863493,""post_id"":5149758,""reputation_change"":10,""reputation_history_type"":""post_upvoted""},{""user_id"":2749,""creation_date"":1370754616,""post_id"":10731127,""reputation_change"":10,""reputation_history_type"":""post_upvoted""},{""user_id"":2749,""creation_date"":1369860751,""post_id"":16821800,""reputation_change"":2,""reputation_history_type"":""asker_accepts_answer""}],""quota_remaining"":289,""quota_max"":300,""has_more"":true}");
var client = mock.Object;
var result = client.Users.GetReputationHistory("stackoverflow", new int[] { 2749 }, pagesize: 3).Result;
Assert.IsTrue(result.Success);
var second = result.Data.Items[1];
Assert.AreEqual(2749, second.UserId);
Assert.AreEqual(1370754616L.ToDateTime(), second.CreationDate);
Assert.AreEqual(10731127, second.PostId);
Assert.AreEqual(10, second.ReputationChange);
Assert.AreEqual(ReputationHistories.ReputationHistoryType.PostUpvoted, second.ReputationHistoryType);
}
示例15: Notice_test
public void Notice_test()
{
var mock = new Mock<StacManClient>(null, "2.1");
//http://api.stackexchange.com/2.1/questions/7399584?order=desc&sort=activity&site=stackoverflow&filter=!9hnGsqOrt
mock.FakeGET(response: @"{""items"":[{""question_id"":7399584,""last_edit_date"":1317126047,""creation_date"":1315906028,""last_activity_date"":1323375260,""score"":7,""answer_count"":1,""accepted_answer_id"":7632327,""bounty_amount"":50,""title"":""Sql Server 2008 R2 DC Inserts Performance Change"",""tags"":[""sql-server"",""sql-server-2008"",""sql-server-2008-r2"",""performance-testing"",""sql-server-performance""],""view_count"":341,""owner"":{""user_id"":546051,""display_name"":""Falcon"",""reputation"":323,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/5d914c55df57402dadc984105382d0a0?d=identicon&r=PG"",""link"":""http://stackoverflow.com/users/546051/falcon"",""accept_rate"":78},""link"":""http://stackoverflow.com/questions/7399584/sql-server-2008-r2-dc-inserts-performance-change"",""is_answered"":true,""notice"":{""body"":""<p>I would like to know why there is a change in performance after 1.5M inserts. Where is the change in the graph from one pattern to another coming from. I expect some kind of a prove.</p>"",""creation_date"":1316505623,""owner_user_id"":546051}}],""quota_remaining"":296,""quota_max"":300,""has_more"":false}");
var client = mock.Object;
var result = client.Questions.GetByIds("stackoverflow", new int[] { 7399584 }, order: Order.Desc, sort: Questions.Sort.Activity, filter: "!9hnGsqOrt").Result;
Assert.IsTrue(result.Success);
var question = result.Data.Items.Single();
Assert.IsNotNull(question.Notice);
Assert.AreEqual("<p>I would like to know why there is a change in performance after 1.5M inserts. Where is the change in the graph from one pattern to another coming from. I expect some kind of a prove.</p>", question.Notice.Body);
Assert.AreEqual(1316505623L.ToDateTime(), question.Notice.CreationDate);
Assert.AreEqual(546051, question.Notice.OwnerUserId);
}