~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/GuiException/UiException/TraceExceptionHelper.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ****************************************************************
2
 
// This is free software licensed under the NUnit license. You may
3
 
// obtain a copy of the license at http://nunit.org
4
 
// ****************************************************************
5
 
 
6
 
using System;
7
 
using System.Collections.Generic;
8
 
using System.Text;
9
 
using System.Diagnostics;
10
 
 
11
 
namespace NUnit.UiException
12
 
{
13
 
    /// <summary>
14
 
    /// (formerly named TraceExceptionHelper)
15
 
    /// 
16
 
    /// Exposes static methods to assert predicates and throw exceptions
17
 
    /// as needed.
18
 
    /// </summary>
19
 
    public class UiExceptionHelper
20
 
    {
21
 
        /// <summary>
22
 
        /// Asserts that reference is not null; otherwise throws an
23
 
        /// ArgumentNullException.
24
 
        /// </summary>
25
 
        /// <param name="value">The reference to be tested.</param>
26
 
        /// <param name="paramName">The name of this reference</param>
27
 
        [DebuggerStepThrough]
28
 
        public static void CheckNotNull(object value, string paramName)
29
 
        {
30
 
            if (value == null)
31
 
                throw new ArgumentNullException(paramName);
32
 
 
33
 
            return;
34
 
        }
35
 
 
36
 
        /// <summary>
37
 
        /// Asserts that 'test' is true or throws an ArgumentException.
38
 
        /// </summary>
39
 
        /// <param name="test">The boolean to be tested.</param>
40
 
        /// <param name="message">The error message.</param>
41
 
        /// <param name="paramName">The parameter name to be passed to ArgumentException.</param>
42
 
        [DebuggerStepThrough]
43
 
        public static void CheckTrue(bool test, string message, string paramName)
44
 
        {
45
 
            if (!test)
46
 
                throw new ArgumentException(message, paramName);
47
 
 
48
 
            return;
49
 
        }
50
 
 
51
 
        /// <summary>
52
 
        /// Asserts that 'test' is false or throws an ArgumentException.
53
 
        /// </summary>
54
 
        /// <param name="test">The boolean to be tested.</param>
55
 
        /// <param name="message">The error message.</param>
56
 
        /// <param name="paramName">The parameter name to be passed to ArgumentException.</param>
57
 
        [DebuggerStepThrough]
58
 
        public static void CheckFalse(bool test, string message, string paramName)
59
 
        {
60
 
            if (test)
61
 
                throw new ArgumentException(message, paramName);
62
 
 
63
 
            return;
64
 
        }
65
 
 
66
 
        /// <summary>
67
 
        /// Throws an ApplicationException with the given message.
68
 
        /// </summary>
69
 
        /// <param name="message">The error message.</param>
70
 
        [DebuggerStepThrough]
71
 
        public static void Fail(string message)
72
 
        {
73
 
            throw new ApplicationException(message);
74
 
        }        
75
 
    }
76
 
}
 
1
// ****************************************************************
 
2
// This is free software licensed under the NUnit license. You may
 
3
// obtain a copy of the license at http://nunit.org
 
4
// ****************************************************************
 
5
 
 
6
using System;
 
7
using System.Collections.Generic;
 
8
using System.Text;
 
9
using System.Diagnostics;
 
10
 
 
11
namespace NUnit.UiException
 
12
{
 
13
    /// <summary>
 
14
    /// (formerly named TraceExceptionHelper)
 
15
    /// 
 
16
    /// Exposes static methods to assert predicates and throw exceptions
 
17
    /// as needed.
 
18
    /// </summary>
 
19
    public class UiExceptionHelper
 
20
    {
 
21
        /// <summary>
 
22
        /// Asserts that reference is not null; otherwise throws an
 
23
        /// ArgumentNullException.
 
24
        /// </summary>
 
25
        /// <param name="value">The reference to be tested.</param>
 
26
        /// <param name="paramName">The name of this reference</param>
 
27
        [DebuggerStepThrough]
 
28
        public static void CheckNotNull(object value, string paramName)
 
29
        {
 
30
            if (value == null)
 
31
                throw new ArgumentNullException(paramName);
 
32
 
 
33
            return;
 
34
        }
 
35
 
 
36
        /// <summary>
 
37
        /// Asserts that 'test' is true or throws an ArgumentException.
 
38
        /// </summary>
 
39
        /// <param name="test">The boolean to be tested.</param>
 
40
        /// <param name="message">The error message.</param>
 
41
        /// <param name="paramName">The parameter name to be passed to ArgumentException.</param>
 
42
        [DebuggerStepThrough]
 
43
        public static void CheckTrue(bool test, string message, string paramName)
 
44
        {
 
45
            if (!test)
 
46
                throw new ArgumentException(message, paramName);
 
47
 
 
48
            return;
 
49
        }
 
50
 
 
51
        /// <summary>
 
52
        /// Asserts that 'test' is false or throws an ArgumentException.
 
53
        /// </summary>
 
54
        /// <param name="test">The boolean to be tested.</param>
 
55
        /// <param name="message">The error message.</param>
 
56
        /// <param name="paramName">The parameter name to be passed to ArgumentException.</param>
 
57
        [DebuggerStepThrough]
 
58
        public static void CheckFalse(bool test, string message, string paramName)
 
59
        {
 
60
            if (test)
 
61
                throw new ArgumentException(message, paramName);
 
62
 
 
63
            return;
 
64
        }
 
65
 
 
66
        /// <summary>
 
67
        /// Throws an ApplicationException with the given message.
 
68
        /// </summary>
 
69
        /// <param name="message">The error message.</param>
 
70
        [DebuggerStepThrough]
 
71
        public static void Fail(string message)
 
72
        {
 
73
            throw new ApplicationException(message);
 
74
        }        
 
75
    }
 
76
}