Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. [Fact]
  2. [ResetDatabase]
  3. public async Task ShouldEditEmployee()
  4. {
  5. var employee = new Employee
  6. {
  7. Email = "jane@jane.com",
  8. FirstName = "Jane",
  9. LastName = "Smith",
  10. Title = "Director",
  11. Office = Office.Austin,
  12. PhoneNumber = "512-555-4321",
  13. Username = "janesmith",
  14. HashedPassword = "1234567890"
  15. };
  16.  
  17. await _fixture.ExecuteDbContextAsync(async dbContext =>
  18. {
  19. dbContext.Employees.Add(employee);
  20. await dbContext.SaveChangesAsync();
  21. });
  22.  
  23. var command = new Edit.Command
  24. {
  25. Id = employee.Id,
  26. Email = "jane@jane2.com",
  27. FirstName = "Jane2",
  28. LastName = "Smith2",
  29. Office = Office.Dallas,
  30. Title = "CEO",
  31. PhoneNumber = "512-555-9999"
  32. };
  33.  
  34. await _fixture.ExecuteScopeAsync(async container =>
  35. {
  36. var mediator = container.GetService<IMediator>();
  37.  
  38. await mediator.SendAsync(command);
  39. });
  40.  
  41. await _fixture.ExecuteDbContextAsync(async dbContext =>
  42. {
  43. var found = await dbContext.Employees.FindAsync(employee.Id);
  44.  
  45. found.Email.ShouldBe(command.Email);
  46. found.FirstName.ShouldBe(command.FirstName);
  47. found.LastName.ShouldBe(command.LastName);
  48. found.Office.ShouldBe(command.Office);
  49. found.Title.ShouldBe(command.Title);
  50. found.PhoneNumber.ShouldBe(command.PhoneNumber);
  51. });
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement