Esempio n. 1
0
        public async Task <PermissionTemplateDTO> CreatePermissionTemplate([FromBody] CreatePermissionTemplateInputDTO input)
        {
            var command = new CreatePermissionTemplateCommand(input);
            var result  = await _commandDispatcher.Execute(command);

            return(result);
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }