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 // Copyright 2011-2012 Xamarin Inc.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 using System;
20 using System.Linq;
21 using Android.Content;
22 using Android.Views;
23 using NUnit.Framework.Internal;
24 
25 namespace Android.NUnitLite.UI {
26 
28 
29  public TestSuiteElement (TestSuite suite) : base (suite)
30  {
31  if (Suite.TestCaseCount > 0)
32  Indicator = ">"; // hint there's more
33  }
34 
35  public TestSuite Suite {
36  get { return Test as TestSuite; }
37  }
38 
39  protected override string GetCaption ()
40  {
41  int count = Suite.TestCaseCount;
42  var suiteName = Suite.Name.Split('.').LastOrDefault() ?? "";
43  string caption = String.Format ("<b>{0}</b><br>", suiteName);
44  if (count == 0) {
45  caption += "<font color='#ff7f00'>no test was found inside this suite</font>";
46  } else if (Result == null) {
47  caption += String.Format ("<font color='green'><b>{0}</b> test case{1}, <i>{2}</i></font>",
48  count, count == 1 ? String.Empty : "s", Suite.RunState);
49  } else {
50  if (Result.FailCount == 0) {
51  caption += String.Format ("<font color='green'><b>Success!</b> {0} test{1}</font>",
52  Result.PassCount, Result.PassCount == 1 ? String.Empty : "s");
53  } else {
54  caption += String.Format ("<font color='green'>{0} success,</font> <font color='red'>{1} failure{2}, {3} skipped{4}</font>",
55  Result.PassCount, Result.FailCount, Result.FailCount > 1 ? "s" : String.Empty,
56  Result.SkipCount, Result.SkipCount > 1 ? "s" : String.Empty);
57  }
58  }
59  return caption;
60  }
61 
62  public override View GetView (Context context, View convertView, ViewGroup parent)
63  {
64  View view = base.GetView (context, convertView, parent);
65  // if there are test cases inside this suite then create an activity to show them
66  if (Suite.TestCaseCount > 0) {
67  view.Click += delegate {
68  Intent intent = new Intent(context, typeof (TestSuiteActivity));
69  intent.PutExtra ("TestSuite", Name);
70  intent.AddFlags (ActivityFlags.NewTask);
71  context.StartActivity (intent);
72  };
73  }
74  return view;
75  }
76  }
77 }
_In_ size_t count
Definition: DirectXTexP.h:174
override View GetView(Context context, View convertView, ViewGroup parent)
Overriden my most derived classes, creates a view that creates a View with the contents for display ...