public void Open_with_events_traces_start_and_end_error() { ConnectionStub <IMyProxy> inner = new ConnectionStub <IMyProxy>(true); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5); ConnectionWithEvents <IMyProxy> outer = new ConnectionWithEvents <IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { Task task = outer.OpenAsync(); Assert.False(task.IsCompleted); listener.VerifyEvent(ClientEventId.ConnectionOpening, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Start, id); listener.Events.Clear(); InvalidTimeZoneException expectedException = new InvalidTimeZoneException("Expected."); inner.OpenCall.SetException(expectedException); Assert.True(task.IsFaulted); AggregateException ae = Assert.IsType <AggregateException>(task.Exception); Assert.Equal(1, ae.InnerExceptions.Count); Assert.Same(expectedException, ae.InnerException); listener.VerifyEvent(ClientEventId.ConnectionError, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Stop, id, "System.InvalidTimeZoneException", "Expected."); listener.Events.Clear(); } }
public void SquareRoot_with_events_traces_event() { ClientEventSource eventSource = ClientEventSource.Instance; CalculatorClientWithEvents client = new CalculatorClientWithEvents(new CalculatorClientStub(() => Task.FromResult(0.0d)), eventSource); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Advanced)) { VerifyResult(0.0d, client.SquareRootAsync(5.0d)); listener.VerifyEvent(ClientEventId.SquareRoot, EventLevel.Informational, ClientEventSource.Keywords.Advanced, 5.0d); } }
public void Add_with_events_traces_event() { ClientEventSource eventSource = ClientEventSource.Instance; CalculatorClientWithEvents client = new CalculatorClientWithEvents(new CalculatorClientStub(() => Task.FromResult(0.0d)), eventSource); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Basic)) { VerifyResult(0.0d, client.AddAsync(1.0d, 2.0d)); listener.VerifyEvent(ClientEventId.Add, EventLevel.Informational, ClientEventSource.Keywords.Basic, 1.0d, 2.0d); } }
private static void VerifyTracesStartAndEnd(Func <ICalculatorClientAsync, Task <double> > doAsync) { ClientEventSource eventSource = ClientEventSource.Instance; TaskCompletionSource <double> tcs = new TaskCompletionSource <double>(); Guid clientId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xC); CalculatorClientWithActivity client = new CalculatorClientWithActivity(new CalculatorClientStub(() => tcs.Task), eventSource, clientId); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Request)) { Task <double> task = VerifyPending(doAsync(client)); listener.VerifyEvent(ClientEventId.Request, EventLevel.Informational, ClientEventSource.Keywords.Request, EventOpcode.Start, clientId); listener.Events.Clear(); tcs.SetResult(0.0d); VerifyResult(0.0d, task); listener.VerifyEvent(ClientEventId.RequestCompleted, EventLevel.Informational, ClientEventSource.Keywords.Request, EventOpcode.Stop, clientId); } }
public void Open_with_events_traces_start_and_end() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(true); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { Task task = outer.OpenAsync(); Assert.False(task.IsCompleted); listener.VerifyEvent(ClientEventId.ConnectionOpening, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Start, id); listener.Events.Clear(); inner.OpenCall.SetResult(false); Assert.Equal(TaskStatus.RanToCompletion, task.Status); listener.VerifyEvent(ClientEventId.ConnectionOpened, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Stop, id); listener.Events.Clear(); } }
public void Open_with_events_traces_start_and_end() { ConnectionStub <IMyProxy> inner = new ConnectionStub <IMyProxy>(true); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); ConnectionWithEvents <IMyProxy> outer = new ConnectionWithEvents <IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { Task task = outer.OpenAsync(); Assert.False(task.IsCompleted); listener.VerifyEvent(ClientEventId.ConnectionOpening, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Start, id); listener.Events.Clear(); inner.OpenCall.SetResult(false); Assert.Equal(TaskStatus.RanToCompletion, task.Status); listener.VerifyEvent(ClientEventId.ConnectionOpened, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Stop, id); listener.Events.Clear(); } }
private static void VerifyTracesStartAndEndError(Func <ICalculatorClientAsync, Task <double> > doAsync) { ClientEventSource eventSource = ClientEventSource.Instance; TaskCompletionSource <double> tcs = new TaskCompletionSource <double>(); Guid clientId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xC); CalculatorClientWithActivity client = new CalculatorClientWithActivity(new CalculatorClientStub(() => tcs.Task), eventSource, clientId); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Request)) { Task <double> task = VerifyPending(doAsync(client)); listener.VerifyEvent(ClientEventId.Request, EventLevel.Informational, ClientEventSource.Keywords.Request, EventOpcode.Start, clientId); listener.Events.Clear(); InvalidCastException expectedException = new InvalidCastException("Expected."); tcs.SetException(expectedException); VerifyResultError(expectedException, task); listener.VerifyEvent(ClientEventId.RequestError, EventLevel.Warning, ClientEventSource.Keywords.Request, EventOpcode.Stop, clientId, "System.InvalidCastException", "Expected."); } }
public void Abort_with_events_traces_event() { ConnectionStub <IMyProxy> inner = new ConnectionStub <IMyProxy>(); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6); ConnectionWithEvents <IMyProxy> outer = new ConnectionWithEvents <IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { outer.Abort(); listener.VerifyEvent(ClientEventId.ConnectionAborting, EventLevel.Informational, ClientEventSource.Keywords.Connection, id); } }
private static void VerifyTracesStartAndEndSyncError(Func <ICalculatorClientAsync, Task <double> > doAsync) { ClientEventSource eventSource = ClientEventSource.Instance; Guid clientId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xC); InvalidTimeZoneException expectedException = new InvalidTimeZoneException("Expected."); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Request)) { Func <Task <double> > verifyStartEventAndThrow = delegate { listener.VerifyEvent(ClientEventId.Request, EventLevel.Informational, ClientEventSource.Keywords.Request, EventOpcode.Start, clientId); listener.Events.Clear(); throw expectedException; }; CalculatorClientWithActivity client = new CalculatorClientWithActivity(new CalculatorClientStub(verifyStartEventAndThrow), eventSource, clientId); InvalidTimeZoneException ite = Assert.Throws <InvalidTimeZoneException>(() => doAsync(client)); Assert.Same(expectedException, ite); listener.VerifyEvent(ClientEventId.RequestError, EventLevel.Warning, ClientEventSource.Keywords.Request, EventOpcode.Stop, clientId, "System.InvalidTimeZoneException", "Expected."); } }
public void Open_with_events_traces_start_and_end_error() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(true); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5); ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { Task task = outer.OpenAsync(); Assert.False(task.IsCompleted); listener.VerifyEvent(ClientEventId.ConnectionOpening, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Start, id); listener.Events.Clear(); InvalidTimeZoneException expectedException = new InvalidTimeZoneException("Expected."); inner.OpenCall.SetException(expectedException); Assert.True(task.IsFaulted); AggregateException ae = Assert.IsType<AggregateException>(task.Exception); Assert.Equal(1, ae.InnerExceptions.Count); Assert.Same(expectedException, ae.InnerException); listener.VerifyEvent(ClientEventId.ConnectionError, EventLevel.Informational, ClientEventSource.Keywords.Connection, EventOpcode.Stop, id, "System.InvalidTimeZoneException", "Expected."); listener.Events.Clear(); } }
public void Abort_with_events_traces_event() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(); ClientEventSource eventSource = ClientEventSource.Instance; Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6); ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, eventSource, id); using (ClientEventListener listener = new ClientEventListener(eventSource, EventLevel.Informational, ClientEventSource.Keywords.Connection)) { outer.Abort(); listener.VerifyEvent(ClientEventId.ConnectionAborting, EventLevel.Informational, ClientEventSource.Keywords.Connection, id); } }