コード例 #1
0
        public async Task <IActionResult> PutPattern(string app, Guid id, [FromBody] UpdatePatternDto request)
        {
            var command = request.ToUpdateCommand(id);

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
コード例 #2
0
        public async Task <IActionResult> PostPattern(string app, [FromBody] UpdatePatternDto request)
        {
            var command = request.ToAddCommand();

            var response = await InvokeCommandAsync(command);

            return(CreatedAtAction(nameof(GetPatterns), new { app }, response));
        }
コード例 #3
0
        public async Task <IActionResult> UpdatePattern(string app, Guid id, [FromBody] UpdatePatternDto request)
        {
            var command = SimpleMapper.Map(request, new UpdatePattern {
                PatternId = id
            });

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> PostPattern(string app, [FromBody] UpdatePatternDto request)
        {
            var command = SimpleMapper.Map(request, new AddPattern());

            await CommandBus.PublishAsync(command);

            var response = SimpleMapper.Map(request, new AppPatternDto {
                PatternId = command.PatternId
            });

            return(CreatedAtAction(nameof(GetPatterns), new { app }, request));
        }
コード例 #5
0
        public async Task Should_manage_patterns()
        {
            var patternName   = Guid.NewGuid().ToString();
            var patternRegex1 = Guid.NewGuid().ToString();
            var patternRegex2 = Guid.NewGuid().ToString();

            // STEP 1: Add pattern.
            var createRequest = new UpdatePatternDto {
                Name = patternName, Pattern = patternRegex1
            };

            var patterns_1 = await _.Apps.PostPatternAsync(_.AppName, createRequest);

            var pattern_1 = patterns_1.Items.Single(x => x.Name == patternName);

            // Should return pattern with correct regex.
            Assert.Equal(patternRegex1, pattern_1.Pattern);


            // STEP 2: Update pattern.
            var updateRequest = new UpdatePatternDto {
                Name = patternName, Pattern = patternRegex2
            };

            var patterns_2 = await _.Apps.PutPatternAsync(_.AppName, pattern_1.Id, updateRequest);

            var pattern_2 = patterns_2.Items.Single(x => x.Name == patternName);

            // Should return pattern with correct regex.
            Assert.Equal(patternRegex2, pattern_2.Pattern);


            // STEP 3: Remove pattern.
            var patterns_3 = await _.Apps.DeletePatternAsync(_.AppName, pattern_2.Id);

            // Should not return deleted pattern.
            Assert.DoesNotContain(patterns_3.Items, x => x.Id == pattern_2.Id);
        }
コード例 #6
0
        public async Task <IActionResult> UpdatePattern(string app, Guid id, [FromBody] UpdatePatternDto request)
        {
            await CommandBus.PublishAsync(request.ToUpdateCommand(id));

            return(NoContent());
        }