Skip to content

Instantly share code, notes, and snippets.

@dck-jp
Created January 22, 2014 03:47
Show Gist options
  • Select an option

  • Save dck-jp/8553197 to your computer and use it in GitHub Desktop.

Select an option

Save dck-jp/8553197 to your computer and use it in GitHub Desktop.
Unit test code for PrefetchedProperty.cs by NUnit & ChainingAssertion
[TestFixture]
public class Test1
{
[Test]
public void TestMethod即座に読み出し()
{
var prefetch = new Class1();
prefetch.PropertyA.Is("abc");
}
[Test]
public void Test1秒後に読み出し()
{
var prefetch = new Class1();
Thread.Sleep(1100);
prefetch.PropertyA.Is("abc");
}
[Test]
public void Test1秒後に読み出し_さらに読み出し()
{
var prefetch = new Class1();
Thread.Sleep(1100);
prefetch.PropertyA.Is("abc");
Thread.Sleep(100);
prefetch.PropertyA.Is("abc");
}
[Test]
public void Test読み出し速度の確認()
{
var sw = new Stopwatch();
sw.Start();
var prefetch = new Class1();
prefetch.PropertyA.Is("abc");
sw.Stop(); var t1 = sw.ElapsedMilliseconds;
sw.Restart();
prefetch.PropertyA.Is("abc");
sw.Stop(); var t2 = sw.ElapsedMilliseconds;
Assert.Greater(t1, t2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment