private static void ShimExecuteReader()

in DeviceBridgeTests/Providers/StorageProviderTests.cs [300:324]


        private static void ShimExecuteReader(string cmdText, Dictionary<string, string> parameters = null, Action<SqlCommand> onExecute = null)
        {
            Func<SqlCommand, Task<SqlDataReader>> shim = (SqlCommand cmd) =>
            {
                Assert.AreEqual(cmdText, cmd.CommandText);

                if (parameters != null)
                {
                    foreach (var entry in parameters)
                    {
                        Assert.AreEqual(entry.Value, cmd.Parameters[entry.Key].Value);
                    }
                }

                if (onExecute != null)
                {
                    onExecute(cmd);
                }

                return Task.FromResult<SqlDataReader>(new System.Data.SqlClient.Fakes.ShimSqlDataReader());
            };

            System.Data.SqlClient.Fakes.ShimSqlCommand.AllInstances.ExecuteReaderAsync = cmd => shim(cmd);
            System.Data.SqlClient.Fakes.ShimSqlCommand.AllInstances.ExecuteReaderAsyncCancellationToken = (cmd, _) => shim(cmd);
        }