From 6e99d78cf402a8ad21d1bcdb28bd7ae2343b31fa Mon Sep 17 00:00:00 2001 From: Jason Pierce Date: Wed, 5 Oct 2016 21:03:45 -0700 Subject: [PATCH] Switch to Xunit --- Projects/Rijndael256.Tests/HashTests.cs | 14 +++---- Projects/Rijndael256.Tests/RijndaelTests.cs | 44 ++++++++++----------- Projects/Rijndael256.Tests/project.json | 7 ++-- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Projects/Rijndael256.Tests/HashTests.cs b/Projects/Rijndael256.Tests/HashTests.cs index cc88e92..1328125 100644 --- a/Projects/Rijndael256.Tests/HashTests.cs +++ b/Projects/Rijndael256.Tests/HashTests.cs @@ -7,7 +7,7 @@ */ using System; -using NUnit.Framework; +using Xunit; namespace Rijndael256.Tests { @@ -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"; @@ -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)); } } } diff --git a/Projects/Rijndael256.Tests/RijndaelTests.cs b/Projects/Rijndael256.Tests/RijndaelTests.cs index 88a357e..2e584b5 100644 --- a/Projects/Rijndael256.Tests/RijndaelTests.cs +++ b/Projects/Rijndael256.Tests/RijndaelTests.cs @@ -8,7 +8,7 @@ using System; using System.Text; -using NUnit.Framework; +using Xunit; namespace Rijndael256.Tests { @@ -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); } } } diff --git a/Projects/Rijndael256.Tests/project.json b/Projects/Rijndael256.Tests/project.json index 4b4b72a..fbcb428 100644 --- a/Projects/Rijndael256.Tests/project.json +++ b/Projects/Rijndael256.Tests/project.json @@ -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",