diff --git a/src/net/KEFCore/KEFCore.csproj b/src/net/KEFCore/KEFCore.csproj
index ff1d0029..936be2e3 100644
--- a/src/net/KEFCore/KEFCore.csproj
+++ b/src/net/KEFCore/KEFCore.csproj
@@ -66,11 +66,11 @@
-
+
All
None
-
+
diff --git a/test/KEFCore.Test/Program.cs b/test/KEFCore.Test/Program.cs
index c744729c..f9ea5251 100644
--- a/test/KEFCore.Test/Program.cs
+++ b/test/KEFCore.Test/Program.cs
@@ -52,6 +52,10 @@ static void ReportString(string message)
static void Main(string[] args)
{
+ BloggingContext context = null;
+ var testWatcher = new Stopwatch();
+ var globalWatcher = new Stopwatch();
+
if (args.Length > 0)
{
config = JsonSerializer.Deserialize(File.ReadAllText(args[0]));
@@ -64,36 +68,38 @@ static void Main(string[] args)
var databaseName = config.UseModelBuilder ? config.DatabaseNameWithModel : config.DatabaseName;
- var globalWatcher = Stopwatch.StartNew();
- StreamsConfigBuilder streamConfig = null;
- if (!config.UseInMemoryProvider)
+ try
{
- streamConfig = StreamsConfigBuilder.Create();
- streamConfig = streamConfig.WithAcceptableRecoveryLag(100);
- }
+ globalWatcher.Start();
+ StreamsConfigBuilder streamConfig = null;
+ if (!config.UseInMemoryProvider)
+ {
+ streamConfig = StreamsConfigBuilder.Create();
+ streamConfig = streamConfig.WithAcceptableRecoveryLag(100);
+ }
- var context = new BloggingContext()
- {
- BootstrapServers = config.BootstrapServers,
- ApplicationId = config.ApplicationId,
- DbName = databaseName,
- StreamsConfigBuilder = streamConfig,
- };
+ context = new BloggingContext()
+ {
+ BootstrapServers = config.BootstrapServers,
+ ApplicationId = config.ApplicationId,
+ DbName = databaseName,
+ StreamsConfigBuilder = streamConfig,
+ };
- if (config.DeleteApplication)
- {
- context.Database.EnsureDeleted();
- context.Database.EnsureCreated();
- }
+ if (config.DeleteApplication)
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+ }
- var testWatcher = Stopwatch.StartNew();
- Stopwatch watch = Stopwatch.StartNew();
- for (int i = 0; i < config.NumberOfElements; i++)
- {
- context.Add(new Blog
+ testWatcher.Start();
+ Stopwatch watch = Stopwatch.StartNew();
+ for (int i = 0; i < config.NumberOfElements; i++)
{
- Url = "http://blogs.msdn.com/adonet" + i.ToString(),
- Posts = new List()
+ context.Add(new Blog
+ {
+ Url = "http://blogs.msdn.com/adonet" + i.ToString(),
+ Posts = new List()
{
new Post()
{
@@ -101,66 +107,66 @@ static void Main(string[] args)
Content = i.ToString()
}
},
- Rating = i,
- });
- }
- watch.Stop();
- ReportString($"Elapsed data load {watch.ElapsedMilliseconds} ms");
+ Rating = i,
+ });
+ }
+ watch.Stop();
+ ReportString($"Elapsed data load {watch.ElapsedMilliseconds} ms");
- watch.Restart();
- context.SaveChanges();
- watch.Stop();
- ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
+ watch.Restart();
+ context.SaveChanges();
+ watch.Stop();
+ ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
+
+ if (config.UseModelBuilder)
+ {
+ watch.Restart();
+ var pageObject = (from op in context.Blogs
+ join pg in context.Posts on op.BlogId equals pg.BlogId
+ where pg.BlogId == op.BlogId
+ select new { pg, op }).SingleOrDefault();
+ watch.Stop();
+ ReportString($"Elapsed UseModelBuilder {watch.ElapsedMilliseconds} ms");
+ }
- if (config.UseModelBuilder)
- {
watch.Restart();
- var pageObject = (from op in context.Blogs
- join pg in context.Posts on op.BlogId equals pg.BlogId
- where pg.BlogId == op.BlogId
- select new { pg, op }).SingleOrDefault();
+ var post = context.Posts.Single(b => b.BlogId == 2);
watch.Stop();
- ReportString($"Elapsed UseModelBuilder {watch.ElapsedMilliseconds} ms");
- }
+ ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 2) {watch.ElapsedMilliseconds} ms. Result is {post}");
- watch.Restart();
- var post = context.Posts.Single(b => b.BlogId == 2);
- watch.Stop();
- ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 2) {watch.ElapsedMilliseconds} ms. Result is {post}");
-
- watch.Restart();
- post = context.Posts.Single(b => b.BlogId == 1);
- watch.Stop();
- ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 1) {watch.ElapsedMilliseconds} ms. Result is {post}");
-
- watch.Restart();
- var all = context.Posts.All((o) => true);
- watch.Stop();
- ReportString($"Elapsed context.Posts.All((o) => true) {watch.ElapsedMilliseconds} ms. Result is {all}");
-
- watch.Restart();
- var blog = context.Blogs!.Single(b => b.BlogId == 1);
- watch.Stop();
- ReportString($"Elapsed context.Blogs!.Single(b => b.BlogId == 1) {watch.ElapsedMilliseconds} ms. Result is {blog}");
-
- watch.Restart();
- context.Remove(post);
- context.Remove(blog);
- watch.Stop();
- ReportString($"Elapsed data remove {watch.ElapsedMilliseconds} ms");
-
- watch.Restart();
- context.SaveChanges();
- watch.Stop();
- ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
-
- watch.Restart();
- for (int i = config.NumberOfElements; i < config.NumberOfElements + config.NumberOfExtraElements; i++)
- {
- context.Add(new Blog
+ watch.Restart();
+ post = context.Posts.Single(b => b.BlogId == 1);
+ watch.Stop();
+ ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 1) {watch.ElapsedMilliseconds} ms. Result is {post}");
+
+ watch.Restart();
+ var all = context.Posts.All((o) => true);
+ watch.Stop();
+ ReportString($"Elapsed context.Posts.All((o) => true) {watch.ElapsedMilliseconds} ms. Result is {all}");
+
+ watch.Restart();
+ var blog = context.Blogs!.Single(b => b.BlogId == 1);
+ watch.Stop();
+ ReportString($"Elapsed context.Blogs!.Single(b => b.BlogId == 1) {watch.ElapsedMilliseconds} ms. Result is {blog}");
+
+ watch.Restart();
+ context.Remove(post);
+ context.Remove(blog);
+ watch.Stop();
+ ReportString($"Elapsed data remove {watch.ElapsedMilliseconds} ms");
+
+ watch.Restart();
+ context.SaveChanges();
+ watch.Stop();
+ ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
+
+ watch.Restart();
+ for (int i = config.NumberOfElements; i < config.NumberOfElements + config.NumberOfExtraElements; i++)
{
- Url = "http://blogs.msdn.com/adonet" + i.ToString(),
- Posts = new List()
+ context.Add(new Blog
+ {
+ Url = "http://blogs.msdn.com/adonet" + i.ToString(),
+ Posts = new List()
{
new Post()
{
@@ -168,28 +174,35 @@ join pg in context.Posts on op.BlogId equals pg.BlogId
Content = i.ToString()
}
},
- Rating = i,
- });
- }
- watch.Stop();
- ReportString($"Elapsed data load {watch.ElapsedMilliseconds} ms");
-
- watch.Restart();
- context.SaveChanges();
- watch.Stop();
- ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
+ Rating = i,
+ });
+ }
+ watch.Stop();
+ ReportString($"Elapsed data load {watch.ElapsedMilliseconds} ms");
- watch.Restart();
- post = context.Posts.Single(b => b.BlogId == 1009);
- watch.Stop();
- ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 1009) {watch.ElapsedMilliseconds} ms. Result is {post}");
+ watch.Restart();
+ context.SaveChanges();
+ watch.Stop();
+ ReportString($"Elapsed SaveChanges {watch.ElapsedMilliseconds} ms");
- var value = context.Blogs.AsQueryable().ToQueryString();
+ watch.Restart();
+ post = context.Posts.Single(b => b.BlogId == 1009);
+ watch.Stop();
+ ReportString($"Elapsed context.Posts.Single(b => b.BlogId == 1009) {watch.ElapsedMilliseconds} ms. Result is {post}");
- context?.Dispose();
- testWatcher.Stop();
- globalWatcher.Stop();
- Console.WriteLine($"Full test completed in {globalWatcher.Elapsed}, only tests completed in {testWatcher.Elapsed}");
+ var value = context.Blogs.AsQueryable().ToQueryString();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.ToString());
+ }
+ finally
+ {
+ context?.Dispose();
+ testWatcher.Stop();
+ globalWatcher.Stop();
+ Console.WriteLine($"Full test completed in {globalWatcher.Elapsed}, only tests completed in {testWatcher.Elapsed}");
+ }
}
}