mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
e6a06915cd
Codestyle fixes Setup CODEOWNERS Setup dependabot
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using FluentAssertions;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.IO;
|
|
using System.Security.Hashing;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SystemExtensions.NetStandard.Security.Tests;
|
|
|
|
[TestClass]
|
|
public sealed class Sha256HashingServiceTests
|
|
{
|
|
private readonly IHashingService hashingService = new Sha256HashingService();
|
|
private string toHashtString;
|
|
private byte[] toHashtBytes;
|
|
private Stream toHashStream;
|
|
|
|
[TestInitialize]
|
|
public void TestInitialize()
|
|
{
|
|
this.toHashtBytes = Encoding.UTF8.GetBytes("toEncrypt");
|
|
this.toHashtString = Convert.ToBase64String(this.toHashtBytes);
|
|
this.toHashStream = new MemoryStream(this.toHashtBytes);
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task HashString()
|
|
{
|
|
var hash = await this.hashingService.Hash(this.toHashtString).ConfigureAwait(false);
|
|
hash.Should().BeOfType<string>();
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task HashBytes()
|
|
{
|
|
var hash = await this.hashingService.Hash(this.toHashtBytes).ConfigureAwait(false);
|
|
hash.Should().BeOfType<byte[]>();
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task HashStream()
|
|
{
|
|
var hash = await this.hashingService.Hash(this.toHashStream).ConfigureAwait(false);
|
|
hash.Should().BeAssignableTo<Stream>();
|
|
}
|
|
}
|