tentative de test sur exception serialisée
continuous-integration/drone/push Build is passing Details

master
Céleste BARBOSA 11 months ago
parent 11eb607a20
commit 32917a5909

@ -58,13 +58,16 @@ namespace UnitTesting
{ {
CodeCompletException exception = new CodeCompletException(); 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); #pragma warning disable SYSLIB0051
CodeCompletException? exceptionSerialisee = exception.GetObjectData(info, contexte);
JsonSerializer.Deserialize<CodeCompletException>(jsonString); #pragma warning restore SYSLIB0051
Assert.NotNull(exceptionSerialisee); Assert.Equal(exception.Message, info.GetString("Message"));
Assert.Equal(exception.Message, exceptionSerialisee.Message);
} }
} }
} }

Loading…
Cancel
Save