je remets
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 11 months ago
parent 9654851502
commit e54daea502

@ -0,0 +1,20 @@
using CoreLibrary.Core;
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting
{
public class AjouterCodeEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
Code monCode = new Code([new Jeton(Couleur.VERT), new Jeton(Couleur.BLEU)]);
AjouterCodeEventArgs evenement = new AjouterCodeEventArgs(monCode);
Assert.Equal(monCode, evenement.Code);
}
}
}

@ -0,0 +1,20 @@
using CoreLibrary.Core;
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting
{
public class AjouterJetonEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
Jeton monJeton = new Jeton(Couleur.JAUNE);
AjouterJetonEventArgs evenement = new AjouterJetonEventArgs(monJeton);
Assert.Equal(monJeton, evenement.Jeton);
}
}
}

@ -0,0 +1,21 @@
using CoreLibrary.Core;
using CoreLibrary.Events;
using CoreLibrary.Joueurs;
using Xunit;
namespace UnitTesting
{
public class AjouterJoueurEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
Joueur monJoueur = new Joueur("Céleste", new Plateau(4, 12));
AjouterJoueursEventArgs evenement = new AjouterJoueursEventArgs(monJoueur);
Assert.Equal(monJoueur, evenement.Joueur);
}
}
}

@ -0,0 +1,85 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.Json;
using Xunit;
namespace UnitTesting
{
public class CodeCompletExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeCompletException>(() => throw new CodeCompletException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeCompletException>(() => throw new CodeCompletException(message));
try
{
throw new CodeCompletException(message);
}
catch (CodeCompletException 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<CodeCompletException>(() => throw new CodeCompletException(message, parent));
try
{
throw new CodeCompletException(message, parent);
}
catch (CodeCompletException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[Fact]
public void ExceptionSerialisation()
{
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
#pragma warning disable SYSLIB0051
exception.GetObjectData(info, contexte);
#pragma warning restore SYSLIB0051
Assert.Equal(exception.Message, info.GetString("Message"));
#pragma warning disable SYSLIB0050
CodeCompletException exceptionSerialisee =
(CodeCompletException) FormatterServices.GetUninitializedObject(typeof(CodeCompletException));
#pragma warning restore SYSLIB0050
ConstructorInfo? constructeur = typeof(CodeCompletException).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);
}
}
}

@ -0,0 +1,83 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class CodeIncompletExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeIncompletException>(() => throw new CodeIncompletException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeIncompletException>(() => throw new CodeIncompletException(message));
try
{
throw new CodeIncompletException(message);
}
catch(CodeIncompletException 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<CodeIncompletException>(() => throw new CodeIncompletException(message, parent));
try
{
throw new CodeIncompletException(message, parent);
}
catch (CodeIncompletException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,100 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class CodeInvalideExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException(3, 4));
try
{
throw new CodeInvalideException(3, 4);
}
catch (CodeInvalideException e)
{
Assert.Contains("3", e.Message);
Assert.Contains("4", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException(message));
try
{
throw new CodeInvalideException(message);
}
catch(CodeInvalideException 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<CodeInvalideException>(() => throw new CodeInvalideException(message, parent));
try
{
throw new CodeInvalideException(message, parent);
}
catch (CodeInvalideException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,225 @@
using CoreLibrary.Core;
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class CodeUT
{
[Fact]
public void TestPremierConstructeurValide()
{
Code code = new Code(4);
Assert.NotNull(code);
Assert.Equal(4, code.Jetons().Count());
Assert.Equal(0, code.NbJetons);
}
[Fact]
public void TestPremierConstructeurInvalide()
{
Assert.Throws<TailleCodeException>(() => new Code(0));
Assert.Throws<TailleCodeException>(() => new Code(-1));
}
[Fact]
public void TestDeuxiemeConstructeurValide()
{
Jeton[] jetons = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
Code code = new Code(jetons);
Assert.NotNull(code);
Assert.Equal(3, code.Jetons().Count());
Assert.Equal(3, code.NbJetons);
}
[Fact]
public void TestDeuxiemeConstructeurInvalide()
{
Assert.Throws<TailleCodeException>(() => new Code([]));
}
[Fact]
public void TestAjouterJetonValide()
{
Jeton jeton = new Jeton(Couleur.JAUNE);
Code code = new Code(3);
code.AjouterJeton(jeton);
Assert.Equal(1, code.NbJetons);
Assert.Equal(jeton, code.Jetons().ElementAt(0));
}
[Fact]
public void TestAjouterJetonInvalide()
{
Code code = new Code([new Jeton(Couleur.NOIR)]);
Assert.Throws<CodeCompletException>(() => code.AjouterJeton(new Jeton(Couleur.ROUGE)));
}
[Fact]
public void TestSupprimerDernierJetonValide()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
code.SupprimerDernierJeton();
Assert.Equal(2, code.NbJetons);
}
[Fact]
public void TestSupprimerDernierJetonInvalide()
{
Code code = new Code(4);
Assert.Throws<CodeVideException>(() => code.SupprimerDernierJeton());
}
[Fact]
public void TestRecupererJetonValide()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Jeton jetonAttendu = new Jeton(Couleur.BLEU);
Jeton jeton = code.RecupererJeton(1);
Assert.Equal(jetonAttendu.Couleur, jeton.Couleur);
}
[Fact]
public void TestRecupererJetonInvalide()
{
Code code = new Code(4);
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(-1));
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(4));
}
[Fact]
public void TestRecupererJetonNull()
{
Code code = new Code(4);
Assert.Throws<IndiceCodeException>(() => code.RecupererJeton(1));
}
[Fact]
public void TestJetonsValide()
{
Jeton[] jetonsAttendus = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
Code code = new Code(jetonsAttendus);
IEnumerable<Jeton?> lesJetons = code.Jetons();
Assert.Equal(jetonsAttendus.Length, lesJetons.Count());
int index = 0;
foreach (Jeton jetonAttendu in jetonsAttendus)
{
Assert.Equal(jetonAttendu.Couleur, lesJetons.ElementAt(index)?.Couleur);
index++;
}
}
[Fact]
public void TestEstCompletValide()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
bool estComplet = code.EstComplet();
Assert.True(estComplet);
}
[Fact]
public void TestEstCompletInvalide()
{
Code code = new Code(3);
bool estComplet = code.EstComplet();
Assert.False(estComplet);
}
[Fact]
public void TestTailleMaximaleValide()
{
Jeton[] jetons = [new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLEU)];
Code code = new Code(jetons);
int tailleMaximale = code.TailleMaximale();
Assert.Equal(jetons.Length, tailleMaximale);
}
[Fact]
public void TestComparerValide()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Equal(3, indicateurs.Count());
Assert.Contains(Indicateur.BONNEPLACE, indicateurs);
Assert.DoesNotContain(Indicateur.BONNECOULEUR, indicateurs);
}
[Fact]
public void TestComparerBonnePlace()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.NOIR)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Equal(2, indicateurs.Count());
Assert.Contains(Indicateur.BONNEPLACE, indicateurs);
Assert.DoesNotContain(Indicateur.BONNECOULEUR, indicateurs);
}
[Fact]
public void TestComparerBonneCouleur()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.ROUGE), new Jeton(Couleur.NOIR)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Equal(2, indicateurs.Count());
Assert.Contains(Indicateur.BONNECOULEUR, indicateurs);
Assert.DoesNotContain(Indicateur.BONNEPLACE, indicateurs);
}
[Fact]
public void TestComparerBonnePlaceEtCouleur()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLANC), new Jeton(Couleur.BLEU)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Equal(3, indicateurs.Count());
Assert.Contains(Indicateur.BONNEPLACE, indicateurs);
Assert.Contains(Indicateur.BONNECOULEUR, indicateurs);
}
[Fact]
public void TestComparerDifferent()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code([new Jeton(Couleur.VERT), new Jeton(Couleur.JAUNE), new Jeton(Couleur.NOIR)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Empty(indicateurs);
}
[Fact]
public void TestComparerMonCodeIncomplet()
{
Code code = new Code(3);
Code autreCode = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Empty(indicateurs);
}
[Fact]
public void TestComparerSonCodeIncomplet()
{
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC)]);
Code autreCode = new Code(3);
IEnumerable<Indicateur> indicateurs = code.Comparer(autreCode);
Assert.Empty(indicateurs);
}
}
}

