I am having a problem with a unit test I have created. First time doing this so I am not sure why I am getting this error
<DeploymentItem("ETDS.exe")> <DataSource("System.Data.SqlClient", "Data Source=Foo;Initial Catalog=FooDB;Integrated Security=True", "User_Names", DataAccessMethod.Sequential)> <TestMethod()> _
Public Sub ValidateUserNameTest()
Dim target As Login_Accessor = New Login_Accessor ' TODO: Initialize to an appropriate value
Dim expected As Boolean = True ' TODO: Initialize to an appropriate value
Dim actual As Boolean
actual = target.ValidateUserName
Assert.AreEqual(expected, actual)
End Sub
The error I am getting is
Test method ETDS_Unit_Tests.LoginTest.ValidateUserNameTest
threw exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).
This is the same connection that my software is using, and the software runs fine, only the unit test is failing. What I am doing wrong?
Edit It Seems to fail one time for each datarow in the table. Also, I am using a Linq Query in the method that I being tested. I believe that this may be what is causing my error.