Esempio n. 1
0
        public async Task <GetAllBatchOptionResponse> Get(GetAllBatchOptionRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var batchOptions = await batchRepository.GetAllBatchOptions(request.BatchId);

            var response = new GetAllBatchOptionResponse
            {
                Options = batchOptions.ConvertTo <List <DomainModels.Option> >()
            };

            return(response);
        }
Esempio n. 2
0
        public void Get_All_BatchOptions_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(false);

            var request = new GetAllBatchOptionRequest
            {
                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");
        }
Esempio n. 3
0
        public async Task It_Should_Get_All_BatchOption()
        {
            // Arrange
            var batchOptions = TestData.Entities.Batches.FullyPopulated.Options;

            batchRepository.DoesBatchExist(Arg.Any <string>())
            .Returns(true);
            batchRepository.GetAllBatchOptions(Arg.Any <string>())
            .Returns(batchOptions);

            var request = new GetAllBatchOptionRequest();

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

            // Assert
            response.Options.Should().BeEquivalentTo(TestData.DomainModels.Batches.FullyPopulated.Options);
        }