我试图在会员提供商上进行集成测试......看起来像这样:
[TestClass]
public class UnitTestMembershipProvider
{
[TestMethod]
public void Are_There_Membership_Users()
{
// Arrange
MembershipUserCollection users = Membership.GetAllUsers();
//Assert
Assert.IsTrue(users.Count > 0);
}
}
为什么我会得到以下结果?
Test Name: Are_There_Membership_Users
Test FullName: Something.UnitTests.Controllers.UnitTestMembershipProvider.Are_There_Membership_Users
Test Source: c:\Users\James\Source\Workspaces\Something\Something.UnitTests\Controllers\UnitTestMembershipProvider.cs : line 12
Test Outcome: Failed
Test Duration: 0:00:00.0298722
Result Message:
Test method Something.UnitTests.Controllers.UnitTestMembershipProvider.Are_There_Membership_Users threw exception:
System.UnauthorizedAccessException: Access to the path 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\App_Data' is denied.
Result StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
at System.IO.Directory.CreateDirectory(String path)
at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString)
at System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(String connectionString)
at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
at System.Web.Security.SqlMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers()
at Something.UnitTests.Controllers.UnitTestMembershipProvider.Are_There_Membership_Users() in c:\Users\James\Source\Workspaces\Something\Something.UnitTests\Controllers\UnitTestMembershipProvider.cs:line 14