-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathBlobStorageTests.cs
41 lines (33 loc) · 1.21 KB
/
BlobStorageTests.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.IO;
using HaveIBeenPwned.PwnedPasswords.Implementations.Azure;
using Xunit;
namespace HaveIBeenPwned.PwnedPasswords.Tests;
public class BlobStorageTests
{
[Fact]
public void RendersHashesWithoutEndingNewline()
{
SortedDictionary<string, int> fakeHahes = new()
{
{ "ABCDEF", 0 },
{ "FEDCBA", 1234 }
};
StringWriter writer = new();
BlobStorage.RenderHashes(fakeHahes, writer);
Assert.Equal($"ABCDEF:0{writer.NewLine}FEDCBA:1234", writer.ToString());
}
[Theory]
[InlineData("FDFD0D9BC12735B077ACF1FA63D6F42229D:1")]
[InlineData("FE5CCB19BA61C4C0873D391E987982FBBD3:86,453")]
public void ParsesCultureIntSuccessfully(string hashLine)
{
if (!string.IsNullOrEmpty(hashLine) && hashLine.Length >= 37 && hashLine[35] == ':' && int.TryParse(hashLine[36..].Replace(",", ""), out int currentPrevalence) && currentPrevalence > 0)
{
return;
}
Assert.Fail($"Failed to parse {hashLine} successfully");
}
}