1
0

Solution restructured to use multiple test projects

This commit is contained in:
2024-07-04 18:22:26 +02:00
parent 508379d704
commit df6763b99b
144 changed files with 387 additions and 1693 deletions

View File

@@ -0,0 +1,26 @@
using System;
using ReflectionMagic;
namespace AMWD.Common.Tests.Utils
{
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
internal class TimeZoneInfoLocalMock : IDisposable
{
private readonly TimeZoneInfo _localTimeZoneInfo;
private TimeZoneInfoLocalMock(TimeZoneInfo timeZoneInfo)
{
_localTimeZoneInfo = TimeZoneInfo.Local;
SetLocalTimeZone(timeZoneInfo);
}
public static IDisposable Create(TimeZoneInfo mockTimeZoneInfo)
=> new TimeZoneInfoLocalMock(mockTimeZoneInfo);
public void Dispose()
=> SetLocalTimeZone(_localTimeZoneInfo);
private static void SetLocalTimeZone(TimeZoneInfo timeZoneInfo)
=> typeof(TimeZoneInfo).AsDynamicType().s_cachedData._localTimeZone = timeZoneInfo;
}
}