Solution restructured to use multiple test projects
This commit is contained in:
27
test/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs
Normal file
27
test/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using ReflectionMagic;
|
||||
|
||||
namespace AMWD.Common.Tests.Utils
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
internal class CryptographyHelperSaltMock : IDisposable
|
||||
{
|
||||
private readonly int _saltLength;
|
||||
|
||||
private CryptographyHelperSaltMock(int saltLength)
|
||||
{
|
||||
_saltLength = typeof(CryptographyHelper).AsDynamicType()._saltLength;
|
||||
SetSaltLength(saltLength);
|
||||
}
|
||||
|
||||
public static IDisposable Create(int saltLength)
|
||||
=> new CryptographyHelperSaltMock(saltLength);
|
||||
|
||||
public void Dispose()
|
||||
=> SetSaltLength(_saltLength);
|
||||
|
||||
private static void SetSaltLength(int length)
|
||||
=> typeof(CryptographyHelper).AsDynamicType()._saltLength = length;
|
||||
}
|
||||
}
|
||||
11
test/AMWD.Common.Tests/Utils/CustomMultipleAttribute.cs
Normal file
11
test/AMWD.Common.Tests/Utils/CustomMultipleAttribute.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace AMWD.Common.Tests.Utils
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
internal class CustomMultipleAttribute(string name) : Attribute
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
}
|
||||
}
|
||||
53
test/AMWD.Common.Tests/Utils/JsonTestClass.cs
Normal file
53
test/AMWD.Common.Tests/Utils/JsonTestClass.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
|
||||
namespace AMWD.Common.Tests.Utils
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
internal class JsonTestClass
|
||||
{
|
||||
public string StringValue { get; set; } = "Hello World!";
|
||||
|
||||
public bool IsBoolTrue { get; set; } = true;
|
||||
|
||||
public float FloatValue { get; set; } = 12.34f;
|
||||
|
||||
public double DoubleValue { get; set; } = 21.42;
|
||||
|
||||
public decimal DecimalValue { get; set; } = 42.21m;
|
||||
|
||||
public DateTime LocalTimestamp { get; set; } = new(2021, 11, 16, 20, 15, 34, DateTimeKind.Local);
|
||||
|
||||
public DateTime UtcTimestamp { get; set; } = new(2021, 11, 16, 20, 15, 34, DateTimeKind.Utc);
|
||||
|
||||
public JsonTestSubClass Object { get; set; } = new();
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
internal class JsonTestSubClass
|
||||
{
|
||||
public int IntegerValue { get; set; } = 42;
|
||||
|
||||
public string StringValue { get; set; } = "Foo-Bar";
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
internal class JsonErrorClass
|
||||
{
|
||||
private int? _number;
|
||||
|
||||
public int Number
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_number.HasValue)
|
||||
return _number.Value;
|
||||
|
||||
throw new Exception("Null value");
|
||||
}
|
||||
set
|
||||
{
|
||||
_number = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
test/AMWD.Common.Tests/Utils/TimeZoneInfoLocalMock.cs
Normal file
26
test/AMWD.Common.Tests/Utils/TimeZoneInfoLocalMock.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user