Fixes #1 - Can now drill right down to tests

This commit is contained in:
Rob Prouse 2015-03-25 16:51:56 -04:00
Родитель 2ed9fb0e55
Коммит f2d0a2e7dd
9 изменённых файлов: 104 добавлений и 36 удалений

Просмотреть файл

@ -5,10 +5,11 @@
Title="Test Results"
Padding="6">
<StackLayout Orientation="Vertical" Spacing="4">
<ScrollView Orientation="Horizontal"
<ScrollView Orientation="Vertical"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" >
<ListView ItemsSource="{Binding Results}"
ItemSelected="ViewTest"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="True">
@ -16,8 +17,9 @@
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Vertical" Spacing="4" HorizontalOptions="FillAndExpand">
<Label Text="{Binding Name}" TextColor="{Binding Color}" LineBreakMode="MiddleTruncation" FontAttributes="Bold" FontSize="Medium" />
<StackLayout Orientation="Vertical" Spacing="4" HorizontalOptions="FillAndExpand" Padding="4">
<Label Text="{Binding Name}" TextColor="{Binding Color}" FontAttributes="Bold" FontSize="Medium" />
<Label Text="{Binding Parent}" LineBreakMode="MiddleTruncation" FontAttributes="Bold" FontSize="Small" />
<Label Text="{Binding Message}" LineBreakMode="WordWrap" FontSize="Small"/>
</StackLayout>
</ViewCell.View>

Просмотреть файл

@ -21,6 +21,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
using System.Threading.Tasks;
using NUnit.Framework.Interfaces;
using NUnit.Runner.ViewModel;
using Xamarin.Forms;
@ -34,5 +36,12 @@ namespace NUnit.Runner.View
BindingContext = model;
InitializeComponent();
}
internal async void ViewTest(object sender, SelectedItemChangedEventArgs e)
{
var result = e.SelectedItem as ResultViewModel;
if (result != null)
await Navigation.PushAsync(new TestView(new TestViewModel(result.TestResult)));
}
}
}

Просмотреть файл

@ -12,8 +12,8 @@
</DataTrigger>
</Button.Triggers>
</Button>
<ScrollView Orientation="Horizontal"
<ScrollView Orientation="Vertical"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" >

Просмотреть файл

@ -1,32 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="NUnit.Runner.View.TestView">
<StackLayout Orientation="Vertical" Padding="6" Spacing="4">
<ScrollView Orientation="Horizontal"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" >
<ListView ItemsSource="{Binding Results}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Vertical" Spacing="4" HorizontalOptions="FillAndExpand">
<Label Text="{Binding FullName}" FontAttributes="Bold" FontSize="Large" />
x:Class="NUnit.Runner.View.TestView"
Title="Test"
Padding="6">
<ScrollView Orientation="Vertical"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" >
<StackLayout Orientation="Vertical" Spacing="6" HorizontalOptions="FillAndExpand">
<Label Text="{Binding TestResult.Name}" TextColor="{Binding Color}" FontAttributes="Bold" FontSize="Large" />
<Label Text="{Binding TestResult.Test.Parent.FullName}" LineBreakMode="MiddleTruncation" FontSize="Medium" />
<StackLayout Orientation="Horizontal" Spacing="4">
<Label Text="Duration:" FontSize="Medium" FontAttributes="Bold" />
<Label Text="{Binding TestResult.Duration.TotalSeconds, StringFormat='{0:F3} seconds'}" FontSize="Medium" />
</StackLayout>
<Label Text="{Binding PassCount, StringFormat='Pass: {0}'}" TextColor="Green" />
<Label Text="{Binding FailCount, StringFormat='Fail: {0}'}" TextColor="Red" />
<Label Text="{Binding SkipCount, StringFormat='Skip: {0}'}" TextColor="Yellow"/>
<Label Text="{Binding InconclusiveCount, StringFormat='Inconclusive: {0}'}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
</StackLayout>
<StackLayout Orientation="Horizontal" Spacing="4">
<Label Text="Asserts:" FontSize="Medium" FontAttributes="Bold" />
<Label Text="{Binding TestResult.AssertCount}" FontSize="Medium" />
</StackLayout>
<Label Text="Properties:" FontAttributes="Bold" FontSize="Medium" />
<Label Text="{Binding Properties}" LineBreakMode="WordWrap" FontSize="Small" />
<Label Text="Message:" FontAttributes="Bold" FontSize="Medium" />
<Label Text="{Binding Message}" LineBreakMode="WordWrap" FontSize="Small" />
<Label Text="Output:" FontAttributes="Bold" FontSize="Medium" />
<Label Text="{Binding Output}" LineBreakMode="WordWrap" FontSize="Small" />
<Label Text="Stack Trace:" FontAttributes="Bold" FontSize="Medium" />
<Label Text="{Binding StackTrace}" LineBreakMode="CharacterWrap" FontSize="Small" />
</StackLayout>
</ScrollView>
</ContentPage>

