Cosmos/Tests/Cosmos.TestRunner.UnitTest/KernelTests.cs
2017-12-31 17:39:26 +00:00

49 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Cosmos.TestRunner.Core;
namespace Cosmos.TestRunner.UnitTest
{
using Assert = NUnit.Framework.Assert;
[TestFixture]
public class KernelTests
{
private static IEnumerable<Type> KernelsToRun => TestKernelSets.GetStableKernelTypes();
[TestCaseSource(nameof(KernelsToRun))]
public void TestKernel(Type aKernelType)
{
try
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(KernelTests).Assembly.Location));
var xEngine = new Engine(new EngineConfiguration(aKernelType));
xEngine.OutputHandler = new TestOutputHandler();
Assert.IsTrue(xEngine.Execute());
}
catch (AssertionException)
{
throw;
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: " + e.ToString());
Assert.Fail();
}
}
private class TestOutputHandler : OutputHandlerFullTextBase
{
protected override void Log(string message)
{
TestContext.WriteLine(String.Concat(DateTime.Now.ToString("hh:mm:ss.ffffff "), new string(' ', mLogLevel * 2), message));
}
}
}
}