Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 调试Microsoft.AspNet.Identity.Core pdb_Debugging_Visual Studio 2012_Task_Asp.net Identity_Symbols - Fatal编程技术网

Debugging 调试Microsoft.AspNet.Identity.Core pdb

Debugging 调试Microsoft.AspNet.Identity.Core pdb,debugging,visual-studio-2012,task,asp.net-identity,symbols,Debugging,Visual Studio 2012,Task,Asp.net Identity,Symbols,我尝试在Microsoft.AspNet.Identity.Core上实现注册库。 package.config: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="EntityFramework" version="6.1.3" targetFramework="net451" /> <package id="Microsoft.AspNet.Identity.Cor

我尝试在Microsoft.AspNet.Identity.Core上实现注册库。

package.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>
public class register_test
    {
        Mock<IUserStore<ApplicationUser>> _userStore;
        IRegisterService _registerService;
        Mock<ApplicationUserManager> _userManagerMock;
        IDataProtectionProvider _dataProvider;


        public register_test()
        {
            _dataProvider = new DpapiDataProtectionProvider("paracours");
            _userStore = new Mock<IUserStore<ApplicationUser>>();
            _userManagerMock = new Mock<ApplicationUserManager>(_userStore.Object, _dataProvider);
            _registerService = new RegisterService(_userManagerMock.Object);
        }
        [Fact]
        public async Task register_sucess()
        {
            ApplicationUser user = new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr" };
            _userManagerMock.Setup(u => u.CreateAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>()))
                .ReturnsAsync(IdentityResult.Success)
                .Callback(() => user.Id = "0f8fad5b-d9cb-469f-a165-70867728950e");


            var result = await _registerService.RegisterAsync(user);

            _userManagerMock.Verify(x =>
                x.CreateAsync(
                It.Is<ApplicationUser>(u => u.Email == "user1@test.fr"),
                It.Is<string>(pass => pass == "P@ssword1")));

            Assert.NotNull(result);
            Assert.Equal(user.Id, "0f8fad5b-d9cb-469f-a165-70867728950e");

        }

        [Fact]
        public void email_token_generation_success()
        {

            _userManagerMock.Setup(u => u.FindByIdAsync(It.IsAny<string>()))
               .ReturnsAsync(new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr", EmailConfirmed = false });
            var result = _registerService.EmailToken("0f8fad5b-d9cb-469f-a165-70867728950e");

            Assert.NotNull(result);

        }
    }
public class RegisterService : IRegisterService
{
    private readonly ApplicationUserManager _userManager;


    public RegisterService() { }

    public RegisterService(ApplicationUserManager userManager)
    {
        _userManager = userManager;
    }

    public virtual async Task<IdentityResult> RegisterAsync(ApplicationUser user)
    {
        return await _userManager.CreateAsync(user, "P@ssword1");
    }

    public virtual string EmailToken(string userId)
    {
        return _userManager.GenerateEmailConfirmationToken(userId);

    }
}

我的单元测试类:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>
public class register_test
    {
        Mock<IUserStore<ApplicationUser>> _userStore;
        IRegisterService _registerService;
        Mock<ApplicationUserManager> _userManagerMock;
        IDataProtectionProvider _dataProvider;


        public register_test()
        {
            _dataProvider = new DpapiDataProtectionProvider("paracours");
            _userStore = new Mock<IUserStore<ApplicationUser>>();
            _userManagerMock = new Mock<ApplicationUserManager>(_userStore.Object, _dataProvider);
            _registerService = new RegisterService(_userManagerMock.Object);
        }
        [Fact]
        public async Task register_sucess()
        {
            ApplicationUser user = new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr" };
            _userManagerMock.Setup(u => u.CreateAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>()))
                .ReturnsAsync(IdentityResult.Success)
                .Callback(() => user.Id = "0f8fad5b-d9cb-469f-a165-70867728950e");


            var result = await _registerService.RegisterAsync(user);

            _userManagerMock.Verify(x =>
                x.CreateAsync(
                It.Is<ApplicationUser>(u => u.Email == "user1@test.fr"),
                It.Is<string>(pass => pass == "P@ssword1")));

            Assert.NotNull(result);
            Assert.Equal(user.Id, "0f8fad5b-d9cb-469f-a165-70867728950e");

        }

        [Fact]
        public void email_token_generation_success()
        {

            _userManagerMock.Setup(u => u.FindByIdAsync(It.IsAny<string>()))
               .ReturnsAsync(new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr", EmailConfirmed = false });
            var result = _registerService.EmailToken("0f8fad5b-d9cb-469f-a165-70867728950e");

            Assert.NotNull(result);

        }
    }
