Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TestRocks.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 // TestRocks.cs: Helpers
5 //
6 // Authors:
7 // Sebastien Pouliot <sebastien@xamarin.com>
8 //
9 // Copyright 2011-2012 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 NUnit.Framework;
25 using NUnit.Framework.Internal;
26 using NUnit.Framework.Api;
27 
28 namespace SiliconStudio.Paradox.UnitTesting {
29 
30  static class TestRock {
31 
32  const string NUnitFrameworkExceptionPrefix = "NUnit.Framework.";
33 
34  static public bool IsIgnored (this TestResult result)
35  {
36  return (result.ResultState.Status == TestStatus.Skipped);
37  }
38 
39  static public bool IsSuccess (this TestResult result)
40  {
41  return (result.ResultState.Status == TestStatus.Passed);
42  }
43 
44  static public bool IsFailure (this TestResult result)
45  {
46  return (result.ResultState.Status == TestStatus.Failed);
47  }
48 
49  static public bool IsInconclusive (this TestResult result)
50  {
51  return (result.ResultState.Status == TestStatus.Inconclusive);
52  }
53 
54  // remove the nunit exception message from the "real" message
55  static public string GetMessage (this TestResult result)
56  {
57  string m = result.Message;
58  if (m == null)
59  return "Unknown error";
60  if (!m.StartsWith (NUnitFrameworkExceptionPrefix))
61  return m;
62  return m.Substring (m.IndexOf (" : ") + 3);
63  }
64  }
65 }
static bool IsInconclusive(this TestResult result)
Definition: TestRocks.cs:49
static bool IsFailure(this TestResult result)
Definition: TestRocks.cs:44
static bool IsIgnored(this TestResult result)
Definition: TestRocks.cs:34
static string GetMessage(this TestResult result)
Definition: TestRocks.cs:55
static bool IsSuccess(this TestResult result)
Definition: TestRocks.cs:39