Exemple #1
0
        private TestConnectionHander GetConnectionHandler(IConnectionFactory conFactory)
        {
            var conHandler = new TestConnectionHander();

            conHandler.SetConnectionFactory(conFactory);
            return(conHandler);
        }
Exemple #2
0
        public void EstablishConnection_ConnectionFactoryThrowsSomeException_Throw()
        {
            var mock     = new Mock <IConnectionFactory>();
            var expected = new Exception("someException");

            mock.Setup(x => x.CreateConnection()).Throws(expected);
            var connectionHandler = new TestConnectionHander();

            connectionHandler.SetConnectionFactory(mock.Object);

            var actual = Assert.Throws <Exception>(() => connectionHandler.EstablishConnection());

            Assert.Equal(expected, actual);
        }