Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions tests/common/ApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

using Xamarin.Tests;

namespace Xamarin.ApiTest
{
namespace Xamarin.ApiTest {
[TestFixture]
public class ApiTest
{
public class ApiTest {
[Test]
#if MONOTOUCH
[TestCase (Profile.iOS)]
Expand Down Expand Up @@ -51,7 +49,7 @@ public void AlwaysOptimizable (Profile profile)
case "BlockLiteral":
if (type == mr.DeclaringType)
continue; // Calls within BlockLiteral without the optimizable attribute is allowed

switch (mr.Name) {
case "SetupBlock":
case "SetupBlockUnsafe":
Expand Down
186 changes: 93 additions & 93 deletions tests/common/Assert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,96 +12,96 @@
using NUnit.Framework.Constraints;

namespace MonoTests {
/*
class CategoryAttribute : Attribute
{
public string Category { get; set; }

public CategoryAttribute (string category)
/*
class CategoryAttribute : Attribute
{
this.Category = category;
}
}
/*
static class Assert
{
public static void AreEqual (object a, object b, string msg)
{
NUnit.Framework.Assert.That (a, Is.EqualTo (b), msg);
}

public static void AreEqual (object a, object b)
{
NUnit.Framework.Assert.That (a, Is.EqualTo (b));
}

public static void IsNotNull (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.Not.Null, msg);
}

public static void IsNotNull (object o)
{
NUnit.Framework.Assert.That (o, Is.Not.Null);
}

public static void IsNull (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.Null, msg);
}

public static void IsNull (object o)
{
NUnit.Framework.Assert.That (o, Is.Null);
}

public static void IsTrue (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.True, msg);
}

public static void IsTrue (object o)
{
NUnit.Framework.Assert.That (o, Is.True);
}

public static void IsFalse (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.False, msg);
}

public static void IsFalse (object o)
{
NUnit.Framework.Assert.That (o, Is.False);
}

public static void AreSame (object a, object b)
{
NUnit.Framework.Assert.That (a, Is.SameAs (b));
}

public static void AreSame (object a, object b, string msg)
{
NUnit.Framework.Assert.That (a, Is.SameAs (b), msg);
}

public static void Fail (string msg)
{
NUnit.Framework.Assert.Fail (msg);
public string Category { get; set; }

public CategoryAttribute (string category)
{
this.Category = category;
}
}
/*
static class Assert
{
public static void AreEqual (object a, object b, string msg)
{
NUnit.Framework.Assert.That (a, Is.EqualTo (b), msg);
}

public static void AreEqual (object a, object b)
{
NUnit.Framework.Assert.That (a, Is.EqualTo (b));
}

public static void IsNotNull (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.Not.Null, msg);
}

public static void IsNotNull (object o)
{
NUnit.Framework.Assert.That (o, Is.Not.Null);
}

public static void IsNull (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.Null, msg);
}

public static void IsNull (object o)
{
NUnit.Framework.Assert.That (o, Is.Null);
}

public static void IsTrue (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.True, msg);
}

public static void IsTrue (object o)
{
NUnit.Framework.Assert.That (o, Is.True);
}

public static void IsFalse (object o, string msg)
{
NUnit.Framework.Assert.That (o, Is.False, msg);
}

public static void IsFalse (object o)
{
NUnit.Framework.Assert.That (o, Is.False);
}

public static void AreSame (object a, object b)
{
NUnit.Framework.Assert.That (a, Is.SameAs (b));
}

public static void AreSame (object a, object b, string msg)
{
NUnit.Framework.Assert.That (a, Is.SameAs (b), msg);
}

public static void Fail (string msg)
{
NUnit.Framework.Assert.Fail (msg);
}
}
}
*/
*/
// nunit 1.x compatibility
public class TestCase {
protected virtual void SetUp ()
{
}

public static void Assert (string msg, bool condition)
{
NUnit.Framework.Assert.True (condition, msg);
}

public static void AssertEquals (object a, object b)
{
NUnit.Framework.Assert.That (a, Is.EqualTo (b));
Expand Down Expand Up @@ -137,45 +137,45 @@ public static void Fail (string msg)
NUnit.Framework.Assert.Fail (msg);
}
}

public class Assertion : TestCase {
}

public class TestFixtureSetUpAttribute : SetUpAttribute {
}

public class StringAssert {
#region StartsWith
static public void StartsWith(string expected, string actual, string message, params object[] args)
static public void StartsWith (string expected, string actual, string message, params object [] args)
{
Assert.That(actual, new StartsWithConstraint(expected), message, args);
Assert.That (actual, new StartsWithConstraint (expected), message, args);
}

static public void StartsWith(string expected, string actual, string message)
static public void StartsWith (string expected, string actual, string message)
{
StartsWith(expected, actual, message, null);
StartsWith (expected, actual, message, null);
}

static public void StartsWith(string expected, string actual)
static public void StartsWith (string expected, string actual)
{
StartsWith(expected, actual, string.Empty, null);
StartsWith (expected, actual, string.Empty, null);
}
#endregion

#region Contains
static public void Contains(string expected, string actual, string message, params object[] args)
static public void Contains (string expected, string actual, string message, params object [] args)
{
Assert.That(actual, new SubstringConstraint(expected), message, args);
Assert.That (actual, new SubstringConstraint (expected), message, args);
}

static public void Contains(string expected, string actual, string message)
static public void Contains (string expected, string actual, string message)
{
Contains(expected, actual, message, null);
Contains (expected, actual, message, null);
}

static public void Contains(string expected, string actual)
static public void Contains (string expected, string actual)
{
Contains(expected, actual, string.Empty, null);
Contains (expected, actual, string.Empty, null);
}
#endregion
}
Expand Down
18 changes: 8 additions & 10 deletions tests/common/AssertHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

using NUnit.Framework;

namespace Xamarin.Tests
{
namespace Xamarin.Tests {
public delegate void Action ();

public static class Asserts
{
public static void Throws<T> (Action action, string expectedExceptionMessage, string message = "") where T: Exception
public static class Asserts {
public static void Throws<T> (Action action, string expectedExceptionMessage, string message = "") where T : Exception
{
try {
action ();
Expand All @@ -20,7 +18,7 @@ public static void Throws<T> (Action action, string expectedExceptionMessage, st
}
}

public static void ThrowsPartial<T> (Action action, string [] expectedExceptionMessages, string message = "") where T: Exception
public static void ThrowsPartial<T> (Action action, string [] expectedExceptionMessages, string message = "") where T : Exception
{
try {
action ();
Expand All @@ -31,8 +29,8 @@ public static void ThrowsPartial<T> (Action action, string [] expectedExceptionM
StartsWith (expectedExceptionMessages [i], actual [i], i.ToString ());
}
}
public static void ThrowsPattern<T> (Action action, string expectedExceptionPattern, string message = "") where T: Exception

public static void ThrowsPattern<T> (Action action, string expectedExceptionPattern, string message = "") where T : Exception
{
try {
action ();
Expand All @@ -41,13 +39,13 @@ public static void ThrowsPattern<T> (Action action, string expectedExceptionPatt
IsLike (expectedExceptionPattern, ex.Message, message);
}
}

public static void StartsWith (string expectedStartsWith, string actual, string message)
{
if (!actual.StartsWith (expectedStartsWith, StringComparison.Ordinal))
throw new AssertionException (string.Format ("Expected '{0}' to start with '{1}'. {2}", actual, expectedStartsWith, message));
}

public static void IsLike (string pattern, string actual, string message)
{
if (!Regex.IsMatch (actual, pattern, RegexOptions.CultureInvariant))
Expand Down
6 changes: 2 additions & 4 deletions tests/common/BundlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
using BundlerTool = Xamarin.MmpTool;
#endif

namespace Xamarin
{
namespace Xamarin {
[TestFixture]
public class BundlerTests
{
public class BundlerTests {
#if __MACOS__
// The cache doesn't work properly in mmp yet.
// [TestCase (Profile.macOSMobile)]
Expand Down
17 changes: 6 additions & 11 deletions tests/common/BundlerTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,23 @@

using Xamarin.Utils;

namespace Xamarin.Tests
{
public enum LinkerOption
{
namespace Xamarin.Tests {
public enum LinkerOption {
Unspecified,
LinkAll,
LinkSdk,
DontLink,
LinkPlatform, // only applicable for XM
}

public enum RegistrarOption
{
public enum RegistrarOption {
Unspecified,
Dynamic,
Static,
}

[Flags]
enum I18N
{
enum I18N {
None = 0,

CJK = 1,
Expand All @@ -42,8 +38,7 @@ enum I18N
}

// This class represents options/logic that is identical between mtouch and mmp
abstract class BundlerTool : Tool
{
abstract class BundlerTool : Tool {
public const string None = "None";
public bool AlwaysShowOutput;

Expand Down Expand Up @@ -327,7 +322,7 @@ public virtual void AssertExecute (string message = null)
return;
var errors = Messages.Where ((v) => v.IsError).ToList ();
Assert.Fail ($"Expected execution to succeed, but exit code was {rv}, and there were {errors.Count} error(s).\nCommand: {ToolPath} {StringUtils.FormatArguments (ToolArguments)}\nMessage: {message}\n\t" +
string.Join ("\n\t", errors.Select ((v) => v.ToString ())));
string.Join ("\n\t", errors.Select ((v) => v.ToString ())));
}

public void AssertExecuteFailure (string message = null)
Expand Down
Loading