Skip to content

Commit

Permalink
Added core.tests to test Saving feature, but it can be expanded upon …
Browse files Browse the repository at this point in the history
…to include more tests for sander1095#13
  • Loading branch information
herrozerro committed Oct 11, 2019
1 parent 3333636 commit c71a7aa
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/DnDCombatTracker.Core.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace DnDCombatTracker.Core.Tests
{
[TestClass]
public class CoreTests
{
[TestMethod]
public void TestPartySaving()
{
File.Delete(string.Join("\\", Directory.GetCurrentDirectory(), "parties.json"));

Party party = new Party()
{
Characters = new List<Character>()
{
new Character("TestChar1", 1, null, null, null, 0, 0, new List<Conditions>(), ""),
new Character("TestChar2", 2, null, null, null, 0, 0, new List<Conditions>(), "")
},
Name = "Test Party",
Notes = "",
partyId = Guid.NewGuid()
};

var partymgr = new PartyManagerService();

partymgr.SaveParty("parties.json", Directory.GetCurrentDirectory(), party);

var parties = partymgr.GetParties("parties.json", Directory.GetCurrentDirectory());

Assert.IsTrue(parties.First().partyId == party.partyId);

//cleanup
File.Delete(string.Join("\\", Directory.GetCurrentDirectory(), "parties.json"));
}
}
}
20 changes: 20 additions & 0 deletions src/DnDCombatTracker.Core.Tests/DnDCombatTracker.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DnDCombatTracker.Core\DnDCombatTracker.Core.csproj" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion src/DnDCombatTracker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ VisualStudioVersion = 16.0.29326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DnDCombatTracker.Forms", "DnDCombatTracker.Forms\DnDCombatTracker.Forms.csproj", "{E6D72DE7-073A-42CB-B4ED-2787B0BB9747}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DnDCombatTracker.Core", "DnDCombatTracker.Core\DnDCombatTracker.Core.csproj", "{5287EE3A-F653-40B0-B82C-5D0A42B74DA1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DnDCombatTracker.Core", "DnDCombatTracker.Core\DnDCombatTracker.Core.csproj", "{5287EE3A-F653-40B0-B82C-5D0A42B74DA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DnDCombatTracker.Core.Tests", "DnDCombatTracker.Core.Tests\DnDCombatTracker.Core.Tests.csproj", "{EA2D8A6E-0751-4D3D-B7DA-373B83A296A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +23,10 @@ Global
{5287EE3A-F653-40B0-B82C-5D0A42B74DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5287EE3A-F653-40B0-B82C-5D0A42B74DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5287EE3A-F653-40B0-B82C-5D0A42B74DA1}.Release|Any CPU.Build.0 = Release|Any CPU
{EA2D8A6E-0751-4D3D-B7DA-373B83A296A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA2D8A6E-0751-4D3D-B7DA-373B83A296A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA2D8A6E-0751-4D3D-B7DA-373B83A296A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA2D8A6E-0751-4D3D-B7DA-373B83A296A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit c71a7aa

Please sign in to comment.