|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Aspire.Cli.Telemetry;
using Microsoft.Extensions.Logging.Abstractions;
namespace Aspire.Cli.Tests.Telemetry;
[SupportedOSPlatform("linux")]
public class LinuxInformationProviderTests
{
[Fact]
public async Task GetOrCreateDeviceId_WorksCorrectly()
{
Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Linux),
"Only supported on Linux.");
// Arrange
var provider = new LinuxMachineInformationProvider(NullLogger<LinuxMachineInformationProvider>.Instance);
// Act
var deviceId = await provider.GetOrCreateDeviceId();
// Assert
Assert.NotNull(deviceId);
Assert.NotEmpty(deviceId);
// Verify it's persisted by calling again
var deviceId2 = await provider.GetOrCreateDeviceId();
Assert.Equal(deviceId, deviceId2);
}
}
|