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); } } }