Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace Daqifi.Desktop.Test.Loggers;
/// <summary>
/// Regression tests for issue #572: sessions whose samples contain duplicate
/// (device serial, channel name) rows at a single timestamp must not abort
/// channel discovery when displaying a logging session.
/// channel discovery when displaying a logging session. The de-duplication now
/// lives in <see cref="SessionDataRepository"/> (extracted from <c>DatabaseLogger</c>, #592).
/// </summary>
[TestClass]
public class DatabaseLoggerChannelDiscoveryTests
public class SessionDataRepositoryChannelDiscoveryTests
{
private static SessionChannelInfo Analog(string channelName, string serial, string color = "#D32F2F")
{
Expand All @@ -30,7 +31,7 @@ public void DeduplicateChannelInfo_DuplicateChannelAtSameTimestamp_ReturnsSingle
};

// Act
var result = DatabaseLogger.DeduplicateChannelInfo(rows);
var result = SessionDataRepository.DeduplicateChannelInfo(rows);

// Assert
Assert.AreEqual(2, result.Count);
Expand All @@ -49,7 +50,7 @@ public void DeduplicateChannelInfo_DuplicateWithDifferentColor_KeepsFirstOccurre
};

// Act
var result = DatabaseLogger.DeduplicateChannelInfo(rows);
var result = SessionDataRepository.DeduplicateChannelInfo(rows);

// Assert
Assert.AreEqual(1, result.Count);
Expand All @@ -67,7 +68,7 @@ public void DeduplicateChannelInfo_SameChannelNameOnDifferentDevices_KeepsBoth()
};

// Act
var result = DatabaseLogger.DeduplicateChannelInfo(rows);
var result = SessionDataRepository.DeduplicateChannelInfo(rows);

// Assert
Assert.AreEqual(2, result.Count);
Expand All @@ -85,7 +86,7 @@ public void DeduplicateChannelInfo_UnorderedChannels_ReturnsNaturalOrder()
};

// Act
var result = DatabaseLogger.DeduplicateChannelInfo(rows);
var result = SessionDataRepository.DeduplicateChannelInfo(rows);

// Assert
string[] expectedOrder = ["AI0", "AI2", "AI10"];
Expand All @@ -96,7 +97,7 @@ public void DeduplicateChannelInfo_UnorderedChannels_ReturnsNaturalOrder()
public void DeduplicateChannelInfo_EmptyInput_ReturnsEmptyList()
{
// Act
var result = DatabaseLogger.DeduplicateChannelInfo([]);
var result = SessionDataRepository.DeduplicateChannelInfo([]);

// Assert
Assert.AreEqual(0, result.Count);
Expand All @@ -116,8 +117,8 @@ public void DeduplicateChannelInfo_DeduplicatedKeys_CanSeedPointDictionaryWithou

var localPoints = new Dictionary<(string deviceSerial, string channelName), List<DataPoint>>();

// Act - mirrors AddChannelSeries seeding one dictionary entry per channel
foreach (var row in DatabaseLogger.DeduplicateChannelInfo(rows))
// Act - mirrors LoadInitialSession seeding one dictionary entry per channel
foreach (var row in SessionDataRepository.DeduplicateChannelInfo(rows))
{
localPoints.Add((row.DeviceSerialNo, row.ChannelName), []);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ namespace Daqifi.Desktop.Test.Loggers;
/// <summary>
/// Covers the single-timestamp value-spread fallback used when a session has no
/// usable time range (issue #572): the spread must aggregate over every row in
/// the database, not just the rows Phase 1 happened to load.
/// the database, not just the rows Phase 1 happened to load. The aggregation now
/// lives in <see cref="SessionDataRepository"/> (extracted from <c>DatabaseLogger</c>, #592).
/// </summary>
[TestClass]
public class DatabaseLoggerSingleTickSpreadTests
public class SessionDataRepositorySingleTickSpreadTests
{
private const string Serial = "9090684023231015079";
private const long Tick = 638_000_000_000_000_000;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void LoadSingleTickValueSpread_AggregatesMinMaxAcrossAllRows()
};

// Act
var result = DatabaseLogger.LoadSingleTickValueSpread(_factory, 1, channelKeys);
var result = SessionDataRepository.LoadSingleTickValueSpread(_factory, 1, channelKeys);

// Assert - AI0 spans its true extrema; both points sit at delta-time zero
var ai0 = result[(Serial, "AI0")];
Expand Down Expand Up @@ -93,7 +94,7 @@ public void LoadSingleTickValueSpread_ConstantValue_ReturnsSinglePoint()
}

// Act
var result = DatabaseLogger.LoadSingleTickValueSpread(
var result = SessionDataRepository.LoadSingleTickValueSpread(
_factory, 1, [(Serial, "AI0")]);

// Assert
Expand All @@ -118,7 +119,7 @@ public void LoadSingleTickValueSpread_OnlyRequestedChannelKeysAreReturned()
}

// Act
var result = DatabaseLogger.LoadSingleTickValueSpread(
var result = SessionDataRepository.LoadSingleTickValueSpread(
_factory, 1, [(Serial, "AI0"), (Serial, "AI1")]);

// Assert
Expand Down
Loading
Loading