コード例 #1
0
        public TenantServiceShould()
        {
            var fixture = TestFixture.Create();

            testUser        = fixture.Create <PlannerAppUser>();
            mockHttpContext = MockHttpContext.CreateAuthenticatedHttpContext();
            var httpContextMock = new Mock <IHttpContextAccessor>();

            httpContextMock.Setup(m => m.HttpContext)
            .Returns(mockHttpContext);
            userManagerWrapperMock = new Mock <IUserManagerWrapper>();
            userManagerWrapperMock.Setup(m => m.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(testUser);
            sut = new TenantService(httpContextMock.Object, userManagerWrapperMock.Object);
        }
コード例 #2
0
 public SignInUserCommandShould()
 {
     fixture = TestFixture.Create();
     mocker  = new AutoMoqer();
     user    = new PlannerAppUser
     {
         Email    = EMAIL,
         TenantID = TENANTID
     };
     mocker.SetInstance <IConfiguration>(new ConfigurationMock());
     mocker.GetMock <IUserService>()
     .Setup(u => u.SignIn(It.IsAny <string>(), It.IsAny <string>()))
     .ReturnsAsync(user);
     sut = mocker.Create <SignInUserCommand>();
 }
コード例 #3
0
 public RegisterNewUserCommandShould()
 {
     registerModel = new RegisterModel
     {
         Email           = EMAIL,
         Password        = PASSWORD,
         ConfirmPassword = PASSWORD
     };
     userServiceMock = new Mock <IUserService>();
     userServiceMock
     .Setup(u => u.CreateUser(It.IsAny <PlannerAppUser>(), It.IsAny <string>()))
     .Callback <PlannerAppUser, string>((PlannerAppUser user, string password) =>
     {
         this.user = user;
     })
     .Returns(Task.FromResult(IdentityResult.Success));
     sut = new RegisterNewUserCommand(userServiceMock.Object);
 }
コード例 #4
0
 public async Task <IdentityResult> CreateUser(PlannerAppUser user, string password)
 {
     return(await userManager.CreateAsync(user, password));
 }