public class RegisterService : IRegisterService
{
    private readonly ApplicationUserManager _userManager;


    public RegisterService() { }

    public RegisterService(ApplicationUserManager userManager)
    {
        _userManager = userManager;
    }

    public virtual async Task<IdentityResult> RegisterAsync(ApplicationUser user)
    {
        return await _userManager.CreateAsync(user, "P@ssword1");
    }

    public virtual string EmailToken(string userId)
    {
        return _userManager.GenerateEmailConfirmationToken(userId);

    }
}
公共类寄存器\u测试
{
模拟用户商店;
IRegisterService\u registerService;
模拟用户管理器控制台;
IDataProtectionProvider\u数据提供者;
公共寄存器_测试()
{
_dataProvider=新的DpapiDataProtectionProvider(“paracours”);
_userStore=newmock();
_userManagerMock=new Mock(_userStore.Object,_dataProvider);
_registerService=newregisterservice(\u userManagerMock.Object);
}
[事实]
公共异步任务寄存器\u sucess()
{
ApplicationUser用户=新的ApplicationUser(){Email=”user1@test.fr“,用户名=”user1@test.fr" };
_userManagerMock.Setup(u=>u.CreateAsync(It.IsAny(),It.IsAny())
.ReturnsAsync(IdentityResult.Success)
.Callback(()=>user.Id=“0f8fad5b-d9cb-469f-a165-70867728950e”);
var result=await\u registerService.registerSync(用户);
_userManagerMock.Verify(x=>
x、 创建异步(
它是(u=>u.Email==”user1@test.fr"),
它是(通过=>通过==”P@ssword1")));
Assert.NotNull(结果);
断言相等(user.Id,“0f8fad5b-d9cb-469f-a165-70867728950e”);
}
[事实]
公共无效电子邮件\u令牌\u生成\u成功()
{
_userManagerMock.Setup(u=>u.FindByIdAsync(It.IsAny()))
.ReturnsAsync(新应用程序用户(){Email=”user1@test.fr“,用户名=”user1@test.fr“,emailconfirm=false});
var结果=_registerService.EmailToken(“0f8fad5b-d9cb-469f-a165-70867728950e”);
Assert.NotNull(结果);
}
}

我的服务:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>
public class register_test
    {
        Mock<IUserStore<ApplicationUser>> _userStore;
        IRegisterService _registerService;
        Mock<ApplicationUserManager> _userManagerMock;
        IDataProtectionProvider _dataProvider;


        public register_test()
        {
            _dataProvider = new DpapiDataProtectionProvider("paracours");
            _userStore = new Mock<IUserStore<ApplicationUser>>();
            _userManagerMock = new Mock<ApplicationUserManager>(_userStore.Object, _dataProvider);
            _registerService = new RegisterService(_userManagerMock.Object);
        }
        [Fact]
        public async Task register_sucess()
        {
            ApplicationUser user = new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr" };
            _userManagerMock.Setup(u => u.CreateAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>()))
                .ReturnsAsync(IdentityResult.Success)
                .Callback(() => user.Id = "0f8fad5b-d9cb-469f-a165-70867728950e");


            var result = await _registerService.RegisterAsync(user);

            _userManagerMock.Verify(x =>
                x.CreateAsync(
                It.Is<ApplicationUser>(u => u.Email == "user1@test.fr"),
                It.Is<string>(pass => pass == "P@ssword1")));

            Assert.NotNull(result);
            Assert.Equal(user.Id, "0f8fad5b-d9cb-469f-a165-70867728950e");

        }

        [Fact]
        public void email_token_generation_success()
        {

            _userManagerMock.Setup(u => u.FindByIdAsync(It.IsAny<string>()))
               .ReturnsAsync(new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr", EmailConfirmed = false });
            var result = _registerService.EmailToken("0f8fad5b-d9cb-469f-a165-70867728950e");

            Assert.NotNull(result);

        }
    }
public class RegisterService : IRegisterService
{
    private readonly ApplicationUserManager _userManager;


    public RegisterService() { }

    public RegisterService(ApplicationUserManager userManager)
    {
        _userManager = userManager;
    }

    public virtual async Task<IdentityResult> RegisterAsync(ApplicationUser user)
    {
        return await _userManager.CreateAsync(user, "P@ssword1");
    }

    public virtual string EmailToken(string userId)
    {
        return _userManager.GenerateEmailConfirmationToken(userId);

    }
}
公共类注册服务:IRegisterService
{
专用只读应用程序userManager\u userManager;
公共注册表服务(){}
公共注册服务(ApplicationUserManager用户管理器)
{
_userManager=userManager;
}
公共虚拟异步任务注册表同步(ApplicationUser用户)
{
返回wait\u userManager.CreateAsync(用户,“P@ssword1");
}
公共虚拟字符串EmailToken(字符串用户ID)
{
return _userManager.GenerateEmailConfirmationToken(userId);
}
}
我的调试配置:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
</packages>
public class register_test
    {
        Mock<IUserStore<ApplicationUser>> _userStore;
        IRegisterService _registerService;
        Mock<ApplicationUserManager> _userManagerMock;
        IDataProtectionProvider _dataProvider;


        public register_test()
        {
            _dataProvider = new DpapiDataProtectionProvider("paracours");
            _userStore = new Mock<IUserStore<ApplicationUser>>();
            _userManagerMock = new Mock<ApplicationUserManager>(_userStore.Object, _dataProvider);
            _registerService = new RegisterService(_userManagerMock.Object);
        }
        [Fact]
        public async Task register_sucess()
        {
            ApplicationUser user = new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr" };
            _userManagerMock.Setup(u => u.CreateAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>()))
                .ReturnsAsync(IdentityResult.Success)
                .Callback(() => user.Id = "0f8fad5b-d9cb-469f-a165-70867728950e");


            var result = await _registerService.RegisterAsync(user);

            _userManagerMock.Verify(x =>
                x.CreateAsync(
                It.Is<ApplicationUser>(u => u.Email == "user1@test.fr"),
                It.Is<string>(pass => pass == "P@ssword1")));

            Assert.NotNull(result);
            Assert.Equal(user.Id, "0f8fad5b-d9cb-469f-a165-70867728950e");

        }

        [Fact]
        public void email_token_generation_success()
        {

            _userManagerMock.Setup(u => u.FindByIdAsync(It.IsAny<string>()))
               .ReturnsAsync(new ApplicationUser() { Email = "user1@test.fr", UserName = "user1@test.fr", EmailConfirmed = false });
            var result = _registerService.EmailToken("0f8fad5b-d9cb-469f-a165-70867728950e");

            Assert.NotNull(result);

        }
    }
public class RegisterService : IRegisterService
{
    private readonly ApplicationUserManager _userManager;


    public RegisterService() { }

    public RegisterService(ApplicationUserManager userManager)
    {
        _userManager = userManager;
    }

    public virtual async Task<IdentityResult> RegisterAsync(ApplicationUser user)
    {
        return await _userManager.CreateAsync(user, "P@ssword1");
    }

    public virtual string EmailToken(string userId)
    {
        return _userManager.GenerateEmailConfirmationToken(userId);

    }
}
  • 取消选中“仅调试我的代码”
  • 选中“激活soupport源服务器” 调试符号
  • 微软服务器 与(http://before)
  • srv.symbolsource.org/pdb/MyGet
  • referencesource.microsoft.com/symbols
  • msdl.microsoft.com/download/symbols
  • msdl.microsoft.com/download/symbols


    我这样做:
    将断点放在:

    公共虚拟字符串EmailToken(字符串用户ID){ return _userManager.GenerateEmailConfirmationToken(userId); }


当我触摸F11时,它会转到:

使用系统;
使用System.Collections.Generic;
使用System.Security.Claims;
命名空间Microsoft.AspNet.Identity
{
/// 
///UserManager的扩展方法
/// 
公共静态类usermanager
{
...
/// 
///获取用户的确认令牌
/// 
/// 
/// 
/// 
公共静态字符串GenerateEmailConfirmationToken(此UserManager,
TKey用户ID)
其中TKey:IEquatable
托瑟:上课,尤瑟
{
if(manager==null)
{
抛出新异常(“管理器”);
}
返回AsyncHelper.RunSync(()=>manager.GenerateEmailConfirmationTokenAsync(userId));
}
...
}
}

我不知道如何调试: manager.GenerateEmailConfirmationTokenAsync(userId)
在…内
AsyncHelper.RunSync(()=>

我需要等待,这对我来说是一项新任务,调试我自己解决我的问题。 当我模拟ApplicationUserManager时:

新的Mock(_userStore.Object,_dataProvider)

创建无法在符号(.pdb)中解析的GenerateEmailConfirmationToken=>的Castle.proxy

解决方案是不要模拟ApplicationUserManager