diff --git a/Sources/UnitTesting/CodeCompletExceptionUT.cs b/Sources/UnitTesting/CodeCompletExceptionUT.cs index c378396..0ac5325 100644 --- a/Sources/UnitTesting/CodeCompletExceptionUT.cs +++ b/Sources/UnitTesting/CodeCompletExceptionUT.cs @@ -59,23 +59,23 @@ namespace UnitTesting { CodeCompletException exception = new CodeCompletException(); - #pragma warning disable SYSLIB0050 +#pragma warning disable SYSLIB0050 SerializationInfo info = new SerializationInfo(typeof(CodeCompletException), new FormatterConverter()); StreamingContext contexte = new StreamingContext(StreamingContextStates.All); - #pragma warning restore SYSLIB0050 +#pragma warning restore SYSLIB0050 - #pragma warning disable SYSLIB0051 +#pragma warning disable SYSLIB0051 exception.GetObjectData(info, contexte); - #pragma warning restore SYSLIB0051 +#pragma warning restore SYSLIB0051 Assert.Equal(exception.Message, info.GetString("Message")); - #pragma warning disable SYSLIB0050 +#pragma warning disable SYSLIB0050 CodeCompletException exceptionSerialisee = (CodeCompletException) FormatterServices.GetUninitializedObject(typeof(CodeCompletException)); - #pragma warning restore SYSLIB0050 +#pragma warning restore SYSLIB0050 - ConstructorInfo? constructeur = typeof(CodeCompletException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null); + ConstructorInfo? constructeur = typeof(CodeCompletException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); Assert.NotNull(constructeur); constructeur.Invoke(exceptionSerialisee, [info, contexte]); diff --git a/Sources/UnitTesting/CodeIncompletExceptionUT.cs b/Sources/UnitTesting/CodeIncompletExceptionUT.cs index b6bed0f..0476bb1 100644 --- a/Sources/UnitTesting/CodeIncompletExceptionUT.cs +++ b/Sources/UnitTesting/CodeIncompletExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -50,5 +52,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + CodeIncompletException exception = new CodeIncompletException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(CodeIncompletException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + CodeIncompletException exceptionSerialisee = + (CodeIncompletException)FormatterServices.GetUninitializedObject(typeof(CodeIncompletException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(CodeIncompletException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/CodeInvalideExceptionUT.cs b/Sources/UnitTesting/CodeInvalideExceptionUT.cs index 7fdf9c0..87242c6 100644 --- a/Sources/UnitTesting/CodeInvalideExceptionUT.cs +++ b/Sources/UnitTesting/CodeInvalideExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -66,5 +68,33 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + CodeInvalideException exception = new CodeInvalideException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(CodeInvalideException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + CodeInvalideException exceptionSerialisee = + (CodeInvalideException)FormatterServices.GetUninitializedObject(typeof(CodeInvalideException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(CodeInvalideException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } + } } diff --git a/Sources/UnitTesting/CodeVideExceptionUT.cs b/Sources/UnitTesting/CodeVideExceptionUT.cs index 650dc3a..0787a4b 100644 --- a/Sources/UnitTesting/CodeVideExceptionUT.cs +++ b/Sources/UnitTesting/CodeVideExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -50,5 +52,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + CodeIncompletException exception = new CodeIncompletException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(CodeIncompletException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + CodeIncompletException exceptionSerialisee = + (CodeIncompletException)FormatterServices.GetUninitializedObject(typeof(CodeIncompletException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(CodeIncompletException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/GrilleCompleteExceptionUT.cs b/Sources/UnitTesting/GrilleCompleteExceptionUT.cs index 592fd65..c083a7d 100644 --- a/Sources/UnitTesting/GrilleCompleteExceptionUT.cs +++ b/Sources/UnitTesting/GrilleCompleteExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -50,5 +52,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + GrilleCompleteException exception = new GrilleCompleteException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(GrilleCompleteException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + GrilleCompleteException exceptionSerialisee = + (GrilleCompleteException)FormatterServices.GetUninitializedObject(typeof(GrilleCompleteException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(GrilleCompleteException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/IndiceCodeExceptionUT.cs b/Sources/UnitTesting/IndiceCodeExceptionUT.cs index 50e40c4..a14c524 100644 --- a/Sources/UnitTesting/IndiceCodeExceptionUT.cs +++ b/Sources/UnitTesting/IndiceCodeExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -66,5 +68,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + IndiceCodeException exception = new IndiceCodeException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(IndiceCodeException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + IndiceCodeException exceptionSerialisee = + (IndiceCodeException)FormatterServices.GetUninitializedObject(typeof(IndiceCodeException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(IndiceCodeException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs b/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs index c0733cf..e5d0c2d 100644 --- a/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs +++ b/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -50,5 +52,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + PartieNonCommenceeException exception = new PartieNonCommenceeException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(PartieNonCommenceeException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + PartieNonCommenceeException exceptionSerialisee = + (PartieNonCommenceeException)FormatterServices.GetUninitializedObject(typeof(PartieNonCommenceeException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(PartieNonCommenceeException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/TailleCodeExceptionUT.cs b/Sources/UnitTesting/TailleCodeExceptionUT.cs index eda2056..7c1bfbe 100644 --- a/Sources/UnitTesting/TailleCodeExceptionUT.cs +++ b/Sources/UnitTesting/TailleCodeExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -65,5 +67,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + TailleCodeException exception = new TailleCodeException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(TailleCodeException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + TailleCodeException exceptionSerialisee = + (TailleCodeException)FormatterServices.GetUninitializedObject(typeof(TailleCodeException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(TailleCodeException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } } diff --git a/Sources/UnitTesting/TailleGrilleExceptionUT.cs b/Sources/UnitTesting/TailleGrilleExceptionUT.cs index 8063a17..7d4bf33 100644 --- a/Sources/UnitTesting/TailleGrilleExceptionUT.cs +++ b/Sources/UnitTesting/TailleGrilleExceptionUT.cs @@ -1,4 +1,6 @@ using CoreLibrary.Exceptions; +using System.Reflection; +using System.Runtime.Serialization; using Xunit; namespace UnitTesting @@ -65,5 +67,32 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + TailleGrilleException exception = new TailleGrilleException(); + +#pragma warning disable SYSLIB0050 + SerializationInfo info = new SerializationInfo(typeof(TailleGrilleException), new FormatterConverter()); + StreamingContext contexte = new StreamingContext(StreamingContextStates.All); +#pragma warning restore SYSLIB0050 + +#pragma warning disable SYSLIB0051 + exception.GetObjectData(info, contexte); +#pragma warning restore SYSLIB0051 + + Assert.Equal(exception.Message, info.GetString("Message")); + +#pragma warning disable SYSLIB0050 + TailleGrilleException exceptionSerialisee = + (TailleGrilleException)FormatterServices.GetUninitializedObject(typeof(TailleGrilleException)); +#pragma warning restore SYSLIB0050 + + ConstructorInfo? constructeur = typeof(TailleGrilleException).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(SerializationInfo), typeof(StreamingContext)], null); + Assert.NotNull(constructeur); + constructeur.Invoke(exceptionSerialisee, [info, contexte]); + + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } }