public void SetConnection_UnsubscribesFromMessageReceivedWithNullConnection() { using (var dispatcher = new MessageDispatcher(new RequestHandlers(), _idGenerator)) { var spy = new ConnectionEventRegistrationSpy(); dispatcher.SetConnection(spy); dispatcher.SetConnection(connection: null); Assert.Equal(1, spy.MessageReceivedRemoveCount); } }
public void SetConnection_SubscribesToMessageReceived() { using (var dispatcher = new MessageDispatcher(new RequestHandlers(), _idGenerator)) { var spy = new ConnectionEventRegistrationSpy(); Assert.Equal(0, spy.MessageReceivedAddCount); dispatcher.SetConnection(spy); Assert.Equal(1, spy.MessageReceivedAddCount); } }