public async Task <UserDTO> DisableUser([FromBody] DisableUserInputDTO input) { var command = new DisableSingleUserCommand(input); var result = await _commandDispatcher.Execute(command); return(result); }
public async void given_disable_single_user_command_command_dispatcher_should_get_same_command_created_in_controller() { //Assemble var mockAgg = new UserControllerMockAggregate(); var id = new Guid(); var userId = new Guid(); var input = new DisableUserInputDTO() { ById = id, UserId = userId }; var command = new DisableSingleUserCommand(input); mockAgg.setup_dispatcher_to_verify_disableSingleUserCommands_are_the_same(command); var controller = mockAgg.CreateUserController(); //Apply var result = await controller.DisableUser(input); //Assert Assert.IsType <UserDTO>(result); Assert.Equal(result.Id, input.UserId); }
public void given_DisableSingleUserCommand_handler_should_call_session_Get_and_Commit_on_active_user() { // Assemble var mockAgg = new DisableSingleUserCommandHandlerMockAggregate(); mockAgg.setup_session_to_ensure_GetAndCommit_are_called(); var testAgg = mockAgg.SetupAdminUser(); var handler = mockAgg.HandlerFactory(); var input = new DisableUserInputDTO { UserId = testAgg.Id, ById = testAgg.Id }; var command = new DisableSingleUserCommand(input); // Apply var result = handler.Handle(command); // Assert Assert.True(mockAgg.SessionGetWasCalled); Assert.True(mockAgg.SessionCommitWasCalled); }
public void setup_dispatcher_to_verify_disableSingleUserCommands_are_the_same(DisableSingleUserCommand command) { CommandDispatcherMock.Setup(a => a.Execute(It.IsAny <DisableSingleUserCommand>())) .Callback <ICommand <UserDTO> >((a) => { UserCommand = (DisableSingleUserCommand)a; }) .ReturnsAsync(new UserDTO() { Id = command.Input.UserId }); }