public async Task ProcessAsync_sends_telemetries_to_all_replicators() { var httpClientMock = new Mock <HttpClient>(); var replicators = new[] { GetTelemetryReplicatorMock().Object, GetTelemetryReplicatorMock().Object, GetTelemetryReplicatorMock().Object, }; var options = TelemetryProxyOptions.Default; options.HttpClientFactory = () => httpClientMock.Object; options.TelemetryReplicatorFactory = new DummyTelemetryReplicatorsFactory(replicators); var sut = new TelemetryProxy(options); await sut.ProcessAsync(GetSampleGzipBody(), SampleHeaders); Assert.All(replicators, replicator => { var mock = Mock.Get(replicator); mock.Verify(x => x.ReplicateAsync( It.Is <JArray>(array => array.Count == 2), It.Is <IEnumerable <KeyValuePair <string, IEnumerable <string> > > >(headers => headers.Count() == 7)), Times.Once); }); }
public void Replicators_are_empty_when_null_replicators_factory_options() { var options = TelemetryProxyOptions.Default; var sut = new TelemetryProxy(options); Assert.False(sut.Replicators.Any()); }
private void InitializeTelemetry() { #if UNITY_ANDROID m_SendResponseHandler = new SendEventResponseHandler(); m_SyncResponseHandler = new SyncResponseHandler(); m_TelemetryProxy = new TelemetryProxy(); m_ExportProxy = new DataExportServiceProxy(); #endif }
public async Task ProcessAsync_sends_telemetries_to_original_destination() { var httpClientMock = new Mock <HttpClient>(); var options = TelemetryProxyOptions.Default; options.HttpClientFactory = () => httpClientMock.Object; var sut = new TelemetryProxy(options); await sut.ProcessAsync(GetSampleGzipBody(), SampleHeaders); httpClientMock .Verify(httpClient => httpClient.SendAsync( It.Is <HttpRequestMessage>(message => message.RequestUri.ToString().Equals(options.EndpointAddress)), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ProcessAsync_returns_response_from_original_destination() { var httpClientMock = new Mock <HttpClient>(); httpClientMock .Setup(httpClient => httpClient.SendAsync( It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(System.Net.HttpStatusCode.OK)); var options = TelemetryProxyOptions.Default; options.HttpClientFactory = () => httpClientMock.Object; var sut = new TelemetryProxy(options); var response = await sut.ProcessAsync(GetSampleGzipBody(), SampleHeaders); Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); }
public async Task ProcessAsync_has_GuardClause(Stream body, HttpRequestHeaders headers) { var sut = new TelemetryProxy(); await Assert.ThrowsAsync <ArgumentNullException>( () => sut.ProcessAsync(body, headers)); }
public SystemOverviewWatcher(TelemetryProxy telemetryProxy) { _telemetryProxy = telemetryProxy; }