protected void SetUp(KustoOptions customOptions = null)
        {
            var collection = new ServiceCollection();

            collection.AddOptions();
            collection.AddLogging(l =>
            {
                l.AddProvider(new XUnitLogger(_output));
            });

            collection.Configure <KustoOptions>(options =>
            {
                options.IngestConnectionString = customOptions != null ? customOptions.IngestConnectionString : "fakekustoconnectionstring";
                options.Database = customOptions != null ? customOptions.Database : "fakekustodatbase";
            });

            collection.AddScoped <TelemetryController>();

            var kustoIngestClientMock = new Mock <IKustoIngestClient>();

            kustoIngestClientMock.Setup(x => x.IngestFromStreamAsync(It.IsAny <System.IO.Stream>(), It.IsAny <KustoIngestionProperties>(), null))
            .Returns(Task.FromResult(Mock.Of <IKustoIngestionResult>()));

            collection.AddSingleton(kustoIngestClientMock.Object);

            _services   = collection.BuildServiceProvider();
            _controller = _services.GetRequiredService <TelemetryController>();
        }
Beispiel #2
0
        public async Task <IActionResult> CollectArcadeValidation([Required] ArcadeValidationData data)
        {
            KustoOptions options = _options.Value;

            if (string.IsNullOrEmpty(options.IngestConnectionString))
            {
                throw new InvalidOperationException("No IngestConnectionString set");
            }

            List <ArcadeValidationData> arcadeValidationDatas = new List <ArcadeValidationData> {
                data
            };

            await KustoHelpers.WriteDataToKustoInMemoryAsync(
                _clientFactory.GetClient(),
                options.Database,
                "ArcadeValidation",
                _logger,
                arcadeValidationDatas,
                b => new[]
            {
                new KustoValue("BuildDateTime", b.BuildDateTime, KustoDataType.DateTime),
                new KustoValue("ArcadeVersion", b.ArcadeVersion, KustoDataType.String),
                new KustoValue("BARBuildID", b.BARBuildID, KustoDataType.Int),
                new KustoValue("ArcadeBuildLink", b.ArcadeBuildLink, KustoDataType.String),
                new KustoValue("ArcadeValidationBuildLink", b.ArcadeValidationBuildLink, KustoDataType.String),
                new KustoValue("ProductRepoName", b.ProductRepoName, KustoDataType.String),
                new KustoValue("ProductRepoBuildLink", b.ProductRepoBuildLink, KustoDataType.String),
                new KustoValue("ProductRepoBuildResult", b.ProductRepoBuildResult, KustoDataType.String),
                new KustoValue("ArcadeDiffLink", b.ArcadeDiffLink, KustoDataType.String)
            });

            return(Ok());
        }