public void Constructor_AddsItselfAsResponseHandler() { IRequestHandler handler; Assert.False(_handlers.TryGet(MessageMethod.Handshake, out handler)); using (var handshake = CreateHandshake()) { Assert.True(_handlers.TryGet(MessageMethod.Handshake, out handler)); Assert.Same(handshake, handler); } }
public void AddOrUpdate_AddsIfDoesNotAlreadyExist() { var handler = Mock.Of <IRequestHandler>(); _handlers.AddOrUpdate(MessageMethod.Handshake, () => handler, oldHandler => handler); IRequestHandler actualHandler; var wasAdded = _handlers.TryGet(MessageMethod.Handshake, out actualHandler); Assert.True(wasAdded); Assert.Same(handler, actualHandler); }