Пример #1
0
        public void SetUpTests()
        {
            //setup server parks
            _serverParkName = "tel";

            _serverParkMock = new Mock <IServerPark>();
            _serverParkMock.Setup(s => s.Name).Returns(_serverParkName);

            var serverParkItems = new List <IServerPark> {
                _serverParkMock.Object
            };

            _serverParkCollectionMock = new Mock <IServerParkCollection>();
            _serverParkCollectionMock.Setup(s => s.GetEnumerator()).Returns(() => serverParkItems.GetEnumerator());

            //setup connection
            _connectedServerMock = new Mock <IConnectedServer>();
            _connectedServerMock.Setup(c => c.ServerParks).Returns(_serverParkCollectionMock.Object);
            _connectedServerMock.Setup(c => c.GetServerPark(_serverParkName)).Returns(_serverParkMock.Object);

            _connectionFactoryMock = new Mock <IConnectedServerFactory>();
            _connectionFactoryMock.Setup(c => c.GetConnection(_connectionModel)).Returns(_connectedServerMock.Object);

            //setup service under test
            _sut = new ServerParkService(_connectionFactoryMock.Object);
        }