Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -0,0 +1,169 @@
// ****************************************************************
// This is free software licensed under the NUnit license. You
// may obtain a copy of the license as well as information regarding
// copyright ownership at http://nunit.org/?p=license&r=2.4.
// ****************************************************************
namespace NUnit.Framework
{
using System;
/// <summary>
/// The Assertion class is obsolete and has been
/// replaced by the Assert class.
/// </summary>
[Obsolete("Use Assert class instead")]
public class Assertion
{
/// <summary>
/// Asserts that a condition is true. If it isn't it throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="message">The message to display is the condition
/// is false</param>
/// <param name="condition">The evaluated condition</param>
static public void Assert(string message, bool condition)
{
NUnit.Framework.Assert.IsTrue(condition, message);
}
/// <summary>
/// Asserts that a condition is true. If it isn't it throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
static public void Assert(bool condition)
{
Assertion.Assert(string.Empty, condition);
}
/// <summary>
/// /// Asserts that two doubles are equal concerning a delta. If the
/// expected value is infinity then the delta value is ignored.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="delta">The maximum acceptable difference between the
/// the expected and the actual</param>
static public void AssertEquals(double expected, double actual, double delta)
{
Assertion.AssertEquals(string.Empty, expected, actual, delta);
}
/// <summary>
/// /// Asserts that two singles are equal concerning a delta. If the
/// expected value is infinity then the delta value is ignored.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="delta">The maximum acceptable difference between the
/// the expected and the actual</param>
static public void AssertEquals(float expected, float actual, float delta)
{
Assertion.AssertEquals(string.Empty, expected, actual, delta);
}
/// <summary>Asserts that two objects are equal. If they are not
/// an <see cref="AssertionException"/> is thrown.</summary>
static public void AssertEquals(Object expected, Object actual)
{
Assertion.AssertEquals(string.Empty, expected, actual);
}
/// <summary>Asserts that two ints are equal. If they are not
/// an <see cref="AssertionException"/> is thrown.</summary>
static public void AssertEquals(int expected, int actual)
{
Assertion.AssertEquals(string.Empty, expected, actual);
}
/// <summary>Asserts that two ints are equal. If they are not
/// an <see cref="AssertionException"/> is thrown.</summary>
static public void AssertEquals(string message, int expected, int actual)
{
NUnit.Framework.Assert.AreEqual(expected, actual, message);
}
/// <summary>Asserts that two doubles are equal concerning a delta.
/// If the expected value is infinity then the delta value is ignored.
/// </summary>
static public void AssertEquals(string message, double expected,
double actual, double delta)
{
NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
}
/// <summary>Asserts that two floats are equal concerning a delta.
/// If the expected value is infinity then the delta value is ignored.
/// </summary>
static public void AssertEquals(string message, float expected,
float actual, float delta)
{
NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
}
/// <summary>
/// Asserts that two objects are equal. Two objects are considered
/// equal if both are null, or if both have the same value. Numeric
/// types are compared via string comparision on their contents to
/// avoid problems comparing values between different types. All
/// non-numeric types are compared by using the <c>Equals</c> method.
/// If they are not equal an <see cref="AssertionException"/> is thrown.
/// </summary>
static public void AssertEquals(string message, Object expected, Object actual)
{
NUnit.Framework.Assert.AreEqual(expected, actual, message);
}
/// <summary>Asserts that an object isn't null.</summary>
static public void AssertNotNull(Object anObject)
{
NUnit.Framework.Assert.IsNotNull(anObject, string.Empty);
}
/// <summary>Asserts that an object isn't null.</summary>
static public void AssertNotNull(string message, Object anObject)
{
NUnit.Framework.Assert.IsNotNull(anObject, message);
}
/// <summary>Asserts that an object is null.</summary>
static public void AssertNull(Object anObject)
{
NUnit.Framework.Assert.IsNull(anObject, string.Empty);
}
/// <summary>Asserts that an object is null.</summary>
static public void AssertNull(string message, Object anObject)
{
NUnit.Framework.Assert.IsNull(anObject, message);
}
/// <summary>Asserts that two objects refer to the same object. If they
/// are not the same an <see cref="AssertionException"/> is thrown.
/// </summary>
static public void AssertSame(Object expected, Object actual)
{
NUnit.Framework.Assert.AreSame(expected, actual, string.Empty);
}
/// <summary>Asserts that two objects refer to the same object.
/// If they are not an <see cref="AssertionException"/> is thrown.
/// </summary>
static public void AssertSame(string message, Object expected, Object actual)
{
NUnit.Framework.Assert.AreSame(expected, actual, message);
}
/// <summary>Fails a test with no message.</summary>
static public void Fail()
{
NUnit.Framework.Assert.Fail();
}
/// <summary>Fails a test with the given message.</summary>
static public void Fail(string message)
{
NUnit.Framework.Assert.Fail(message);
}
}
}