@ -0,0 +1,83 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class CodeVideExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeVideException>(() => throw new CodeVideException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeVideException>(() => throw new CodeVideException(message));
try
{
throw new CodeVideException(message);
}
catch(CodeVideException 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<CodeVideException>(() => throw new CodeVideException(message, parent));
try
{
throw new CodeVideException(message, parent);
}
catch (CodeVideException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[Fact]
public void ExceptionSerialisation()
{
CodeVideException exception = new CodeVideException();
#pragma warning disable SYSLIB0050
SerializationInfo info = new SerializationInfo(typeof(CodeVideException), 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
CodeVideException exceptionSerialisee =
(CodeVideException)FormatterServices.GetUninitializedObject(typeof(CodeVideException));
#pragma warning restore SYSLIB0050
ConstructorInfo? constructeur = typeof(CodeVideException).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);
}
}
}

@ -0,0 +1,16 @@
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting
{
public class DemanderJoueurEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
DemanderJoueurEventArgs evenement = new DemanderJoueurEventArgs(3);
Assert.Equal(3, evenement.Numero);
}
}
}

@ -0,0 +1,83 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class GrilleCompleteExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<GrilleCompleteException>(() => throw new GrilleCompleteException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<GrilleCompleteException>(() => throw new GrilleCompleteException(message));
try
{
throw new GrilleCompleteException(message);
}
catch(GrilleCompleteException 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<GrilleCompleteException>(() => throw new GrilleCompleteException(message, parent));
try
{
throw new GrilleCompleteException(message, parent);
}
catch (GrilleCompleteException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,99 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class IndiceCodeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException(5, 3));
try
{
throw new IndiceCodeException(5, 3);
}
catch (IndiceCodeException e)
{
Assert.Contains("5", e.Message);
Assert.Contains("3", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException(message));
try
{
throw new IndiceCodeException(message);
}
catch(IndiceCodeException 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<IndiceCodeException>(() => throw new IndiceCodeException(message, parent));
try
{
throw new IndiceCodeException(message, parent);
}
catch (IndiceCodeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,20 @@
using CoreLibrary.Core;
using Xunit;
namespace UnitTesting
{
public class JetonUT
{
[Fact]
public void TestConstructeurValide()
{
Couleur[] listeCouleurs = (Couleur[])Enum.GetValues(typeof(Couleur));
for (int i=0; i<listeCouleurs.Length; ++i)
{
Jeton jeton = new Jeton(listeCouleurs[i]);
Assert.Equal(listeCouleurs[i], jeton.Couleur);
}
}
}
}

@ -0,0 +1,19 @@
using CoreLibrary.Core;
using CoreLibrary.Joueurs;
using Xunit;
namespace UnitTesting
{
public class JoueurUT
{
[Fact]
public void TestConstructeurValide()
{
Plateau plateau = new Plateau(4, 10);
Joueur joueur = new Joueur("MonJoueur", plateau);
Assert.Equal("MonJoueur", joueur.Nom);
Assert.Equal(plateau, joueur.Plateau);
}
}
}

@ -0,0 +1,26 @@
using CoreLibrary.Joueurs;
using CoreLibrary.Core;
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting
{
public class NouveauTourEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
Plateau monPlateau = new Plateau(4, 12);
Joueur monJoueur = new Joueur("Céleste", monPlateau);
NouveauTourEventArgs evenement =
new NouveauTourEventArgs(monJoueur, 5, monPlateau.Grille(), monPlateau.Indicateurs());
Assert.Equal(monJoueur, evenement.Joueur);
Assert.Equal(5, evenement.Tour);
Assert.Equal(monPlateau.Grille(), evenement.Grille);
Assert.Equal(monPlateau.Indicateurs(), evenement.Indicateurs);
}
}
}

@ -0,0 +1,83 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class PartieNonCommenceeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException(message));
try
{
throw new PartieNonCommenceeException(message);
}
catch(PartieNonCommenceeException 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<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException(message, parent));
try
{
throw new PartieNonCommenceeException(message, parent);
}
catch (PartieNonCommenceeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,24 @@
using CoreLibrary.Joueurs;
using CoreLibrary.Core;
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting
{
public class PartieTermineeEventArgsUT
{
[Fact]
public void TestConstructeurValide()
{
Plateau plateau = new Plateau(4, 12);
Joueur[] gagnants = [new Joueur("Pauline", plateau), new Joueur("Camille", plateau)];
Joueur[] perdants = [new Joueur("Céleste", plateau)];
PartieTermineeEventArgs evenement = new PartieTermineeEventArgs(gagnants, perdants);
Assert.Equal(gagnants, evenement.Gagnants);
Assert.Equal(perdants, evenement.Perdants);
}
}
}

@ -0,0 +1,207 @@
using CoreLibrary;
using CoreLibrary.Regles;
using CoreLibrary.Core;
using Xunit;
using System.Reflection;
using CoreLibrary.Events;
namespace UnitTesting
{
public class PartieUT
{
[Fact]
public void TestPartieInitialiseCorrectement()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
Assert.NotNull(partie);
}
[Fact]
public void TestJouerAppelleDemanderJoueurEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.DemanderJoueur += (sender, e) =>
{
eventAppelle = true;
return $"Joueur {e.Numero}";
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleDemanderJetonEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.DemanderJeton += (sender, e) =>
{
eventAppelle = true;
return new Jeton();
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleAjouterJoueurEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.AjouterJoueur += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleDebutPartieEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.DebutPartie += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleNouveauTourEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.NouveauTour += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleNouveauJetonEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.AjouterJeton += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppelleNouveauCodeEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.AjouterCode += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppellePasserMainEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.PasserMain += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestJouerAppellePartieTermineeEvent()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool eventAppelle = false;
partie.PartieTerminee += (sender, e) =>
{
eventAppelle = true;
};
partie.Jouer();
Assert.True(eventAppelle);
}
[Fact]
public void TestSupprimerDernierJeton()
{
IRegles regles = new ReglesClassiques();
Partie partie = new Partie(regles);
bool appele = false;
partie.DemanderJeton += (sender, e) =>
{
if (e.Indice == 0 || appele)
return new Jeton();
return null;
};
partie.SupprimerDernierJeton += (sender, e) =>
{
appele = true;
};
partie.Jouer();
Assert.True(appele);
}
[Fact]
public void TestSupprimerDernierJetonNull()
{
Partie partie = new Partie(new ReglesClassiques());
MethodInfo? methode = typeof(Partie).GetMethod("QuandSupprimerDernierJeton", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(methode);
methode.Invoke(partie, null);
}
}
}

@ -0,0 +1,269 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using CoreLibrary.Core;
using Xunit;
namespace UnitTesting
{
public class PlateauUT
{
[Fact]
public void TestConstructeurValide()
{
Plateau plateau = new Plateau(4,12);
Assert.NotNull(plateau);
Assert.Equal(1, plateau.Tour);
Assert.False(plateau.Victoire);
}
[Fact]
public void TestConstructeurInvalide()
{
Assert.Throws<TailleCodeException>(() => new Plateau(0, 10));
Assert.Throws<TailleGrilleException>(() => new Plateau(3, 0));
}
[Fact]
public void TestEstCompletTrue()
{
Plateau plateau = new Plateau(4, 3);
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE)]);
plateau.AjouterCode(code);
plateau.AjouterCode(code);
plateau.AjouterCode(code);
bool estComplet = plateau.EstComplet();
Assert.True(estComplet);
}
[Fact]
public void TestEstCompletFalse()
{
Plateau plateau = new Plateau(4, 3);
Code code = new Code([new Jeton(Couleur.ROUGE), new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE)]);
plateau.AjouterCode(code);
plateau.AjouterCode(code);
bool estComplet = plateau.EstComplet();
Assert.False(estComplet);
}
[Fact]
public void TestAjouterCodeValide()
{
Plateau plateau = new Plateau(4, 10);
Code code = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE), new Jeton(Couleur.BLANC)]);
plateau.AjouterCode(code);
Assert.Equal(2, plateau.Tour);
}
[Fact]
public void TestAjouterCodeTailleIncorrecte()
{
Plateau plateau = new Plateau(4, 10);
Code code = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE)]);
Assert.Throws<CodeInvalideException>(() => plateau.AjouterCode(code));
}
[Fact]
public void TestAjouterCodeIncomplet()
{
Plateau plateau = new Plateau(4, 10);
Code code = new Code(4);
Assert.Throws<CodeIncompletException>(() => plateau.AjouterCode(code));
}
[Fact]
public void TestAjouterCodeBonCode()
{
Plateau plateau = new Plateau(4, 10);
Type type = typeof(Plateau);
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(fieldInfo);
Code? codeSecret = (Code?)fieldInfo.GetValue(plateau);
Assert.NotNull(codeSecret);
plateau.AjouterCode(codeSecret);
Assert.True(plateau.Victoire);
}
[Fact]
public void TestEstBonCodeTailleException()
{
Plateau plateau = new Plateau(3, 5);
Code code = new Code(4);
Assert.Throws<CodeInvalideException>(() => plateau.EstBonCode(code));
}
[Fact]
public void TestEstBonCodeIncomplet()
{
Plateau plateau = new Plateau(3, 5);
Code code = new Code(3);
Assert.Throws<CodeIncompletException>(() => plateau.EstBonCode(code));
}
[Fact]
public void TestEstBonCodeTrue()
{
Plateau plateau = new Plateau(4, 10);
Type type = typeof(Plateau);
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(fieldInfo);
Code? codeSecret = (Code?)fieldInfo.GetValue(plateau);
Assert.NotNull(codeSecret);
Assert.True(plateau.EstBonCode(codeSecret));
}
[Fact]
public void TestEstBonCodeFalse()
{
Plateau plateau = new Plateau(2, 10);
Type type = typeof(Plateau);
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(fieldInfo);
Code? codeSecret = (Code?)fieldInfo.GetValue(plateau);
Assert.NotNull(codeSecret);
Jeton[] jetons = codeSecret.Jetons().Where(jeton => jeton.HasValue).Select(jeton => jeton!.Value).ToArray();
int i = 0;
int j = 1;
while (jetons[i].Couleur == jetons[j].Couleur)
{
++i;
++j;
if (j == jetons.Length)
{
plateau = new Plateau(2, 10);
codeSecret = (Code?)fieldInfo.GetValue(plateau);
Assert.NotNull(codeSecret);
jetons = codeSecret.Jetons().Where(jeton => jeton.HasValue).Select(jeton => jeton!.Value).ToArray();
i = 0;
j = 1;
}
}
Jeton tmp = jetons[0];
jetons[0] = jetons[1];
jetons[1] = tmp;
Code code = new Code(jetons);
Assert.False(plateau.EstBonCode(code));
}
[Fact]
public void TestEstBonCodeAucunIndicateur()
{
List<Couleur> couleurs = new List<Couleur>((Couleur[])Enum.GetValues(typeof(Couleur)));
Plateau plateau = new Plateau(4, 10);
Type type = typeof(Plateau);
FieldInfo? fieldInfo = type.GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(fieldInfo);
Code? codeSecret = (Code?)fieldInfo.GetValue(plateau);
Assert.NotNull(codeSecret);
Jeton[] jetons = codeSecret.Jetons().Where(jeton => jeton.HasValue).Select(jeton => jeton!.Value).ToArray();
for (int i=0; i<jetons.Length; ++i)
{
Couleur couleurJeton = jetons[i].Couleur;
couleurs.Remove(couleurJeton);
}
Code code = new Code(
[
new Jeton(couleurs[0]),
new Jeton(couleurs[0]),
new Jeton(couleurs[0]),
new Jeton(couleurs[0])
]
);
Assert.False(plateau.EstBonCode(code));
}
[Fact]
public void TestGrilleValide()
{
Plateau plateau = new Plateau(4, 3);
Code code1 = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE), new Jeton(Couleur.BLANC)]);
Code code2 = new Code([new Jeton(Couleur.VERT), new Jeton(Couleur.JAUNE), new Jeton(Couleur.ROUGE), new Jeton(Couleur.NOIR)]);
plateau.AjouterCode(code1);
plateau.AjouterCode(code2);
IEnumerable<IEnumerable<Jeton?>> grille = plateau.Grille();
Assert.Equal(4, grille.First().Count());
Assert.Equal(4, grille.Last().Count());
Assert.Equal(code1.Jetons(), grille.ElementAt(0));
Assert.Equal(code2.Jetons(), grille.ElementAt(1));
}
[Fact]
public void TestGrilleVide()
{
Plateau plateau = new Plateau(4, 3);
IEnumerable<IEnumerable<Jeton?>> grille = plateau.Grille();
foreach (IEnumerable<Jeton?> tour in grille)
{
Assert.All(tour, jeton => Assert.Null(jeton));
}
}
[Fact]
public void TestIndicateursVide()
{
Plateau plateau = new Plateau(4, 5);
foreach(Indicateur[] indicateur in plateau.Indicateurs())
{
Assert.Null(indicateur);
}
}
[Fact]
public void TestIndicateursAjouterDeuxCodes()
{
Plateau plateau = new Plateau(4, 5);
Code code1 = new Code([new Jeton(Couleur.BLEU), new Jeton(Couleur.BLANC), new Jeton(Couleur.JAUNE), new Jeton(Couleur.BLANC)]);
Code code2 = new Code([new Jeton(Couleur.VERT), new Jeton(Couleur.JAUNE), new Jeton(Couleur.ROUGE), new Jeton(Couleur.NOIR)]);
plateau.AjouterCode(code1);
plateau.AjouterCode(code2);
Assert.NotNull(plateau.Indicateurs().ElementAt(0));
Assert.NotNull(plateau.Indicateurs().ElementAt(1));
Assert.Null(plateau.Indicateurs().ElementAt(2));
Assert.Null(plateau.Indicateurs().ElementAt(3));
Assert.Null(plateau.Indicateurs().ElementAt(4));
}
}
}

