コード例 #1
0
        public async void given_CreatePermissionTemplateCommand_handler_should_call_context_Add_and_Save()
        {
            // Assemble
            var mockAgg           = new CreatePermissionTemplateCommandHandlerMockAggregate();
            var testPermissionAgg = mockAgg.SetupTestPermission();

            mockAgg.setup_context_to_return_one_item(testPermissionAgg);
            var handler = mockAgg.CreatePermissionTemplateHandlerFactory();

            var input = new CreatePermissionTemplateInputDTO
            {
                Name = "testTemplateName",
                TemplatePermissions = new Dictionary <Guid, string>
                {
                    { testPermissionAgg.Id, testPermissionAgg.Name }
                }
            };

            var command = new CreatePermissionTemplateCommand(input);

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

            // Assert
            Assert.True(mockAgg.ContextSaveWasCalled);
            Assert.True(mockAgg.ContextAddWasCalled);
        }
コード例 #2
0
        public async Task <PermissionTemplateDTO> CreatePermissionTemplate([FromBody] CreatePermissionTemplateInputDTO input)
        {
            var command = new CreatePermissionTemplateCommand(input);
            var result  = await _commandDispatcher.Execute(command);

            return(result);
        }
コード例 #3
0
        public async void given_valid_input_create_permission_template_method_returns_valid_results()
        {
            var mockAgg = new PermissionControllerMockAggregate();

            var controller = mockAgg.PermissionControllerFactory();

            var templateName = "TestName";

            var permissions = new Dictionary <Guid, string>();

            permissions.Add(new Guid(), "TestInput");

            var input = new CreatePermissionTemplateInputDTO()
            {
                Name = templateName,
                TemplatePermissions = permissions
            };

            var command = new CreatePermissionTemplateCommand(input);

            mockAgg.setup_dispatcher_to_verify_createPermissionTemplateCommands_are_the_same(input);

            var result = await controller.CreatePermissionTemplate(input);

            //Assert
            Assert.IsType <PermissionTemplateDTO>(result);
            Assert.Equal(result.Name, input.Name);
            Assert.Equal(result.TemplatePermissions, result.TemplatePermissions);
        }
コード例 #4
0
 public void setup_dispatcher_to_verify_createPermissionTemplateCommands_are_the_same(CreatePermissionTemplateInputDTO dto)
 {
     CommandDispatcherMock.Setup(a => a.Execute(It.IsAny <CreatePermissionTemplateCommand>()))
     .Callback <ICommand <PermissionTemplateDTO> >((a) => { PermissionTemplateCommand = (CreatePermissionTemplateCommand)a; })
     .ReturnsAsync(new PermissionTemplateDTO()
     {
         Name = dto.Name,
         TemplatePermissions = dto.TemplatePermissions
     });
 }
コード例 #5
0
 public CreatePermissionTemplateCommand(CreatePermissionTemplateInputDTO input)
 {
     Input = input;
 }