public void FirstNameTooLong_ShouldThrow(TestContextFixture testContextFixture, AddUser.Command addUser) { //arrange addUser.FirstName = "Hottentottentententtentoonstelling"; //act Should.Throw <DbUpdateException>(() => testContextFixture.Send(addUser)); }
public void ShouldAddNewUser(TestContextFixture testContextFixture, AddUser.Command addUser) { //act testContextFixture.Send(addUser); //assert User saved = null; testContextFixture.DoClean( context => saved = context.Set <User>() .SingleOrDefault(s => s.Email == addUser.Email) ); saved.ShouldNotBeNull(); }
public async Task AddedRecordsShouldBePersisted() { // Arrange var userOneCommand = new AddUser.Command { FirstName = "Sarah", Surname = "Smith" }; var userTwoCommand = new AddUser.Command { FirstName = "Michael", Surname = "Bailey" }; // Act await using var dbContext = new BugTraqContext(_inMemoryDbOptions); await new AddUser.Handler(dbContext).Handle(userOneCommand, It.IsAny <CancellationToken>()); await new AddUser.Handler(dbContext).Handle(userTwoCommand, It.IsAny <CancellationToken>()); // Assert dbContext.Users.Count().Should().Be(2, "we added two records to the database"); }
public async Task <IActionResult> Add([FromBody] AddUser.Command command) { await _commandBus.Process(command); return(NoContent()); }
public async Task <ActionResult <List <MessageThreadUser> > > AddUser(AddUser.Command command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> CreateUser([FromBody] AddUser.Command user) { await _mediator.Send(user); return(Ok()); }
public async Task AddUser([FromBody] AddUser.Command user) { await _mediator.Send(user); }