зеркало из https://github.com/microsoft/Omex.git
restore unrelated files
This commit is contained in:
Родитель
36618449f6
Коммит
b59f440357
|
@ -46,14 +46,7 @@ public static class OmexHealthCheckServiceCollectionExtensions
|
|||
/// <param name="predicate"></param>
|
||||
public static bool TryRemoveServiceByPredicate(this IServiceCollection @this, Func<ServiceDescriptor, bool> predicate)
|
||||
{
|
||||
|
||||
/* Unmerged change from project 'Microsoft.Omex.Extensions.Diagnostics.HealthChecks(netstandard2.0)'
|
||||
Before:
|
||||
var descriptorToRemove = @this.SingleOrDefault(predicate);
|
||||
After:
|
||||
ServiceDescriptor descriptorToRemove = @this.SingleOrDefault(predicate);
|
||||
*/
|
||||
ServiceDescriptor? descriptorToRemove = @this.SingleOrDefault(predicate);
|
||||
var descriptorToRemove = @this.SingleOrDefault(predicate);
|
||||
if (descriptorToRemove != null)
|
||||
{
|
||||
return @this.Remove(descriptorToRemove);
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks
|
|||
}
|
||||
|
||||
#if !NETCOREAPP3_1 && !NETSTANDARD2_0
|
||||
clone.VersionPolicy = message.VersionPolicy;
|
||||
clone.VersionPolicy = message.VersionPolicy;
|
||||
|
||||
foreach (KeyValuePair<string, object?> option in message.Options)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ internal static class NonCapturingTimer
|
|||
}
|
||||
|
||||
// Don't capture the current ExecutionContext and its AsyncLocals onto the timer
|
||||
bool restoreFlow = false;
|
||||
var restoreFlow = false;
|
||||
try
|
||||
{
|
||||
if (!ExecutionContext.IsFlowSuppressed())
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.Fabric;
|
||||
using System.Fabric.Health;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Omex.Extensions.Abstractions;
|
||||
using System.Fabric.Health;
|
||||
|
||||
namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks
|
||||
{
|
||||
|
|
|
@ -34,9 +34,9 @@ internal struct ValueStopwatch
|
|||
throw new InvalidOperationException("An uninitialized, or 'default', ValueStopwatch cannot be used to get elapsed time.");
|
||||
}
|
||||
|
||||
long end = Stopwatch.GetTimestamp();
|
||||
long timestampDelta = end - _startTimestamp;
|
||||
long ticks = (long)(TimestampToTicks * timestampDelta);
|
||||
var end = Stopwatch.GetTimestamp();
|
||||
var timestampDelta = end - _startTimestamp;
|
||||
var ticks = (long)(TimestampToTicks * timestampDelta);
|
||||
return new TimeSpan(ticks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ internal sealed partial class OmexHealthCheckPublisherHostedService : IHostedSer
|
|||
// actually tries to **run** health checks would be real baaaaad.
|
||||
ValidateRegistrations(_healthCheckServiceOptions.Value.Registrations);
|
||||
|
||||
_defaultTimerOptions = (_healthCheckPublisherOptions.Value.Delay, _healthCheckPublisherOptions.Value.Period, _healthCheckPublisherOptions.Value.Timeout);
|
||||
_defaultTimerOptions = (_healthCheckPublisherOptions.Value.Delay, _healthCheckPublisherOptions.Value.Period, _healthCheckPublisherOptions.Value.Timeout);
|
||||
|
||||
// Group healthcheck registrations by Delay, Period and Timeout, to build a Dictionary<(TimeSpan, TimeSpan, TimeSpan), List<HealthCheckRegistration>>
|
||||
// For HCs with no Delay, Period or Timeout, we default to the publisher values
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.Web.Middlewares
|
|||
private static readonly string[] s_officeClientQueryParameters = {
|
||||
"client", // Identifies the client application and platform
|
||||
"av", // Identifies the client application, platform and partial version
|
||||
"app" }; // Identifies the client application
|
||||
"app" }; // Identifies the client application
|
||||
|
||||
private const string CorrelationHeader = "X-CorrelationId";
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Omex.Extensions.Logging
|
|||
/// </summary>
|
||||
public static ILogger Instance { get; private set; } = LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder.LoadInitializationLogger();
|
||||
builder.LoadInitializationLogger();
|
||||
}).CreateLogger("Initial-Logging");
|
||||
|
||||
private static ILoggingBuilder LoadInitializationLogger(this ILoggingBuilder builder)
|
||||
|
@ -56,7 +56,7 @@ namespace Microsoft.Omex.Extensions.Logging
|
|||
/// <param name="serviceNameForLogging">Service name for logging</param>
|
||||
/// <param name="ex">Exception to log</param>
|
||||
/// <param name="message">Message to log</param>
|
||||
public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "")
|
||||
public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "")
|
||||
{
|
||||
ServiceInitializationEventSource.Instance.LogHostFailed(ex?.ToString() ?? string.Empty, serviceNameForLogging, message);
|
||||
Instance.LogError(Tag.Create(), ex, message);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Diagnostics;
|
||||
using Moq;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Microsoft.Omex.Extensions.Activities.UnitTests
|
||||
{
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using Microsoft.Omex.Extensions.Abstractions.Activities.Processing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Omex.Extensions.Abstractions.Activities.Processing;
|
||||
using Microsoft.Omex.Extensions.Testing.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Omex.Extensions.Activities.UnitTests
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests.Extensions
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests.Extension
|
|||
throw new TimeoutException(CreateMessage(timeout, filePath, lineNumber));
|
||||
}
|
||||
#else
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
var cts = new CancellationTokenSource();
|
||||
if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token)).ConfigureAwait(false))
|
||||
{
|
||||
cts.Cancel();
|
||||
|
|
|
@ -28,9 +28,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task StartAsync_WithoutPublishers_DoesNotStartTimer()
|
||||
{
|
||||
// Arrange
|
||||
IHealthCheckPublisher[] publishers = Array.Empty<IHealthCheckPublisher>();
|
||||
var publishers = Array.Empty<IHealthCheckPublisher>();
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers);
|
||||
var service = CreateService(publishers);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -53,12 +53,12 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task StartAsync_WithPublishers_StartsTimer()
|
||||
{
|
||||
// Arrange
|
||||
IHealthCheckPublisher[] publishers = new IHealthCheckPublisher[]
|
||||
var publishers = new IHealthCheckPublisher[]
|
||||
{
|
||||
new TestPublisher(),
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers);
|
||||
var service = CreateService(publishers);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -81,11 +81,11 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task StartAsync_WithPublishers_StartsTimer_RunsPublishers()
|
||||
{
|
||||
// Arrange
|
||||
TaskCompletionSource<object?> unblock0 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource<object?> unblock1 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource<object?> unblock2 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock0 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock1 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock2 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock0.Task, },
|
||||
new TestPublisher() { Wait = unblock1.Task, },
|
||||
|
@ -126,9 +126,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task StopAsync_CancelsExecution()
|
||||
{
|
||||
// Arrange
|
||||
TaskCompletionSource<object?> unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock.Task, }
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await service.StartAsync();
|
||||
|
||||
// Start execution
|
||||
Task running = service.RunAsync();
|
||||
var running = service.RunAsync();
|
||||
|
||||
// Wait for the publisher to see the cancellation token
|
||||
await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
@ -170,9 +170,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_WaitsForCompletion_Single()
|
||||
{
|
||||
// Arrange
|
||||
TaskCompletionSource<object?> unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock.Task, },
|
||||
};
|
||||
|
@ -184,7 +184,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await service.StartAsync();
|
||||
|
||||
// Act
|
||||
Task running = service.RunAsync();
|
||||
var running = service.RunAsync();
|
||||
|
||||
await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
||||
|
@ -196,10 +196,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
Assert.IsTrue(service.IsTimerRunning);
|
||||
Assert.IsFalse(service.IsStopping);
|
||||
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
Assert.IsTrue(publishers[i].Entries.Count == 1);
|
||||
HealthReport report = publishers[i].Entries.Single().report;
|
||||
var report = publishers[i].Entries.Single().report;
|
||||
CollectionAssert.AreEqual(new[] { "one", "two", }, report.Entries.Keys.OrderBy(k => k).ToArray());
|
||||
}
|
||||
}
|
||||
|
@ -217,15 +217,15 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
// Arrange
|
||||
const string HealthyMessage = "Everything is A-OK";
|
||||
|
||||
TaskCompletionSource<object?> unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource<object?> unblockDelayedCheck = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblockDelayedCheck = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock.Task, },
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers, configureBuilder: b =>
|
||||
var service = CreateService(publishers, configureBuilder: b =>
|
||||
{
|
||||
b.AddAsyncCheck("CheckDefault", _ =>
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await service.StartAsync();
|
||||
|
||||
// Act
|
||||
Task running = service.RunAsync();
|
||||
var running = service.RunAsync();
|
||||
|
||||
await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
||||
|
@ -278,10 +278,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
Assert.IsTrue(service.IsTimerRunning);
|
||||
Assert.IsFalse(service.IsStopping);
|
||||
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
Assert.IsTrue(publishers[i].Entries.Count == 4);
|
||||
string[] entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray();
|
||||
var entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray();
|
||||
CollectionAssert.AreEqual(
|
||||
new[] { "CheckDefault", "CheckDelay2Period18", "CheckDelay7Period11", "CheckDelay9Period5" },
|
||||
entries);
|
||||
|
@ -299,11 +299,11 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_WaitsForCompletion_Multiple()
|
||||
{
|
||||
// Arrange
|
||||
TaskCompletionSource<object?> unblock0 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource<object?> unblock1 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource<object?> unblock2 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock0 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock1 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock2 = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock0.Task, },
|
||||
new TestPublisher() { Wait = unblock1.Task, },
|
||||
|
@ -317,7 +317,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await service.StartAsync();
|
||||
|
||||
// Act
|
||||
Task running = service.RunAsync();
|
||||
var running = service.RunAsync();
|
||||
|
||||
await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await publishers[1].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
@ -333,10 +333,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
Assert.IsTrue(service.IsTimerRunning);
|
||||
Assert.IsFalse(service.IsStopping);
|
||||
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
Assert.IsTrue(publishers[i].Entries.Count == 1);
|
||||
HealthReport report = publishers[i].Entries.Single().report;
|
||||
var report = publishers[i].Entries.Single().report;
|
||||
CollectionAssert.AreEqual(new[] { "one", "two", }, report.Entries.Keys.OrderBy(k => k).ToArray());
|
||||
}
|
||||
}
|
||||
|
@ -352,21 +352,21 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_PublishersCanTimeout()
|
||||
{
|
||||
// Arrange
|
||||
TaskCompletionSource<object?> unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblock = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Wait = unblock.Task, },
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers);
|
||||
var service = CreateService(publishers);
|
||||
|
||||
try
|
||||
{
|
||||
await service.StartAsync();
|
||||
|
||||
// Act
|
||||
Task running = service.RunAsync();
|
||||
var running = service.RunAsync();
|
||||
|
||||
await publishers[0].Started.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
||||
|
@ -394,13 +394,13 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_CanFilterHealthChecks()
|
||||
{
|
||||
// Arrange
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher(),
|
||||
new TestPublisher(),
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers, configurePublisherOptions: (options) =>
|
||||
var service = CreateService(publishers, configurePublisherOptions: (options) =>
|
||||
{
|
||||
options.Predicate = (r) => r.Name == "one";
|
||||
});
|
||||
|
@ -413,10 +413,10 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await service.RunAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
|
||||
// Assert
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
Assert.IsTrue(publishers[i].Entries.Count == 1);
|
||||
HealthReport report = publishers[i].Entries.Single().report;
|
||||
var report = publishers[i].Entries.Single().report;
|
||||
CollectionAssert.AreEqual(new[] { "one" }, report.Entries.Keys.OrderBy(k => k).ToArray());
|
||||
}
|
||||
}
|
||||
|
@ -434,15 +434,15 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
// Arrange
|
||||
const string HealthyMessage = "Everything is A-OK";
|
||||
|
||||
TaskCompletionSource<object?> unblockDelayedCheck = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unblockDelayedCheck = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher(),
|
||||
new TestPublisher(),
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(
|
||||
var service = CreateService(
|
||||
publishers,
|
||||
configurePublisherOptions: (options) =>
|
||||
{
|
||||
|
@ -492,9 +492,9 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
await unblockDelayedCheck.Task;
|
||||
|
||||
// Assert
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
string[] entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray();
|
||||
var entries = publishers[i].Entries.SelectMany(e => e.report.Entries.Select(e2 => e2.Key)).OrderBy(k => k).ToArray();
|
||||
|
||||
Assert.IsTrue(entries.Count() == 3);
|
||||
CollectionAssert.AreEqual(
|
||||
|
@ -514,12 +514,12 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_HandlesExceptions()
|
||||
{
|
||||
// Arrange
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Exception = new InvalidTimeZoneException(), },
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers);
|
||||
var service = CreateService(publishers);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -541,14 +541,14 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
public async Task RunAsync_HandlesExceptions_Multiple()
|
||||
{
|
||||
// Arrange
|
||||
TestPublisher[] publishers = new TestPublisher[]
|
||||
var publishers = new TestPublisher[]
|
||||
{
|
||||
new TestPublisher() { Exception = new InvalidTimeZoneException(), },
|
||||
new TestPublisher(),
|
||||
new TestPublisher() { Exception = new InvalidTimeZoneException(), },
|
||||
};
|
||||
|
||||
OmexHealthCheckPublisherHostedService service = CreateService(publishers);
|
||||
var service = CreateService(publishers);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -597,7 +597,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
|
||||
if (publishers != null)
|
||||
{
|
||||
for (int i = 0; i < publishers.Length; i++)
|
||||
for (var i = 0; i < publishers.Length; i++)
|
||||
{
|
||||
serviceCollection.AddSingleton(publishers[i]);
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
serviceCollection.Configure(configurePublisherOptions);
|
||||
}
|
||||
|
||||
ServiceProvider services = serviceCollection.BuildServiceProvider();
|
||||
var services = serviceCollection.BuildServiceProvider();
|
||||
return services.GetServices<IHostedService>().OfType<OmexHealthCheckPublisherHostedService>().Single();
|
||||
}
|
||||
|
||||
|
|
|
@ -122,19 +122,19 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
|
||||
private static PublisherContext CreatePublisher(bool canInitizlize = true)
|
||||
{
|
||||
Dictionary<string, HealthStateInfo> reportedState = new();
|
||||
Mock<IHealthStatusSender> mockSender = new();
|
||||
Dictionary<string, HealthStateInfo> reportedState = new ();
|
||||
Mock<IHealthStatusSender> mockSender = new ();
|
||||
mockSender.Setup(s => s.IntializeAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult(canInitizlize));
|
||||
mockSender.Setup(s_sendStatusExpression)
|
||||
.Callback((string name, HealthStatus status, string description, CancellationToken token) =>
|
||||
reportedState[name] = new HealthStateInfo(status, description))
|
||||
.Returns(Task.CompletedTask);
|
||||
|
||||
OmexHealthCheckPublisher publisher = new(
|
||||
OmexHealthCheckPublisher publisher = new (
|
||||
mockSender.Object,
|
||||
new DefaultObjectPoolProvider());
|
||||
|
||||
return new(publisher, mockSender, reportedState);
|
||||
return new (publisher, mockSender, reportedState);
|
||||
}
|
||||
|
||||
private record PublisherContext(
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
|||
Mock<IExecutionContext> mockContext = new();
|
||||
mockContext.SetupGet(c => c.NodeName).Returns("TestNodeName");
|
||||
|
||||
RestHealthStatusSender sender = new(sfClientWrapper.Object, mockContext.Object);
|
||||
RestHealthStatusSender sender = new (sfClientWrapper.Object, mockContext.Object);
|
||||
|
||||
return new SenderInfo(sender, sfClientWrapper, reportedState);
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Fabric;
|
||||
using System.Fabric.Health;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Omex.Extensions.Abstractions.Accessors;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System.Fabric.Health;
|
||||
|
||||
namespace Microsoft.Omex.Extensions.Diagnostics.HealthChecks.UnitTests
|
||||
{
|
||||
|
|
|
@ -175,8 +175,7 @@ namespace Microsoft.Omex.Extensions.Hosting.UnitTests
|
|||
{
|
||||
storeMock.Verify(expression, times, message);
|
||||
storeMock.Invocations.Clear();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests.Scrubbing
|
|||
public void AddRegexLogScrubbingRule_Scrubs(string input, string expected)
|
||||
{
|
||||
ILoggingBuilder builder2 = new MockLoggingBuilder()
|
||||
.AddRegexLogScrubbingRule(Regex, "REDACTED&");
|
||||
.AddRegexLogScrubbingRule(Regex,"REDACTED&");
|
||||
|
||||
ILogScrubbingRule[] logScrubbingRules = GetTypeRegistrations(builder2.Services);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests
|
|||
[DataRow(int.MaxValue, "\u007f???")]
|
||||
public void TagIdAsString_ConvertsProperly(int tagId, string expected)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
# pragma warning disable 618
|
||||
Assert.AreEqual(expected, new EventId(tagId).ToTagId());
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче