Exemplo n.º 1
0
        public async Task ShouldCreateTodoItem()
        {
            var userId = await RunAsDefaultUserAsync();

            var listId = await SendAsync(new CreateTodoListCommand
            {
                Title = "New List"
            });

            var command = new CreateThrottlingCommand
            {
                ListId = listId,
                Title  = "Tasks"
            };

            var itemId = await SendAsync(command);

            var item = await FindAsync <TodoItem>(itemId);

            item.Should().NotBeNull();
            item.ListId.Should().Be(command.ListId);
            item.Title.Should().Be(command.Title);
            item.CreatedBy.Should().Be(userId);
            item.Created.Should().BeCloseTo(DateTime.Now, 10000);
            item.LastModifiedBy.Should().BeNull();
            item.LastModified.Should().BeNull();
        }
Exemplo n.º 2
0
        public void ShouldRequireLimitStringNotEmpty()
        {
            var command = new CreateThrottlingCommand();

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemplo n.º 3
0
        public void ShouldRequireCorrectLimitString()
        {
            var command = new CreateThrottlingCommand
            {
                LimitString = "12sec",
                Pattern     = "http://example.com"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
 public async Task <IActionResult> Create([FromBody] CreateThrottlingCommand command)
 {
     // maybe return created
     return(Ok(await Mediator.Send(command)));
 }