Пример #1
0
        public void TestGetConnection()
        {
            var connection1 = ConnectionFactoryFactory.GetConnection(string.Empty);
            var connection2 = ConnectionFactoryFactory.GetConnection(string.Empty);

            Assert.IsNotNull(connection1);
            Assert.IsNotNull(connection2);
            Assert.AreEqual(1, ConnectionFactoryFactory.PoolCount);
        }
Пример #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "Mongo" /> class.
        /// </summary>
        /// <param name = "configuration">The mongo configuration.</param>
        public Mongo(MongoConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            configuration.ValidateAndSeal();

            _configuration = configuration;
            _connection    = ConnectionFactoryFactory.GetConnection(configuration.ConnectionString);
        }
Пример #3
0
        public void TestSendQueryMessage()
        {
            //Connection conn = new Connection("10.141.153.2");
            var conn = ConnectionFactoryFactory.GetConnection(string.Empty);

            conn.Open();

            var qmsg = GenerateQueryMessage();

            conn.SendTwoWayMessage(qmsg, string.Empty);

            conn.Close();
        }
Пример #4
0
        public void TestReconnectOnce()
        {
            var conn = ConnectionFactoryFactory.GetConnection(string.Empty);

            conn.Open();

            WriteBadMessage(conn);
            try
            {
                var qmsg = GenerateQueryMessage();
                conn.SendTwoWayMessage(qmsg, string.Empty);
            }
            catch (IOException)
            {
                //Should be able to resend.
                Assert.IsTrue(conn.IsConnected);
                var qmsg = GenerateQueryMessage();
                var rmsg = conn.SendTwoWayMessage(qmsg, string.Empty);
                Assert.IsNotNull(rmsg);
            }
        }