0

我正在为我的测试项目创建库。创建库项目时命名空间不起作用。请帮忙

#region(获取记录的用户 ID)

    static public Guid GetUserId()
    {
        Guid guUser = Guid.Empty;

        try
        {
            MembershipUser muUser = Membership.GetUser();
            if (muUser != null)
            {
                guUser = (Guid)muUser.ProviderUserKey;
                Membership.GetUser(guUser, true);
            }
            else
            {
                //Log out and redirect to login page
                FormsAuthentication.SignOut();
                FormsAuthentication.RedirectToLoginPage();
            }
        }
        catch (Exception ex)
        {
            ApplicationError.LogErrors(ex);
        }

        return guUser;
    }

    #endregion
4

1 回答 1

0

如果在单元测试解决方案中进行测试,这将不起作用,因为您的单元测试解决方案必须具有与最终应用程序项目相同的 .config 文件。否则它会完美运行。

于 2013-09-27T12:25:03.487 回答