protected void Arrange() { _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict); _sessionMock = new Mock<ISession>(MockBehavior.Strict); _netConfSessionMock = new Mock<INetConfSession>(MockBehavior.Strict); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _netConfClient.OperationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _sessionMock.InSequence(sequence).Setup(p => p.OnDisconnecting()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _sessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfClient.Connect(); _netConfClient.Disconnect(); }
protected void Arrange() { _serviceFactoryMock = new Mock <IServiceFactory>(MockBehavior.Strict); _sessionMock = new Mock <ISession>(MockBehavior.Strict); _netConfSessionMock = new Mock <INetConfSession>(MockBehavior.Strict); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _operationTimeout = new Random().Next(1000, 10000); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); _netConfClient.OperationTimeout = TimeSpan.FromMilliseconds(_operationTimeout); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _operationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _sessionMock.InSequence(sequence).Setup(p => p.OnDisconnecting()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _sessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfClient.Connect(); _netConfClient.Disconnect(); }
protected override void Arrange() { base.Arrange(); _netConfClient.Connect(); _netConfClient.Disconnect(); }