Skip to content

Commit

Permalink
Switch to Xunit
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonPierce committed Oct 6, 2016
1 parent 942e740 commit 6e99d78
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
14 changes: 7 additions & 7 deletions Projects/Rijndael256.Tests/HashTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

using System;
using NUnit.Framework;
using Xunit;

namespace Rijndael256.Tests
{
Expand All @@ -19,17 +19,17 @@ public class HashTests

#endregion

[Test]
[Fact]
public void Sha512()
{
const string proof = "5670CA06284E9328D363CD7F6986374D22806F21A106DE5EDFE5D5667B577B33D69024A1E13E468B44A9C4EE5542AB9" +
"BC4D19BCF083BE1270D2E66A989105429";

var hash = Hash.Sha512(Data);
Assert.AreEqual(hash, proof);
Assert.Equal(hash, proof);
}

[Test]
[Fact]
public void Pbkdf2()
{
const string salt = "0A9FDB669FA44FF1BEC484A1BE6B6E2A";
Expand All @@ -39,9 +39,9 @@ public void Pbkdf2()
var hash100 = Hash.Pbkdf2(Data, salt, 100);
var hash1000 = Hash.Pbkdf2(Data, salt, 1000);

Assert.AreEqual(Convert.ToBase64String(hash100), proof100);
Assert.AreEqual(Convert.ToBase64String(hash1000), proof1000);
Assert.AreNotEqual(Convert.ToBase64String(hash100), Convert.ToBase64String(hash1000));
Assert.Equal(Convert.ToBase64String(hash100), proof100);
Assert.Equal(Convert.ToBase64String(hash1000), proof1000);
Assert.NotEqual(Convert.ToBase64String(hash100), Convert.ToBase64String(hash1000));
}
}
}
44 changes: 22 additions & 22 deletions Projects/Rijndael256.Tests/RijndaelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using System;
using System.Text;
using NUnit.Framework;
using Xunit;

namespace Rijndael256.Tests
{
Expand All @@ -26,85 +26,85 @@ public class RijndaelTests

#endregion

[Test]
[Fact]
public void Encrypt128()
{
var data = Encoding.UTF8.GetBytes(Data);
var cipher = Rijndael.Encrypt(data, Password, InitializationVector, KeySize.Aes128);
Assert.AreEqual(Convert.ToBase64String(cipher), Cipher128);
Assert.Equal(Convert.ToBase64String(cipher), Cipher128);
}

[Test]
[Fact]
public void Encrypt192()
{
var data = Encoding.UTF8.GetBytes(Data);
var cipher = Rijndael.Encrypt(data, Password, InitializationVector, KeySize.Aes192);
Assert.AreEqual(Convert.ToBase64String(cipher), Cipher192);
Assert.Equal(Convert.ToBase64String(cipher), Cipher192);
}

[Test]
[Fact]
public void Encrypt256()
{
var data = Encoding.UTF8.GetBytes(Data);
var cipher = Rijndael.Encrypt(data, Password, InitializationVector, KeySize.Aes256);
Assert.AreEqual(Convert.ToBase64String(cipher), Cipher256);
Assert.Equal(Convert.ToBase64String(cipher), Cipher256);
}

[Test]
[Fact]
public void Decrypt128()
{
var cipher = Convert.FromBase64String(Cipher128);
var data = Rijndael.Decrypt(cipher, Password, InitializationVector, KeySize.Aes128);
Assert.AreEqual(Encoding.UTF8.GetString(data), Data);
Assert.Equal(Encoding.UTF8.GetString(data), Data);
}

[Test]
[Fact]
public void Decrypt192()
{
var cipher = Convert.FromBase64String(Cipher192);
var data = Rijndael.Decrypt(cipher, Password, InitializationVector, KeySize.Aes192);
Assert.AreEqual(Encoding.UTF8.GetString(data), Data);
Assert.Equal(Encoding.UTF8.GetString(data), Data);
}

[Test]
[Fact]
public void Decrypt256()
{
var cipher = Convert.FromBase64String(Cipher256);
var data = Rijndael.Decrypt(cipher, Password, InitializationVector, KeySize.Aes256);
Assert.AreEqual(Encoding.UTF8.GetString(data), Data);
Assert.Equal(Encoding.UTF8.GetString(data), Data);
}

[Test]
[Fact]
public void RandomIv128()
{
var cipher1 = Rijndael.Encrypt(Data, Password, KeySize.Aes128);
var cipher2 = Rijndael.Encrypt(Data, Password, KeySize.Aes128);
var data = Rijndael.Decrypt(cipher1, Password, KeySize.Aes128);

Assert.AreEqual(data, Data);
Assert.AreNotEqual(cipher1, cipher2);
Assert.Equal(data, Data);
Assert.NotEqual(cipher1, cipher2);
}

[Test]
[Fact]
public void RandomIv192()
{
var cipher1 = Rijndael.Encrypt(Data, Password, KeySize.Aes192);
var cipher2 = Rijndael.Encrypt(Data, Password, KeySize.Aes192);
var data = Rijndael.Decrypt(cipher1, Password, KeySize.Aes192);

Assert.AreEqual(data, Data);
Assert.AreNotEqual(cipher1, cipher2);
Assert.Equal(data, Data);
Assert.NotEqual(cipher1, cipher2);
}

[Test]
[Fact]
public void RandomIv256()
{
var cipher1 = Rijndael.Encrypt(Data, Password, KeySize.Aes256);
var cipher2 = Rijndael.Encrypt(Data, Password, KeySize.Aes256);
var data = Rijndael.Decrypt(cipher1, Password, KeySize.Aes256);

Assert.AreEqual(data, Data);
Assert.AreNotEqual(cipher1, cipher2);
Assert.Equal(data, Data);
Assert.NotEqual(cipher1, cipher2);
}
}
}
7 changes: 3 additions & 4 deletions Projects/Rijndael256.Tests/project.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"version": "2.0.0",
"testRunner": "xunit",

"dependencies": {
"Rijndael256": {
"target": "project"
},
"NUnit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-2"
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},

"testRunner": "nunit",

"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net45+win8",
Expand Down

0 comments on commit 6e99d78

Please sign in to comment.