Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Aug 1, 2024
1 parent 664427c commit 14aa1ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Aspire.Dashboard/Otlp/Model/DurationFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;

namespace Aspire.Dashboard.Otlp.Model;

public static class DurationFormatter
{
[DebuggerDisplay("Unit = {Unit}, Ticks = {Ticks}, IsDecimal = {IsDecimal}")]
private sealed class UnitStep
{
public required string Unit { get; init; }
Expand Down
14 changes: 14 additions & 0 deletions tests/Aspire.Dashboard.Tests/DurationFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ namespace Aspire.Dashboard.Tests;

public class DurationFormatterTests
{
[Theory]
[InlineData(0, "μs")]
[InlineData(1, "μs")]
[InlineData(1_000, "μs")]
[InlineData(1_000_000, "ms")]
[InlineData(1_000_000_000, "s")]
[InlineData(1_000_000_000_000, "h")]
[InlineData(1_000_000_000_000_000, "h")]
[InlineData(1_000_000_000_000_000_000, "h")]
public void GetUnit(long ticks, string unit)
{
Assert.Equal(unit, DurationFormatter.GetUnit(TimeSpan.FromTicks(ticks)));
}

[Fact]
public void KeepsMicrosecondsTheSame()
{
Expand Down

0 comments on commit 14aa1ef

Please sign in to comment.