@ -0,0 +1,55 @@
using CoreLibrary;
using CoreLibrary.Regles;
using CoreLibrary.Core;
using Xunit;
namespace UnitTesting
{
public class ProgramUT
{
[Fact]
public void TestPartieConfiguration()
{
IRegles regle = new ReglesClassiques();
Partie maPartie = new Partie(new ReglesClassiques());
bool demanderJoueurCalled = false;
bool debutPartieCalled = false;
bool nouveauTourCalled = false;
bool demanderJetonCalled = false;
bool ajouterJetonCalled = false;
bool ajouterCodeCalled = false;
bool partieTermineeCalled = false;
maPartie.DemanderJoueur += (sender, e) =>
{
demanderJoueurCalled = true;
return $"Joueur {e.Numero}";
};
maPartie.DebutPartie += (sender, e) => debutPartieCalled = true;
maPartie.NouveauTour += (sender, e) => nouveauTourCalled = true;
maPartie.DemanderJeton += (sender, e) =>
{
demanderJetonCalled = true;
return new Jeton();
};
maPartie.AjouterJeton += (sender, e) => ajouterJetonCalled = true;
maPartie.AjouterCode += (sender, e) => ajouterCodeCalled = true;
maPartie.PartieTerminee += (sender, e) => partieTermineeCalled = true;
maPartie.Jouer();
Assert.True(demanderJoueurCalled);
Assert.True(debutPartieCalled);
Assert.True(nouveauTourCalled);
Assert.True(demanderJetonCalled);
Assert.True(ajouterJetonCalled);
Assert.True(ajouterCodeCalled);
Assert.True(partieTermineeCalled);
}
}
}

@ -0,0 +1,98 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class TailleCodeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException(-3));
try
{
throw new TailleCodeException(-3);
}
catch (TailleCodeException e)
{
Assert.Contains("-3", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException(message));
try
{
throw new TailleCodeException(message);
}
catch(TailleCodeException 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<TailleCodeException>(() => throw new TailleCodeException(message, parent));
try
{
throw new TailleCodeException(message, parent);
}
catch (TailleCodeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}

@ -0,0 +1,98 @@
using CoreLibrary.Exceptions;
using System.Reflection;
using System.Runtime.Serialization;
using Xunit;
namespace UnitTesting
{
public class TailleGrilleExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException(0));
try
{
throw new TailleCodeException(0);
}
catch (TailleCodeException e)
{
Assert.Contains("0", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException(message));
try
{
throw new TailleGrilleException(message);
}
catch(TailleGrilleException 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<TailleGrilleException>(() => throw new TailleGrilleException(message, parent));
try
{
throw new TailleGrilleException(message, parent);
}
catch (TailleGrilleException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
[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);
}
}
}
Loading…
Cancel
Save