Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TestSuiteElement.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under Apache 2.0 License. See LICENSE.md for details.
3 //
4 // TestSuiteElement.cs: MonoTouch.Dialog element for TestSuite
5 //
6 // Authors:
7 // Sebastien Pouliot <sebastien@xamarin.com>
8 //
9 // Copyright 2011-2013 Xamarin Inc.
10 //
11 // Licensed under the Apache License, Version 2.0 (the "License");
12 // you may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at
14 //
15 // http://www.apache.org/licenses/LICENSE-2.0
16 //
17 // Unless required by applicable law or agreed to in writing, software
18 // distributed under the License is distributed on an "AS IS" BASIS,
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 // See the License for the specific language governing permissions and
21 // limitations under the License.
22 //
23 
24 using System;
25 using System.Linq;
26 using System.Text;
27 using System.Threading.Tasks;
28 #if XAMCORE_2_0
29 using UIKit;
30 #else
31 using MonoTouch.UIKit;
32 #endif
33 
34 using MonoTouch.Dialog;
35 
36 using NUnit.Framework.Internal;
37 
38 namespace SiliconStudio.Paradox.UnitTesting.UI {
39 
41 
42  public TestSuiteElement (TestSuite test, TouchRunner runner)
43  : base (test, runner)
44  {
45  Caption = Suite.Name.Split('.').LastOrDefault() ?? "";
46  int count = Suite.TestCaseCount;
47  if (count > 0) {
48  Accessory = UITableViewCellAccessory.DisclosureIndicator;
49  DetailColor = DarkGreen;
50  Value = String.Format ("{0} test case{1}, {2}", count, count == 1 ? String.Empty : "s", Suite.RunState);
51  Tapped += delegate {
52  runner.Show (Suite);
53  };
54  } else {
55  DetailColor = UIColor.Orange;
56  Value = "No test was found inside this suite";
57  }
58  }
59 
60  public TestSuite Suite {
61  get { return Test as TestSuite; }
62  }
63 
64  public async Task Run ()
65  {
66  Result = await Runner.Run (Suite);
67  }
68 
69  public override void Update ()
70  {
71  int positive = Result.PassCount + Result.InconclusiveCount;
72  int failure = Result.FailCount;
73  int skipped = Result.SkipCount;
74 
75  StringBuilder sb = new StringBuilder ();
76  if (failure == 0) {
77  DetailColor = DarkGreen;
78  sb.Append ("Success! ").Append (Result.Duration.TotalMilliseconds).Append (" ms for ").Append (positive).Append (" test");
79  if (positive > 1)
80  sb.Append ('s');
81  } else {
82  DetailColor = UIColor.Red;
83  if (positive > 0)
84  sb.Append (positive).Append (" success");
85  if (sb.Length > 0)
86  sb.Append (", ");
87  sb.Append (failure).Append (" failure");
88  if (failure > 1)
89  sb.Append ('s');
90  if (skipped > 0)
91  sb.Append (", ").Append (skipped).Append (" ignored");
92  }
93  Value = sb.ToString ();
94 
95  if (GetContainerTableView () != null) {
96  var root = GetImmediateRootElement ();
97  root.Reload (this, UITableViewRowAnimation.Fade);
98  }
99  }
100  }
101 }
_In_ size_t count
Definition: DirectXTexP.h:174
TestSuiteElement(TestSuite test, TouchRunner runner)