From c1eda625d3e41e3613b407fc00088e3fea78668d Mon Sep 17 00:00:00 2001 From: mikependon Date: Sun, 25 Sep 2022 10:55:37 +0200 Subject: [PATCH 1/3] #941 More updates on the CancellableTraceLog Unit Testing. --- .../Trace/CancellableTraceLogTest.cs | 917 ++++++++++++++++++ .../Operations/DbConnection/InsertAll.cs | 4 +- RepoDb.Core/RepoDb/QueryGroup.cs | 9 +- .../RepoDb/QueryGroup/AsMappedObject.cs | 4 +- RepoDb.Core/RepoDb/Trace/Tracer.cs | 2 +- 5 files changed, 929 insertions(+), 7 deletions(-) diff --git a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs index 44ecc8ca..93cb5ec3 100644 --- a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs +++ b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs @@ -215,6 +215,923 @@ public void ThrowExceptionOnAverageAllAsyncCancelledOperation() #endregion + #region BatchQuery + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnBatchQueryCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .BatchQuery("", 0, 100, null, (object)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnBatchQueryAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .BatchQueryAsync("", 0, 100, null, (object)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Count + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnCountCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Count("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnCountAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .CountAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region CountAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnCountAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .CountAll("", trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnCountAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .CountAllAsync("", trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Delete + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnDeleteCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Delete("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnDeleteAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .DeleteAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region DeleteAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnDeleteAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .DeleteAll("", trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnDeleteAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .DeleteAllAsync("", trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Exists + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnExistsCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Exists("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnExistsAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .ExistsAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Insert + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnInsertCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Insert("", null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnInsertAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .InsertAsync("", null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region InsertAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnInsertAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + + // Act + connection + .InsertAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnInsertAllMultipleEntitiesCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .InsertAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnInsertAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + // Act + connection + .InsertAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnInsertAllAsyncMultipleEntitiesCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .InsertAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Max + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMaxCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Max("", (Field)null, (object)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMaxAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MaxAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region MaxAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMaxAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MaxAll("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMaxAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MaxAllAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Merge + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMergeCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Merge("", null, (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMergeAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MergeAsync("", null, (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region MergeAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMergeAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + // Act + connection + .MergeAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMergeAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + // Act + connection + .MergeAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMergeAllMultipleEntitiesCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .MergeAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMergeAllMultipleEntitiesAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .MergeAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Min + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMinCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Min("", (Field)null, (object)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMinAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MinAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region MaxAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnMinAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MinAll("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnMinAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .MinAllAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Query + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Query("", (QueryField)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryAsync("", (QueryField)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region QueryAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryAll("", trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryAllAsync("", trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region QueryMultiple + + #region T2 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT2CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT2AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region T3 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT3CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT3AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region T4 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT4CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT4AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region T5 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT5CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT5AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region T6 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT6CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT6AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region T7 + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnQueryMultipleForT7CancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultiple("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnQueryMultipleForT7AsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .QueryMultipleAsync("", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + "", (QueryField)null, + trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #endregion + + #region Sum + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnSumCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Sum("", (Field)null, (object)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnSumAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .SumAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region SumAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnSumAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .SumAll("", (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnSumAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .SumAllAsync("", (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Truncate + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnTruncateCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Truncate("", trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnTruncateAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .TruncateAsync("", trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region Update + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnUpdateCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .Update("", null, (Field)null, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnUpdateAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + + // Act + connection + .UpdateAsync("", null, (Field)null, trace: new CancelTrace()) + .Wait(); + } + + #endregion + + #region UpdateAll + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnUpdateAllCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + // Act + connection + .UpdateAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnUpdateAllAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object() + }; + + // Act + connection + .UpdateAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + [TestMethod, ExpectedException(typeof(CancelledExecutionException))] + public void ThrowExceptionOnUpdateAllMultipleEntitiesCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .UpdateAll("", entities, trace: new CancelTrace()); + } + + [TestMethod, ExpectedException(typeof(AggregateException))] + public void ThrowExceptionOnUpdateAllMultipleEntitiesAsyncCancelledOperation() + { + // Prepare + var connection = new TraceDbConnection(); + var entities = new[] + { + new object(), + new object(), + new object() + }; + + // Act + connection + .UpdateAllAsync("", entities, trace: new CancelTrace()) + .Wait(); + } + + #endregion + #endregion } } \ No newline at end of file diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/InsertAll.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/InsertAll.cs index eb2a8592..6a588f0b 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/InsertAll.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/InsertAll.cs @@ -292,7 +292,7 @@ internal static Task InsertAllAsyncInternal(this IDbConnection con fields: GetQualifiedFields(fields, entities?.FirstOrDefault()), hints: hints, commandTimeout: commandTimeout, - traceKey: traceKey, + traceKey: traceKey, transaction: transaction, trace: trace, statementBuilder: statementBuilder, @@ -307,7 +307,7 @@ internal static Task InsertAllAsyncInternal(this IDbConnection con fields: GetQualifiedFields(fields, entities?.FirstOrDefault()), hints: hints, commandTimeout: commandTimeout, - traceKey: traceKey, + traceKey: traceKey, transaction: transaction, trace: trace, statementBuilder: statementBuilder, diff --git a/RepoDb.Core/RepoDb/QueryGroup.cs b/RepoDb.Core/RepoDb/QueryGroup.cs index 7693fdd3..5478abd1 100644 --- a/RepoDb.Core/RepoDb/QueryGroup.cs +++ b/RepoDb.Core/RepoDb/QueryGroup.cs @@ -543,9 +543,14 @@ internal static void FixForQueryMultiple(QueryGroup[] queryGroups) { for (var i = 0; i < queryGroups.Length; i++) { - foreach (var field in queryGroups[i].GetFields(true)) + var fields = queryGroups[i]?.GetFields(true); + + if (fields?.Any() == true) { - field.Parameter.SetName(string.Format("T{0}_{1}", i, field.Parameter.Name)); + foreach (var field in fields) + { + field.Parameter.SetName(string.Format("T{0}_{1}", i, field.Parameter.Name)); + } } } } diff --git a/RepoDb.Core/RepoDb/QueryGroup/AsMappedObject.cs b/RepoDb.Core/RepoDb/QueryGroup/AsMappedObject.cs index 402948ac..d4b1284b 100644 --- a/RepoDb.Core/RepoDb/QueryGroup/AsMappedObject.cs +++ b/RepoDb.Core/RepoDb/QueryGroup/AsMappedObject.cs @@ -41,11 +41,11 @@ private static void AsMappedObject(IDictionary dictionary, bool fixParameters = true) { var queryFields = queryGroupTypeMap - .QueryGroup + .QueryGroup? .GetFields(true); // Identify if there are fields to count - if (queryFields.Any() != true) + if (queryFields?.Any() != true) { return; } diff --git a/RepoDb.Core/RepoDb/Trace/Tracer.cs b/RepoDb.Core/RepoDb/Trace/Tracer.cs index 4dfd7a83..7ec92a44 100644 --- a/RepoDb.Core/RepoDb/Trace/Tracer.cs +++ b/RepoDb.Core/RepoDb/Trace/Tracer.cs @@ -146,7 +146,7 @@ public static async Task InvokeAfterExecutionAsync(TraceResult result, private static void ValidateCancellation(string key, CancellableTraceLog log) { - if (log.IsThrowException) + if (log?.IsCancelled == true && log?.IsThrowException == true) { throw new CancelledExecutionException($"The execution has been cancelled for {key}."); } From f3f00f5a95dc07f737dfb048e5544f889efd52f5 Mon Sep 17 00:00:00 2001 From: Michael Pendon Date: Tue, 27 Sep 2022 08:21:52 +0200 Subject: [PATCH 2/3] CancellableTraceLog Tests for Silent Cancellation. --- .../Interfaces/ITraceForDbConnectionTest.cs | 17 + .../Trace/CancellableTraceLogTest.cs | 3065 ++++++++++++++++- 2 files changed, 3053 insertions(+), 29 deletions(-) diff --git a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs index 3614ac20..3a84f57a 100644 --- a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs +++ b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs @@ -1621,6 +1621,23 @@ public void TestDbConnectionTraceForAfterMaxViaTableName() #region MaxAsync + [TestMethod] + public void TestDbConnectionTraceForBeforeMaxAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + [TestMethod] public void TestDbConnectionTraceForAfterMaxAsync() { diff --git a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs index 93cb5ec3..d23c75a8 100644 --- a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs +++ b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs @@ -1,8 +1,11 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; using RepoDb.Exceptions; +using RepoDb.Extensions; using RepoDb.Interfaces; using RepoDb.UnitTests.CustomObjects; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -49,9 +52,15 @@ public Task BeforeExecutionAsync(CancellableTraceLog log, } } + private class TraceEntity + { + public int Id { get; set; } + public string Name { get; set; } + } + #endregion - #region Methods + #region Cancelled #region ExecuteNonQuery @@ -413,7 +422,7 @@ public void ThrowExceptionOnInsertAllCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 } }; @@ -429,9 +438,7 @@ public void ThrowExceptionOnInsertAllMultipleEntitiesCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 } }; // Act @@ -446,7 +453,9 @@ public void ThrowExceptionOnInsertAllAsyncCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -462,9 +471,9 @@ public void ThrowExceptionOnInsertAllAsyncMultipleEntitiesCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -539,7 +548,7 @@ public void ThrowExceptionOnMergeCancelledOperation() // Act connection - .Merge("", null, (Field)null, trace: new CancelTrace()); + .Merge("", new { Id = 1 }, (Field)null, trace: new CancelTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -550,7 +559,7 @@ public void ThrowExceptionOnMergeAsyncCancelledOperation() // Act connection - .MergeAsync("", null, (Field)null, trace: new CancelTrace()) + .MergeAsync("", new { Id = 1 }, (Field)null, trace: new CancelTrace()) .Wait(); } @@ -565,7 +574,7 @@ public void ThrowExceptionOnMergeAllCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 } }; // Act @@ -580,7 +589,7 @@ public void ThrowExceptionOnMergeAllAsyncCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 } }; // Act @@ -596,9 +605,9 @@ public void ThrowExceptionOnMergeAllMultipleEntitiesCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -613,9 +622,9 @@ public void ThrowExceptionOnMergeAllMultipleEntitiesAsyncCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -1045,7 +1054,7 @@ public void ThrowExceptionOnUpdateCancelledOperation() // Act connection - .Update("", null, (Field)null, trace: new CancelTrace()); + .Update("", new { Id = 1 }, (Field)null, trace: new CancelTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1056,7 +1065,7 @@ public void ThrowExceptionOnUpdateAsyncCancelledOperation() // Act connection - .UpdateAsync("", null, (Field)null, trace: new CancelTrace()) + .UpdateAsync("", new { Id = 1 }, (Field)null, trace: new CancelTrace()) .Wait(); } @@ -1071,7 +1080,7 @@ public void ThrowExceptionOnUpdateAllCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 } }; // Act @@ -1086,7 +1095,7 @@ public void ThrowExceptionOnUpdateAllAsyncCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object() + new { Id = 1 } }; // Act @@ -1102,9 +1111,9 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -1119,9 +1128,9 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesAsyncCancelledOperation() var connection = new TraceDbConnection(); var entities = new[] { - new object(), - new object(), - new object() + new { Id = 1 }, + new { Id = 2 }, + new { Id = 3 } }; // Act @@ -1133,5 +1142,3003 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesAsyncCancelledOperation() #endregion #endregion + + #region Silent Cancellation + + #region Average + + #region Average + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverage() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Average(trace: trace.Object, + field: e => e.Id, + where: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Average(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region AverageAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region AverageAll + + #region AverageAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAll(trace: trace.Object, + field: e => e.Id); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAll(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region AverageAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAllAsync(trace: trace.Object, + field: e => e.Id).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAverageAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.AverageAllAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region BatchQuery + + #region BatchQuery + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForBatchQuery() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.BatchQuery(0, + 10, + OrderField.Ascending(t => t.Id).AsEnumerable(), + where: (QueryGroup)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>>()), Times.Exactly(0)); + } + + #endregion + + #region BatchQueryAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForBatchQueryAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.BatchQueryAsync(0, + 10, + OrderField.Ascending(t => t.Id).AsEnumerable(), + where: (QueryGroup)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region BulkInsert + + //#region BulkInsert + + //[TestMethod] + //public void TestDbConnectionTraceSilentCancellationForBulkInsert() + //{ + // // Prepare + // var trace = new Mock(); + // var connection = new TraceDbConnection(); + // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; + + // // Act + // connection.BulkInsert(entities, + // trace: trace.Object); + + // // Assert + // trace.Verify(t => t.BeforeBulkInsert(It.IsAny()), Times.Exactly(1)); + //} + + //[TestMethod] + //public void TestDbConnectionTraceSilentCancellationForAfterBulkInsert() + //{ + // // Prepare + // var trace = new Mock(); + // var connection = new TraceDbConnection(); + // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; + + // // Act + // connection.BulkInsert(entities, + // trace: trace.Object); + + // // Assert + // trace.Verify(t => t.AfterBulkInsert(It.IsAny()), Times.Exactly(1)); + //} + + //#endregion + + //#region BulkInsertAsync + + //[TestMethod] + //public void TestDbConnectionTraceSilentCancellationForBulkInsertAsync() + //{ + // // Prepare + // var trace = new Mock(); + // var connection = new TraceDbConnection(); + // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; + + // // Act + // connection.BulkInsertAsync(entities, + // trace: trace.Object).Wait(); + + // // Assert + // trace.Verify(t => t.BeforeBulkInsert(It.IsAny()), Times.Exactly(1)); + //} + + //[TestMethod] + //public void TestDbConnectionTraceSilentCancellationForAfterBulkInsertAsync() + //{ + // // Prepare + // var trace = new Mock(); + // var connection = new TraceDbConnection(); + // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; + + // // Act + // connection.BulkInsertAsync(entities, + // trace: trace.Object).Wait(); + + // // Assert + // trace.Verify(t => t.AfterBulkInsert(It.IsAny()), Times.Exactly(1)); + //} + + //#endregion + + #endregion + + #region Count + + #region Count + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCount() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Count(trace: trace.Object, + where: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Count(ClassMappedNameCache.Get(), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region CountAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAsync(trace: trace.Object, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAsync(ClassMappedNameCache.Get(), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region CountAll + + #region CountAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAll(trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAll(ClassMappedNameCache.Get(), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region CountAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAllAsync(trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForCountAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.CountAllAsync(ClassMappedNameCache.Get(), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Delete + + #region Delete + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDelete() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Delete(0, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Delete(ClassMappedNameCache.Get(), + new + { + Id = 1 + }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region DeleteAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAsync(0, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAsync(ClassMappedNameCache.Get(), + new + { + Id = 1 + }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region DeleteAll + + #region DeleteAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAll(trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAll(ClassMappedNameCache.Get(), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region DeleteAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAllAsync(trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForDeleteAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.DeleteAllAsync(ClassMappedNameCache.Get(), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Exists + + #region Exists + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForExists() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Exists(trace: trace.Object, + what: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForExistsViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Exists(ClassMappedNameCache.Get(), + what: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region ExistsAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForExistsAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.ExistsAsync(trace: trace.Object, + what: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForExistsAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.ExistsAsync(ClassMappedNameCache.Get(), + what: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Insert + + #region Insert + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsert() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Insert( + new TraceEntity { Name = "Name" }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Insert(ClassMappedNameCache.Get(), + new { Name = "Name" }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region InsertAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAsync( + new TraceEntity { Name = "Name" }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAsync(ClassMappedNameCache.Get(), + new { Name = "Name" }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region InsertAll + + #region InsertAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAll(new[] { new TraceEntity { Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAll(ClassMappedNameCache.Get(), + new[] { new { Name = "Name" } }, + fields: Field.From("Name"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region InsertAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAllAsync(new[] { new TraceEntity { Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForInsertAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.InsertAllAsync(ClassMappedNameCache.Get(), + new[] { new { Name = "Name" } }, + fields: Field.From("Name"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Max + + #region Max + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMax() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Max(trace: trace.Object, + field: e => e.Id, + where: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Max(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MaxAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region MaxAll + + #region MaxAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAll(trace: trace.Object, + field: e => e.Id); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAll(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MaxAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAllAsync(trace: trace.Object, + field: e => e.Id).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMaxAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MaxAllAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Merge + + #region Merge + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMerge() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Merge( + new TraceEntity { Id = 1, Name = "Name" }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Merge(ClassMappedNameCache.Get(), + new { Id = 1, Name = "Name" }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MergeAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAsync( + new TraceEntity { Id = 1, Name = "Name" }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAsync(ClassMappedNameCache.Get(), + new { Id = 1, Name = "Name" }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region MergeAll + + #region MergeAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAll( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAll(ClassMappedNameCache.Get(), + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MergeAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAllAsync( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMergeAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MergeAllAsync(ClassMappedNameCache.Get(), + new[] { new { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Min + + #region Min + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMin() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Min(trace: trace.Object, + field: e => e.Id, + where: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Min(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MinAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region MinAll + + #region MinAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAll(trace: trace.Object, + field: e => e.Id); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAll(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + } + + #endregion + + #region MinAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAllAsync(trace: trace.Object, + field: e => e.Id).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForMinAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.MinAllAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region Query + + #region Query + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQuery() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Query(te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecution(It.IsAny>>()), Times.Exactly(0)); + } + + #endregion + + #region QueryAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryAsync(te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>>(), + It.IsAny()), Times.Exactly(0)); + } + + #endregion + + #endregion + + #region QueryAll + + #region QueryAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryAll(trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryAll(trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>>()), Times.Exactly(1)); + } + + #endregion + + #region QueryAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryAllAsync(trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryAllAsync(trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region QueryMultiple + + #region QueryMultiple + + #region T2 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT2() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT2() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #region T3 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT3() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT3() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #region T4 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT4() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT4() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #region T5 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT5() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT5() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #region T6 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT6() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT6() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #region T7 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT7() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT7() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultiple(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region QueryMultipleAsync + + #region T2 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT2() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT2() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #region T3 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT3() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT3() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #region T4 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT4() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT4() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #region T5 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT5() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT5() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #region T6 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT6() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT6() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #region T7 + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT7() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT7() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.QueryMultipleAsync(te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + te => te.Id == 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable, + IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #endregion + + #region Sum + + #region Sum + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSum() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Sum(trace: trace.Object, + field: e => e.Id, + where: (object)null); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSum() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Sum(trace: trace.Object, + field: e => e.Id, + where: (object)null); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Sum(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Sum(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + #endregion + + #region SumAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAsync(trace: trace.Object, + field: e => e.Id, + where: (object)null).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + where: (object)null, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region SumAll + + #region SumAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAll(trace: trace.Object, + field: e => e.Id); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAll(trace: trace.Object, + field: e => e.Id); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAll(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAll(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + #endregion + + #region SumAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAllAsync(trace: trace.Object, + field: e => e.Id).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAllAsync(trace: trace.Object, + field: e => e.Id).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForSumAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAllAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterSumAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.SumAllAsync(ClassMappedNameCache.Get(), + field: new Field("Id"), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region Truncate + + #region Truncate + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForTruncate() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Truncate(trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterTruncate() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Truncate(trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForTruncateViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Truncate(ClassMappedNameCache.Get(), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterTruncateViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Truncate(ClassMappedNameCache.Get(), + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + #endregion + + #region TruncateAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForTruncateAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.TruncateAsync(trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterTruncateAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.TruncateAsync(trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForTruncateAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.TruncateAsync(ClassMappedNameCache.Get(), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterTruncateAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.TruncateAsync(ClassMappedNameCache.Get(), + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region Update + + #region Update + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdate() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Update( + new TraceEntity + { + Id = 1, + Name = "Name" + }, + what: 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdate() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Update( + new TraceEntity + { + Id = 1, + Name = "Name" + }, + what: 1, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Update(ClassMappedNameCache.Get(), + new + { + Name = "Name" + }, + new + { + Id = 1 + }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.Update(ClassMappedNameCache.Get(), + new + { + Name = "Name" + }, + new + { + Id = 1 + }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + #endregion + + #region UpdateAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAsync( + new TraceEntity + { + Id = 1, + Name = "Name" + }, + what: 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAsync( + new TraceEntity + { + Id = 1, + Name = "Name" + }, + what: 1, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAsync(ClassMappedNameCache.Get(), + new + { + Name = "Name" + }, + new + { + Id = 1 + }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAsync(ClassMappedNameCache.Get(), + new + { + Name = "Name" + }, + new + { + Id = 1 + }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #region UpdateAll + + #region UpdateAll + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAll( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAll() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAll( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAll(ClassMappedNameCache.Get(), + new[] { new { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAll(ClassMappedNameCache.Get(), + new[] { new { Id = 1, Name = "Name" } }, + trace: trace.Object); + + // Assert + trace.Verify(t => + t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + } + + #endregion + + #region UpdateAllAsync + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAllAsync( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllAsync() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAllAsync( + new[] { new TraceEntity { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForUpdateAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAllAsync(ClassMappedNameCache.Get(), + new[] { new { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); + } + + [TestMethod] + public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllAsyncViaTableName() + { + // Prepare + var trace = new Mock(); + var connection = new TraceDbConnection(); + + // Act + connection.UpdateAllAsync(ClassMappedNameCache.Get(), + new[] { new { Id = 1, Name = "Name" } }, + trace: trace.Object).Wait(); + + // Assert + trace.Verify(t => + t.AfterExecutionAsync(It.IsAny>(), + It.IsAny()), Times.Exactly(1)); + } + + #endregion + + #endregion + + #endregion } } \ No newline at end of file From ce31afe47e719e4d12d1c0eaea4e86392f5c4e37 Mon Sep 17 00:00:00 2001 From: Michael Camara Pendon Date: Wed, 28 Sep 2022 22:15:03 +0200 Subject: [PATCH 3/3] #941 Unit Tests for the Silent Cancellation --- .../Interfaces/ITraceForDbConnectionTest.cs | 3 +- .../Trace/CancellableTraceLogTest.cs | 1933 +++++------------ RepoDb.Core/RepoDb/Trace/Tracer.cs | 5 + 3 files changed, 512 insertions(+), 1429 deletions(-) diff --git a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs index 3a84f57a..93c8bd60 100644 --- a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs +++ b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Interfaces/ITraceForDbConnectionTest.cs @@ -1635,7 +1635,8 @@ public void TestDbConnectionTraceForBeforeMaxAsync() // Assert trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); + t.BeforeExecutionAsync(It.IsAny(), + It.IsAny()), Times.Exactly(1)); } [TestMethod] diff --git a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs index d23c75a8..769a9de8 100644 --- a/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs +++ b/RepoDb.Core/RepoDb.Tests/RepoDb.UnitTests/Trace/CancellableTraceLogTest.cs @@ -1,11 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; using RepoDb.Exceptions; using RepoDb.Extensions; using RepoDb.Interfaces; using RepoDb.UnitTests.CustomObjects; using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -26,11 +24,16 @@ public static void ClassInitialize(TestContext context) private class TraceDbConnection : CustomDbConnection { } - private class CancelTrace : ITrace + private class TraceEntity + { + public int Id { get; set; } + public string Name { get; set; } + } + + private class ErroneousCancellationTrace : ITrace { public void AfterExecution(ResultTraceLog log) { - // Do nothing } public Task AfterExecutionAsync(ResultTraceLog log, @@ -52,10 +55,41 @@ public Task BeforeExecutionAsync(CancellableTraceLog log, } } - private class TraceEntity + private class SilentCancellationTrace : ITrace { - public int Id { get; set; } - public string Name { get; set; } + public void AfterExecution(ResultTraceLog log) + { + AfterExecutionInvocationCount++; + } + + public Task AfterExecutionAsync(ResultTraceLog log, + CancellationToken cancellationToken = default) + { + AfterExecutionInvocationCount++; + return Task.CompletedTask; + } + + public void BeforeExecution(CancellableTraceLog log) + { + log.Cancel(false); + BeforeExecutionInvocationCount++; + } + + public Task BeforeExecutionAsync(CancellableTraceLog log, + CancellationToken cancellationToken = default) + { + log.Cancel(false); + BeforeExecutionInvocationCount++; + return Task.CompletedTask; + } + + #region Properties + + public int BeforeExecutionInvocationCount { get; private set; } + + public int AfterExecutionInvocationCount { get; private set; } + + #endregion } #endregion @@ -72,7 +106,7 @@ public void ThrowExceptionOnExecuteNonQueryCancelledOperation() // Act connection - .ExecuteNonQuery("", trace: new CancelTrace()); + .ExecuteNonQuery("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -83,7 +117,7 @@ public void ThrowExceptionOnExecuteNonQueryAsyncCancelledOperation() // Act connection - .ExecuteNonQueryAsync("", trace: new CancelTrace()) + .ExecuteNonQueryAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -99,7 +133,7 @@ public void ThrowExceptionOnExecuteQueryCancelledOperation() // Act connection - .ExecuteQuery("", trace: new CancelTrace()); + .ExecuteQuery("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -110,7 +144,7 @@ public void ThrowExceptionOnExecuteQueryAsyncCancelledOperation() // Act connection - .ExecuteQueryAsync("", trace: new CancelTrace()) + .ExecuteQueryAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -126,7 +160,7 @@ public void ThrowExceptionOnExecuteScalarCancelledOperation() // Act connection - .ExecuteScalar("", trace: new CancelTrace()); + .ExecuteScalar("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -137,7 +171,7 @@ public void ThrowExceptionOnExecuteScalarAsyncCancelledOperation() // Act connection - .ExecuteScalarAsync("", trace: new CancelTrace()) + .ExecuteScalarAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -153,7 +187,7 @@ public void ThrowExceptionOnExecuteQueryMultipleCancelledOperation() // Act connection - .ExecuteQueryMultiple("", trace: new CancelTrace()); + .ExecuteQueryMultiple("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -164,7 +198,7 @@ public void ThrowExceptionExecuteQueryMultipleAsyncCancelledOperation() // Act connection - .ExecuteQueryMultipleAsync("", trace: new CancelTrace()) + .ExecuteQueryMultipleAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -180,7 +214,7 @@ public void ThrowExceptionOnAverageCancelledOperation() // Act connection - .Average("", (Field)null, (object)null, trace: new CancelTrace()); + .Average("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -191,7 +225,7 @@ public void ThrowExceptionOnAverageAsyncCancelledOperation() // Act connection - .AverageAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .AverageAsync("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -207,7 +241,7 @@ public void ThrowExceptionOnAverageAllCancelledOperation() // Act connection - .AverageAll("", (Field)null, trace: new CancelTrace()); + .AverageAll("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -218,7 +252,7 @@ public void ThrowExceptionOnAverageAllAsyncCancelledOperation() // Act connection - .AverageAllAsync("", (Field)null, trace: new CancelTrace()) + .AverageAllAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -234,7 +268,7 @@ public void ThrowExceptionOnBatchQueryCancelledOperation() // Act connection - .BatchQuery("", 0, 100, null, (object)null, trace: new CancelTrace()); + .BatchQuery("", 0, 100, null, (object)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -245,7 +279,7 @@ public void ThrowExceptionOnBatchQueryAsyncCancelledOperation() // Act connection - .BatchQueryAsync("", 0, 100, null, (object)null, trace: new CancelTrace()) + .BatchQueryAsync("", 0, 100, null, (object)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -261,7 +295,7 @@ public void ThrowExceptionOnCountCancelledOperation() // Act connection - .Count("", (Field)null, trace: new CancelTrace()); + .Count("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -272,7 +306,7 @@ public void ThrowExceptionOnCountAsyncCancelledOperation() // Act connection - .CountAsync("", (Field)null, trace: new CancelTrace()) + .CountAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -288,7 +322,7 @@ public void ThrowExceptionOnCountAllCancelledOperation() // Act connection - .CountAll("", trace: new CancelTrace()); + .CountAll("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -299,7 +333,7 @@ public void ThrowExceptionOnCountAllAsyncCancelledOperation() // Act connection - .CountAllAsync("", trace: new CancelTrace()) + .CountAllAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -315,7 +349,7 @@ public void ThrowExceptionOnDeleteCancelledOperation() // Act connection - .Delete("", (Field)null, trace: new CancelTrace()); + .Delete("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -326,7 +360,7 @@ public void ThrowExceptionOnDeleteAsyncCancelledOperation() // Act connection - .DeleteAsync("", (Field)null, trace: new CancelTrace()) + .DeleteAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -342,7 +376,7 @@ public void ThrowExceptionOnDeleteAllCancelledOperation() // Act connection - .DeleteAll("", trace: new CancelTrace()); + .DeleteAll("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -353,7 +387,7 @@ public void ThrowExceptionOnDeleteAllAsyncCancelledOperation() // Act connection - .DeleteAllAsync("", trace: new CancelTrace()) + .DeleteAllAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -369,7 +403,7 @@ public void ThrowExceptionOnExistsCancelledOperation() // Act connection - .Exists("", (Field)null, trace: new CancelTrace()); + .Exists("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -380,7 +414,7 @@ public void ThrowExceptionOnExistsAsyncCancelledOperation() // Act connection - .ExistsAsync("", (Field)null, trace: new CancelTrace()) + .ExistsAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -396,7 +430,7 @@ public void ThrowExceptionOnInsertCancelledOperation() // Act connection - .Insert("", null, trace: new CancelTrace()); + .Insert("", null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -407,7 +441,7 @@ public void ThrowExceptionOnInsertAsyncCancelledOperation() // Act connection - .InsertAsync("", null, trace: new CancelTrace()) + .InsertAsync("", null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -428,7 +462,7 @@ public void ThrowExceptionOnInsertAllCancelledOperation() // Act connection - .InsertAll("", entities, trace: new CancelTrace()); + .InsertAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(CancelledExecutionException))] @@ -443,7 +477,7 @@ public void ThrowExceptionOnInsertAllMultipleEntitiesCancelledOperation() // Act connection - .InsertAll("", entities, trace: new CancelTrace()); + .InsertAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -460,7 +494,7 @@ public void ThrowExceptionOnInsertAllAsyncCancelledOperation() // Act connection - .InsertAllAsync("", entities, trace: new CancelTrace()) + .InsertAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -478,7 +512,7 @@ public void ThrowExceptionOnInsertAllAsyncMultipleEntitiesCancelledOperation() // Act connection - .InsertAllAsync("", entities, trace: new CancelTrace()) + .InsertAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -494,7 +528,7 @@ public void ThrowExceptionOnMaxCancelledOperation() // Act connection - .Max("", (Field)null, (object)null, trace: new CancelTrace()); + .Max("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -505,7 +539,7 @@ public void ThrowExceptionOnMaxAsyncCancelledOperation() // Act connection - .MaxAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .MaxAsync("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -521,7 +555,7 @@ public void ThrowExceptionOnMaxAllCancelledOperation() // Act connection - .MaxAll("", (Field)null, trace: new CancelTrace()); + .MaxAll("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -532,7 +566,7 @@ public void ThrowExceptionOnMaxAllAsyncCancelledOperation() // Act connection - .MaxAllAsync("", (Field)null, trace: new CancelTrace()) + .MaxAllAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -548,7 +582,7 @@ public void ThrowExceptionOnMergeCancelledOperation() // Act connection - .Merge("", new { Id = 1 }, (Field)null, trace: new CancelTrace()); + .Merge("", new { Id = 1 }, (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -559,7 +593,7 @@ public void ThrowExceptionOnMergeAsyncCancelledOperation() // Act connection - .MergeAsync("", new { Id = 1 }, (Field)null, trace: new CancelTrace()) + .MergeAsync("", new { Id = 1 }, (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -579,7 +613,7 @@ public void ThrowExceptionOnMergeAllCancelledOperation() // Act connection - .MergeAll("", entities, trace: new CancelTrace()); + .MergeAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -594,7 +628,7 @@ public void ThrowExceptionOnMergeAllAsyncCancelledOperation() // Act connection - .MergeAllAsync("", entities, trace: new CancelTrace()) + .MergeAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -612,7 +646,7 @@ public void ThrowExceptionOnMergeAllMultipleEntitiesCancelledOperation() // Act connection - .MergeAll("", entities, trace: new CancelTrace()); + .MergeAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -629,7 +663,7 @@ public void ThrowExceptionOnMergeAllMultipleEntitiesAsyncCancelledOperation() // Act connection - .MergeAllAsync("", entities, trace: new CancelTrace()) + .MergeAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -645,7 +679,7 @@ public void ThrowExceptionOnMinCancelledOperation() // Act connection - .Min("", (Field)null, (object)null, trace: new CancelTrace()); + .Min("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -656,7 +690,7 @@ public void ThrowExceptionOnMinAsyncCancelledOperation() // Act connection - .MinAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .MinAsync("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -672,7 +706,7 @@ public void ThrowExceptionOnMinAllCancelledOperation() // Act connection - .MinAll("", (Field)null, trace: new CancelTrace()); + .MinAll("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -683,7 +717,7 @@ public void ThrowExceptionOnMinAllAsyncCancelledOperation() // Act connection - .MinAllAsync("", (Field)null, trace: new CancelTrace()) + .MinAllAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -699,7 +733,7 @@ public void ThrowExceptionOnQueryCancelledOperation() // Act connection - .Query("", (QueryField)null, trace: new CancelTrace()); + .Query("", (QueryField)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -710,7 +744,7 @@ public void ThrowExceptionOnQueryAsyncCancelledOperation() // Act connection - .QueryAsync("", (QueryField)null, trace: new CancelTrace()) + .QueryAsync("", (QueryField)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -726,7 +760,7 @@ public void ThrowExceptionOnQueryAllCancelledOperation() // Act connection - .QueryAll("", trace: new CancelTrace()); + .QueryAll("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -737,7 +771,7 @@ public void ThrowExceptionOnQueryAllAsyncCancelledOperation() // Act connection - .QueryAllAsync("", trace: new CancelTrace()) + .QueryAllAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -757,7 +791,7 @@ public void ThrowExceptionOnQueryMultipleForT2CancelledOperation() connection .QueryMultiple("", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -770,7 +804,7 @@ public void ThrowExceptionOnQueryMultipleForT2AsyncCancelledOperation() connection .QueryMultipleAsync("", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -789,7 +823,7 @@ public void ThrowExceptionOnQueryMultipleForT3CancelledOperation() .QueryMultiple("", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -803,7 +837,7 @@ public void ThrowExceptionOnQueryMultipleForT3AsyncCancelledOperation() .QueryMultipleAsync("", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -823,7 +857,7 @@ public void ThrowExceptionOnQueryMultipleForT4CancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -838,7 +872,7 @@ public void ThrowExceptionOnQueryMultipleForT4AsyncCancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -859,7 +893,7 @@ public void ThrowExceptionOnQueryMultipleForT5CancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -875,7 +909,7 @@ public void ThrowExceptionOnQueryMultipleForT5AsyncCancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -897,7 +931,7 @@ public void ThrowExceptionOnQueryMultipleForT6CancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -914,7 +948,7 @@ public void ThrowExceptionOnQueryMultipleForT6AsyncCancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -937,7 +971,7 @@ public void ThrowExceptionOnQueryMultipleForT7CancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()); + trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -955,7 +989,7 @@ public void ThrowExceptionOnQueryMultipleForT7AsyncCancelledOperation() "", (QueryField)null, "", (QueryField)null, "", (QueryField)null, - trace: new CancelTrace()) + trace: new ErroneousCancellationTrace()) .Wait(); } @@ -973,7 +1007,7 @@ public void ThrowExceptionOnSumCancelledOperation() // Act connection - .Sum("", (Field)null, (object)null, trace: new CancelTrace()); + .Sum("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -984,7 +1018,7 @@ public void ThrowExceptionOnSumAsyncCancelledOperation() // Act connection - .SumAsync("", (Field)null, (object)null, trace: new CancelTrace()) + .SumAsync("", (Field)null, (object)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1000,7 +1034,7 @@ public void ThrowExceptionOnSumAllCancelledOperation() // Act connection - .SumAll("", (Field)null, trace: new CancelTrace()); + .SumAll("", (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1011,7 +1045,7 @@ public void ThrowExceptionOnSumAllAsyncCancelledOperation() // Act connection - .SumAllAsync("", (Field)null, trace: new CancelTrace()) + .SumAllAsync("", (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1027,7 +1061,7 @@ public void ThrowExceptionOnTruncateCancelledOperation() // Act connection - .Truncate("", trace: new CancelTrace()); + .Truncate("", trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1038,7 +1072,7 @@ public void ThrowExceptionOnTruncateAsyncCancelledOperation() // Act connection - .TruncateAsync("", trace: new CancelTrace()) + .TruncateAsync("", trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1054,7 +1088,7 @@ public void ThrowExceptionOnUpdateCancelledOperation() // Act connection - .Update("", new { Id = 1 }, (Field)null, trace: new CancelTrace()); + .Update("", new { Id = 1 }, (Field)null, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1065,7 +1099,7 @@ public void ThrowExceptionOnUpdateAsyncCancelledOperation() // Act connection - .UpdateAsync("", new { Id = 1 }, (Field)null, trace: new CancelTrace()) + .UpdateAsync("", new { Id = 1 }, (Field)null, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1085,7 +1119,7 @@ public void ThrowExceptionOnUpdateAllCancelledOperation() // Act connection - .UpdateAll("", entities, trace: new CancelTrace()); + .UpdateAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1100,7 +1134,7 @@ public void ThrowExceptionOnUpdateAllAsyncCancelledOperation() // Act connection - .UpdateAllAsync("", entities, trace: new CancelTrace()) + .UpdateAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1118,7 +1152,7 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesCancelledOperation() // Act connection - .UpdateAll("", entities, trace: new CancelTrace()); + .UpdateAll("", entities, trace: new ErroneousCancellationTrace()); } [TestMethod, ExpectedException(typeof(AggregateException))] @@ -1135,7 +1169,7 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesAsyncCancelledOperation() // Act connection - .UpdateAllAsync("", entities, trace: new CancelTrace()) + .UpdateAllAsync("", entities, trace: new ErroneousCancellationTrace()) .Wait(); } @@ -1153,19 +1187,17 @@ public void ThrowExceptionOnUpdateAllMultipleEntitiesAsyncCancelledOperation() public void TestDbConnectionTraceSilentCancellationForAverage() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Average(trace: trace.Object, + connection.Average(trace: trace, field: e => e.Id, where: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } @@ -1173,20 +1205,18 @@ public void TestDbConnectionTraceSilentCancellationForAverage() public void TestDbConnectionTraceSilentCancellationForAverageViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Average(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1197,43 +1227,35 @@ public void TestDbConnectionTraceSilentCancellationForAverageViaTableName() public void TestDbConnectionTraceSilentCancellationForAverageAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.AverageAsync(trace: trace.Object, + connection.AverageAsync(trace: trace, field: e => e.Id, where: (object)null).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForAverageAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.AverageAsync(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1248,37 +1270,33 @@ public void TestDbConnectionTraceSilentCancellationForAverageAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForAverageAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.AverageAll(trace: trace.Object, + connection.AverageAll(trace: trace, field: e => e.Id); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForAverageAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.AverageAll(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1289,41 +1307,33 @@ public void TestDbConnectionTraceSilentCancellationForAverageAllViaTableName() public void TestDbConnectionTraceSilentCancellationForAverageAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.AverageAllAsync(trace: trace.Object, + connection.AverageAllAsync(trace: trace, field: e => e.Id).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForAverageAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.AverageAllAsync(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1338,7 +1348,7 @@ public void TestDbConnectionTraceSilentCancellationForAverageAllAsyncViaTableNam public void TestDbConnectionTraceSilentCancellationForBatchQuery() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -1346,13 +1356,11 @@ public void TestDbConnectionTraceSilentCancellationForBatchQuery() 10, OrderField.Ascending(t => t.Id).AsEnumerable(), where: (QueryGroup)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1363,7 +1371,7 @@ public void TestDbConnectionTraceSilentCancellationForBatchQuery() public void TestDbConnectionTraceSilentCancellationForBatchQueryAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -1371,97 +1379,17 @@ public void TestDbConnectionTraceSilentCancellationForBatchQueryAsync() 10, OrderField.Ascending(t => t.Id).AsEnumerable(), where: (QueryGroup)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion #endregion - #region BulkInsert - - //#region BulkInsert - - //[TestMethod] - //public void TestDbConnectionTraceSilentCancellationForBulkInsert() - //{ - // // Prepare - // var trace = new Mock(); - // var connection = new TraceDbConnection(); - // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; - - // // Act - // connection.BulkInsert(entities, - // trace: trace.Object); - - // // Assert - // trace.Verify(t => t.BeforeBulkInsert(It.IsAny()), Times.Exactly(1)); - //} - - //[TestMethod] - //public void TestDbConnectionTraceSilentCancellationForAfterBulkInsert() - //{ - // // Prepare - // var trace = new Mock(); - // var connection = new TraceDbConnection(); - // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; - - // // Act - // connection.BulkInsert(entities, - // trace: trace.Object); - - // // Assert - // trace.Verify(t => t.AfterBulkInsert(It.IsAny()), Times.Exactly(1)); - //} - - //#endregion - - //#region BulkInsertAsync - - //[TestMethod] - //public void TestDbConnectionTraceSilentCancellationForBulkInsertAsync() - //{ - // // Prepare - // var trace = new Mock(); - // var connection = new TraceDbConnection(); - // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; - - // // Act - // connection.BulkInsertAsync(entities, - // trace: trace.Object).Wait(); - - // // Assert - // trace.Verify(t => t.BeforeBulkInsert(It.IsAny()), Times.Exactly(1)); - //} - - //[TestMethod] - //public void TestDbConnectionTraceSilentCancellationForAfterBulkInsertAsync() - //{ - // // Prepare - // var trace = new Mock(); - // var connection = new TraceDbConnection(); - // var entities = new[] { new TraceEntity() { Id = 1, Name = "Name" } }; - - // // Act - // connection.BulkInsertAsync(entities, - // trace: trace.Object).Wait(); - - // // Assert - // trace.Verify(t => t.AfterBulkInsert(It.IsAny()), Times.Exactly(1)); - //} - - //#endregion - - #endregion - #region Count #region Count @@ -1470,37 +1398,33 @@ public void TestDbConnectionTraceSilentCancellationForBatchQueryAsync() public void TestDbConnectionTraceSilentCancellationForCount() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Count(trace: trace.Object, + connection.Count(trace: trace, where: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForCountViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Count(ClassMappedNameCache.Get(), where: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1511,40 +1435,33 @@ public void TestDbConnectionTraceSilentCancellationForCountViaTableName() public void TestDbConnectionTraceSilentCancellationForCountAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.CountAsync(trace: trace.Object, + connection.CountAsync(trace: trace, where: (object)null).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForCountAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.CountAsync(ClassMappedNameCache.Get(), where: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1559,35 +1476,31 @@ public void TestDbConnectionTraceSilentCancellationForCountAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForCountAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.CountAll(trace: trace.Object); + connection.CountAll(trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForCountAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.CountAll(ClassMappedNameCache.Get(), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1598,39 +1511,31 @@ public void TestDbConnectionTraceSilentCancellationForCountAllViaTableName() public void TestDbConnectionTraceSilentCancellationForCountAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.CountAllAsync(trace: trace.Object).Wait(); + connection.CountAllAsync(trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForCountAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.CountAllAsync(ClassMappedNameCache.Get(), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1645,25 +1550,23 @@ public void TestDbConnectionTraceSilentCancellationForCountAllAsyncViaTableName( public void TestDbConnectionTraceSilentCancellationForDelete() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Delete(0, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForDeleteViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -1672,13 +1575,11 @@ public void TestDbConnectionTraceSilentCancellationForDeleteViaTableName() { Id = 1 }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1689,27 +1590,23 @@ public void TestDbConnectionTraceSilentCancellationForDeleteViaTableName() public void TestDbConnectionTraceSilentCancellationForDeleteAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.DeleteAsync(0, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForDeleteAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -1718,15 +1615,11 @@ public void TestDbConnectionTraceSilentCancellationForDeleteAsyncViaTableName() { Id = 1 }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1741,35 +1634,31 @@ public void TestDbConnectionTraceSilentCancellationForDeleteAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForDeleteAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.DeleteAll(trace: trace.Object); + connection.DeleteAll(trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForDeleteAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.DeleteAll(ClassMappedNameCache.Get(), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1780,39 +1669,31 @@ public void TestDbConnectionTraceSilentCancellationForDeleteAllViaTableName() public void TestDbConnectionTraceSilentCancellationForDeleteAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.DeleteAllAsync(trace: trace.Object).Wait(); + connection.DeleteAllAsync(trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForDeleteAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.DeleteAllAsync(ClassMappedNameCache.Get(), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1827,37 +1708,33 @@ public void TestDbConnectionTraceSilentCancellationForDeleteAllAsyncViaTableName public void TestDbConnectionTraceSilentCancellationForExists() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Exists(trace: trace.Object, + connection.Exists(trace: trace, what: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForExistsViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Exists(ClassMappedNameCache.Get(), what: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1868,41 +1745,33 @@ public void TestDbConnectionTraceSilentCancellationForExistsViaTableName() public void TestDbConnectionTraceSilentCancellationForExistsAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.ExistsAsync(trace: trace.Object, + connection.ExistsAsync(trace: trace, what: (object)null).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForExistsAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.ExistsAsync(ClassMappedNameCache.Get(), what: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1917,38 +1786,34 @@ public void TestDbConnectionTraceSilentCancellationForExistsAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForInsert() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Insert( new TraceEntity { Name = "Name" }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForInsertViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Insert(ClassMappedNameCache.Get(), new { Name = "Name" }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -1959,42 +1824,34 @@ public void TestDbConnectionTraceSilentCancellationForInsertViaTableName() public void TestDbConnectionTraceSilentCancellationForInsertAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAsync( new TraceEntity { Name = "Name" }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForInsertAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAsync(ClassMappedNameCache.Get(), new { Name = "Name" }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2009,38 +1866,34 @@ public void TestDbConnectionTraceSilentCancellationForInsertAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForInsertAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAll(new[] { new TraceEntity { Name = "Name" } }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForInsertAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAll(ClassMappedNameCache.Get(), new[] { new { Name = "Name" } }, fields: Field.From("Name"), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2051,42 +1904,34 @@ public void TestDbConnectionTraceSilentCancellationForInsertAllViaTableName() public void TestDbConnectionTraceSilentCancellationForInsertAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAllAsync(new[] { new TraceEntity { Name = "Name" } }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForInsertAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.InsertAllAsync(ClassMappedNameCache.Get(), new[] { new { Name = "Name" } }, fields: Field.From("Name"), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2101,39 +1946,35 @@ public void TestDbConnectionTraceSilentCancellationForInsertAllAsyncViaTableName public void TestDbConnectionTraceSilentCancellationForMax() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Max(trace: trace.Object, + connection.Max(trace: trace, field: e => e.Id, where: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMaxViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Max(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2144,41 +1985,35 @@ public void TestDbConnectionTraceSilentCancellationForMaxViaTableName() public void TestDbConnectionTraceSilentCancellationForMaxAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MaxAsync(trace: trace.Object, + connection.MaxAsync(trace: trace, field: e => e.Id, where: (object)null).Wait(); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMaxAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MaxAsync(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2193,37 +2028,33 @@ public void TestDbConnectionTraceSilentCancellationForMaxAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForMaxAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MaxAll(trace: trace.Object, + connection.MaxAll(trace: trace, field: e => e.Id); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMaxAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MaxAll(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2234,41 +2065,33 @@ public void TestDbConnectionTraceSilentCancellationForMaxAllViaTableName() public void TestDbConnectionTraceSilentCancellationForMaxAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MaxAllAsync(trace: trace.Object, + connection.MaxAllAsync(trace: trace, field: e => e.Id).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMaxAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MaxAllAsync(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2283,38 +2106,34 @@ public void TestDbConnectionTraceSilentCancellationForMaxAllAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForMerge() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Merge( new TraceEntity { Id = 1, Name = "Name" }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMergeViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Merge(ClassMappedNameCache.Get(), new { Id = 1, Name = "Name" }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2325,42 +2144,34 @@ public void TestDbConnectionTraceSilentCancellationForMergeViaTableName() public void TestDbConnectionTraceSilentCancellationForMergeAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAsync( new TraceEntity { Id = 1, Name = "Name" }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMergeAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAsync(ClassMappedNameCache.Get(), new { Id = 1, Name = "Name" }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2375,38 +2186,34 @@ public void TestDbConnectionTraceSilentCancellationForMergeAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForMergeAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAll( new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMergeAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAll(ClassMappedNameCache.Get(), new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2417,42 +2224,34 @@ public void TestDbConnectionTraceSilentCancellationForMergeAllViaTableName() public void TestDbConnectionTraceSilentCancellationForMergeAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAllAsync( new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMergeAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MergeAllAsync(ClassMappedNameCache.Get(), new[] { new { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2467,39 +2266,35 @@ public void TestDbConnectionTraceSilentCancellationForMergeAllAsyncViaTableName( public void TestDbConnectionTraceSilentCancellationForMin() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Min(trace: trace.Object, + connection.Min(trace: trace, field: e => e.Id, where: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMinViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Min(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2510,43 +2305,35 @@ public void TestDbConnectionTraceSilentCancellationForMinViaTableName() public void TestDbConnectionTraceSilentCancellationForMinAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MinAsync(trace: trace.Object, + connection.MinAsync(trace: trace, field: e => e.Id, where: (object)null).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMinAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MinAsync(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2561,37 +2348,33 @@ public void TestDbConnectionTraceSilentCancellationForMinAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForMinAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MinAll(trace: trace.Object, + connection.MinAll(trace: trace, field: e => e.Id); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMinAllViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MinAll(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2602,41 +2385,33 @@ public void TestDbConnectionTraceSilentCancellationForMinAllViaTableName() public void TestDbConnectionTraceSilentCancellationForMinAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.MinAllAsync(trace: trace.Object, + connection.MinAllAsync(trace: trace, field: e => e.Id).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForMinAllAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.MinAllAsync(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2651,18 +2426,16 @@ public void TestDbConnectionTraceSilentCancellationForMinAllAsyncViaTableName() public void TestDbConnectionTraceSilentCancellationForQuery() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Query(te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecution(It.IsAny>>()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2673,20 +2446,16 @@ public void TestDbConnectionTraceSilentCancellationForQuery() public void TestDbConnectionTraceSilentCancellationForQueryAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.QueryAsync(te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>>(), - It.IsAny()), Times.Exactly(0)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2701,30 +2470,15 @@ public void TestDbConnectionTraceSilentCancellationForQueryAsync() public void TestDbConnectionTraceSilentCancellationForQueryAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.QueryAll(trace: trace.Object); + connection.QueryAll(trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryAll() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryAll(trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2735,32 +2489,15 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryAll() public void TestDbConnectionTraceSilentCancellationForQueryAllAsync() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryAllAsync(trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryAllAsync() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.QueryAllAsync(trace: trace.Object); + connection.QueryAllAsync(trace: trace); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2777,35 +2514,17 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryAllAsync() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT2() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT2() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.QueryMultiple(te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2816,38 +2535,18 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT2() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT3() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.QueryMultiple(te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT3() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2858,26 +2557,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT3() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT4() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT4() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -2885,14 +2565,11 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT4() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2903,7 +2580,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT4() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT5() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -2912,35 +2589,11 @@ public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT5() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT5() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -2951,28 +2604,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT5() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT6() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT6() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -2982,16 +2614,11 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT6() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3002,29 +2629,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT6() public void TestDbConnectionTraceSilentCancellationForQueryMultipleForT7() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultiple(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT7() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3035,17 +2640,11 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT7() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3060,36 +2659,17 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleForT7() public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT2() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.QueryMultipleAsync(te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT2() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3100,39 +2680,18 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT3() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.QueryMultipleAsync(te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT3() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3143,27 +2702,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT4() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT4() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3171,14 +2710,11 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3189,28 +2725,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT5() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT5() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3219,15 +2734,11 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3238,7 +2749,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT6() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3248,38 +2759,11 @@ public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT6() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT6() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3290,7 +2774,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT7() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3301,40 +2785,11 @@ public void TestDbConnectionTraceSilentCancellationForQueryMultipleAsyncForT7() te => te.Id == 1, te => te.Id == 1, te => te.Id == 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncForT7() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.QueryMultipleAsync(te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - te => te.Id == 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable, - IEnumerable>>>(), It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3351,70 +2806,35 @@ public void TestDbConnectionTraceSilentCancellationForAfterQueryMultipleAsyncFor public void TestDbConnectionTraceSilentCancellationForSum() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Sum(trace: trace.Object, + connection.Sum(trace: trace, field: e => e.Id, where: (object)null); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSum() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Sum(trace: trace.Object, - field: e => e.Id, - where: (object)null); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForSumViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Sum(ClassMappedNameCache.Get(), - field: new Field("Id"), - where: (object)null, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Sum(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3425,74 +2845,35 @@ public void TestDbConnectionTraceSilentCancellationForAfterSumViaTableName() public void TestDbConnectionTraceSilentCancellationForSumAsync() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAsync(trace: trace.Object, - field: e => e.Id, - where: (object)null).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAsync() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.SumAsync(trace: trace.Object, + connection.SumAsync(trace: trace, field: e => e.Id, where: (object)null).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForSumAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.SumAsync(ClassMappedNameCache.Get(), field: new Field("Id"), where: (object)null, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAsyncViaTableName() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAsync(ClassMappedNameCache.Get(), - field: new Field("Id"), - where: (object)null, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3507,66 +2888,33 @@ public void TestDbConnectionTraceSilentCancellationForAfterSumAsyncViaTableName( public void TestDbConnectionTraceSilentCancellationForSumAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.SumAll(trace: trace.Object, + connection.SumAll(trace: trace, field: e => e.Id); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAll() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAll(trace: trace.Object, - field: e => e.Id); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForSumAllViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAll(ClassMappedNameCache.Get(), - field: new Field("Id"), - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAllViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.SumAll(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3577,70 +2925,33 @@ public void TestDbConnectionTraceSilentCancellationForAfterSumAllViaTableName() public void TestDbConnectionTraceSilentCancellationForSumAllAsync() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAllAsync(trace: trace.Object, - field: e => e.Id).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAllAsync() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.SumAllAsync(trace: trace.Object, + connection.SumAllAsync(trace: trace, field: e => e.Id).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForSumAllAsyncViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.SumAllAsync(ClassMappedNameCache.Get(), - field: new Field("Id"), - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterSumAllAsyncViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.SumAllAsync(ClassMappedNameCache.Get(), field: new Field("Id"), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3655,62 +2966,31 @@ public void TestDbConnectionTraceSilentCancellationForAfterSumAllAsyncViaTableNa public void TestDbConnectionTraceSilentCancellationForTruncate() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.Truncate(trace: trace.Object); + connection.Truncate(trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterTruncate() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Truncate(trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForTruncateViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Truncate(ClassMappedNameCache.Get(), - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterTruncateViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.Truncate(ClassMappedNameCache.Get(), - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3721,66 +3001,31 @@ public void TestDbConnectionTraceSilentCancellationForAfterTruncateViaTableName( public void TestDbConnectionTraceSilentCancellationForTruncateAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act - connection.TruncateAsync(trace: trace.Object).Wait(); + connection.TruncateAsync(trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterTruncateAsync() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.TruncateAsync(trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForTruncateAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.TruncateAsync(ClassMappedNameCache.Get(), - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterTruncateAsyncViaTableName() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.TruncateAsync(ClassMappedNameCache.Get(), - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3795,29 +3040,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterTruncateAsyncViaTable public void TestDbConnectionTraceSilentCancellationForUpdate() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Update( - new TraceEntity - { - Id = 1, - Name = "Name" - }, - what: 1, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdate() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3828,18 +3051,18 @@ public void TestDbConnectionTraceSilentCancellationForAfterUpdate() Name = "Name" }, what: 1, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForUpdateViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3852,35 +3075,11 @@ public void TestDbConnectionTraceSilentCancellationForUpdateViaTableName() { Id = 1 }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateViaTableName() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.Update(ClassMappedNameCache.Get(), - new - { - Name = "Name" - }, - new - { - Id = 1 - }, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3891,7 +3090,7 @@ public void TestDbConnectionTraceSilentCancellationForAfterUpdateViaTableName() public void TestDbConnectionTraceSilentCancellationForUpdateAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3902,42 +3101,18 @@ public void TestDbConnectionTraceSilentCancellationForUpdateAsync() Name = "Name" }, what: 1, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAsync() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAsync( - new TraceEntity - { - Id = 1, - Name = "Name" - }, - what: 1, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForUpdateAsyncViaTableName() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act @@ -3950,37 +3125,11 @@ public void TestDbConnectionTraceSilentCancellationForUpdateAsyncViaTableName() { Id = 1 }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAsyncViaTableName() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAsync(ClassMappedNameCache.Get(), - new - { - Name = "Name" - }, - new - { - Id = 1 - }, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -3995,68 +3144,34 @@ public void TestDbConnectionTraceSilentCancellationForAfterUpdateAsyncViaTableNa public void TestDbConnectionTraceSilentCancellationForUpdateAll() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.UpdateAll( new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAll() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAll( - new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForUpdateAllViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAll(ClassMappedNameCache.Get(), - new[] { new { Id = 1, Name = "Name" } }, - trace: trace.Object); - - // Assert - trace.Verify(t => - t.BeforeExecution(It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.UpdateAll(ClassMappedNameCache.Get(), new[] { new { Id = 1, Name = "Name" } }, - trace: trace.Object); + trace: trace); // Assert - trace.Verify(t => - t.AfterExecution(It.IsAny>()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion @@ -4067,72 +3182,34 @@ public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllViaTableName public void TestDbConnectionTraceSilentCancellationForUpdateAllAsync() { // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.UpdateAllAsync( new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllAsync() - { - // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAllAsync( - new[] { new TraceEntity { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } [TestMethod] public void TestDbConnectionTraceSilentCancellationForUpdateAllAsyncViaTableName() { // Prepare - var trace = new Mock(); - var connection = new TraceDbConnection(); - - // Act - connection.UpdateAllAsync(ClassMappedNameCache.Get(), - new[] { new { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); - - // Assert - trace.Verify(t => - t.BeforeExecutionAsync(It.IsAny(), - It.IsAny()), Times.Exactly(1)); - } - - [TestMethod] - public void TestDbConnectionTraceSilentCancellationForAfterUpdateAllAsyncViaTableName() - { - // Prepare - var trace = new Mock(); + var trace = new SilentCancellationTrace(); var connection = new TraceDbConnection(); // Act connection.UpdateAllAsync(ClassMappedNameCache.Get(), new[] { new { Id = 1, Name = "Name" } }, - trace: trace.Object).Wait(); + trace: trace).Wait(); // Assert - trace.Verify(t => - t.AfterExecutionAsync(It.IsAny>(), - It.IsAny()), Times.Exactly(1)); + Assert.AreEqual(1, trace.BeforeExecutionInvocationCount); + Assert.AreEqual(0, trace.AfterExecutionInvocationCount); } #endregion diff --git a/RepoDb.Core/RepoDb/Trace/Tracer.cs b/RepoDb.Core/RepoDb/Trace/Tracer.cs index 7ec92a44..8a219f0f 100644 --- a/RepoDb.Core/RepoDb/Trace/Tracer.cs +++ b/RepoDb.Core/RepoDb/Trace/Tracer.cs @@ -90,6 +90,11 @@ public static void InvokeAfterExecution(TraceResult result, return; } + if (result.CancellableTraceLog?.IsCancelled == true) + { + return; + } + var log = new ResultTraceLog(result.SessionId, result.CancellableTraceLog.Key, result.CancellableTraceLog.Statement,