add thargoid kills to transaction parser
This commit is contained in:
@@ -44,6 +44,9 @@
|
||||
<None Update="SellOrganicData.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ThargoidKills.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
25
EDPlayerJournalTests/Helper.cs
Normal file
25
EDPlayerJournalTests/Helper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournalTests;
|
||||
|
||||
public class Helper {
|
||||
public static List<Entry>? LoadTestData(string filename) {
|
||||
string path = Path.GetFullPath("./" + filename);
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
List<Entry> entries = new();
|
||||
|
||||
foreach (string line in lines) {
|
||||
line.Trim();
|
||||
if (string.IsNullOrEmpty(line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entry? entry = Entry.Parse(line);
|
||||
if (entry != null) {
|
||||
entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
@@ -6,31 +6,11 @@ namespace EDPlayerJournalTests;
|
||||
|
||||
[TestClass]
|
||||
public class TestTransactionParser {
|
||||
private List<Entry>? LoadTestData(string filename) {
|
||||
string path = Path.GetFullPath("./" + filename);
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
List<Entry> entries = new();
|
||||
|
||||
foreach (string line in lines) {
|
||||
line.Trim();
|
||||
if (string.IsNullOrEmpty(line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entry? entry = Entry.Parse(line);
|
||||
if (entry != null) {
|
||||
entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DoubleFiveINF() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("double-five-inf.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("double-five-inf.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -46,7 +26,7 @@ public class TestTransactionParser {
|
||||
public void DoubleSupport() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("double-support.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("double-support.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -62,7 +42,7 @@ public class TestTransactionParser {
|
||||
public void MissionFailed() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("mission-failed.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("mission-failed.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -78,7 +58,7 @@ public class TestTransactionParser {
|
||||
public void MissionNoINF() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("mission-noinfforsourceortarget.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("mission-noinfforsourceortarget.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -94,7 +74,7 @@ public class TestTransactionParser {
|
||||
public void Murder() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("murder.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("murder.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -118,7 +98,7 @@ public class TestTransactionParser {
|
||||
public void NoFactionNameNoInfluence() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("nofactionname-andnoinfluence.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("nofactionname-andnoinfluence.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
@@ -134,7 +114,7 @@ public class TestTransactionParser {
|
||||
public void SellOrganicData() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = LoadTestData("SellOrganicData.txt");
|
||||
List<Entry>? entries = Helper.LoadTestData("SellOrganicData.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
|
||||
33
EDPlayerJournalTests/ThargoidKills.cs
Normal file
33
EDPlayerJournalTests/ThargoidKills.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using EDPlayerJournal.BGS;
|
||||
using EDPlayerJournal.Entries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EDPlayerJournalTests;
|
||||
|
||||
[TestClass]
|
||||
public class ThargoidKills {
|
||||
[TestMethod]
|
||||
public void ThargoidBonks() {
|
||||
TransactionParser parser = new();
|
||||
|
||||
List<Entry>? entries = Helper.LoadTestData("ThargoidKills.txt");
|
||||
Assert.IsNotNull(entries, "could not load test data");
|
||||
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Transaction>? transactions = parser.Parse(entries);
|
||||
|
||||
Assert.IsNotNull(transactions, "could not parse entries");
|
||||
Assert.AreEqual(transactions.Count, 4);
|
||||
|
||||
Assert.IsInstanceOfType(transactions[0], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
||||
Assert.IsInstanceOfType(transactions[1], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
||||
Assert.IsInstanceOfType(transactions[2], typeof(ThargoidKill), "result is not of type ThargoidKill");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user