forked from sander1095/DnDCombatTracker
-
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.
Added core.tests to test Saving feature, but it can be expanded upon …
…to include more tests for sander1095#13
- Loading branch information
1 parent
3333636
commit c71a7aa
Showing
3 changed files
with
68 additions
and
1 deletion.
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,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
20
src/DnDCombatTracker.Core.Tests/DnDCombatTracker.Core.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.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> |
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