|
|
@ -1,4 +1,6 @@
|
|
|
|
using CoreLibrary.Exceptions;
|
|
|
|
using CoreLibrary.Exceptions;
|
|
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace UnitTesting
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|