Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. [Fact]
  2. public async Task Test_Create_User()
  3. {
  4. var options = new DbContextOptionsBuilder<TinRollContext>()
  5. .UseInMemoryDatabase(databaseName: "Create_User")
  6. .Options;
  7.  
  8. var newUser = new User
  9. {
  10. Email = "test@email.com",
  11. UserName = "userName"
  12. };
  13.  
  14. int ? userId = null;
  15. //create user in memory database
  16. using (var context = new TinRollContext(options))
  17. {
  18. var userRepository = new UserRepository(context);
  19. userId = await userRepository.CreateUserAsync(newUser);
  20. }
  21.  
  22. Assert.NotNull(userId);
  23. //check to make sure it exists
  24. using (var context = new TinRollContext(options))
  25. {
  26. var userCount = await context.Users.CountAsync();
  27. Assert.Equal(1, userCount);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement