public async Task TestGetPreferredTranslators() { var mockedClient = new MockedGengoClient(); var group = new AccountMethodGroup(mockedClient); mockedClient.Json["account/preferred_translators"] = @" [ { ""translators"": [ { ""last_login"": 1375824155, ""number_of_jobs"": 5, ""id"": 8596 }, { ""last_login"": 1372822132, ""number_of_jobs"": 2, ""id"": 24123 } ], ""lc_tgt"": ""ja"", ""lc_src"": ""en"", ""tier"": ""standard"" }, { ""translators"": [ { ""last_login"": 1375825234, ""number_of_jobs"": 10, ""id"": 14765 }, { ""last_login"": 1372822132, ""number_of_jobs"": 1, ""id"": 3627 } ], ""lc_tgt"": ""en"", ""lc_src"": ""ja"", ""tier"": ""pro"" } ] "; var preferences = await group.GetPreferredTranslators(); Assert.IsNotNull(preferences); Assert.AreEqual(2, preferences.Length, "Lengths does not match"); Assert.AreEqual(new DateTime(2013, 7, 3), preferences[0].Translators[1].LastLogin.Date, "Login dates don't match"); Assert.AreEqual(TranslationTier.Standard, preferences[0].Tier, "First tier don't match"); Assert.AreEqual(TranslationTier.Pro, preferences[1].Tier, "Second tier don't match"); Assert.AreEqual(2, preferences[0].Translators[1].NumberOfJobs, "Number of jobs don't match"); Assert.AreEqual(3627, preferences[1].Translators[1].Id, "Translator Ids don't match"); }
private void initClient() { Account = new AccountMethodGroup(this); Glossary = new GlossaryMethodGroup(this); Job = new JobMethodGroup(this); Jobs = new JobsMethodGroup(this); Service = new ServiceMethodGroup(this); Order = new OrderMethodGroup(this); var assemblyName = GetType().Assembly.GetName(); var headers = _client.DefaultRequestHeaders; headers.UserAgent.Add(new ProductInfoHeaderValue(assemblyName.Name, assemblyName.Version.ToString())); headers.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8")); headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MimeTypeApplicationJson)); }