View File

@@ -62,6 +62,8 @@ namespace NUnitLite.Runner
private FinallyDelegate finallyDelegate;
public bool Failure;
#region Constructors
/// <summary>
@@ -304,7 +306,9 @@ namespace NUnitLite.Runner
new ResultReporter(result, writer).ReportResults();
string resultFile = commandLineOptions.ResultFile;
string resultFormat = commandLineOptions.ResultFormat;
this.Failure = (result.ResultState == ResultState.Failure);
if (resultFile != null || commandLineOptions.ResultFormat != null)
{
if (resultFile == null)

View File

@@ -0,0 +1,227 @@
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System.ComponentModel;
using NUnit.Framework.Constraints;
namespace NUnit.Framework
{
/// <summary>
/// Basic Asserts on strings.
/// </summary>
public class StringAssert
{
#region Equals and ReferenceEquals
/// <summary>
/// The Equals method throws an AssertionException. This is done
/// to make sure there is no mistake by calling this function.
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static new bool Equals(object a, object b)
{
throw new AssertionException("Assert.Equals should not be used for Assertions");
}
/// <summary>
/// override the default ReferenceEquals to throw an AssertionException. This
/// implementation makes sure there is no mistake in calling this function
/// as part of Assert.
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
public static new void ReferenceEquals(object a, object b)
{
throw new AssertionException("Assert.ReferenceEquals should not be used for Assertions");
}
#endregion
#region Contains
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void Contains( string expected, string actual, string message, params object[] args )
{
Assert.That(actual, new SubstringConstraint(expected), message, args);
}
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void Contains( string expected, string actual, string message )
{
Contains( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void Contains( string expected, string actual )
{
Contains( expected, actual, string.Empty, null );
}
#endregion
#region StartsWith
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void StartsWith( string expected, string actual, string message, params object[] args )
{
Assert.That(actual, new StartsWithConstraint(expected), message, args);
}
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void StartsWith( string expected, string actual, string message )
{
StartsWith( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void StartsWith( string expected, string actual )
{
StartsWith( expected, actual, string.Empty, null );
}
#endregion
#region EndsWith
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void EndsWith( string expected, string actual, string message, params object[] args )
{
Assert.That(actual, new EndsWithConstraint(expected), message, args);
}
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void EndsWith( string expected, string actual, string message )
{
EndsWith( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void EndsWith( string expected, string actual )
{
EndsWith( expected, actual, string.Empty, null );
}
#endregion
#region AreEqualIgnoringCase
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void AreEqualIgnoringCase( string expected, string actual, string message, params object[] args )
{
Assert.That(actual, new EqualConstraint(expected).IgnoreCase, message, args);
}
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
static public void AreEqualIgnoringCase( string expected, string actual, string message )
{
AreEqualIgnoringCase( expected, actual, message, null );
}
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
static public void AreEqualIgnoringCase( string expected, string actual )
{
AreEqualIgnoringCase( expected, actual, string.Empty, null );
}
#endregion
#region IsMatch
/// <summary>
/// Asserts that a string matches an expected regular expression pattern.
/// </summary>
/// <param name="expected">The expected expression</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void IsMatch( string expected, string actual, string message, params object[] args )
{
Assert.That(actual, new RegexConstraint(expected), message, args);
}
/// <summary>
/// Asserts that a string matches an expected regular expression pattern.
/// </summary>
/// <param name="expected">The expected expression</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
static public void IsMatch( string expected, string actual, string message )
{
IsMatch( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string matches an expected regular expression pattern.
/// </summary>
/// <param name="expected">The expected expression</param>
/// <param name="actual">The actual string</param>
static public void IsMatch( string expected, string actual )
{
IsMatch( expected, actual, string.Empty, null );
}
#endregion
}
}