public ReceiveMessageHelper(BinaryConnection connection, int responseTo, MessageEncoderSettings messageEncoderSettings, ICompressorSource compressorSource) { _compressorSource = compressorSource; _connection = connection; _responseTo = responseTo; _messageEncoderSettings = messageEncoderSettings; }
public void Setup() { _capturedEvents = new EventCapturer() .Capture<CommandStartedEvent>() .Capture<CommandSucceededEvent>() .Capture<CommandFailedEvent>(); _streamFactory = Substitute.For<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For<IConnectionInitializer>(); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _streamFactory.CreateStreamAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult<Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public void Setup() { _capturedEvents = new EventCapturer() .Capture <CommandStartedEvent>() .Capture <CommandSucceededEvent>() .Capture <CommandFailedEvent>(); _streamFactory = Substitute.For <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For <IConnectionInitializer>(); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _streamFactory.CreateStreamAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult <Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public BinaryConnection_CommandEventTests() { _capturedEvents = new EventCapturer() .Capture<CommandStartedEvent>() .Capture<CommandSucceededEvent>() .Capture<CommandFailedEvent>(); _mockStreamFactory = new Mock<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock<IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _mockStreamFactory.Setup(f => f.CreateStreamAsync(_endPoint, CancellationToken.None)) .Returns(Task.FromResult<Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnection(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(() => new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public BinaryConnection_CommandEventTests() { _capturedEvents = new EventCapturer() .Capture <CommandStartedEvent>() .Capture <CommandSucceededEvent>() .Capture <CommandFailedEvent>(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _mockStreamFactory.Setup(f => f.CreateStreamAsync(_endPoint, CancellationToken.None)) .Returns(Task.FromResult <Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); var connectionId = new ConnectionId(serverId); var isMasterResult = new IsMasterResult(new BsonDocument { { "ok", 1 }, { "maxMessageSizeBytes", 48000000 } }); var buildInfoResult = new BuildInfoResult(new BsonDocument { { "ok", 1 }, { "version", "2.6.3" } }); var connectionDescription = new ConnectionDescription(connectionId, isMasterResult, buildInfoResult); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer .Setup(i => i.InitializeConnection(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(connectionDescription); _mockConnectionInitializer .Setup(i => i.InitializeConnectionAsync(It.IsAny <IConnection>(), CancellationToken.None)) .ReturnsAsync(connectionDescription); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock<IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnection(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public void Setup() { _capturedEvents = new EventCapturer(); _streamFactory = Substitute.For <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For <IConnectionInitializer>(); _connectionInitializer.InitializeConnection(null, CancellationToken.None) .ReturnsForAnyArgs(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); }
public void Setup() { _capturedEvents = new EventCapturer(); _streamFactory = Substitute.For<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For<IConnectionInitializer>(); _connectionInitializer.InitializeConnection(null, CancellationToken.None) .ReturnsForAnyArgs(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); }
public SendMessagesHelper(BinaryConnection connection, IEnumerable <RequestMessage> messages, MessageEncoderSettings messageEncoderSettings) { _connection = connection; _messages = messages.ToList(); _messageEncoderSettings = messageEncoderSettings; _commandStopwatch = Stopwatch.StartNew(); _requestIds = new Lazy <List <int> >(() => _messages.Select(m => m.RequestId).ToList()); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); var connectionId = new ConnectionId(serverId); var helloResult = new HelloResult(new BsonDocument { { "ok", 1 }, { "maxMessageSizeBytes", 48000000 }, { "maxWireVersion", WireVersion.Server36 } }); _connectionDescription = new ConnectionDescription(connectionId, helloResult); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer .Setup(i => i.SendHello(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(_connectionDescription); _mockConnectionInitializer .Setup(i => i.Authenticate(It.IsAny <IConnection>(), It.IsAny <ConnectionDescription>(), CancellationToken.None)) .Returns(_connectionDescription); _mockConnectionInitializer .Setup(i => i.SendHelloAsync(It.IsAny <IConnection>(), CancellationToken.None)) .ReturnsAsync(_connectionDescription); _mockConnectionInitializer .Setup(i => i.AuthenticateAsync(It.IsAny <IConnection>(), It.IsAny <ConnectionDescription>(), CancellationToken.None)) .ReturnsAsync(_connectionDescription); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public ReceiveMessageHelper(BinaryConnection connection, int responseTo, MessageEncoderSettings messageEncoderSettings) { _connection = connection; _responseTo = responseTo; _messageEncoderSettings = messageEncoderSettings; }
public OpenConnectionHelper(BinaryConnection connection) { _connection = connection; }
public SendMessagesHelper(BinaryConnection connection, IEnumerable<RequestMessage> messages, MessageEncoderSettings messageEncoderSettings) { _connection = connection; _messages = messages.ToList(); _messageEncoderSettings = messageEncoderSettings; _commandStopwatch = Stopwatch.StartNew(); _requestIds = new Lazy<List<int>>(() => _messages.Select(m => m.RequestId).ToList()); }