コード例 #1
0
        public async Task <PermissionDTO> DisablePermission([FromBody] DisablePermissionInputDTO input)
        {
            var command = new DisablePermissionCommand(input);
            var result  = await _commandDispatcher.Execute(command);

            return(result);
        }
コード例 #2
0
        public async void given_DisablePermissionCommand_handler_should_call_session_Get_and_Commit_on_active_permission()
        {
            // Assemble
            var mockAgg           = new DisablePermissionCommandHandlerMockAggregate();
            var handler           = mockAgg.DisablePermissionHandlerFactory();
            var testAgg           = mockAgg.SetupAdminUser();
            var testPermissionAgg = mockAgg.SetupTestPermission();

            mockAgg.setup_session_to_ensure_addAndCommit_are_called(testPermissionAgg, testAgg);
            mockAgg.setup_context_to_return_no_items();

            var input = new DisablePermissionInputDTO
            {
                PermissionId = testPermissionAgg.Id,
                ById         = testAgg.Id,
            };

            var command = new DisablePermissionCommand(input);

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

            // Assert
            Assert.True(mockAgg.SessionGetWasCalled);
            Assert.True(mockAgg.SessionCommitWasCalled);
        }
コード例 #3
0
        public async void given_valid_input_disable_permission_method_returns_valid_results()
        {
            var mockAgg = new PermissionControllerMockAggregate();

            var controller = mockAgg.PermissionControllerFactory();

            var permissionId = new Guid();

            var byId = new Guid();

            var input = new DisablePermissionInputDTO()
            {
                PermissionId = permissionId,
                ById         = byId
            };

            var command = new DisablePermissionCommand(input);

            mockAgg.setup_dispatcher_to_verify_disablePermissionCommands_are_the_same(permissionId);

            var result = await controller.DisablePermission(input);

            //Assert
            Assert.IsType <PermissionDTO>(result);
            Assert.Equal(result.Id, input.PermissionId);
        }