Просмотреть файл

@ -30,7 +30,6 @@ namespace NUnit.Runner.View
{
public TestView(TestViewModel model)
{
model.Navigation = Navigation;
BindingContext = model;
InitializeComponent();
}

Просмотреть файл

@ -21,8 +21,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
using System.Windows.Input;
using NUnit.Framework.Interfaces;
using NUnit.Runner.Extensions;
using NUnit.Runner.View;
using Xamarin.Forms;
namespace NUnit.Runner.ViewModel
@ -32,12 +34,14 @@ namespace NUnit.Runner.ViewModel
public ResultViewModel(ITestResult result)
{
TestResult = result;
Name = result.FullName;
Name = result.Name;
Parent = result.Test.Parent.FullName;
Message = result.Message;
}
public ITestResult TestResult { get; private set; }
public string Name { get; private set; }
public string Parent { get; private set; }
public string Message { get; private set; }
/// <summary>

Просмотреть файл

@ -22,7 +22,10 @@
// ***********************************************************************
using System.Collections.ObjectModel;
using System.Windows.Input;
using NUnit.Framework.Interfaces;
using NUnit.Runner.View;
using Xamarin.Forms;
namespace NUnit.Runner.ViewModel
{

Просмотреть файл

@ -22,12 +22,53 @@
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework.Interfaces;
using NUnit.Runner.Extensions;
using Xamarin.Forms;
namespace NUnit.Runner.ViewModel
{
public class TestViewModel : BaseViewModel
{
public TestViewModel(ITestResult result)
{
TestResult = result;
Message = StringOrNone(result.Message);
Output = StringOrNone(result.Output);
StackTrace = StringOrNone(result.StackTrace);
var builder = new StringBuilder();
IPropertyBag props = result.Test.Properties;
foreach (string key in props.Keys)
{
foreach (var value in props[key])
{
builder.AppendFormat("{0} = {1}{2}", key, value, Environment.NewLine);
}
}
Properties = StringOrNone(builder.ToString());
}
public ITestResult TestResult { get; private set; }
public string Message { get; private set; }
public string Output { get; private set; }
public string StackTrace { get; private set; }
public string Properties { get; private set; }
/// <summary>
/// Gets the color for this result.
/// </summary>
public Color Color
{
get { return TestResult.Color(); }
}
private string StringOrNone(string str)
{
if (string.IsNullOrWhiteSpace(str))
return "<none>";
return str;
}
}
}

Просмотреть файл

@ -27,6 +27,7 @@ using NUnit.Framework;
namespace NUnit.Runner.Tests
{
[TestFixture]
[Author("Rob Prouse")]
public class TestsSample
{
[SetUp]
@ -37,13 +38,16 @@ namespace NUnit.Runner.Tests
public void Tear() { }
[Test]
[Category("Passing")]
public void Pass()
{
Console.WriteLine("test1");
TestContext.WriteLine("Capture some output");
Assert.True(true);
}
[Test]
[Category("Failing")]
[Author("Code Monkey")]
public void Fail()
{
Assert.False(true);
@ -65,6 +69,7 @@ namespace NUnit.Runner.Tests
[Test]
public void Error()
{
TestContext.WriteLine("I am about to throw!!!");
throw new NotSupportedException("This method isn't ready yet");
}
}