1
0

feat: add tests to "L4.LD_24"

This commit is contained in:
Rokas Puzonas 2022-05-05 15:55:21 +03:00
parent 2e41918039
commit 473552e643
3 changed files with 75 additions and 0 deletions

View File

@ -5,6 +5,8 @@ VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24Tests", "LD_24Tests\LD_24Tests.csproj", "{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.Build.0 = Release|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LD_24\LD_24.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,42 @@
using System;
using Xunit;
using LD_24.Code;
using System.Collections.Generic;
using FluentAssertions;
namespace LD_24Tests
{
public class TaskUtilsTests
{
[Fact]
public void TestFindAllClasses()
{
List<Actor> actors = new List<Actor>();
actors.Add(new NPC("foo", "bar", "baz", "ClassAAA", 10, 10, 10, 10, "biz"));
actors.Add(new Hero("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, 10, 10, 10, 10));
actors.Add(new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, "baz"));
actors.Add(new Hero("foo", "bar", "baz", "ClassCCC", 10, 10, 10, 10, 10, 10, 10, 10));
List<string> classes = TaskUtils.FindAllClasses(actors);
classes.Should().BeEquivalentTo("ClassAAA", "ClassBBB", "ClassCCC");
}
[Fact]
public void TestFilterNPCsByAttack()
{
List<Actor> actors = new List<Actor>();
var actor1 = new NPC("foo", "bar", "baz", "ClassAAA", 10, 10, 9, 10, "biz");
var actor2 = new Hero("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, 10, 10, 10, 10);
var actor3 = new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, "baz");
var actor4 = new Hero("foo", "bar", "baz", "ClassCCC", 10, 10, 10, 10, 10, 10, 10, 10);
var actor5 = new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 5, 10, "baz");
actors.Add(actor1);
actors.Add(actor2);
actors.Add(actor3);
actors.Add(actor4);
actors.Add(actor5);
var NPCs = TaskUtils.FilterNPCsByAttack(actors, 10);
NPCs.Should().BeEquivalentTo(new List<NPC> { actor1, actor5 });
}
}
}