Example #1
0
        public void given_UpdatePermissionInfoCommand_handler_should_call_session_Get_and_Commit()
        {
            // Asemble
            var mockAgg           = new EnablePermissionCommandHandlerMockAggregate();
            var testPermissionAgg = mockAgg.SetupTestDisabledPermission();
            var testAgg           = mockAgg.SetupAdminUser();

            mockAgg.setup_session_to_ensure_addAndCommit_are_called(testPermissionAgg, testAgg);
            var handler = mockAgg.EnablePermissionHandlerFactory();
            var input   = new EnablePermissionInputDTO()
            {
                ById         = testAgg.Id,
                PermissionId = testPermissionAgg.Id
            };

            var command = new EnablePermissionCommand(input);

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

            // Assert
            Assert.True(mockAgg.SessionGetWasCalled);
            Assert.True(mockAgg.SessionGetPermissionWasCalled);
            Assert.True(mockAgg.SessionCommitWasCalled);
        }
Example #2
0
        public async Task <PermissionDTO> EnablePermission([FromBody] EnablePermissionInputDTO input)
        {
            var command = new EnablePermissionCommand(input);
            var result  = await _commandDispatcher.Execute(command);

            return(result);
        }
Example #3
0
        public async void given_valid_input_enable_permission_method_returns_valid_results()
        {
            var mockAgg = new PermissionControllerMockAggregate();

            var controller = mockAgg.PermissionControllerFactory();

            var permissionId = new Guid();

            var byId = new Guid();

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

            var command = new EnablePermissionCommand(input);

            mockAgg.setup_dispatcher_to_verify_enablePermissionCommands_are_the_same(permissionId);

            var result = await controller.EnablePermission(input);

            //Assert
            Assert.IsType <PermissionDTO>(result);
            Assert.Equal(result.Id, input.PermissionId);
        }
Example #4
0
 public EnablePermissionCommand(EnablePermissionInputDTO input)
 {
     Input = input;
 }