예제 #1
0
        public TestResultsService(ITestResultsRepository testResultsRepository,
                                  ISearchRepository <TestScenarioResultIndex> searchRepository,
                                  IMapper mapper,
                                  ILogger logger,
                                  ITelemetry telemetry,
                                  ITestRunnerResiliencePolicies policies,
                                  IProviderService providerService)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(testResultsRepository, nameof(testResultsRepository));
            Guard.ArgumentNotNull(mapper, nameof(mapper));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(telemetry, nameof(telemetry));
            Guard.ArgumentNotNull(policies, nameof(policies));
            Guard.ArgumentNotNull(providerService, nameof(providerService));

            _testResultsRepository = testResultsRepository;
            _searchRepository      = searchRepository;
            _mapper                  = mapper;
            _logger                  = logger;
            _telemetry               = telemetry;
            _testResultsPolicy       = policies.TestResultsRepository;
            _testResultsSearchPolicy = policies.TestResultsSearchRepository;
            _providerService         = providerService;
        }
예제 #2
0
        public TestEngineService(
            ICacheProvider cacheProvider,
            ISpecificationRepository specificationRepository,
            ILogger logger,
            ITestEngine testEngine,
            IScenariosRepository scenariosRepository,
            IProviderSourceDatasetsRepository providerSourceDatasetsRepository,
            ITestResultsService testResultsService,
            ITestResultsRepository testResultsRepository,
            IBuildProjectRepository buildProjectRepository,
            ITelemetry telemetry,
            ITestRunnerResiliencePolicies resiliencePolicies,
            ICalculationsRepository calculationsRepository)
        {
            _cacheProvider           = cacheProvider;
            _specificationRepository = specificationRepository;
            _logger              = logger;
            _testEngine          = testEngine;
            _scenariosRepository = scenariosRepository;
            _providerSourceDatasetsRepository = providerSourceDatasetsRepository;
            _testResultsService    = testResultsService;
            _testResultsRepository = testResultsRepository;
            _telemetry             = telemetry;

            _cacheProviderPolicy                    = resiliencePolicies.CacheProviderRepository;
            _specificationRepositoryPolicy          = resiliencePolicies.SpecificationRepository;
            _scenariosRepositoryPolicy              = resiliencePolicies.ScenariosRepository;
            _providerSourceDatasetsRepositoryPolicy = resiliencePolicies.ProviderSourceDatasetsRepository;
            _testResultsRepositoryPolicy            = resiliencePolicies.TestResultsRepository;
            _builProjectsRepositoryPolicy           = resiliencePolicies.BuildProjectRepository;
            _buildProjectRepository                 = buildProjectRepository;
            _calculationsRepository                 = calculationsRepository;
        }
        public TestResultsService(ITestResultsRepository testResultsRepository,
                                  ISearchRepository <TestScenarioResultIndex> searchRepository,
                                  IMapper mapper,
                                  ILogger logger,
                                  ITelemetry telemetry,
                                  ITestRunnerResiliencePolicies policies,
                                  IProvidersApiClient providersApiClient,
                                  IJobManagement jobManagement) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(testResultsRepository, nameof(testResultsRepository));
            Guard.ArgumentNotNull(mapper, nameof(mapper));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(telemetry, nameof(telemetry));
            Guard.ArgumentNotNull(policies?.TestResultsRepository, nameof(policies.TestResultsRepository));
            Guard.ArgumentNotNull(policies?.TestResultsSearchRepository, nameof(policies.TestResultsSearchRepository));
            Guard.ArgumentNotNull(providersApiClient, nameof(providersApiClient));

            _testResultsRepository = testResultsRepository;
            _searchRepository      = searchRepository;
            _mapper                  = mapper;
            _logger                  = logger;
            _telemetry               = telemetry;
            _testResultsPolicy       = policies.TestResultsRepository;
            _testResultsSearchPolicy = policies.TestResultsSearchRepository;
            _providersApiClient      = providersApiClient;
        }
 public TestResultsSearchService(ILogger logger,
                                 ISearchRepository <TestScenarioResultIndex> searchRepository,
                                 ITestRunnerResiliencePolicies resiliencePolicies)
 {
     _logger                 = logger;
     _searchRepository       = searchRepository;
     _searchRepositoryPolicy = resiliencePolicies.TestResultsSearchRepository;
 }
