Added unittest
This commit is contained in:
52
Katteker.Test/KattekerLibTest.cs
Normal file
52
Katteker.Test/KattekerLibTest.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Katteker.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class KattekerLibTest
|
||||
{
|
||||
private static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
private static readonly string ExampleFile = Path.Combine(BaseDir, "testdata", "Example.exe");
|
||||
|
||||
[TestMethod]
|
||||
public void Sha1ChecksumOfFile()
|
||||
{
|
||||
var actual = Utility.ComputeFileHash(ExampleFile);
|
||||
const string expected = "0zgDmFuotnldZIyADoWrpiSDUx4=";
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CheckIfStringIsWebUrl()
|
||||
{
|
||||
const string test1 = "http://TolleUrl.de/Test";
|
||||
const string test2 = "https://TolleUrl.de/Test";
|
||||
const string test3 = "C:\\Test";
|
||||
const string test4 = "furz";
|
||||
|
||||
Assert.IsTrue(Utility.IsWebUrl(test1));
|
||||
Assert.IsTrue(Utility.IsWebUrl(test2));
|
||||
Assert.IsFalse(Utility.IsWebUrl(test3));
|
||||
Assert.ThrowsException<UriFormatException>(() => Utility.IsWebUrl(test4));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CheckRightAssemblyName()
|
||||
{
|
||||
const string expected = "Example";
|
||||
var actual = Utility.GetApplicationName(Assembly.LoadFile(ExampleFile));
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CheckAssemblyVersionStuff()
|
||||
{
|
||||
var expected = new Semver.SemVersion(1, 0, 53);
|
||||
var actual = VersionUtils.GetCurrentVersion(Assembly.LoadFile(ExampleFile));
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user