Beispiel #1
0
        public async void given_update_user_command_command_dispatcher_should_get_same_command_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id = new Guid();

            var input = new UpdateUserInformationDTO()
            {
                ForID     = id,
                FirstName = "testFName",
                LastName  = "testLName"
            };

            var command = new UpdateSingleUserCommand(input.ForID, input);

            mockAgg.setup_dispatcher_to_verify_updateUserInformationCommands_are_the_same(command);

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.UpdateUser(input);

            //Assert
            Assert.IsType <UpdateUserInformationDTO>(result);
            Assert.Equal(result.FirstName, input.FirstName);
            Assert.Equal(result.LastName, input.LastName);
            Assert.Equal(result.ForID, input.ForID);
        }
Beispiel #2
0
        public async Task <UpdateUserInformationDTO> UpdateUser([FromBody] UpdateUserInformationDTO input)
        {
            var message = new UpdateSingleUserCommand(input.ForID, input);
            var result  = await _commandDispatcher.Execute(message);

            return(result);
        }
Beispiel #3
0
        public void given_UpdateSingleUserCommand_handler_should_call_session_get_and_commit()
        {
            // Assemble
            var mockAgg = new UpdateSingleUserCommandHandlerMockAggregate();

            mockAgg.setup_session_to_ensure_GetAndCommit_are_called();
            var handler = mockAgg.HandlerFactory();
            var testAgg = mockAgg.SetupAdminUser();

            var input = new UpdateUserInformationDTO
            {
                ForID      = testAgg.Id,
                FirstName  = "changed",
                LastName   = "changed",
                Email      = "changed",
                Position   = "changed",
                Department = "changed",
                IsAdmin    = false
            };
            var command = new UpdateSingleUserCommand(input.ForID, input);

            // Apply
            var result = handler.Handle(command);

            // Assert
            Assert.True(mockAgg.SessionGetWasCalled);
            Assert.True(mockAgg.SessionCommitWasCalled);
        }
Beispiel #4
0
 public void setup_dispatcher_to_verify_updateUserInformationCommands_are_the_same(UpdateSingleUserCommand command)
 {
     CommandDispatcherMock.Setup(a => a.Execute(It.IsAny <UpdateSingleUserCommand>()))
     .Callback <ICommand <UpdateUserInformationDTO> >((a) => { UpdateUserCommand = (UpdateSingleUserCommand)a; })
     .ReturnsAsync(new UpdateUserInformationDTO()
     {
         FirstName = command.Input.FirstName,
         LastName  = command.Input.LastName,
         ForID     = command.Input.ForID
     });
 }