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
18 changes: 16 additions & 2 deletions Rapr/Utils/DriverStoreEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ public class DriverStoreEntry
/// </summary>
public Guid DriverExtensionId { get; set; }

// The date columns format with {0:d} and ObjectListView sorts the raw value, so a time part
// makes the sort disagree with the text on screen and starves the secondary sort column.
private DateTime driverDate;

/// <summary>
/// Sys file date
/// </summary>
public DateTime DriverDate { get; set; }
public DateTime DriverDate
{
get => this.driverDate;
set => this.driverDate = value.Date;
}

/// <summary>
/// Sys file version
Expand Down Expand Up @@ -174,10 +182,16 @@ private static string SanitizeFolderName(string name, int maxLength)
/// </summary>
public bool? DevicePresent { get; set; }

private DateTime? installDate;

/// <summary>
/// Driver install date - when the driver package was imported/added to the driver store
/// </summary>
public DateTime? InstallDate { get; set; }
public DateTime? InstallDate
{
get => this.installDate;
set => this.installDate = value?.Date;
}

/// <summary>
/// List of driver files (sys, DLLs) in the driver package
Expand Down
62 changes: 62 additions & 0 deletions RaprTests/DriverStoreEntryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Rapr.Utils;

namespace Rapr.Tests
{
[TestClass]
public class DriverStoreEntryTests
{
[TestMethod]
public void InstallDateIsTruncatedToTheDayItDisplays()
{
var morning = new DriverStoreEntry { DriverInfName = "morning", InstallDate = new DateTime(2026, 10, 6, 8, 15, 1) };
var evening = new DriverStoreEntry { DriverInfName = "evening", InstallDate = new DateTime(2026, 10, 6, 23, 45, 59) };
var nextDay = new DriverStoreEntry { DriverInfName = "nextDay", InstallDate = new DateTime(2026, 10, 7, 0, 0, 0) };

Assert.AreEqual(new DateTime(2026, 10, 6), morning.InstallDate);
Assert.AreEqual(new DateTime(2026, 10, 6), evening.InstallDate);
Assert.AreEqual(new DateTime(2026, 10, 7), nextDay.InstallDate);

// ObjectListView falls through to the secondary column only when this compare returns
// 0, and OrderBy keeps ties in input order, so "evening" staying ahead of "morning"
// is the order a reader now gets instead of the raw 23:45 sorting after 08:15.
CollectionAssert.AreEqual(
new[] { "evening", "morning", "nextDay" },
new List<DriverStoreEntry> { evening, nextDay, morning }
.OrderBy(e => e.InstallDate)
.Select(e => e.DriverInfName)
.ToArray());
}

[TestMethod]
public void InstallDateKeepsNull()
{
var entry = new DriverStoreEntry { InstallDate = null };
Assert.IsNull(entry.InstallDate);

entry.InstallDate = new DateTime(2026, 10, 6, 8, 15, 1);
Assert.AreEqual(new DateTime(2026, 10, 6), entry.InstallDate);

entry.InstallDate = null;
Assert.IsNull(entry.InstallDate);
}

[TestMethod]
public void DriverDateIsTruncatedToTheDayItDisplays()
{
var entry = new DriverStoreEntry { DriverDate = new DateTime(2026, 10, 6, 23, 45, 59) };
Assert.AreEqual(new DateTime(2026, 10, 6), entry.DriverDate);

entry.DriverDate = default(DateTime);
Assert.AreEqual(default(DateTime), entry.DriverDate);

entry.SetDriverDateAndVersion("2026-10-06 31.0.15.3623");
Assert.AreEqual(new DateTime(2026, 10, 6), entry.DriverDate);
}
}
}
Loading