-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c647fc5
commit 5bc21eb
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace ClassLibrary; | ||
|
||
public class Catalog | ||
{ | ||
private List<Pokemon> pokemons = new List<Pokemon>(); | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ClassLibrary; | ||
|
||
public class Pokemon | ||
{ | ||
public string Name { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Tests; | ||
|
||
using ClassLibrary; | ||
|
||
public class CatalogTests | ||
{ | ||
[Test] | ||
public void FindPokemonByName_WhenPokemonDoesNotExists_ReturnNull() | ||
Check warning on line 10 in test/LibraryTests/CatalogTests.cs GitHub Actions / build-test-generate-docs
Check warning on line 10 in test/LibraryTests/CatalogTests.cs GitHub Actions / build-test-generate-docs
|
||
{ | ||
Catalog catalog = new Catalog(); | ||
|
||
Pokemon pokemon = catalog.FindPokemonByName("Otro pokemon"); | ||
|
||
Assert.That(pokemon, Is.Null); | ||
} | ||
|
||
[Test] | ||
public void FindPokemonByName_WhenPokemonExists_ReturnPokemon() | ||
Check warning on line 20 in test/LibraryTests/CatalogTests.cs GitHub Actions / build-test-generate-docs
Check warning on line 20 in test/LibraryTests/CatalogTests.cs GitHub Actions / build-test-generate-docs
|
||
{ | ||
Catalog catalog = new Catalog(); | ||
|
||
Pokemon pokemon = catalog.FindPokemonByName("Pikachu"); | ||
|
||
Assert.That(pokemon.Name, Is.EqualTo("Pikachu")); | ||
} | ||
} |