protected void CreateClient(ICacheProvider cacheProvider) { this.logger = new InMemoryLogger(); this.fakeHttpClient = new ResourceReturningHttpClient(BaseUrl); this.client = Clients.Builder() .SetHttpClient(this.fakeHttpClient) .SetCacheProvider(cacheProvider) .SetLogger(this.logger) .Build(); }
public async Task Csharp_code_creates_csharp_user_agent() { var fakeHttpClient = new ResourceReturningHttpClient("http://foo.bar", FakeJson.Account); var client = Clients.Builder() .SetApiKey(FakeApiKey.Create(valid: true)) .SetBaseUrl("http://foo.bar/") .SetHttpClient(fakeHttpClient) .SetCacheProvider(Cache.Caches.NewDisabledCacheProvider()) .Build(); var tenant = await client.GetResourceAsync<IAccount>("http://foo.bar/fooAccount"); var userAgent = fakeHttpClient.Calls.Single().Headers.UserAgent; userAgent.Split(' ').Count(x => x.StartsWith("lang")).ShouldBe(1); userAgent.ShouldContain("lang/csharp"); }