I am learning Microsofts built in Unit Testing capability in VS2010 and came across a problem.
[TestClass]
public class HomeControllerTest
{
[TestMethod]
public void SomeTest()
{
//Arrange
HomeController controller = new HomeController();
//Act
ViewResult results = controller.Index() as ViewResult;
//Assert
ViewDataDictionary viewData = results.ViewData;
Assert.AreEqual(null, viewData["Message"]);
}
}
I know this will return failed, that isn't an issue. What is an issue however is that I am hitting my EntityFramework model "myModel.edmx" and getting the error "System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
This is in the file MyModel.Designer.cs. The line in question is:
public Tool_Entities() : base("name=Tool_Entities", "Tool_Entities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
I know this line is ok as when I run the non-test project, I can connect to this model fine.