From d7268307bc1e9653bb6a3533c3490c493dcc43b4 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Sat, 8 Jul 2023 03:29:49 +0800 Subject: [PATCH] Fix generating a custom OleDbException for the tests --- .../TestUtilities/SqlExceptionFactory.cs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/test/EFCore.Jet.FunctionalTests/TestUtilities/SqlExceptionFactory.cs b/test/EFCore.Jet.FunctionalTests/TestUtilities/SqlExceptionFactory.cs index 8fbe682..feaa1f6 100644 --- a/test/EFCore.Jet.FunctionalTests/TestUtilities/SqlExceptionFactory.cs +++ b/test/EFCore.Jet.FunctionalTests/TestUtilities/SqlExceptionFactory.cs @@ -12,26 +12,12 @@ namespace EntityFrameworkCore.Jet.FunctionalTests.TestUtilities { public static OleDbException CreateOleDbException(int number, Guid? connectionId = null) { - var errorCtors = typeof(OleDbError) - .GetTypeInfo() - .DeclaredConstructors; - - var error = (OleDbError)errorCtors.First(c => c.GetParameters().Length == 8) - .Invoke(new object[] { number, (byte)0, (byte)0, "Server", "ErrorMessage", "Procedure", 0, null }); - var errors = (OleDbErrorCollection)typeof(OleDbErrorCollection) - .GetTypeInfo() - .DeclaredConstructors - .Single() - .Invoke(null); - - typeof(OleDbErrorCollection).GetRuntimeMethods().Single(m => m.Name == "Add").Invoke(errors, new object[] { error }); - var exceptionCtors = typeof(OleDbException) .GetTypeInfo() .DeclaredConstructors; - return (OleDbException)exceptionCtors.First(c => c.GetParameters().Length == 4) - .Invoke(new object[] { "Bang!", errors, null, connectionId ?? Guid.NewGuid() }); + return (OleDbException)exceptionCtors.First(c => c.GetParameters().Length == 3) + .Invoke(new object[] { "Bang!", number, null }); } } }