forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCryptoUtilTest.cs
More file actions
58 lines (48 loc) · 1.68 KB
/
Copy pathCryptoUtilTest.cs
File metadata and controls
58 lines (48 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.TestCommon;
namespace System.Web.Helpers.Test
{
public class CryptoUtilTest
{
[Theory]
[InlineData(new byte[0], null)]
[InlineData(null, new byte[0])]
[InlineData(new byte[0], new byte[] { 0x00 })]
[InlineData(new byte[] { 0x01, 0x02 }, new byte[] { 0x02, 0x01 })]
public void AreByteArraysEqual_False(byte[] a, byte[] b)
{
// Act
bool retVal = CryptoUtil.AreByteArraysEqual(a, b);
// Assert
Assert.NotEqual(a, b);
}
[Fact]
public void AreByteArraysEqual_True()
{
// Arrange
byte[] a = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
byte[] b = (byte[])a.Clone();
// Act
bool retVal = CryptoUtil.AreByteArraysEqual(a, b);
// Assert
Assert.Equal(a, b);
}
[Fact]
public void TestVectors_Empty()
{
// Act
byte[] retVal = CryptoUtil.ComputeSHA256(new string[0]);
// Assert
Assert.Equal("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", Convert.ToBase64String(retVal));
}
[Fact]
public void TestVectors_NonEmpty()
{
// Act
byte[] retVal = CryptoUtil.ComputeSHA256(new string[] { "a parameter", "another parameter" });
// Assert
Assert.Equal("Bez9yYh4Zq9jK1H5jD21wh04HTZi/vgxp6yDE7Y6cfo=", Convert.ToBase64String(retVal));
}
}
}