Exemple #1
0
        public void DictionaryWithParametersValue_ReturnsCorrectlyComposedOleDbParameters()
        {
            // Arrange
            var sqlServerProvider = new OleDbProvider("fakeConnectionString");
            var parametersDictionary = new Dictionary<string, object>
            {
                {"TestParameterInt", 123},
                {"TestParameterString", "TestStringValue"}
            };

            // Act
            IEnumerable<IDataParameter> parameters = sqlServerProvider.CreateParameters(parametersDictionary);

            // Assert
            var oleDbParameterInt = parameters.ElementAt(0) as OleDbParameter;
            var oleDbParameterString = parameters.ElementAt(1) as OleDbParameter;

            Assert.IsNotNull(oleDbParameterInt);
            Assert.AreEqual("?", oleDbParameterInt.ParameterName);
            Assert.AreEqual(123, oleDbParameterInt.Value);

            Assert.IsNotNull(oleDbParameterString);
            Assert.AreEqual("?", oleDbParameterString.ParameterName);
            Assert.AreEqual("TestStringValue", oleDbParameterString.Value);
        }
Exemple #2
0
        public void ConnectionString_ReturnsOleDbConnection()
        {
            // Arrange
            var oleDbProvider = new OleDbProvider(TestConnectionString);

            // Act
            var oleDbConnection = oleDbProvider.CreateConnection();

            // Assert
            Assert.IsInstanceOf<OleDbConnection>(oleDbConnection);
            Assert.AreEqual(TestConnectionString, oleDbConnection.ConnectionString);
        }
Exemple #3
0
        public void QueryOleDbConnectionAndCommandType_ReturnsCorrectlyComposedOleDbCommand()
        {
            // Arrange
            var oleDbProvider = new OleDbProvider(TestConnectionString) { CommandTimeout = CommandTimeout };
            var mockOleDbConnection = new OleDbConnection(TestConnectionString);

            // Act
            var command = oleDbProvider.CreateCommand(SelectQuery, mockOleDbConnection, CommandType.Text);

            // Assert
            Assert.IsInstanceOf<OleDbCommand>(command);
            Assert.AreEqual(SelectQuery, command.CommandText);
            Assert.AreEqual(mockOleDbConnection, command.Connection);
            Assert.AreEqual(CommandType.Text, command.CommandType);
            Assert.AreEqual(CommandTimeout, command.CommandTimeout);
        }