Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Fact]
- [ResetDatabase]
- public async Task ShouldEditEmployee()
- {
- var employee = new Employee
- {
- Email = "jane@jane.com",
- FirstName = "Jane",
- LastName = "Smith",
- Title = "Director",
- Office = Office.Austin,
- PhoneNumber = "512-555-4321",
- Username = "janesmith",
- HashedPassword = "1234567890"
- };
- await _fixture.ExecuteDbContextAsync(async dbContext =>
- {
- dbContext.Employees.Add(employee);
- await dbContext.SaveChangesAsync();
- });
- var command = new Edit.Command
- {
- Id = employee.Id,
- Email = "jane@jane2.com",
- FirstName = "Jane2",
- LastName = "Smith2",
- Office = Office.Dallas,
- Title = "CEO",
- PhoneNumber = "512-555-9999"
- };
- await _fixture.ExecuteScopeAsync(async container =>
- {
- var mediator = container.GetService<IMediator>();
- await mediator.SendAsync(command);
- });
- await _fixture.ExecuteDbContextAsync(async dbContext =>
- {
- var found = await dbContext.Employees.FindAsync(employee.Id);
- found.Email.ShouldBe(command.Email);
- found.FirstName.ShouldBe(command.FirstName);
- found.LastName.ShouldBe(command.LastName);
- found.Office.ShouldBe(command.Office);
- found.Title.ShouldBe(command.Title);
- found.PhoneNumber.ShouldBe(command.PhoneNumber);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement