Skip to content

Commit 6a1ba6a

Browse files
committed
Resolve cod review feedback
1 parent f94da0b commit 6a1ba6a

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/Common/Commands.Common/MetricHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static string HashMacAddress
6868
nic.GetPhysicalAddress() != null &&
6969
!string.IsNullOrWhiteSpace(nic.GetPhysicalAddress().ToString()))?
7070
.GetPhysicalAddress()?.ToString();
71-
_hashMacAddress = string.IsNullOrWhiteSpace(macAddress) ? null : GenerateSha256HashString(macAddress).Replace("-", string.Empty).ToLowerInvariant();
71+
_hashMacAddress = string.IsNullOrWhiteSpace(macAddress) ? null : GenerateSha256HashString(macAddress)?.Replace("-", string.Empty)?.ToLowerInvariant();
7272
}
7373

7474
return _hashMacAddress;
@@ -249,7 +249,7 @@ public static string GenerateSha256HashString(string originInput)
249249
{
250250
if (string.IsNullOrWhiteSpace(originInput))
251251
{
252-
return null;
252+
return string.Empty;
253253
}
254254

255255
using (var sha256 = new SHA256CryptoServiceProvider())

src/ResourceManager/Profile/Commands.Profile.Test/TelemetryTests.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public class TelemetryTests
2525
{
2626
[Fact]
2727
[Trait(Category.AcceptanceType, Category.CheckIn)]
28-
public void HashOfNullOrWhitespaceValueReturnsNull()
28+
public void HashOfNullOrWhitespaceValueReturnsEmptyString()
2929
{
30-
Assert.Null(MetricHelper.GenerateSha256HashString(null));
31-
Assert.Null(MetricHelper.GenerateSha256HashString(string.Empty));
32-
Assert.Null(MetricHelper.GenerateSha256HashString(" "));
30+
Assert.Equal(string.Empty, MetricHelper.GenerateSha256HashString(null));
31+
Assert.Equal(string.Empty, MetricHelper.GenerateSha256HashString(string.Empty));
32+
Assert.Equal(string.Empty, MetricHelper.GenerateSha256HashString(" "));
3333
}
3434

3535
[Fact]
@@ -45,22 +45,12 @@ public void HashOfValidValueSucceeds()
4545

4646
[Fact]
4747
[Trait(Category.AcceptanceType, Category.CheckIn)]
48-
public void NetworkInterfaceWithEmptyAddressReturnsNull()
48+
public void NetworkInterfaceWithEmptyAddressReturnsEmptyString()
4949
{
50-
var networkInterfaceMock = new Mock<NetworkInterface>();
51-
networkInterfaceMock.Setup(t => t.GetPhysicalAddress())
52-
.Returns(
53-
() =>
54-
{
55-
return new PhysicalAddress(new byte[] { });
56-
}
57-
);
58-
59-
var address = networkInterfaceMock.Object.GetPhysicalAddress();
60-
Assert.NotNull(address);
50+
var address = new PhysicalAddress(new byte[] { } );
6151
Assert.Equal(string.Empty, address.ToString());
6252
var hashAddress = MetricHelper.GenerateSha256HashString(address.ToString());
63-
Assert.Null(hashAddress);
53+
Assert.Equal(string.Empty, hashAddress);
6454
}
6555
}
6656
}

0 commit comments

Comments
 (0)