From 70782b37e7f6df33ecdf9bcedf92ff919e16025e Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Fri, 7 Jun 2024 11:13:46 +0200 Subject: [PATCH] jdt inutil --- .../JoueurDejaConnecteExceptionUT.cs | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 Sources/UnitTesting/JoueurDejaConnecteExceptionUT.cs diff --git a/Sources/UnitTesting/JoueurDejaConnecteExceptionUT.cs b/Sources/UnitTesting/JoueurDejaConnecteExceptionUT.cs deleted file mode 100644 index f1035e6..0000000 --- a/Sources/UnitTesting/JoueurDejaConnecteExceptionUT.cs +++ /dev/null @@ -1,83 +0,0 @@ -using CoreLibrary.Exceptions; -using System.Reflection; -using System.Runtime.Serialization; -using Xunit; - -namespace UnitTesting -{ - public class JoueurDejaConnecteExceptionUT - { - [Fact] - public void ExceptionDefaut() - { - Assert.ThrowsAsync(() => throw new JoueurDejaConnecteException()); - } - - [Fact] - public void ExceptionMessage() - { - string message = "Mon super gros problème."; - - Assert.ThrowsAsync(() => throw new JoueurDejaConnecteException(message)); - - try - { - throw new JoueurDejaConnecteException(message); - } - catch (JoueurDejaConnecteException e) - { - Assert.Equal(message, e.Message); - } - } - - [Fact] - public void ExceptionMessageEtException() - { - string message = "Mon super gros problème."; - string message2 = "Pas de chance..."; - InvalidOperationException parent = new InvalidOperationException(message2); - - Assert.ThrowsAsync(() => throw new JoueurDejaConnecteException(message, parent)); - - try - { - throw new JoueurDejaConnecteException(message, parent); - } - catch (JoueurDejaConnecteException e) - { - Assert.Equal(message, e.Message); - Assert.NotNull(e.InnerException); - Assert.IsType(e.InnerException); - Assert.Equal(message2, e.InnerException.Message); - } - } - - [Fact] - public void ExceptionSerialisation() - { - JoueurDejaConnecteException exception = new JoueurDejaConnecteException(); - -#pragma warning disable SYSLIB0050 - SerializationInfo info = new SerializationInfo(typeof(JoueurDejaConnecteException), 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 - JoueurDejaConnecteException exceptionSerialisee = - (JoueurDejaConnecteException)FormatterServices.GetUninitializedObject(typeof(JoueurDejaConnecteException)); -#pragma warning restore SYSLIB0050 - - ConstructorInfo? constructeur = typeof(JoueurDejaConnecteException).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); - } - } -}