public void EmptyMapReturnsNullHandlers() { var map = new HandlerMap(); var handler = map.Get(typeof(SimpleMessage)); handler.ShouldBeNull(); }
public void EmptyMapReturnsNullHandlers() { var map = new HandlerMap(); var handler = map.Get(typeof(GenericMessage)); Assert.That(handler, Is.Null); }
public void CorrectHandlerIsReturnedForType() { Func <Message, Task <bool> > fn1 = m => Task.FromResult(true); Func <Message, Task <bool> > fn2 = m => Task.FromResult(true); var map = new HandlerMap(); map.Add(typeof(SimpleMessage), fn1); map.Add(typeof(AnotherSimpleMessage), fn2); var handler1 = map.Get(typeof(SimpleMessage)); handler1.ShouldBe(fn1); var handler2 = map.Get(typeof(AnotherSimpleMessage)); handler2.ShouldBe(fn2); }
public void HandlerIsNotReturnedForNonMatchingType() { var map = new HandlerMap(); map.Add(typeof(GenericMessage), m => Task.FromResult(true)); var handler = map.Get(typeof(AnotherGenericMessage)); Assert.That(handler, Is.Null); }
public void HandlerIsNotReturnedForNonMatchingType() { var map = new HandlerMap(); map.Add(typeof(SimpleMessage), m => Task.FromResult(true)); var handler = map.Get(typeof(AnotherSimpleMessage)); handler.ShouldBeNull(); }
public void HandlerIsReturnedForMatchingType() { var map = new HandlerMap(); map.Add(typeof(GenericMessage), m => Task.FromResult(true)); var handler = map.Get(typeof(GenericMessage)); handler.ShouldNotBeNull(); }
public void CorrectHandlerIsReturnedForType() { Func <Message, Task <bool> > fn1 = m => Task.FromResult(true); Func <Message, Task <bool> > fn2 = m => Task.FromResult(true); var map = new HandlerMap(); map.Add(typeof(GenericMessage), fn1); map.Add(typeof(AnotherGenericMessage), fn2); var handler1 = map.Get(typeof(GenericMessage)); Assert.That(handler1, Is.Not.Null); Assert.That(handler1, Is.EqualTo(fn1)); var handler2 = map.Get(typeof(AnotherGenericMessage)); Assert.That(handler2, Is.Not.Null); Assert.That(handler2, Is.EqualTo(fn2)); }
public void HandlerIsReturnedForMatchingType() { var map = new HandlerMap(); map.Add(typeof(GenericMessage), m => Task.FromResult(true)); var handlers = map.Get(typeof(GenericMessage)); Assert.That(handlers, Is.Not.Null); Assert.That(handlers.Count, Is.EqualTo(1)); }
public void MultipleHandlersForATypeAreSupported() { Func <Message, Task <bool> > fn1 = m => Task.FromResult(true); Func <Message, Task <bool> > fn2 = m => Task.FromResult(true); var map = new HandlerMap(); map.Add(typeof(GenericMessage), fn1); map.Add(typeof(GenericMessage), fn2); var handlers1 = map.Get(typeof(GenericMessage)); Assert.That(handlers1, Is.Not.Null); Assert.That(handlers1.Count, Is.EqualTo(2)); Assert.That(handlers1[0], Is.EqualTo(fn1)); Assert.That(handlers1[1], Is.EqualTo(fn2)); var handlers2 = map.Get(typeof(AnotherGenericMessage)); Assert.That(handlers2, Is.Null); }