コード例 #1
0
        async public Task GetDatasetDefinitions_GivenDefinitionsRequestedButContainsResults_ReturnsArray()
        {
            //Arrange
            HttpRequest request = Substitute.For <HttpRequest>();

            IEnumerable <DatasetDefinition> definitions = new[]
            {
                new DatasetDefinition(), new DatasetDefinition()
            };

            IDatasetRepository repository = CreateDataSetsRepository();

            repository
            .GetDatasetDefinitions()
            .Returns(definitions);

            DefinitionsService service = CreateDefinitionsService(datasetsRepository: repository);

            //Act
            IActionResult result = await service.GetDatasetDefinitions(request);

            //Assert
            result
            .Should()
            .BeOfType <OkObjectResult>();

            OkObjectResult objResult = (OkObjectResult)result;

            IEnumerable <DatasetDefinition> objValue = (IEnumerable <DatasetDefinition>)objResult.Value;

            objValue
            .Count()
            .Should()
            .Be(2);
        }
コード例 #2
0
        async public Task <IActionResult> GetDatasetDefinitions(HttpRequest request)
        {
            IEnumerable <DatasetDefinition> definitions = await _datasetsRepositoryPolicy.ExecuteAsync(() => _datasetsRepository.GetDatasetDefinitions());

            return(new OkObjectResult(definitions));
        }