67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using NUnit.Framework;
|
|
|
|
namespace Katteker.Test
|
|
{
|
|
[TestFixture]
|
|
public class KattekerLibTest
|
|
{
|
|
private static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
|
|
private static readonly string ExamplePath = Path.Combine(BaseDir, "testdata");
|
|
private static readonly string ExampleFile = Path.Combine(ExamplePath, "Example.exe");
|
|
|
|
[Test]
|
|
public void Sha1ChecksumOfFile()
|
|
{
|
|
var actual = Utility.ComputeFileHash(ExampleFile);
|
|
const string expected = "maFpV7FK3EtnU2G5+q2nZ1E3YKY=";
|
|
Assert.AreEqual(expected, actual);
|
|
}
|
|
|
|
[Test]
|
|
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.True(Utility.IsWebUrl(test1));
|
|
Assert.True(Utility.IsWebUrl(test2));
|
|
Assert.False(Utility.IsWebUrl(test3));
|
|
Assert.Throws<UriFormatException>(() => Utility.IsWebUrl(test4));
|
|
}
|
|
|
|
[Test]
|
|
public void CheckRightAssemblyName()
|
|
{
|
|
const string expected = "Example";
|
|
var actual = Utility.GetApplicationName(Assembly.LoadFile(ExampleFile));
|
|
Assert.AreEqual(expected, actual);
|
|
}
|
|
|
|
[Test]
|
|
public void CheckAssemblyVersionStuff()
|
|
{
|
|
var expected = new Semver.SemVersion(1, 0, 53);
|
|
var actual = VersionUtils.GetCurrentVersion(Assembly.LoadFile(ExampleFile));
|
|
Assert.AreEqual(expected, actual);
|
|
}
|
|
|
|
[Test]
|
|
public void TestGetLocalAppDataDirectory()
|
|
{
|
|
var expected = Utility.GetLocalAppDataDirectory();
|
|
Assert.IsTrue(expected.Contains("AppData\\Local\\Programs"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestEnumerateFiles()
|
|
{
|
|
var list = KattekerCreator.Helper.Utils.EnumerateFiles(ExamplePath, new[] {"*.xml"});
|
|
Assert.AreEqual(13, list.Count);
|
|
}
|
|
}
|
|
} |