| 1 |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. |
| 2 |
|
| 3 |
#if !NO_STOPWATCH |
| 4 |
using System; |
| 5 |
using System.Reactive.Concurrency; |
| 6 |
using System.Threading; |
| 7 |
#if NUNIT |
| 8 |
using NUnit.Framework; |
| 9 |
using TestClassAttribute = NUnit.Framework.TestFixtureAttribute; |
| 10 |
using TestMethodAttribute = NUnit.Framework.TestAttribute; |
| 11 |
using TestInitializeAttribute = NUnit.Framework.SetUpAttribute; |
| 12 |
#else |
| 13 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 14 |
#endif |
| 15 |
|
| 16 |
namespace ReactiveTests.Tests |
| 17 |
{ |
| 18 |
static class StopwatchTest |
| 19 |
{ |
| 20 |
public static void Run(IStopwatchProvider stopwatchProvider) |
| 21 |
{ |
| 22 |
/* |
| 23 |
* TODO: Temporarily disabled until we iron out all of the scheduler improvements. |
| 24 |
*/ |
| 25 |
|
| 26 |
//var N = 10; |
| 27 |
//var t = default(long); |
| 28 |
//var d = 1; |
| 29 |
|
| 30 |
//for (int i = 0; i < N; i++) |
| 31 |
//{ |
| 32 |
// var sw = stopwatchProvider.StartStopwatch(); |
| 33 |
|
| 34 |
// var e1 = sw.Elapsed; |
| 35 |
// Thread.Sleep(d); |
| 36 |
// var e2 = sw.Elapsed; |
| 37 |
|
| 38 |
// Assert.IsTrue(e2.Ticks > e1.Ticks); |
| 39 |
// t += (e2 - e1).Ticks; |
| 40 |
|
| 41 |
// sw.Dispose(); |
| 42 |
//} |
| 43 |
|
| 44 |
//Assert.IsTrue(TimeSpan.FromTicks(t / N).TotalMilliseconds < d * 10 /* 10x margin */); |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
#endif |