public async Task Create_RoleIdStringArgument()
        {
            var usersAndRolesDbContextId = Guid.NewGuid().ToString();

            await using (var usersAndRolesDbContext = InMemoryUserAndRolesDbContext(usersAndRolesDbContextId))
            {
                var repository = new UserInviteRepository(usersAndRolesDbContext);
                var userInvite = await repository.Create("*****@*****.**", Role.Analyst.GetEnumValue(), _createdById);

                Assert.Equal("*****@*****.**", userInvite.Email);
                Assert.Equal(Role.Analyst.GetEnumValue(), userInvite.RoleId);
                Assert.Equal(_createdById.ToString(), userInvite.CreatedById);
                Assert.InRange(DateTime.UtcNow.Subtract(userInvite.Created).Milliseconds, 0, 1500);
            }

            await using (var usersAndRolesDbContext = InMemoryUserAndRolesDbContext(usersAndRolesDbContextId))
            {
                var userInvite = usersAndRolesDbContext.UserInvites
                                 .AsQueryable()
                                 .Single();

                Assert.Equal("*****@*****.**", userInvite.Email);
                Assert.Equal(Role.Analyst.GetEnumValue(), userInvite.RoleId);
                Assert.Equal(_createdById.ToString(), userInvite.CreatedById);
                Assert.InRange(DateTime.UtcNow.Subtract(userInvite.Created).Milliseconds, 0, 1500);
            }
        }
예제 #2
0
 public ProviderWorkerManager(IHttpContextAccessor httpContextAccessor, AppUserManager appUserManager, IMapper mapper, ILoggerFactory loggerFactory,
                              AppUserRepository appUserRepository, ProviderRepository providerRepository, UserInviteRepository userInviteRepository) : base(httpContextAccessor, appUserManager, mapper, loggerFactory)
 {
     _appUserRepository    = appUserRepository;
     _providerRepository   = providerRepository;
     _userInviteRepository = userInviteRepository;
 }
        public async Task Create_RoleArgument_ExistingInvite()
        {
            var usersAndRolesDbContextId = Guid.NewGuid().ToString();

            await using (var usersAndRolesDbContext = InMemoryUserAndRolesDbContext(usersAndRolesDbContextId))
            {
                await usersAndRolesDbContext.AddAsync(new UserInvite
                {
                    Email       = "*****@*****.**",
                    RoleId      = Role.BauUser.GetEnumValue(),
                    CreatedById = _createdById.ToString(),
                    Created     = new DateTime(2000, 1, 1),
                });

                await usersAndRolesDbContext.SaveChangesAsync();
            }

            await using (var usersAndRolesDbContext = InMemoryUserAndRolesDbContext(usersAndRolesDbContextId))
            {
                var repository = new UserInviteRepository(usersAndRolesDbContext);
                var userInvite = await repository.Create("*****@*****.**", Role.Analyst, _createdById);

                Assert.Equal("*****@*****.**", userInvite.Email);
                Assert.Equal(Role.BauUser.GetEnumValue(), userInvite.RoleId);
                Assert.Equal(_createdById.ToString(), userInvite.CreatedById);
                Assert.Equal(new DateTime(2000, 1, 1), userInvite.Created);
            }

            await using (var usersAndRolesDbContext = InMemoryUserAndRolesDbContext(usersAndRolesDbContextId))
            {
                var userInvite = usersAndRolesDbContext.UserInvites
                                 .AsQueryable()
                                 .Single();

                Assert.Equal("*****@*****.**", userInvite.Email);
                Assert.Equal(Role.BauUser.GetEnumValue(), userInvite.RoleId);
                Assert.Equal(_createdById.ToString(), userInvite.CreatedById);
                Assert.Equal(new DateTime(2000, 1, 1), userInvite.Created);
            }
        }