/
TestMethodViewModel.cs
60 lines (50 loc) · 1.84 KB
/
TestMethodViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Rubberduck.Interaction.Navigation;
using Rubberduck.UnitTesting;
using Rubberduck.VBEditor;
namespace Rubberduck.UI.UnitTesting.ViewModels
{
public enum TestRunState
{
Stopped,
Queued,
Running
}
public class TestMethodViewModel : ViewModelBase, INavigateSource
{
public TestMethodViewModel(TestMethod test)
{
Method = test;
}
public TestMethod Method { get; }
private TestResult _result = new TestResult(TestOutcome.Unknown);
public TestResult Result
{
get => _result;
set { _result = value; OnPropertyChanged(); }
}
private TestRunState _state;
public TestRunState RunState
{
get => _state;
set { _state = value; OnPropertyChanged(); }
}
public QualifiedMemberName QualifiedName => Method.Declaration.QualifiedName;
// Delegate Navigability to encapsulated TestMethod
public NavigateCodeEventArgs GetNavigationArgs() => Method.GetNavigationArgs();
public override string ToString() => $"{Method.Declaration.QualifiedName}: {Result.Outcome} ({Result.Duration}ms) {Result.Output}";
public override bool Equals(object obj) => obj is TestMethodViewModel other && Method.Equals(other.Method);
public override int GetHashCode() => Method.GetHashCode();
public object[] ToArray()
{
var declaration = Method.Declaration;
return new object[] {
declaration.QualifiedName.QualifiedModuleName.ProjectName,
declaration.QualifiedName.QualifiedModuleName.ComponentName,
declaration.IdentifierName,
_result.Outcome.ToString(),
_result.Output,
_result.Duration
};
}
}
}