Exemple #1
0
        public async Task <GetBatchOptionResponse> Get(GetBatchOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchOption = await batchRepository.GetBatchOption(request.BatchId, request.OptionName);

            if (batchOption == null)
            {
                throw Err.BatchOptionNotFound(request.OptionName);
            }

            return(batchOption.ConvertTo <GetBatchOptionResponse>());
        }
Exemple #2
0
        public void Get_BatchOption_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new GetBatchOptionRequest
            {
                BatchId = TestBatchId
            };

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

            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString());
            exception.Message.Should().Be("Batch TestBatch not found");
        }
        public void It_Should_Throw_When_Getting_Option_When_Batch_Id_Does_Not_Exist()
        {
            var request = new GetBatchOptionRequest {
                BatchId = "invalid", OptionName = "invalid"
            };

            try
            {
                Sut.Get(request);
                Assert.Fail("Should throw");
            }
            catch (WebServiceException webEx)
            {
                webEx.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
                webEx.Message.Should().Be(ErrMsg.BatchNotFound(request.BatchId));
            }
        }
Exemple #4
0
        public async Task It_Should_Get_BatchOption()
        {
            // Arrange
            var batchOption = BatchOptions.Log;

            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);
            batchRepository.GetBatchOption(Arg.Any <string>(), Arg.Any <string>())
            .Returns(batchOption);

            var request = new GetBatchOptionRequest();

            // Act
            var response = await Sut.Get(request);

            // Assert
            response.Should().BeEquivalentTo(TestData.DomainModels.BatchOptions.Log,
                                             o => o.ExcludingMissingMembers());
            response.OptionName.Should().Be(TestData.DomainModels.BatchOptions.Log.Name);
        }