예제 #1
0
        public void FirstNameTooLong_ShouldThrow(TestContextFixture testContextFixture,
                                                 AddUser.Command addUser)
        {
            //arrange
            addUser.FirstName = "Hottentottentententtentoonstelling";

            //act
            Should.Throw <DbUpdateException>(() => testContextFixture.Send(addUser));
        }
예제 #2
0
        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();
        }
예제 #3
0
            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());
        }
예제 #5
0
 public async Task <ActionResult <List <MessageThreadUser> > > AddUser(AddUser.Command command)
 {
     return(await Mediator.Send(command));
 }
예제 #6
0
        public async Task <IActionResult> CreateUser([FromBody] AddUser.Command user)
        {
            await _mediator.Send(user);

            return(Ok());
        }
예제 #7
0
 public async Task AddUser([FromBody] AddUser.Command user)
 {
     await _mediator.Send(user);
 }