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); }
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>(); }
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); }
public async Task <IdentityResult> CreateUser(PlannerAppUser user, string password) { return(await userManager.CreateAsync(user, password)); }