1
0
Files
common/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs
2021-11-19 23:19:33 +01:00

28 lines
746 B
C#

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)
{
this.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;
}
}