Skip to content

Commit

Permalink
Enable more tests to run during PR (#4784)
Browse files Browse the repository at this point in the history
  • Loading branch information
jander-msft authored Jun 30, 2023
1 parent b64e141 commit 6214cee
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Microsoft.Diagnostics.Monitoring.Tool.UnitTests
{
[TargetFrameworkMonikerTrait(TargetFrameworkMonikerExtensions.CurrentTargetFrameworkMoniker)]
public sealed class FileSystemEgressExtensionTests
{
const string ProviderName = "TestProvider";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Diagnostics.Monitoring.Options;
using Microsoft.Diagnostics.Monitoring.TestCommon;
using Microsoft.Diagnostics.Tools.Monitor;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
using Xunit;

namespace Microsoft.Diagnostics.Monitoring.Tool.UnitTests
{
[TargetFrameworkMonikerTrait(TargetFrameworkMonikerExtensions.CurrentTargetFrameworkMoniker)]
public sealed class InProcessFeaturesOptionsBinderTests
{
private const string FeatureConfigurationKey = "InProcessFeatures:TestFeature";
Expand Down Expand Up @@ -199,58 +201,6 @@ public void InProcessFeaturesOptionsBinder_BindEnabled_EnabledPropertyDisabledFe
Assert.False(options.Enabled.Value);
}

/// <summary>
/// Tests that a feature is enabled if InProcessFeatures:<Feature> is true.
/// </summary>
[Fact]
public void InProcessFeaturesOptionsBinder_BindEnabled_EnabledSection()
{
IConfigurationRoot configurationRoot = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string>()
{
{ FeatureConfigurationKey, "true" }
})
.Build();

TestFeatureOptions options = new();

InProcessFeatureOptionsBinder.BindEnabled(
options,
FeatureConfigurationKey,
configurationRoot,
enabledByDefault: true);

Assert.True(options.Enabled.HasValue);
Assert.True(options.Enabled.Value);
}

/// <summary>
/// Tests that a feature is disabled if InProcessFeatures:<Feature> is true
/// and InProcessFeatures:Enabled is false.
/// </summary>
[Fact]
public void InProcessFeaturesOptionsBinder_BindEnabled_EnabledSectionDisabledFeatures()
{
IConfigurationRoot configurationRoot = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string>()
{
{ ConfigurationKeys.InProcessFeatures_Enabled, "false" },
{ FeatureConfigurationKey, "true" }
})
.Build();

TestFeatureOptions options = new();

InProcessFeatureOptionsBinder.BindEnabled(
options,
FeatureConfigurationKey,
configurationRoot,
enabledByDefault: true);

Assert.True(options.Enabled.HasValue);
Assert.False(options.Enabled.Value);
}

private sealed class TestFeatureOptions : IInProcessFeatureOptions
{
public bool? Enabled { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Diagnostics.Monitoring.EventPipe;
using Microsoft.Diagnostics.Monitoring.TestCommon;
using Microsoft.Diagnostics.Monitoring.WebApi;
using Microsoft.Extensions.Logging;
using System;
Expand All @@ -14,6 +15,7 @@

namespace Microsoft.Diagnostics.Monitoring.Tool.UnitTests
{
[TargetFrameworkMonikerTrait(TargetFrameworkMonikerExtensions.CurrentTargetFrameworkMoniker)]
public sealed class MetricsFormattingTests
{
private ITestOutputHelper _outputHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Microsoft.Diagnostics.Monitoring.Tool.UnitTests
{
[TargetFrameworkMonikerTrait(TargetFrameworkMonikerExtensions.CurrentTargetFrameworkMoniker)]
public class MetricsSettingsTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down

0 comments on commit 6214cee

Please sign in to comment.