public ApplicationTests(ApplicationFixture fixture) { _fixture = fixture; _context = fixture.Context; _context.Add(CreateEmailTemplate()); _context.SaveChanges(); }
public void GetAllRolesShouldBeSuccessful() { _context.Add(CreateRole()); _context.SaveChanges(); var mapper = _fixture.GetMapper(new RoleProfile()); var query = new RoleQuery(_context, mapper); var result = query.GetRoles(); result.ShouldNotBeNull(); result.Length.ShouldBeGreaterThanOrEqualTo(1); result.First().Code.ShouldBe("testRole"); }
public Task <TokenUserModel> Handle(AuthenticateCommand request, CancellationToken cancellationToken) { var user = _context.Users .Include(x => x.Roles).ThenInclude(x => x.Role) .AsSplitQuery() .FirstOrDefault(x => x.Email.Equals(request.Email.ToAsciiLower()) && x.Password.Equals(request.Password.ToSha256())) ?? throw new AuthenticateFailedException(); var history = new UserHistory(user, request.IpAddress, request.UserAgent); _context.Add(history); _context.SaveChanges(); return(Task.FromResult(new TokenUserModel { Token = user.GetToken(_configuration["Authentication:Secret"]) })); }