Merge pull request #129 from tidusjar/master

More Unit Tests
This commit is contained in:
MaxXor 2015-05-14 10:37:47 +02:00
commit 74cbf47a80
6 changed files with 77 additions and 2 deletions

View File

@ -39,6 +39,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
@ -53,8 +54,10 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Core\Compression\JpgCompressionTests.cs" />
<Compile Include="Core\Encryption\AES.Tests.cs" />
<Compile Include="Core\Encryption\SHA256.Tests.cs" />
<Compile Include="Core\Information\GeoIPTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,24 @@
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using xClient.Core.Compression;
namespace xClient.Tests.Core.Compression
{
[TestClass]
public class JpgCompressionTests
{
[TestMethod]
public void CompressionTest()
{
var quality = Int64.MaxValue;
var jpg = new JpgCompression(quality);
var bitmap = new Bitmap(200, 200);
var result = jpg.Compress(bitmap);
Assert.IsNotNull(result);
CollectionAssert.AllItemsAreNotNull(result);
}
}
}

View File

@ -1,4 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using xClient.Core.Encryption;
using xClient.Core.Helper;
@ -8,7 +10,7 @@ namespace xClient.Tests.Core.Encryption
public class AESTests
{
[TestMethod]
public void EncryptAndDecryptTest()
public void EncryptAndDecryptStringTest()
{
var input = Helper.GetRandomName(100);
var password = Helper.GetRandomName(50);
@ -21,5 +23,26 @@ namespace xClient.Tests.Core.Encryption
Assert.IsTrue(input == decrypted);
}
[TestMethod]
public void EncryptAndDecryptByteArrayTest()
{
var input = Helper.GetRandomName(100);
var inputByte = Encoding.UTF8.GetBytes(input);
var password = Helper.GetRandomName(50);
var passwordByte = Encoding.UTF8.GetBytes(password);
var encrypted = AES.Encrypt(inputByte, passwordByte);
Assert.IsNotNull(encrypted);
Assert.AreNotEqual(encrypted, input);
var decrypted = AES.Decrypt(encrypted, passwordByte);
//The decryption method is adding on blank bytes.
var realDecrypted = decrypted.Take(100).ToArray();
CollectionAssert.AreEqual(inputByte,realDecrypted);
}
}
}

View File

@ -0,0 +1,21 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using xClient.Core.Information;
namespace xClient.Tests.Core.Information
{
[TestClass]
public class GeoIPTests
{
[TestMethod]
public void GetGeoIPTest()
{
var ipInformation = new GeoIP();
Assert.IsNotNull(ipInformation.City);
Assert.IsNotNull(ipInformation.Country);
Assert.IsNotNull(ipInformation.CountryCode);
Assert.IsNotNull(ipInformation.Region);
Assert.IsNotNull(ipInformation.WanIp);
}
}
}

View File

@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
@ -12,6 +13,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("Client.Tests")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von

View File

@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using xServer.Settings;
@ -13,6 +14,7 @@ using xServer.Settings;
[assembly: AssemblyCopyright("Copyright © MaxX0r 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("Server.Tests")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von