Add telemetry data points for .NET Core 2.0
This commit is contained in:
parent
676fe41aca
commit
081f208942
29 changed files with 1324 additions and 77 deletions
54
test/dotnet.Tests/TelemetryCommonPropertiesTests.cs
Normal file
54
test/dotnet.Tests/TelemetryCommonPropertiesTests.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
using System;
|
||||
using Microsoft.DotNet.Cli;
|
||||
using Microsoft.DotNet.Cli.Telemetry;
|
||||
using Microsoft.DotNet.Configurer;
|
||||
|
||||
namespace Microsoft.DotNet.Tests
|
||||
{
|
||||
public class TelemetryCommonPropertiesTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TelemetryCommonPropertiesShouldContainIfItIsInDockerOrNot()
|
||||
{
|
||||
var unitUnderTest = new TelemetryCommonProperties(userLevelCacheWriter: new NothingCache());
|
||||
unitUnderTest.GetTelemetryCommonProperties().Should().ContainKey("Docker Container");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TelemetryCommonPropertiesShouldReturnHashedPath()
|
||||
{
|
||||
var unitUnderTest = new TelemetryCommonProperties(() => "ADirectory", userLevelCacheWriter: new NothingCache());
|
||||
unitUnderTest.GetTelemetryCommonProperties()["Current Path Hash"].Should().NotBe("ADirectory");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TelemetryCommonPropertiesShouldReturnHashedMachineId()
|
||||
{
|
||||
var unitUnderTest = new TelemetryCommonProperties(getMACAddress: () => "plaintext", userLevelCacheWriter: new NothingCache());
|
||||
unitUnderTest.GetTelemetryCommonProperties()["Machine ID"].Should().NotBe("plaintext");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TelemetryCommonPropertiesShouldReturnNewGuidWhenCannotGetMacAddress()
|
||||
{
|
||||
var unitUnderTest = new TelemetryCommonProperties(getMACAddress: () => null, userLevelCacheWriter: new NothingCache());
|
||||
var assignedMachineId = unitUnderTest.GetTelemetryCommonProperties()["Machine ID"];
|
||||
|
||||
Guid.TryParse(assignedMachineId, out var _).Should().BeTrue("it should be a guid");
|
||||
}
|
||||
|
||||
private class NothingCache : IUserLevelCacheWriter
|
||||
{
|
||||
public string RunWithCache(string cacheKey, Func<string> getValueToCache)
|
||||
{
|
||||
return getValueToCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue