tags:

views:

52

answers:

0

I don't understand this behavior.

This works:

<TestMethod()> _
<DataSource("System.Data.SqlClient", _
            "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True", _
            "MyTable", DataAccessMethod.Sequential)> _
Public Sub TestWithoutConstant()
    Assert.IsNotNull(TestContext.DataRow)
End Sub

But this does not work:

Public Const MyConnectionStringConstant As String = _
    "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True"

<TestMethod()> _
<DataSource("System.Data.SqlClient", _
            MyConnectionStringConstant, _
            "MyTable", DataAccessMethod.Sequential)> _
Public Sub TestWithConstant()
    Assert.IsNotNull(TestContext.DataRow)
End Sub

In the first test I use a string literal as the connection string.
In the second test I use a string constant as the connection string.

Anybody have any ideas?

Update: TestContext.DataRow is not null in the first test, but is null in the second test. The failed assert error message is "Assert.IsNotNull failed."