From 37318f9653330952f8ce3eb8863feeadb68c14fb Mon Sep 17 00:00:00 2001 From: EugeneTes Date: Thu, 23 Jul 2026 07:46:44 +0000 Subject: [PATCH] add InsinEventKinds and PrintErrorType mapping --- .../Telemetry/InsinEventKindsTests.cs | 28 +++++++++++++++++++ .../PrintServer/Telemetry/InsinEventKinds.cs | 19 +++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Inspectron.Epson.Tests/Telemetry/InsinEventKindsTests.cs create mode 100644 Inspectron.Epson/PrintServer/Telemetry/InsinEventKinds.cs diff --git a/Inspectron.Epson.Tests/Telemetry/InsinEventKindsTests.cs b/Inspectron.Epson.Tests/Telemetry/InsinEventKindsTests.cs new file mode 100644 index 0000000..ca56f1d --- /dev/null +++ b/Inspectron.Epson.Tests/Telemetry/InsinEventKindsTests.cs @@ -0,0 +1,28 @@ +using Inspectron.Epson.PrintServer.Telemetry; +using Inspectron.Epson.Queue; + +namespace Inspectron.Epson.Tests.Telemetry; + +public class InsinEventKindsTests +{ + [Theory] + [InlineData(PrintErrorType.OutOfPaper, "job.failed.paper_out")] + [InlineData(PrintErrorType.Offline, "job.failed.connection")] + [InlineData(PrintErrorType.ConversionError, "job.failed.other")] + [InlineData(PrintErrorType.Other, "job.failed.other")] + [InlineData(PrintErrorType.None, "job.failed.other")] + public void MapErrorTypeToKind(PrintErrorType input, string expected) + { + Assert.Equal(expected, InsinEventKinds.MapErrorTypeToKind(input)); + } + + [Fact] + public void Constants_have_expected_values() + { + Assert.Equal("service.started", InsinEventKinds.ServiceStarted); + Assert.Equal("job.printed", InsinEventKinds.JobPrinted); + Assert.Equal("printer.discovered", InsinEventKinds.PrinterDiscovered); + Assert.Equal("printer.online", InsinEventKinds.PrinterOnline); + Assert.Equal("printer.offline", InsinEventKinds.PrinterOffline); + } +} diff --git a/Inspectron.Epson/PrintServer/Telemetry/InsinEventKinds.cs b/Inspectron.Epson/PrintServer/Telemetry/InsinEventKinds.cs new file mode 100644 index 0000000..5aad7ae --- /dev/null +++ b/Inspectron.Epson/PrintServer/Telemetry/InsinEventKinds.cs @@ -0,0 +1,19 @@ +using Inspectron.Epson.Queue; + +namespace Inspectron.Epson.PrintServer.Telemetry; + +public static class InsinEventKinds +{ + public const string ServiceStarted = "service.started"; + public const string JobPrinted = "job.printed"; + public const string PrinterDiscovered = "printer.discovered"; + public const string PrinterOnline = "printer.online"; + public const string PrinterOffline = "printer.offline"; + + public static string MapErrorTypeToKind(PrintErrorType errorType) => errorType switch + { + PrintErrorType.OutOfPaper => "job.failed.paper_out", + PrintErrorType.Offline => "job.failed.connection", + _ => "job.failed.other", + }; +}