From 32917a5909ec3b2b31269f0fb7d32367a9f23df9 Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Fri, 17 May 2024 19:12:08 +0200 Subject: [PATCH] =?UTF-8?q?tentative=20de=20test=20sur=20exception=20seria?= =?UTF-8?q?lis=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/UnitTesting/CodeCompletExceptionUT.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Sources/UnitTesting/CodeCompletExceptionUT.cs b/Sources/UnitTesting/CodeCompletExceptionUT.cs index 5982a14..cafd51a 100644 --- a/Sources/UnitTesting/CodeCompletExceptionUT.cs +++ b/Sources/UnitTesting/CodeCompletExceptionUT.cs @@ -58,13 +58,16 @@ namespace UnitTesting { CodeCompletException exception = new CodeCompletException(); + #pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(CodeCompletException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); + #pragma warning restore SYSLIB0050 - string jsonString = JsonSerializer.Serialize(exception); - CodeCompletException? exceptionSerialisee = - JsonSerializer.Deserialize(jsonString); + #pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); + #pragma warning restore SYSLIB0051 - Assert.NotNull(exceptionSerialisee); - Assert.Equal(exception.Message, exceptionSerialisee.Message); + Assert.Equal(exception.Message, info.GetString("Message")); } } }