Cosmos/Tests/Cosmos.TestRunner.UI.Avalonia/ViewModels/MainWindowViewModel.cs
2018-01-23 16:46:12 +00:00

42 lines
1.2 KiB
C#

using System;
using System.ComponentModel;
using System.Threading;
using Cosmos.TestRunner.Core;
namespace Cosmos.TestRunner.UI.ViewModels
{
internal class MainWindowViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public MainWindowViewModel(IEngineConfiguration aEngineConfiguration)
{
var xEngine = new Engine(aEngineConfiguration)
{
OutputHandler = new OutputHandler(
m =>
{
TestRunnerLog += m + Environment.NewLine;
OnPropertyChanged(nameof(TestRunnerLog));
})
};
new Thread(() => xEngine.Execute()).Start();
}
public string TestRunnerLog { get; set; }
private void OnPropertyChanged(string aPropertyName) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(aPropertyName));
internal class OutputHandler : OutputHandlerFullTextBase
{
private Action<string> mLog;
public OutputHandler(Action<string> aLog) => mLog = aLog;
protected override void Log(string message) => mLog(message);
}
}
}