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 NonExistingDynamicObjectRegistered() { var baseScheduler = new TestScheduler(); var connection = new ConnectionStub(); using (var host = new TestHost(connection, new NoopObjectPlatformBinder(), baseScheduler)) { host.ResolvingBoundObject += (s, args) => { args.Object = new object(); }; baseScheduler.Start(); connection.IncomingSubject.OnNext(new RpcResponse <object> { DynamicObjectRequest = new DynamicObjectRequest { ExecutionId = 1, Name = "testObj" } }); baseScheduler.AdvanceBy(1); Assert.Equal("testObj", host.Repository.Objects.Values.First().Name); } }
public void NonExistingDynamicObjectAddedAsNonDisposable() { var disposable = Mock.Of <IDisposable>(); var disposableMock = Mock.Get(disposable); var baseScheduler = new TestScheduler(); var connection = new ConnectionStub(); using (var host = new TestHost(connection, new NoopObjectPlatformBinder(), baseScheduler)) { host.ResolvingBoundObject += (s, args) => { args.Object = disposable; args.Disposable = false; }; baseScheduler.Start(); connection.IncomingSubject.OnNext(new RpcResponse <object> { DynamicObjectRequest = new DynamicObjectRequest() { ExecutionId = 1, Name = "testObj" } }); baseScheduler.AdvanceBy(1); } disposableMock.Verify(_ => _.Dispose(), Times.Never); }
public void Get_instance_with_events_calls_inner() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(); MyProxyStub proxyStub = new MyProxyStub(); inner.Instance = proxyStub; ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, ClientEventSource.Instance, Guid.Empty); Assert.Same(proxyStub, outer.Instance); }
public void Abort_with_events_calls_inner() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(); ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, ClientEventSource.Instance, Guid.Empty); outer.Abort(); Assert.Equal(1, inner.AbortCount); }
public void Open_with_events_calls_inner() { ConnectionStub<IMyProxy> inner = new ConnectionStub<IMyProxy>(); ConnectionWithEvents<IMyProxy> outer = new ConnectionWithEvents<IMyProxy>(inner, ClientEventSource.Instance, Guid.Empty); Task task = outer.OpenAsync(); Assert.Equal(TaskStatus.RanToCompletion, task.Status); Assert.Equal(1, inner.OpenCount); }
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 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); } }