|
|
@ -1,14 +1,7 @@
|
|
|
|
using ConsoleApp;
|
|
|
|
using ConsoleApp;
|
|
|
|
using CoreLibrary;
|
|
|
|
using CoreLibrary.Core;
|
|
|
|
using CoreLibrary.Events;
|
|
|
|
using CoreLibrary.Events;
|
|
|
|
using Microsoft.VisualStudio.TestPlatform.Utilities;
|
|
|
|
using CoreLibrary.Joueurs;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Diagnostics.Tracing;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -16,19 +9,15 @@ namespace UnitTesting
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class EvenementsUT
|
|
|
|
public class EvenementsUT
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestCommencerLaPartie()
|
|
|
|
public void TestCommencerLaPartie()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TextWriter sortieDefaut = Console.Out;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
using (var sw = new StringWriter())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.SetOut(sw);
|
|
|
|
Console.SetOut(sw);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Evenements.CommencerLaPartie(null, new DebutPartieEventArgs());
|
|
|
|
Evenements.CommencerLaPartie(null, new DebutPartieEventArgs());
|
|
|
|
|
|
|
|
|
|
|
|
string consoleOutput = sw.ToString().Trim();
|
|
|
|
string consoleOutput = sw.ToString().Trim();
|
|
|
@ -43,34 +32,37 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(phraseAttendue, resteSortieAttendue);
|
|
|
|
Assert.Equal(phraseAttendue, resteSortieAttendue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.SetOut(sortieDefaut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestAjouterJeton()
|
|
|
|
public void TestAjouterJeton()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TextWriter sortieDefaut = Console.Out;
|
|
|
|
|
|
|
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.SetOut(sw);
|
|
|
|
Console.SetOut(sw);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Couleur couleurJeton = Couleur.BLEU;
|
|
|
|
Couleur couleurJeton = Couleur.BLEU;
|
|
|
|
Jeton jeton = new Jeton(couleurJeton);
|
|
|
|
Jeton jeton = new Jeton(couleurJeton);
|
|
|
|
|
|
|
|
|
|
|
|
Evenements.AjouterJeton(null, new AjouterJetonEventArgs(jeton));
|
|
|
|
Evenements.AjouterJeton(null, new AjouterJetonEventArgs(jeton));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string consoleOutput = sw.ToString().Trim();
|
|
|
|
string consoleOutput = sw.ToString().Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string expectedOutput = $"O";
|
|
|
|
string expectedOutput = $"⬤";
|
|
|
|
|
|
|
|
Assert.Contains(expectedOutput, consoleOutput);
|
|
|
|
Assert.Contains(expectedOutput, consoleOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.SetOut(sortieDefaut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestSupprimerDernierJeton()
|
|
|
|
public void TestSupprimerDernierJeton()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TextWriter sortieDefaut = Console.Out;
|
|
|
|
|
|
|
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -85,11 +77,14 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("\b\b\b \b\b\b\b\b\b", consoleOutput);
|
|
|
|
Assert.Equal("\b\b\b \b\b\b\b\b\b", consoleOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.SetOut(sortieDefaut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestAjouterCode()
|
|
|
|
public void TestAjouterCode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TextWriter sortieDefaut = Console.Out;
|
|
|
|
|
|
|
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -105,6 +100,8 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("───────────────────────────────────────────────────────", consoleOutput);
|
|
|
|
Assert.Equal("───────────────────────────────────────────────────────", consoleOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.SetOut(sortieDefaut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,6 +113,7 @@ namespace UnitTesting
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestPartieTerminee()
|
|
|
|
public void TestPartieTerminee()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TextWriter sortieDefaut = Console.Out;
|
|
|
|
|
|
|
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -138,6 +136,8 @@ namespace UnitTesting
|
|
|
|
Assert.Contains("C'est une victoire de Camille.", consoleOutput);
|
|
|
|
Assert.Contains("C'est une victoire de Camille.", consoleOutput);
|
|
|
|
Assert.Contains("C'est une égalité !", consoleOutput);
|
|
|
|
Assert.Contains("C'est une égalité !", consoleOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.SetOut(sortieDefaut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|