|
using System.Reflection;
using NUnit.Framework;
namespace Business.Test
{
[TestFixture]
public class RangeFixture
{
private readonly dynamic _range;
public RangeFixture()
{
_range = new DynamicObjectBase(typeof(Range<int>));
}
[Test,
Description("Tests two ranges that don't overlap.")]
public void OverlapTest([Random(0, 1000, 5)] int firstStart,
[Random(1001, 2000, 5)] int firstEnd,
[Random(2001, 5000, 5)] int secondStart,
[Random(5001, 10000, 5)] int secondEnd)
{
var methodInfo = typeof(Range<int>).GetMethod("Overlaps", BindingFlags.NonPublic | BindingFlags.Static);
var result = methodInfo.Invoke(null, new []
{
new Range<int>(firstStart, firstEnd),
new Range<int>(secondStart, secondEnd)
});
Assert.False((bool)result);
}
[Test,
Description("Tests two ranges that don't overlap.")]
public void DynamicOverlapTest([Random(0, 1000, 5)] int firstStart,
[Random(1001, 2000, 5)] int firstEnd,
[Random(2001, 5000, 5)] int secondStart,
[Random(5001, 10000, 5)] int secondEnd)
{
Assert.False(_range.Overlaps(new Range<int>(firstStart, firstEnd),
new Range<int>(secondStart, secondEnd)));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Idalgo Cantelli. I'm a software developer skilled in .Net technologies. I work with .Net since February, 2002. I also have a strong experience as a technical trainer, having taught in more than thirty classroom courses. I'm MCTS and MCPD-EAD on .Net 2.0, planning an upgrade to 3.5.