Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

59 lines
1.4 KiB
C#

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
#if NUNIT
using NUnit.Framework;
using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
using TestMethodAttribute = NUnit.Framework.TestAttribute;
using TestInitializeAttribute = NUnit.Framework.SetUpAttribute;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace Tests
{
[TestClass]
public partial class Tests
{
public void AssertThrows<E>(Action a)
where E : Exception
{
try
{
a();
Assert.Fail();
}
catch (E)
{
}
}
public void AssertThrows<E>(Action a, Func<E, bool> assert)
where E : Exception
{
try
{
a();
Assert.Fail();
}
catch (E e)
{
Assert.IsTrue(assert(e));
}
}
public void NoNext<T>(IEnumerator<T> e)
{
Assert.IsFalse(e.MoveNext());
}
public void HasNext<T>(IEnumerator<T> e, T value)
{
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(value, e.Current);
}
}
}