Ejemplo n.º 1
0
        Settings(
            string trackingId,
            bool useTestResultReportingService,
            bool useResultEventReceivingService,
            string eventHubConnectionString,
            string iotHubConnectionString,
            string deviceId,
            string moduleId,
            ushort webHostPort,
            string logAnalyticsWorkspaceId,
            string logAnalyticsSharedKey,
            string logAnalyticsLogType,
            string storagePath,
            bool optimizeForPerformance,
            TimeSpan testStartDelay,
            TimeSpan testDuration,
            TimeSpan verificationDelay,
            TimeSpan sendReportFrequency,
            bool logUploadEnabled,
            string storageAccountConnectionString,
            string networkControllerRunProfileName,
            ushort unmatchedResultsMaxSize,
            string testInfo,
            TestMode testMode)
        {
            Preconditions.CheckRange(testDuration.Ticks, 1);

            if (useResultEventReceivingService)
            {
                this.TestResultEventReceivingServiceSettings = Option.Some(new TestResultEventReceivingServiceSettings()
                {
                    EventHubConnectionString = Preconditions.CheckNonWhiteSpace(eventHubConnectionString, nameof(eventHubConnectionString)),
                    ConsumerGroupName        = "$Default"
                });
            }

            if (useTestResultReportingService)
            {
                this.TestResultReportingServiceSettings = Option.Some(new TestResultReportingServiceSettings()
                {
                    StorageAccountConnectionString = Preconditions.CheckNonWhiteSpace(storageAccountConnectionString, nameof(storageAccountConnectionString)),
                    LogAnalyticsLogType            = Preconditions.CheckNonWhiteSpace(logAnalyticsLogType, nameof(logAnalyticsLogType)),
                    LogAnalyticsSharedKey          = Preconditions.CheckNonWhiteSpace(logAnalyticsSharedKey, nameof(logAnalyticsSharedKey)),
                    LogAnalyticsWorkspaceId        = Preconditions.CheckNonWhiteSpace(logAnalyticsWorkspaceId, nameof(logAnalyticsWorkspaceId)),
                    LogUploadEnabled = logUploadEnabled
                });
            }

            this.ConnectivitySpecificSettings = Option.None <ConnectivitySpecificSettings>();
            this.LongHaulSpecificSettings     = Option.None <LongHaulSpecificSettings>();
            switch (testMode)
            {
            case TestMode.Connectivity:
            {
                this.ConnectivitySpecificSettings = Option.Some(new ConnectivitySpecificSettings()
                    {
                        TestDuration          = testDuration,
                        TestVerificationDelay = verificationDelay
                    });
                break;
            }

            case TestMode.LongHaul:
            {
                this.LongHaulSpecificSettings = Option.Some(new LongHaulSpecificSettings()
                    {
                        SendReportFrequency = sendReportFrequency
                    });
                break;
            }
            }

            this.TrackingId             = Preconditions.CheckNonWhiteSpace(trackingId, nameof(trackingId));
            this.IoTHubConnectionString = Preconditions.CheckNonWhiteSpace(iotHubConnectionString, nameof(iotHubConnectionString));
            this.DeviceId                = Preconditions.CheckNonWhiteSpace(deviceId, nameof(deviceId));
            this.ModuleId                = Preconditions.CheckNonWhiteSpace(moduleId, nameof(moduleId));
            this.WebHostPort             = Preconditions.CheckNotNull(webHostPort, nameof(webHostPort));
            this.StoragePath             = storagePath;
            this.OptimizeForPerformance  = Preconditions.CheckNotNull(optimizeForPerformance);
            this.TestStartDelay          = testStartDelay;
            this.NetworkControllerType   = this.GetNetworkControllerType(networkControllerRunProfileName);
            this.UnmatchedResultsMaxSize = Preconditions.CheckRange <ushort>(unmatchedResultsMaxSize, 1);

            this.TestInfo = ModuleUtil.ParseKeyValuePairs(testInfo, Logger, true);
            this.TestInfo.Add("DeviceId", this.DeviceId);
            this.TestMode = testMode;
        }