-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New test project created with a few to test the factory pattern and s…
…ome of the object's implementations, such as a pokemon receiving damage or a trainer not having any pokemons left to battle.
- Loading branch information
1 parent
7d7e47f
commit 56835cc
Showing
9 changed files
with
153 additions
and
2 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,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace PokemonAdventureGame.Tests | ||
{ | ||
public class BattleTests | ||
{ | ||
[Theory] | ||
[InlineData(3)] | ||
public void ShouldNotBeNull(object something) | ||
{ | ||
Assert.NotNull(something); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
PokemonAdventureGame.Tests/PokemonAdventureGame.Tests.csproj
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\PokemonAdventureGame\PokemonAdventureGame.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
PokemonAdventureGame.Tests/PokemonAdventureGame.Tests/BattleSystemTests.cs
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,22 @@ | ||
using PokemonAdventureGame.Interfaces; | ||
using PokemonAdventureGame.Factories; | ||
using System; | ||
using Xunit; | ||
using PokemonAdventureGame.Trainers; | ||
using PokemonAdventureGame.BattleSystem; | ||
|
||
namespace PokemonAdventureGame.Tests | ||
{ | ||
public class BattleTests | ||
{ | ||
private static readonly ITrainer _trainer = TrainerFactory.CreateTrainer<Player>(); | ||
private static readonly ITrainer _enemyTrainer = TrainerFactory.CreateTrainer<Gary>(); | ||
|
||
[Fact] | ||
public void BattleObjectShouldNotBeNull() | ||
{ | ||
Battle battle = new Battle(_trainer, _enemyTrainer); | ||
Assert.NotNull(battle); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
PokemonAdventureGame.Tests/PokemonAdventureGame.Tests/PokemonAdventureGame.Tests.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\PokemonAdventureGame\PokemonAdventureGame.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
34 changes: 34 additions & 0 deletions
34
PokemonAdventureGame.Tests/PokemonAdventureGame.Tests/PokemonTests.cs
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,34 @@ | ||
using PokemonAdventureGame.Factories; | ||
using PokemonAdventureGame.Interfaces; | ||
using PokemonAdventureGame.Pokemon; | ||
using Xunit; | ||
|
||
namespace PokemonAdventureGame.Tests | ||
{ | ||
public class PokemonFactoryTests | ||
{ | ||
[Fact] | ||
public void PikachuCreationShouldNotReturnNull() | ||
=> Assert.NotNull(PokemonFactory.CreatePokemon<Pikachu>()); | ||
|
||
[Fact] | ||
public void EeveeCreationShouldNotReturnNull() | ||
=> Assert.NotNull(PokemonFactory.CreatePokemon<Eevee>()); | ||
|
||
[Fact] | ||
public void PokemonShouldFaint() | ||
{ | ||
IPokemon pokemon = PokemonFactory.CreatePokemon<Pikachu>(); | ||
pokemon.ReceiveDamage(pokemon.HealthPoints); | ||
Assert.True(pokemon.HasFainted()); | ||
} | ||
|
||
[Fact] | ||
public void PokemonShouldReceiveDamage() | ||
{ | ||
IPokemon pokemon = PokemonFactory.CreatePokemon<Eevee>(); | ||
pokemon.ReceiveDamage(10); | ||
Assert.True(pokemon.CurrentHealthPoints < pokemon.HealthPoints); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
PokemonAdventureGame.Tests/PokemonAdventureGame.Tests/TrainerTests.cs
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,35 @@ | ||
using Xunit; | ||
using PokemonAdventureGame.Factories; | ||
using PokemonAdventureGame.Trainers; | ||
using PokemonAdventureGame.Interfaces; | ||
using System.Linq; | ||
|
||
namespace PokemonAdventureGame.Tests | ||
{ | ||
public class TrainerFactoryTests | ||
{ | ||
[Fact] | ||
public void TrainerPlayerCreationShouldNotReturnNull() | ||
=> Assert.NotNull(TrainerFactory.CreateTrainer<Player>()); | ||
|
||
[Fact] | ||
public void TrainerGaryCreationShouldNotReturnNull() | ||
=> Assert.NotNull(TrainerFactory.CreateTrainer<Gary>()); | ||
|
||
[Fact] | ||
public void TrainerShouldNotHaveAnyPokemonLeftToBattle() | ||
{ | ||
ITrainer trainer = TrainerFactory.CreateTrainer<Player>(); | ||
trainer.PokemonTeam.ForEach(pkmn => pkmn.SetAsFainted()); | ||
Assert.False(trainer.HasAvailablePokemon()); | ||
} | ||
|
||
[Fact] | ||
public void ShouldSetChosenPokemonAsCurrent() | ||
{ | ||
ITrainer trainer = TrainerFactory.CreateTrainer<Gary>(); | ||
trainer.PokemonTeam.First().SetAsCurrent(); | ||
Assert.True(trainer.PokemonTeam.First().Current); | ||
} | ||
} | ||
} |
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
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
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