1
0
Files
common/UnitTests/Common/Utils/CryptographyHelperSaltMock.cs

28 lines
745 B
C#

using System;
using System.Security.Cryptography;
using ReflectionMagic;
namespace UnitTests.Common.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;
}
}