1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Data.SqlClient; 7 using System.Reflection; 8 9 namespace System.Data.SqlClient.ManualTesting.Tests.SystemDataInternals 10 { 11 internal static class CommandHelper 12 { 13 private static Type s_sqlCommand = typeof(SqlCommand); 14 private static MethodInfo s_completePendingReadWithSuccess = s_sqlCommand.GetMethod("CompletePendingReadWithSuccess", BindingFlags.NonPublic | BindingFlags.Instance); 15 private static MethodInfo s_completePendingReadWithFailure = s_sqlCommand.GetMethod("CompletePendingReadWithFailure", BindingFlags.NonPublic | BindingFlags.Instance); 16 private static PropertyInfo s_debugForceAsyncWriteDelay = s_sqlCommand.GetProperty("DebugForceAsyncWriteDelay", BindingFlags.NonPublic | BindingFlags.Static); 17 CompletePendingReadWithSuccess(SqlCommand command, bool resetForcePendingReadsToWait)18 internal static void CompletePendingReadWithSuccess(SqlCommand command, bool resetForcePendingReadsToWait) 19 { 20 s_completePendingReadWithSuccess.Invoke(command, new object[] { resetForcePendingReadsToWait }); 21 } 22 CompletePendingReadWithFailure(SqlCommand command, int errorCode, bool resetForcePendingReadsToWait)23 internal static void CompletePendingReadWithFailure(SqlCommand command, int errorCode, bool resetForcePendingReadsToWait) 24 { 25 s_completePendingReadWithFailure.Invoke(command, new object[] { errorCode, resetForcePendingReadsToWait }); 26 } 27 28 internal static int ForceAsyncWriteDelay 29 { 30 get { return (int)s_debugForceAsyncWriteDelay.GetValue(null); } 31 set { s_debugForceAsyncWriteDelay.SetValue(null, value); } 32 } 33 } 34 } 35