From 5bc21eb1a5ddd80449862b30e7aa09cae283b575 Mon Sep 17 00:00:00 2001 From: Macarenapineiro1 Date: Tue, 8 Oct 2024 11:28:15 -0300 Subject: [PATCH] Agregue Pokemon v1 y Catalog v1 --- src/Library/Catalog.cs | 26 ++++++++++++++++++++++++++ src/Library/Pokemon.cs | 6 ++++++ test/LibraryTests/CatalogTests.cs | 28 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/Library/Catalog.cs create mode 100644 src/Library/Pokemon.cs create mode 100644 test/LibraryTests/CatalogTests.cs diff --git a/src/Library/Catalog.cs b/src/Library/Catalog.cs new file mode 100644 index 0000000..77ba1ff --- /dev/null +++ b/src/Library/Catalog.cs @@ -0,0 +1,26 @@ +namespace ClassLibrary; + +public class Catalog +{ + private List pokemons = new List(); + + public Catalog() + { + Pokemon pikachu = new Pokemon(); + pikachu.Name = "Pikachu"; + this.pokemons.Add(pikachu); + } + + public Pokemon FindPokemonByName(string name) + { + foreach (var pokemon in this.pokemons) + { + if (pokemon.Name == name) + { + return pokemon; + } + } + + return null; + } +} \ No newline at end of file diff --git a/src/Library/Pokemon.cs b/src/Library/Pokemon.cs new file mode 100644 index 0000000..5418522 --- /dev/null +++ b/src/Library/Pokemon.cs @@ -0,0 +1,6 @@ +namespace ClassLibrary; + +public class Pokemon +{ + public string Name { get; set; } +} \ No newline at end of file diff --git a/test/LibraryTests/CatalogTests.cs b/test/LibraryTests/CatalogTests.cs new file mode 100644 index 0000000..c56cd37 --- /dev/null +++ b/test/LibraryTests/CatalogTests.cs @@ -0,0 +1,28 @@ +using NUnit.Framework; + +namespace Tests; + +using ClassLibrary; + +public class CatalogTests +{ + [Test] + public void FindPokemonByName_WhenPokemonDoesNotExists_ReturnNull() + { + Catalog catalog = new Catalog(); + + Pokemon pokemon = catalog.FindPokemonByName("Otro pokemon"); + + Assert.That(pokemon, Is.Null); + } + + [Test] + public void FindPokemonByName_WhenPokemonExists_ReturnPokemon() + { + Catalog catalog = new Catalog(); + + Pokemon pokemon = catalog.FindPokemonByName("Pikachu"); + + Assert.That(pokemon.Name, Is.EqualTo("Pikachu")); + } +} \ No newline at end of file