public async Task CreateUserOfUserNotInSystemShouldWork(string userName, string userRole, string userEmail) { User?enteredUser = null; User?returnedUser = null; await using (var ctx = new TestKitchenRpContext(_options)) { ctx.Database.EnsureCreated(); var users = new UserRepository(ctx, new RolesRepository(ctx)); enteredUser = await users.CreateNewUser(userName, userRole, userEmail); } await using (var ctx = new TestKitchenRpContext(_options)) { var users = new UserRepository(ctx, new RolesRepository(ctx)); Assert.NotNull(enteredUser.Id); returnedUser = await users.FindById(enteredUser.Id.Value); } Assert.NotNull(returnedUser); Assert.Equal(returnedUser.Id, enteredUser.Id); Assert.Equal(returnedUser.Email, enteredUser.Email); Assert.Equal(returnedUser.Sub, enteredUser.Sub); Assert.Equal(returnedUser.AllowNotifications, enteredUser.AllowNotifications); Assert.Equal(returnedUser.Role?.Id, enteredUser.Role?.Id); Assert.Equal(returnedUser.Email, userEmail); Assert.Equal(returnedUser.Sub, userName); Assert.Equal(returnedUser.Role?.RoleName, userRole); }
// [Theory] // [InlineData("a", "aba", "[email protected]")] // [InlineData("a", "ba", "[email protected]")] // [InlineData("a", "afd", null)] public async Task CreateUserOfUserWithNotExistingRoleShouldThrow(string userName, string userRole, string userEmail) { await using (var ctx = new TestKitchenRpContext(_options)) { ctx.Database.EnsureCreated(); var users = new UserRepository(ctx, new RolesRepository(ctx)); await Assert.ThrowsAsync <NotFoundException>(async() => await users.CreateNewUser(userName, userRole, userEmail)); } }