public async Task Should_commit_UserCreated_to_Outbox_when_Handler_is_called(CreateUser.Command command, [Frozen] Mock <IOutboxListener> outboxMock) { var handler = new CreateUser.Handler(outboxMock.Object, _db); await handler.Handle(command, CancellationToken.None); outboxMock.Verify(x => x.Commit(It.IsAny <UserCreated>()), Times.Once); }
public async Task Should_commit_same_Id_to_Outbox_when_Handler_is_called(CreateUser.Command command, [Frozen] Mock <IOutboxListener> outboxMock) { var handler = new CreateUser.Handler(outboxMock.Object, _db); var result = await handler.Handle(command, CancellationToken.None); var expectedId = result.Id; outboxMock.Verify(x => x.Commit(It.Is <UserCreated>(user => user.UserId == expectedId))); }
public async Task Should_not_return_empty_guid_when_User_is_created(CreateUser.Command command, [Frozen] Mock <IOutboxListener> outboxMock) { var handler = new CreateUser.Handler(outboxMock.Object, _db); var result = await handler.Handle(command, CancellationToken.None); var actualId = result.Id; actualId.Should().NotBe(Guid.Empty); }
public async Task Should_insert_User_in_db_when_Handler_is_called(CreateUser.Command command, [Frozen] Mock <IOutboxListener> outboxMock) { var expectedUserCount = _db.Users.Count() + 1; var handler = new CreateUser.Handler(outboxMock.Object, _db); await handler.Handle(command, CancellationToken.None); var actualUserCount = _db.Users.Count(); actualUserCount.Should().Be(expectedUserCount); }
public async Task Should_save_User_with_requested_properties_to_db_when_saving_User(CreateUser.Command command, [Frozen] Mock <IOutboxListener> outboxMock) { var handler = new CreateUser.Handler(outboxMock.Object, _db); var result = await handler.Handle(command, CancellationToken.None); var actualUser = _db.Users.Select(u => new CreateUser.Command { FirstName = u.FirstName, LastName = u.LastName, Email = u.Email }).First(); actualUser.Should().BeEquivalentTo(command); }
public SeedService(AppDbContext appDbContext, CreateRole.Handler createRoleHandler, CreateUser.Handler createUserHandler) { _appDbContext = appDbContext; _createRoleHandler = createRoleHandler; _createUserHandler = createUserHandler; }