예제 #5
0
 public StepParserFactory(
     ICodeMetadataGeneratorService codeMetadataGeneratorService,
     IProviderResultsRepository providerResultsRepository,
     ITestRunnerResiliencePolicies resiliencePolicies)
 {
     _codeMetadataGeneratorService = codeMetadataGeneratorService;
     _providerResultsRepository    = providerResultsRepository;
     _resiliencePolicies           = resiliencePolicies;
 }
예제 #6
0
 static TestResultsSearchService CreateTestResultsSearchService(
     ILogger logger = null,
     ISearchRepository <TestScenarioResultIndex> serachRepository = null,
     ITestRunnerResiliencePolicies resiliencePolicies             = null)
 {
     return(new TestResultsSearchService(
                logger ?? CreateLogger(),
                serachRepository ?? CreateSearchRepository(),
                resiliencePolicies ?? TestRunnerResilienceTestHelper.GenerateTestPolicies()));
 }
        public TestEngineService(
            ICacheProvider cacheProvider,
            ISpecificationsApiClient specificationsApiClient,
            ILogger logger,
            ITestEngine testEngine,
            IScenariosRepository scenariosRepository,
            IProviderSourceDatasetsRepository providerSourceDatasetsRepository,
            ITestResultsService testResultsService,
            ITestResultsRepository testResultsRepository,
            ICalculationsApiClient calcsApiClient,
            ITelemetry telemetry,
            ITestRunnerResiliencePolicies resiliencePolicies,
            ICalculationsRepository calculationsRepository,
            IMapper mapper)
        {
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(testEngine, nameof(testEngine));
            Guard.ArgumentNotNull(scenariosRepository, nameof(scenariosRepository));
            Guard.ArgumentNotNull(providerSourceDatasetsRepository, nameof(providerSourceDatasetsRepository));
            Guard.ArgumentNotNull(testResultsService, nameof(testResultsService));
            Guard.ArgumentNotNull(testResultsRepository, nameof(testResultsRepository));
            Guard.ArgumentNotNull(telemetry, nameof(telemetry));
            Guard.ArgumentNotNull(resiliencePolicies?.CacheProviderRepository, nameof(resiliencePolicies.CacheProviderRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.SpecificationsApiClient, nameof(resiliencePolicies.SpecificationsApiClient));
            Guard.ArgumentNotNull(resiliencePolicies?.ScenariosRepository, nameof(resiliencePolicies.ScenariosRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.ProviderSourceDatasetsRepository, nameof(resiliencePolicies.ProviderSourceDatasetsRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.TestResultsRepository, nameof(resiliencePolicies.TestResultsRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.CalculationsApiClient, nameof(resiliencePolicies.CalculationsApiClient));;
            Guard.ArgumentNotNull(resiliencePolicies?.SpecificationsApiClient, nameof(resiliencePolicies.SpecificationsApiClient));
            Guard.ArgumentNotNull(calcsApiClient, nameof(calcsApiClient));
            Guard.ArgumentNotNull(calculationsRepository, nameof(calculationsRepository));
            Guard.ArgumentNotNull(mapper, nameof(mapper));

            _cacheProvider           = cacheProvider;
            _specificationsApiClient = specificationsApiClient;
            _logger              = logger;
            _testEngine          = testEngine;
            _scenariosRepository = scenariosRepository;
            _providerSourceDatasetsRepository = providerSourceDatasetsRepository;
            _testResultsService    = testResultsService;
            _testResultsRepository = testResultsRepository;
            _telemetry             = telemetry;
            _mapper = mapper;

            _cacheProviderPolicy       = resiliencePolicies.CacheProviderRepository;
            _scenariosRepositoryPolicy = resiliencePolicies.ScenariosRepository;
            _providerSourceDatasetsRepositoryPolicy = resiliencePolicies.ProviderSourceDatasetsRepository;
            _testResultsRepositoryPolicy            = resiliencePolicies.TestResultsRepository;
            _calcsApiClientPolicy          = resiliencePolicies.CalculationsApiClient;
            _calcsApiClient                = calcsApiClient;
            _calculationsRepository        = calculationsRepository;
            _specificationsApiClientPolicy = resiliencePolicies.SpecificationsApiClient;
        }
예제 #8
0
        public TestResultsSearchService(ILogger logger,
                                        ISearchRepository <TestScenarioResultIndex> searchRepository,
                                        ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.TestResultsSearchRepository, nameof(resiliencePolicies.TestResultsSearchRepository));

            _logger                 = logger;
            _searchRepository       = searchRepository;
            _searchRepositoryPolicy = resiliencePolicies.TestResultsSearchRepository;
        }
        public StepParserFactory(
            ICodeMetadataGeneratorService codeMetadataGeneratorService,
            IProviderResultsRepository providerResultsRepository,
            ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(codeMetadataGeneratorService, nameof(codeMetadataGeneratorService));
            Guard.ArgumentNotNull(providerResultsRepository, nameof(providerResultsRepository));
            Guard.ArgumentNotNull(resiliencePolicies, nameof(resiliencePolicies));

            _codeMetadataGeneratorService = codeMetadataGeneratorService;
            _providerResultsRepository    = providerResultsRepository;
            _resiliencePolicies           = resiliencePolicies;
        }
        public GherkinExecutor(IGherkinParser parser,
                               ICacheProvider cacheProvider,
                               ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(parser, nameof(parser));
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(resiliencePolicies?.CacheProviderRepository, nameof(resiliencePolicies.CacheProviderRepository));

            _parser        = parser;
            _cacheProvider = cacheProvider;

            _cacheProviderPolicy = resiliencePolicies.CacheProviderRepository;
        }
예제 #11
0
        public GherkinParserService(
            IGherkinParser gherkinParser,
            ILogger logger,
            IBuildProjectRepository buildProjectRepository,
            ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(resiliencePolicies, nameof(resiliencePolicies));

            _gherkinParser          = gherkinParser;
            _logger                 = logger;
            _buildProjectRepository = buildProjectRepository;

            _buildProjectRepositoryPolicy = resiliencePolicies.BuildProjectRepository;
        }
        public GherkinParserService(
            IGherkinParser gherkinParser,
            ILogger logger,
            ICalculationsApiClient calcsApiClient,
            ITestRunnerResiliencePolicies resiliencePolicies,
            IMapper mapper)
        {
            Guard.ArgumentNotNull(resiliencePolicies?.CalculationsApiClient, nameof(resiliencePolicies.CalculationsApiClient));
            Guard.ArgumentNotNull(gherkinParser, nameof(gherkinParser));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(calcsApiClient, nameof(calcsApiClient));

            _gherkinParser  = gherkinParser;
            _logger         = logger;
            _calcsApiClient = calcsApiClient;
            _mapper         = mapper;

            _calcsApiClientPolicy = resiliencePolicies.CalculationsApiClient;
        }
예제 #13
0
        public async Task Execute_WhenFieldNameCaseIsDifferent_ThenTestIsSuccessfullyExecuted()
        {
            // Arrange
            string dataSetName = "Test Dataset";
            string fieldName   = "URN";
            string calcName    = "Test Calc";
            string gherkin     = $"Given the dataset '{dataSetName}' field '{fieldName.ToLower()}' is equal to '100050'\n\nThen the result for '{calcName}' is greater than '12' ";

            ICodeMetadataGeneratorService codeMetadataGeneratorService = CreateCodeMetadataGeneratorService();

            codeMetadataGeneratorService
            .GetTypeInformation(Arg.Any <byte[]>())
            .Returns(new List <TypeInformation>
            {
                new TypeInformation {
                    Type = "Calculations", Methods = new List <MethodInformation> {
                        new MethodInformation {
                            FriendlyName = calcName
                        }
                    }
                },
                new TypeInformation {
                    Type = "Datasets", Properties = new List <PropertyInformation> {
                        new PropertyInformation {
                            FriendlyName = dataSetName, Type = "DSType"
                        }
                    }
                },
                new TypeInformation {
                    Type = "DSType", Properties = new List <PropertyInformation> {
                        new PropertyInformation {
                            FriendlyName = fieldName, Type = "String"
                        }
                    }
                }
            });

            IProviderResultsRepository providerResultsRepository = CreateProviderResultsRepository();

            ITestRunnerResiliencePolicies resiliencePolicies = CreateResiliencePolicies();

            IStepParserFactory stepParserFactory = new StepParserFactory(codeMetadataGeneratorService, providerResultsRepository, resiliencePolicies);

            ICalculationsRepository calculationsRepository = CreateCalculationsRepository();

            calculationsRepository
            .GetAssemblyBySpecificationId(Arg.Is("spec1"))
            .Returns(new byte[1]);

            ILogger logger = CreateLogger();

            GherkinParser gherkinParser = new GherkinParser(stepParserFactory, calculationsRepository, logger);

            ICacheProvider cacheProvider = CreateCacheProvider();

            GherkinExecutor gherkinExecutor = CreateGherkinExecutor(gherkinParser, cacheProvider);

            ProviderResult providerResult = new ProviderResult
            {
                Provider = new ProviderSummary {
                    Id = "prov1"
                },
                CalculationResults = new List <CalculationResult>
                {
                    new CalculationResult {
                        Calculation = new Common.Models.Reference {
                            Name = calcName
                        }, Value = 14
                    }
                }
            };
            IEnumerable <ProviderSourceDataset> datasets = new List <ProviderSourceDataset>
            {
                new ProviderSourceDataset
                {
                    DataRelationship = new Common.Models.Reference {
                        Name = dataSetName
                    },
                    Current = new ProviderSourceDatasetVersion
                    {
                        Rows = new List <Dictionary <string, object> >
                        {
                            new Dictionary <string, object> {
                                { fieldName, 100050 }
                            }
                        }
                    }
                }
            };
            IEnumerable <TestScenario> testScenarios = new List <TestScenario>
            {
                new TestScenario {
                    Id = "ts1", Name = "Test Scenario 1", SpecificationId = "spec1", Current = new TestScenarioVersion {
                        Gherkin = gherkin
                    }
                }
            };
            BuildProject buildProject = new BuildProject {
                Build = new Build()
            };

            // Act
            IEnumerable <ScenarioResult> scenarioResults = await gherkinExecutor.Execute(providerResult, datasets, testScenarios, buildProject);

            // Assert
            scenarioResults
            .Should()
            .HaveCount(1);

            scenarioResults
            .First().HasErrors
            .Should()
            .BeFalse("there should be no errors");

            scenarioResults
            .First().StepsExecuted
            .Should()
            .Be(scenarioResults.First().TotalSteps, "all steps should be executed");
        }
예제 #14
0
 private static GherkinExecutor CreateGherkinExecutor(IGherkinParser gherkinParser = null, ICacheProvider cacheProvider = null, ITestRunnerResiliencePolicies resiliencePolicies = null)
 {
     return(new GherkinExecutor(
                gherkinParser ?? CreateGherkinParser(),
                cacheProvider ?? CreateCacheProvider(),
                resiliencePolicies ?? CreateResiliencePolicies()));
 }
        public ProviderStepParser(IProviderResultsRepository providerResultsRepository, ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(providerResultsRepository, nameof(providerResultsRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.ProviderResultsRepository, nameof(providerResultsRepository));

            _providerResultsRepository       = providerResultsRepository;
            _providerResultsRepositoryPolicy = resiliencePolicies.ProviderResultsRepository;
        }
예제 #16
0
 public ProviderStepParser(IProviderResultsRepository providerResultsRepository, ITestRunnerResiliencePolicies resiliencePolicies)
 {
     _providerResultsRepository       = providerResultsRepository;
     _providerResultsRepositoryPolicy = resiliencePolicies.ProviderResultsRepository;
 }