public void ParametersArePreservedAsProperties() { var message = typeof(object); Func<ConnectionMultiplexer, object, CancellationToken, Task> handler = (connection, msg, token) => Task.FromResult(false); var sut = new RedisProjectionHandler(message, handler); Assert.That(sut.Message, Is.EqualTo(message)); Assert.That(sut.Handler, Is.EqualTo(handler)); }
public void ParametersArePreservedAsProperties() { var message = typeof(object); Func <ConnectionMultiplexer, object, CancellationToken, Task> handler = (connection, msg, token) => Task.FromResult(false); var sut = new RedisProjectionHandler(message, handler); Assert.That(sut.Message, Is.EqualTo(message)); Assert.That(sut.Handler, Is.EqualTo(handler)); }
public void ConcatHandlerReturnsExpectedResult() { var handler1 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler2 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler3 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var sut = new RedisProjection(new[] { handler1, handler2 }); var result = sut.Concat(handler3); Assert.That(result.Handlers, Is.EquivalentTo(new[] { handler1, handler2, handler3 })); }
public void ToBuilderReturnsExpectedResult() { var handler1 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler2 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var sut = new RedisProjection(new[] { handler1, handler2 }); var result = sut.ToBuilder().Build().Handlers; Assert.That(result, Is.EquivalentTo(new[] { handler1, handler2 })); }
public void DecoratedProjectionHandlersAreCopiedOnConstruction() { var handler1 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler2 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var projection = new RedisProjection(new[] { handler1, handler2 }); var sut = new RedisProjectionBuilder(projection); var result = sut.Build(); Assert.That(result.Handlers, Is.EquivalentTo(new[] { handler1, handler2 })); }
public void ImplicitConversionToRedisProjectionHandlerArray() { var handler1 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler2 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handlers = new[] { handler1, handler2 }; var sut = new RedisProjection(handlers); RedisProjectionHandler[] result = sut; Assert.That(result, Is.EquivalentTo(handlers)); }
public void HandlersArePreservedAsProperty() { var handler1 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handler2 = new RedisProjectionHandler(typeof(object), (connection, message, token) => Task.FromResult(false)); var handlers = new[] { handler1, handler2 }; var sut = new RedisProjection(handlers); var result = sut.Handlers; Assert.That(result, Is.EquivalentTo(handlers)); }
private static AsyncRedisProjector SutFactory(RedisProjectionHandler[] handlers) { return new AsyncRedisProjector(handlers); }
public void SetUp() { _connection = ConnectionMultiplexer.Connect(new ConfigurationOptions { AbortOnConnectFail = false, ConnectTimeout = 1, EndPoints = { { IPAddress.Loopback, 1234 } } }); _calls = new List<RedisProjectionHandlerCall>(); var handler1 = new RedisProjectionHandler( typeof(MatchMessage1), (connection, msg, token) => { _calls.Add(new RedisProjectionHandlerCall(connection, msg, token)); return Task.FromResult(false); }); var handler2 = new RedisProjectionHandler( typeof(MatchMessage2), (connection, msg, token) => { _calls.Add(new RedisProjectionHandlerCall(connection, msg, token)); return Task.FromResult(false); }); var handler3 = new RedisProjectionHandler( typeof(MatchMessage1), (connection, msg, token) => { _calls.Add(new RedisProjectionHandlerCall(connection, msg, token)); return Task.FromResult(false); }); var handler4 = new RedisProjectionHandler( typeof(MatchMessage2), (connection, msg, token) => { _calls.Add(new RedisProjectionHandlerCall(connection, msg, token)); return Task.FromResult(false); }); _sut = SutFactory(new[] { handler1, handler2, handler3, handler4 }); }