My project is C# MVC5 with Entity Freamework 6.
I have added a test project to the solution.
The first test is just a simple sanity check to ensure all is connected etc, so it just instantiates a class which calls a stored procedure in the constructor.
However I'm having problems because the test project doesn't have an app.config file and EF wants this for the connection details etc.
I appreciate that the client project is the one whose config is used, but this kind of destroys part of the reason for testing as I also want to ensure that the configuration is correct.
Surely there is a way to tell the subject project to use its own config?
Unit test code:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyNamespace.Classes;
namespace MyNamespace_Tests
{
[TestClass]
public class MyTests
{
[TestMethod]
public void Test1()
{
var test = new MyClass(1, 2010, 2, 80000, 25000, 48);
var a = test.Text1;
var b = test.Text2;
Assert.IsTrue(true); // not actually doing a useful test yet
}
}
}
Error is:
System.InvalidOperationException: No connection string named 'Entities' could be found in the application config file.
Aucun commentaire:
Enregistrer un commentaire