Skip to content

Commit

Permalink
Fix failing unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkael committed Nov 9, 2024
1 parent a74c30d commit 2d891b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Tests/EddiCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,26 @@ public void TestSignalDetectedDeDuplication()
var line3 = @"{ ""timestamp"":""2019-02-04T02:38:53Z"", ""event"":""FSSSignalDiscovered"", ""SystemAddress"":6606892846275, ""SignalName"":""$Fixed_Event_Life_Ring;"", ""SignalName_Localised"":""Notable stellar phenomena"" }";
var line4 = @"{ ""timestamp"":""2019-02-04T02:38:53Z"", ""event"":""FSSSignalDiscovered"", ""SystemAddress"":6606892846275, ""SignalName"":""$NumberStation;"", ""SignalName_Localised"":""Unregistered Comms Beacon"" }";

JournalMonitor.ParseJournalEntry(line0);
var event0 = (SignalDetectedEvent)JournalMonitor.ParseJournalEntry(line0).FirstOrDefault();
EDDI.Instance.eventSignalDetected( event0 );
Assert.AreEqual(1, currentStarSystem?.signalsources.Count());
Assert.AreEqual("Unregistered Comms Beacon", currentStarSystem?.signalsources[0]);

JournalMonitor.ParseJournalEntry(line1);
var event1 = (SignalDetectedEvent)JournalMonitor.ParseJournalEntry(line1).FirstOrDefault();
EDDI.Instance.eventSignalDetected( event1 );
Assert.AreEqual(1, currentStarSystem?.signalsources.Count() );

JournalMonitor.ParseJournalEntry(line2);
var event2 = (SignalDetectedEvent)JournalMonitor.ParseJournalEntry(line2).FirstOrDefault();
EDDI.Instance.eventSignalDetected( event2 );
Assert.AreEqual(2, currentStarSystem?.signalsources.Count() );
Assert.AreEqual("Notable Stellar Phenomena", currentStarSystem?.signalsources[1]);

JournalMonitor.ParseJournalEntry(line3);
var event3 = (SignalDetectedEvent)JournalMonitor.ParseJournalEntry(line3).FirstOrDefault();
EDDI.Instance.eventSignalDetected( event3 );
Assert.AreEqual(2, currentStarSystem?.signalsources.Count() );

JournalMonitor.ParseJournalEntry(line4);
var event4 = (SignalDetectedEvent)JournalMonitor.ParseJournalEntry(line4).FirstOrDefault();
EDDI.Instance.eventSignalDetected( event4 );
Assert.AreEqual(2, currentStarSystem?.signalsources.Count() );
}

Expand Down
7 changes: 6 additions & 1 deletion Tests/JournalMonitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ public void TestSignalDetectedEvent3()
public void TestSignalDetectedEvent4()
{
// Test a carrier signal source
string line = @"{ ""timestamp"":""2021-01-11T19:44:08Z"", ""event"":""FSSSignalDiscovered"", ""SystemAddress"":1733119939274, ""SignalName"":""PBSF SPACE ODDITY XBH-64Y"", ""IsStation"":true }";
string line = @"{ ""timestamp"":""2021-01-11T19:44:08Z"", ""event"":""FSSSignalDiscovered"", ""SystemAddress"":1733119939274, ""SignalName"":""PBSF SPACE ODDITY XBH-64Y"", ""SignalType"":""FleetCarrier"", ""IsStation"":true }";
List<Event> events = JournalMonitor.ParseJournalEntry(line);
SignalDetectedEvent @event = (SignalDetectedEvent)events[0];
Assert.IsNotNull(@event);
Expand Down Expand Up @@ -1340,26 +1340,31 @@ public void TestSignalDetectedUnique()
var events0 = JournalMonitor.ParseJournalEntry(line0);
var event0 = (SignalDetectedEvent)events0[0];
Assert.AreEqual("Unregistered Comms Beacon", event0.signalSource.invariantName);
EDDI.Instance.eventSignalDetected( event0 );
Assert.IsTrue(event0.unique);

var events1 = JournalMonitor.ParseJournalEntry(line1);
var event1 = (SignalDetectedEvent)events1[0];
Assert.AreEqual("Unregistered Comms Beacon", event1.signalSource.invariantName);
EDDI.Instance.eventSignalDetected( event1 );
Assert.IsFalse(event1.unique);

var events2 = JournalMonitor.ParseJournalEntry(line2);
var event2 = (SignalDetectedEvent)events2[0];
Assert.AreEqual("Notable Stellar Phenomena", event2.signalSource.invariantName);
EDDI.Instance.eventSignalDetected( event2 );
Assert.IsTrue(@event2.unique);

var events3 = JournalMonitor.ParseJournalEntry(line3);
var event3 = (SignalDetectedEvent)events3[0];
Assert.AreEqual("Notable Stellar Phenomena", event3.signalSource.invariantName);
EDDI.Instance.eventSignalDetected( event3 );
Assert.IsFalse(@event3.unique);

var events4 = JournalMonitor.ParseJournalEntry(line4);
var event4 = (SignalDetectedEvent)events4[0];
Assert.AreEqual("Unregistered Comms Beacon", event4.signalSource.invariantName);
EDDI.Instance.eventSignalDetected( event4 );
Assert.IsFalse(event4.unique);
}

Expand Down

0 comments on commit 2d891b7

Please sign in to comment.