52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
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);
|
|
}
|
|
}
|
|
} |