public void SetDefaultValueWhenReceivedInvalidTwin() { var diagnosticProvider = new ContinuousDiagnosticProvider(SamplingRateSource.Server); var twin = new Twin(); twin.Properties.Desired["diag_enableInvalid"] = false; twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagSamplingRateKey] = 10; diagnosticProvider.SetSamplingConfigFromTwin(twin.Properties.Desired); Assert.AreEqual(diagnosticProvider.SamplingOn, true); Assert.AreEqual(diagnosticProvider.SamplingRatePercentage, 10); twin = new Twin(); twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagEnableKey] = "dddd"; twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagSamplingRateKey] = 10; diagnosticProvider.SetSamplingConfigFromTwin(twin.Properties.Desired); Assert.AreEqual(diagnosticProvider.SamplingOn, false); twin = new Twin(); twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagEnableKey] = true; twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagSamplingRateKey] = "xxx"; diagnosticProvider.SetSamplingConfigFromTwin(twin.Properties.Desired); Assert.AreEqual(diagnosticProvider.SamplingRatePercentage, 0); twin = new Twin(); twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagEnableKey] = true; twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagSamplingRateKey] = 10; diagnosticProvider.SetSamplingConfigFromTwin(twin.Properties.Desired); }
public void UpdateDiagnosticSettingsFromServer() { var diagnosticProvider = new ContinuousDiagnosticProvider(SamplingRateSource.Server); var twin = new Twin(); twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagEnableKey] = true; twin.Properties.Desired[BaseDiagnosticProvider.TwinDiagSamplingRateKey] = 10; diagnosticProvider.SetSamplingConfigFromTwin(twin.Properties.Desired); Assert.AreEqual(diagnosticProvider.SamplingOn, true); Assert.AreEqual(diagnosticProvider.SamplingRatePercentage, 10); }