Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Fact]
- public async Task Test_Create_User()
- {
- var options = new DbContextOptionsBuilder<TinRollContext>()
- .UseInMemoryDatabase(databaseName: "Create_User")
- .Options;
- var newUser = new User
- {
- Email = "test@email.com",
- UserName = "userName"
- };
- int ? userId = null;
- //create user in memory database
- using (var context = new TinRollContext(options))
- {
- var userRepository = new UserRepository(context);
- userId = await userRepository.CreateUserAsync(newUser);
- }
- Assert.NotNull(userId);
- //check to make sure it exists
- using (var context = new TinRollContext(options))
- {
- var userCount = await context.Users.CountAsync();
- Assert.Equal(1, userCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement