public void Setup() { _nodeMocks = new[] { GenerateNodeMock(1), GenerateNodeMock(2), GenerateNodeMock(3), GenerateNodeMock(4) }; _routingTable = null; _consumeMock.Setup(c => c.Stop()).Returns(Task.FromResult(new Void())); _routerMock.Setup(r => r.Stop()).Returns(Task.FromResult(new Void())); _routerMock.Setup(r => r.ChangeRoutingTable(It.IsAny <RoutingTable>())).Callback <RoutingTable>(r => { _routingTable = r; }); _cluster = new Cluster( new Configuration { Seeds = "localhost:1", TaskScheduler = new CurrentThreadTaskScheduler(), MinimumTimeBetweenRefreshMetadata = TimeSpan.FromSeconds(0), MinInSyncReplicas = 2 }, new DevNullLogger(), (h, p) => _nodeMocks[p - 1].Object, () => _routerMock.Object, () => _consumeMock.Object); _internalErrors = 0; _cluster.InternalError += _ => ++ _internalErrors; }