public async Task TestGetSamplingStrategy() { _httpClient.MakeGetRequestAsync("http://www.example.com/sampling?service=clairvoyant") .Returns("{\"strategyType\":\"PROBABILISTIC\",\"probabilisticSampling\":{\"samplingRate\":0.001},\"rateLimitingSampling\":null}"); SamplingStrategyResponse response = await _undertest.GetSamplingStrategyAsync("clairvoyant"); Assert.NotNull(response.ProbabilisticSampling); }
public async Task TestDefaultConstructor() { _httpClient.MakeGetRequestAsync("http://127.0.0.1:5778/sampling?service=name") .Returns(new Func <CallInfo, string>(_ => { throw new InvalidOperationException(); })); HttpSamplingManager httpSamplingManager = new HttpSamplingManager(_httpClient); await Assert.ThrowsAsync <InvalidOperationException>(() => httpSamplingManager.GetSamplingStrategyAsync("name")); }
public async Task TestAllowHostPortSyntax() { var instance = new HttpSamplingManager(_httpClient, "example.com:80"); _httpClient.MakeGetRequestAsync("http://example.com/?service=clairvoyant") .Returns("{\"strategyType\":\"PROBABILISTIC\",\"probabilisticSampling\":{\"samplingRate\":0.001},\"rateLimitingSampling\":null}"); SamplingStrategyResponse response = await instance.GetSamplingStrategyAsync("clairvoyant"); Assert.NotNull(response.ProbabilisticSampling); }