public void ShouldRequireMinimumFields() { var command = new CreateQueueCommand(); FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public async Task ShouldCreateQueue() { // Arrange var command = new CreateQueueCommand { Name = "IntegrationTest", VisibilityTimeouSeconds = 12 }; // Act var queueUrl = await SendAsync(command); // Assert queueUrl.Should().NotBeEmpty(); }
public async Task WhenPostingCollection_ItShouldIssueCreateCollectionCommand() { const byte HourOfWeekValue = 42; var initialWeeklyReleaseTime = HourOfWeek.Parse(HourOfWeekValue); this.random.Setup(_ => _.Next(Shared.HourOfWeek.MinValue, Shared.HourOfWeek.MaxValue + 1)).Returns(HourOfWeekValue); var data = new NewQueueData(BlogId, QueueName.Value); var command = new CreateQueueCommand(Requester, QueueId, BlogId, QueueName, initialWeeklyReleaseTime); this.requesterContext.Setup(_ => _.GetRequesterAsync()).ReturnsAsync(Requester); this.guidCreator.Setup(_ => _.CreateSqlSequential()).Returns(QueueId.Value); this.createCollection.Setup(_ => _.HandleAsync(command)).Returns(Task.FromResult(0)).Verifiable(); var result = await this.target.PostQueueAsync(data); Assert.AreEqual(result, new QueueCreation(QueueId, initialWeeklyReleaseTime)); this.createCollection.Verify(); }
public void ShouldFailWithAQueueNameLongerThan80() { // Arrange var longerName = new string('-', 81); var command = new CreateQueueCommand { Name = longerName }; // Act Func <Task> action = async() => { await SendAsync(command); }; // Assert action.Should().Throw <ValidationException>() .And.Errors.Should().ContainKey(nameof(CreateQueueCommand.Name)) .WhichValue.Should().BeEquivalentTo("Name must not exceed 80 characters."); }
public void ShouldFailWithAQueueVisibilityTimeoutLongerThanOneMinute() { // Arrange var name = new string('-', 80); const int maxVisibilityTimeout = 60; var command = new CreateQueueCommand { Name = name, VisibilityTimeouSeconds = maxVisibilityTimeout + 1 }; // Act Func <Task> action = async() => { await SendAsync(command); }; // Assert const string timeoutFieldName = nameof(CreateQueueCommand.VisibilityTimeouSeconds); action.Should().Throw <ValidationException>() .And.Errors.Should().ContainKey(timeoutFieldName) .WhichValue.Should().BeEquivalentTo($"{timeoutFieldName} should be less than {maxVisibilityTimeout} seconds."); }
public async Task <IActionResult> CreateQueue([FromBody] CreateQueueCommand input) { var result = await _mediator.Send(input); return(Ok(result)); }