From cc61e723cb8acfc20cfb12e16e2188344606a3de Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Fri, 17 May 2024 19:16:52 +0200 Subject: [PATCH] =?UTF-8?q?fin=20exception=20s=C3=A9rialis=C3=A9e=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/UnitTesting/CodeCompletExceptionUT.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/UnitTesting/CodeCompletExceptionUT.cs b/Sources/UnitTesting/CodeCompletExceptionUT.cs index cafd51a..c378396 100644 --- a/Sources/UnitTesting/CodeCompletExceptionUT.cs +++ b/Sources/UnitTesting/CodeCompletExceptionUT.cs @@ -1,4 +1,5 @@ using CoreLibrary.Exceptions; +using System.Reflection; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Text.Json; @@ -68,6 +69,17 @@ namespace UnitTesting #pragma warning restore SYSLIB0051 Assert.Equal(exception.Message, info.GetString("Message")); + + #pragma warning disable SYSLIB0050 + CodeCompletException exceptionSerialisee = + (CodeCompletException) FormatterServices.GetUninitializedObject(typeof(CodeCompletException)); + #pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(CodeCompletException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); } } }