Skip to content

Commit

Permalink
testfacade
Browse files Browse the repository at this point in the history
  • Loading branch information
mateogutierrezo committed Nov 8, 2024
1 parent 432ec9c commit 41cbe0c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 33 deletions.
9 changes: 7 additions & 2 deletions src/Library/Facade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,18 @@ public static string ChooseTeam(string playerName, string cPokemon)
{
foreach (Pokemon pokemon in PokemonCatalogue.SetCatalogue())
{
if (pokemon.Name == cPokemon && !player.GetPokemonTeam().Contains(pokemon))
if (pokemon.Name == cPokemon && !player.CheckPokemonInTeam(cPokemon))
{
player.AddToTeam(pokemon);
if (player.GetPokemonTeam().Count == 1)
{
player.SetActivePokemon(pokemon);
}
return $"El pokemon {cPokemon} fue añadido al equipo";
}
return $"El pokemon {cPokemon} ya está en el equipo, no puedes volver a añadirlo";

}
return $"El pokemon {cPokemon} ya está en el equipo, no puedes volver a añadirlo";
}
return $"El pokemon {cPokemon} no fue encontrado";
}
Expand Down
57 changes: 52 additions & 5 deletions src/Library/Library.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/Library/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,21 @@ public string GetPokemonAttacks()
}
return result;
}

public bool CheckPokemonInTeam(string pokemonName)
{
if (this.PokemonTeam.Count == 0)
{
return false;
}

foreach (Pokemon pokemon in this.PokemonTeam)
{
if (pokemon.Name == pokemonName)
return true;
}

return false;
}

}
4 changes: 1 addition & 3 deletions src/Program/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//--------------------------------------------------------------------------------

using System;
using ClassLibrary;
using Library;

namespace ConsoleApplication
{
Expand All @@ -19,8 +19,6 @@ public static class Program
/// </summary>
public static void Main()
{
var train = new Train();
train.StartEngines();
Console.WriteLine("Hello World!");
}
}
Expand Down
8 changes: 7 additions & 1 deletion test/LibraryTests/FacadeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public void TestShowAttacks()
Facade.CreateGame("mateo", "ines");
Facade.StartBattle("mateo", "ines");
Facade.ChooseTeam("mateo", "Caterpie");
string result = "Bug bite\nTackle\nBug Stomp\nString Shot";
string result = "Bug bite\nTackle\nBug stomp\nString shot\n";
Assert.That(Facade.ShowAtacks("mateo"), Is.EqualTo(result));
}

[Test]
public void TestShowPokemonsHP()
{

}
}
24 changes: 2 additions & 22 deletions test/LibraryTests/LibraryTests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41cbe0c

Please sign in to comment.