Beispiel #1
0
        public void Should_map_all_properties()
        {
            var user    = new UserBuilder(EmailData.FAKE_EMAIL_STEM, 1).BuildUser();
            var userDto = UserToUserDtoMapper.Map(user);

            userDto.Should().BeEquivalentTo(user);
        }
Beispiel #2
0
        public async Task <UserDto> Handle(GetUserByUsernameQuery query)
        {
            var user = await _context.Users
                       .AsNoTracking()
                       .SingleOrDefaultAsync(x => x.Username.ToLower() == query.Username.ToLower());

            return(user == null ? null : UserToUserDtoMapper.Map(user));
        }
        public async Task <UserDto> Handle(GetUserByUserTypeAppAndNumberQuery query)
        {
            var user = await _context.Users
                       .AsNoTracking()
                       .SingleOrDefaultAsync(x => x.UserType == query.UserType.MapToContractEnum() &&
                                             x.Application == query.Application.MapToContractEnum() &&
                                             x.Number == query.Number &&
                                             x.IsProdUser == query.IsProdUser);

            return(user == null ? null : UserToUserDtoMapper.Map(user));
        }
        public async Task <UserDto> SeedUser(TestType testType, UserType userType = UserType.Judge)
        {
            await using var db = new TestApiDbContext(_dbContextOptions);

            const Application APPLICATION  = Application.TestApi;
            const bool        IS_PROD_USER = false;

            var number = await IterateUserNumber(userType, APPLICATION, IS_PROD_USER, testType);

            var user = new UserBuilder(_context.Config.UsernameStem, number)
                       .WithUserType(userType)
                       .ForApplication(APPLICATION)
                       .ForTestType(testType)
                       .BuildUser();

            await db.Users.AddAsync(user);

            await db.SaveChangesAsync();

            return(UserToUserDtoMapper.Map(user));
        }
        public async Task <UserDto> SeedUser(UserType userType = UserType.Judge, bool isProdUser = false)
        {
            await using var db = new TestApiDbContext(_dbContextOptions);

            const Application application = Application.TestApi;
            const TestType    testType    = TestType.Automated;

            var number = await IterateUserNumber(userType, application, isProdUser, testType);

            var user = new UserBuilder(_context.Config.UsernameStem, number)
                       .WithUserType(userType)
                       .ForApplication(application)
                       .IsProdUser(isProdUser)
                       .BuildUser();

            await db.Users.AddAsync(user);

            await db.SaveChangesAsync();

            return(UserToUserDtoMapper.Map(user));
        }