|
using System;
using UnitTest;
namespace CaseStudy
{
[TestFixture]
public class CaseStudyPerformanceTests
{
private Vendor vendor;
private Random rnd;
[FixtureSetUp]
public void TestFixtureSetup()
{
// use the same seed for repeatability
rnd=new Random(0);
vendor=new Vendor();
for (int i=0; i<100000; i++)
{
Part p=new Part();
p.Number=i.ToString();
vendor.Add(p);
}
}
[Test]
[MinOperationsPerSecond(150000)]
public void RandomAccessTestByPart()
{
int n=rnd.Next(0, 100000);
Part p=new Part();
p.Number=n.ToString();
bool found=vendor.Contains(p);
Assertion.Assert(found==true, "Expected to find the part!");
}
[Test]
[MinOperationsPerSecond(150000)]
public void RandomAccessTestByIndex()
{
int n=rnd.Next(0, 100000);
Part p=vendor.Parts[n];
Assertion.Assert(p.Number==n.ToString(), "Parts not in the same order as when added!");
}
[Test]
[Ignore("Takes too long!")]
[MinOperationsPerSecond(150000)]
[Repeat(100)]
public void RandomAccessTestByNumber()
{
int n=rnd.Next(0, 100000);
bool found=vendor.Contains(n.ToString());
Assertion.Assert(found==true, "Expected to find the part!");
}
[FixtureTearDown]
public void TestFixtureTearDown()
{
vendor.Clear();
}
}
}
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here