Browse Source

Unit tests some string extensions

Former-commit-id: 86f7663ed5656b3241f9a7ea8b1e532140399e7b
pull/17/head
Thomas Broust 12 years ago
committed by James South
parent
commit
d02be122fd
  1. 91
      src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs
  2. 1
      src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj

91
src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs

@ -0,0 +1,91 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StringExtensionsUnitTests.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Provides a test harness for the string extensions
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests
{
using System;
using Common.Extensions;
using NUnit.Framework;
/// <summary>
/// Test harness for the string extensions
/// </summary>
[TestFixture]
public class StringExtensionsUnitTests
{
/// <summary>
/// Tests the MD5 fingerprint
/// </summary>
/// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param>
[Test]
[TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")]
[TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")]
[TestCase("LoReM IpSuM DoLoR", "41e201da794c7fbdb8ce5526a71c8c83")]
[TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")]
public void TestToMd5Fingerprint(string input, string expected)
{
var result = input.ToMD5Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison);
}
/// <summary>
/// Tests the SHA-1 fingerprint
/// </summary>
/// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param>
[Test]
[TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")]
[TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")]
[TestCase("LoReM IpSuM DoLoR", "2f44519afae72fc0837b72c6b53cb11338a1f916")]
[TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")]
public void TestToSHA1Fingerprint(string input, string expected)
{
var result = input.ToSHA1Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison);
}
/// <summary>
/// Tests the SHA-256 fingerprint
/// </summary>
/// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param>
[Test]
[TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")]
[TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")]
[TestCase("LoReM IpSuM DoLoR", "55f6cb90ba5cd8eeb6f5f16f083ebcd48ea06c34cc5aed8e33246fc3153d3898")]
[TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")]
public void TestToSHA256Fingerprint(string input, string expected)
{
var result = input.ToSHA256Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison);
}
/// <summary>
/// Tests the SHA-512 fingerprint
/// </summary>
/// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param>
[Test]
[TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")]
[TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")]
[TestCase("LoReM IpSuM DoLoR", "3e4704d31f838456c0a5f0892afd392fbc79649a029d017b8104ebd00e2816d94ab4629f731765bf655088b130c51f6f47ca2f8b047749dbd992cf45e89ff431")]
[TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")]
public void TestToSHA512Fingerprint(string input, string expected)
{
var result = input.ToSHA512Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison);
}
}
}

1
src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj

@ -48,6 +48,7 @@
</Compile>
<Compile Include="Extensions\DoubleExtensionsUnitTests.cs" />
<Compile Include="Extensions\IntegerExtensionsUnitTests.cs" />
<Compile Include="Extensions\StringExtensionsUnitTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

Loading…
Cancel
Save