Begin process of adding unit tests with NUnit
This commit is contained in:
@@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
Directory.Packages.props = Directory.Packages.props
|
Directory.Packages.props = Directory.Packages.props
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CritterFolioTests", "CritterFolioTests\CritterFolioTests.csproj", "{8FC9599B-8CE1-4AA2-B428-17F923598643}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -44,6 +46,10 @@ Global
|
|||||||
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8FC9599B-8CE1-4AA2-B428-17F923598643}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8FC9599B-8CE1-4AA2-B428-17F923598643}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8FC9599B-8CE1-4AA2-B428-17F923598643}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8FC9599B-8CE1-4AA2-B428-17F923598643}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -29,4 +29,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Assets\Fonts\" />
|
<Folder Include="Assets\Fonts\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
|
||||||
|
<_Parameter1>CritterFolioTests</_Parameter1>
|
||||||
|
</AssemblyAttribute>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public partial class HomePage : Page
|
|||||||
Sys.Navigation?.PushPage(critterPage);
|
Sys.Navigation?.PushPage(critterPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AddButtonClicked(object? sender, RoutedEventArgs e)
|
internal async void AddButtonClicked(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var newCritter = new Critter();
|
var newCritter = new Critter();
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public partial class TestPage : Page
|
|||||||
};
|
};
|
||||||
await DatabaseService.AddCritter(polities);
|
await DatabaseService.AddCritter(polities);
|
||||||
|
|
||||||
var torielId = (await DatabaseService.GetCritter("Toriel")).Id;
|
var torielId = (await DatabaseService.GetCritter("Toriel"))!.Id;
|
||||||
var poliId = (await DatabaseService.GetCritter("Polities")).Id;
|
var poliId = (await DatabaseService.GetCritter("Polities"))!.Id;
|
||||||
|
|
||||||
var jessie = new Critter
|
var jessie = new Critter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||||
|
<PackageReference Include="NUnit" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="NUnit.Framework" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\CritterFolio\CritterFolio.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
34
critterfolio/CritterFolio/CritterFolioTests/UnitTest1.cs
Normal file
34
critterfolio/CritterFolio/CritterFolioTests/UnitTest1.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Avalonia.Interactivity;
|
||||||
|
using CritterFolio;
|
||||||
|
using CritterFolio.DataModels;
|
||||||
|
using CritterFolio.Pages;
|
||||||
|
using CritterFolio.Services;
|
||||||
|
|
||||||
|
namespace CritterFolioTests;
|
||||||
|
|
||||||
|
public class Tests
|
||||||
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TestAddingCritter()
|
||||||
|
{
|
||||||
|
var homePage = new HomePage();
|
||||||
|
var currentCritterDbCount = (await DatabaseService.GetAllCritters()).Count;
|
||||||
|
|
||||||
|
homePage.AddButtonClicked(null, new RoutedEventArgs());
|
||||||
|
|
||||||
|
var newCritterDbCount = (await DatabaseService.GetAllCritters()).Count;
|
||||||
|
|
||||||
|
Assert.That(newCritterDbCount == currentCritterDbCount + 1, Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TestGettingCritter()
|
||||||
|
{
|
||||||
|
Assert.That(await DatabaseService.GetCritter(-1), Is.True);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,5 +20,10 @@
|
|||||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
<PackageVersion Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
|
<PackageVersion Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
|
||||||
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.15" />
|
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.15" />
|
||||||
|
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
|
||||||
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||||
|
<PackageVersion Include="NUnit" Version="3.14.0" />
|
||||||
|
<PackageVersion Include="NUnit.Analyzers" Version="3.9.0" />
|
||||||
|
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user