Merge branch 'UT' of https://codefirst.iut.uca.fr/git/nicolas.barbosa/mastermind into UT
continuous-integration/drone/push Build is passing Details

master
Camille TURPIN-ETIENNE 11 months ago
commit ad7cb74d5f

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CoreLibrary\CoreLibrary.csproj" />
</ItemGroup>
</Project>

@ -1,27 +0,0 @@
// Cas 3 - Plateau rempli, code mauvaise couleur
using CoreLibrary.Core;
using System.Reflection;
Code code3 = new Code(1);
code3.AjouterJeton(new Jeton(Couleur.Rouge));
Plateau plateau3;
Code? codeSecret3;
do
{
plateau3 = new Plateau(1, 1);
FieldInfo? codeSecretInfo3 = typeof(Plateau).GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
codeSecret3 = codeSecretInfo3.GetValue(plateau2) as Code;
Assert.NotNull(codeSecret3);
} while (codeSecret3.RecupererJeton(0).Equals(code3.RecupererJeton(0)));
plateau3.AjouterCode(codeSecret3);
MethodInfo? EstCodePossible3 = typeof(Robot).GetMethod("EstCodePossible", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
Assert.NotNull(EstCodePossible3);
object? estPossibleObj3 = EstCodePossible3.Invoke(new Robot(), [plateau3, code3]);
Assert.NotNull(estPossibleObj3);
Assert.IsType<bool>(estPossibleObj3);
Assert.False((bool)estPossibleObj3);

@ -137,9 +137,6 @@ namespace CoreLibrary.Joueurs
/// <param name="codes">Une liste de tous les codes restants possibles.</param>
private static void SupprimerCodesImpossibles(List<Code> codes, Plateau plateau)
{
if (codes == null)
return;
List<int> indicesASupprimer = new List<int>();
// Pour chaque code possible

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection;
using Xunit;
using CoreLibrary;
using CoreLibrary.Core;
@ -9,8 +6,6 @@ using CoreLibrary.Joueurs;
using CoreLibrary.Regles;
using CoreLibrary.Evenements;
using CoreLibrary.Exceptions;
using System.Diagnostics.Tracing;
using Xunit.Abstractions;
namespace UnitTesting

@ -1,6 +1,4 @@
using CoreLibrary;
using CoreLibrary.Core;
using CoreLibrary.Evenements;
using CoreLibrary.Core;
using CoreLibrary.Joueurs;
using System.Reflection;
using Xunit;
@ -69,5 +67,40 @@ namespace UnitTesting
Assert.IsType<bool>(estPossibleObj3);
Assert.False((bool)estPossibleObj3);
}
[Fact]
public void TestSupprimerCodesImpossibles()
{
Code codeSecret = new Code(1);
codeSecret.AjouterJeton(new Jeton(Couleur.Rouge));
Code code1 = new Code(1);
code1.AjouterJeton(new Jeton(Couleur.Vert));
Code code2 = new Code(1);
code2.AjouterJeton(new Jeton(Couleur.Jaune));
List<Code> codes = new List<Code>([
codeSecret,
code1,
code2,
]);
Plateau plateau = new Plateau(1, 1);
FieldInfo? codeSecretInfo = typeof(Plateau).GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(codeSecretInfo);
codeSecretInfo.SetValue(plateau, codeSecret);
plateau.AjouterCode(codeSecret);
Assert.Equal(3, codes.Count);
MethodInfo? SupprimerCodesImpossiblesInfo = typeof(Robot).GetMethod("SupprimerCodesImpossibles", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
Assert.NotNull(SupprimerCodesImpossiblesInfo);
SupprimerCodesImpossiblesInfo.Invoke(new Robot(), [codes, plateau]);
Assert.Single(codes);
}
}
}

@ -16,8 +16,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTesting", "UnitTesting\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistance", "Persistance\Persistance.csproj", "{B9E8C10D-9E0E-42F1-8F2C-1E2200DD96FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{2C86B541-6E8A-4C92-BC64-582413B22A49}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -46,10 +44,6 @@ Global
{B9E8C10D-9E0E-42F1-8F2C-1E2200DD96FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9E8C10D-9E0E-42F1-8F2C-1E2200DD96FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9E8C10D-9E0E-42F1-8F2C-1E2200DD96FA}.Release|Any CPU.Build.0 = Release|Any CPU
{2C86B541-6E8A-4C92-BC64-582413B22A49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C86B541-6E8A-4C92-BC64-582413B22A49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C86B541-6E8A-4C92-BC64-582413B22A49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C86B541-6E8A-4C92-BC64-582413B22A49}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save