Skip to content
Permalink
Browse files

Added test to prove potential fault with profiling

Profiling first result is fine but timing doesn't stop till the enumerator is disposed (or on error).
  • Loading branch information...
Turnerj committed Jul 28, 2019
1 parent 62a1373 commit b14910f2d5902b17807ce5b5fcb885c5a9afe0ff
@@ -1,4 +1,5 @@
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MongoFramework.Attributes;
using MongoFramework.Profiling.MiniProfiler;
@@ -134,6 +135,36 @@ public void ProfilingRead()
}
}

[TestMethod]
public void ProfilingReadWithEnforcedSleep()
{
using (var context = new TestContext(GetConnection()))
{
for (int i = 0, l = 10; i < l; i++)
{
context.GeneralProfiling.Add(new GeneralProfileModel
{
Number = i,
Name = "ProfilingRead"
});
}

context.GeneralProfiling.SaveChanges();

var profiler = SEProfiling.MiniProfiler.StartNew();

var queryable = context.GeneralProfiling;
foreach (var entity in queryable)
{
Thread.Sleep(100);
}

Assert.IsTrue(profiler.Root.CustomTimings.ContainsKey("mongodb"));
var timings = profiler.Root.CustomTimings["mongodb"];
Assert.IsTrue(timings[0].DurationMilliseconds > 1000);
}
}

[TestMethod]
public void ProfilingIndex()
{

0 comments on commit b14910f

Please sign in to comment.
You can’t perform that action at this time.