-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to intercept some SQL operations done through SqlHelper a…
…nd EntityConnectionExtensions by implementing ISqlOperationInterceptor and/or IRowOperationInterceptor in the mock connection class.
- Loading branch information
1 parent
3a1edcc
commit 4058bd2
Showing
20 changed files
with
583 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Serenity.Net.Services/Data/SqlHelpers/ISqlOperationInterceptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Serenity.Data; | ||
|
||
/// <summary> | ||
/// An interface that makes it possible to intercept basic SQL operations on connections | ||
/// (e.g. SqlHelper extensions) mostly for testing purposes. Note that this does not | ||
/// intercept all SQL operations, only the ones that are done through SqlHelper extensions. | ||
/// It does not intercept Dapper operations, for example. | ||
/// This interface should be implemented by the mock connection class used in tests. | ||
/// </summary> | ||
public interface ISqlOperationInterceptor | ||
{ | ||
/// <summary> | ||
/// Intercepts SqlHelper.Execute(SqlDelete/SqlUpdate/SqlInsert) method. | ||
/// <param name="commandText">Command text</param> | ||
/// <param name="parameters">Parameters</param> | ||
/// <param name="query">The query.</param> | ||
/// <param name="expectedRows">Expected rows</param> | ||
/// <param name="getNewId">True if InsertAndGetID is called</param> | ||
/// </summary> | ||
OptionalValue<long?> ExecuteNonQuery(string commandText, IDictionary<string, object> parameters, ExpectedRows expectedRows, IQueryWithParams query, bool getNewId); | ||
|
||
/// <summary> | ||
/// Intercepts SqlHelper.ExecuteReader method. | ||
/// </summary> | ||
/// <param name="commandText">Command text</param> | ||
/// <param name="parameters">The parameters.</param> | ||
/// <param name="query">The query</param> | ||
OptionalValue<IDataReader> ExecuteReader(string commandText, IDictionary<string, object> parameters, SqlQuery query); | ||
|
||
/// <summary> | ||
/// Intercepts SqlHelper.ExecuteReader method. | ||
/// </summary> | ||
/// <param name="commandText">Command text</param> | ||
/// <param name="parameters">The parameters.</param> | ||
/// <param name="query">The query</param> | ||
OptionalValue<object> ExecuteScalar(string commandText, IDictionary<string, object> parameters, SqlQuery query); | ||
} |
This file was deleted.
Oops, something went wrong.
231 changes: 80 additions & 151 deletions
231
src/Serenity.Net.Services/Data/SqlHelpers/SqlHelper.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.