Ejemplo n.º 1
0
        public async Task <UpdateBatchResponse> Put(UpdateBatchRequest request)
        {
            var batch = request.ConvertTo <Batch>();

            var updated = await batchRepository.Update(batch);

            if (!updated)
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            return(new UpdateBatchResponse());
        }
Ejemplo n.º 2
0
        public void Update_Batch_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.Update(Arg.Any <Batch>()).Returns(false);

            var request = new UpdateBatchRequest
            {
                BatchId = TestBatchId
            };

            // Act / Assert
            var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Put(request));

            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString());
            exception.Message.Should().Be("Batch TestBatch not found");
        }
        public async Task ShouldUpdateMessages()
        {
            //Arrange
            var service            = SetupService();
            var updateBatchRequest = new UpdateBatchRequest();

            //Act
            await service.UpdateMessagesAsync(new ConcurrentBag <UpdateBatchRequest> {
                updateBatchRequest
            });

            //Assert
            Assert.Equal(1, _queService.ReceivedCalls().Count(c => c.GetMethodInfo().Name == "UpdateMessagesAsync"));
            Assert.Equal(updateBatchRequest, (_queService.ReceivedCalls()
                                              .Single(c => c.GetMethodInfo().Name == "UpdateMessagesAsync").GetArguments()
                                              .Single() as IEnumerable <UpdateBatchRequest>)?.Single());
        }