Skip to content

Commit

Permalink
[INTERNAL] Tests: Adds more details to assert message (#3218)
Browse files Browse the repository at this point in the history
Co-authored-by: Sourabh Jain <sourabhjain@microsoft.com>
  • Loading branch information
sourabh1007 and sourabh1007 authored May 24, 2022
1 parent dad5849 commit cb2a7b3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ private static void ResetSystemUsageMonitor(bool isTelemetryEnabled)
[TestCleanup]
public async Task Cleanup()
{
var isInitializedField = typeof(VmMetadataApiHandler).GetField("isInitialized",
FieldInfo isInitializedField = typeof(VmMetadataApiHandler).GetField("isInitialized",
BindingFlags.Static |
BindingFlags.NonPublic);
isInitializedField.SetValue(null, false);

var azMetadataField = typeof(VmMetadataApiHandler).GetField("azMetadata",
FieldInfo azMetadataField = typeof(VmMetadataApiHandler).GetField("azMetadata",
BindingFlags.Static |
BindingFlags.NonPublic);
azMetadataField.SetValue(null, null);
Expand Down Expand Up @@ -944,17 +944,17 @@ private static void AssertAccountLevelInformation(
}
}

Assert.AreEqual(1, machineId.Count);
Assert.AreEqual(1, machineId.Count, $"Multiple Machine Id has been generated i.e {JsonConvert.SerializeObject(machineId)}");

if(isAzureInstance.HasValue)
{
if (isAzureInstance.Value)
{
Assert.AreEqual("vmId:d0cb93eb-214b-4c2b-bd3d-cc93e90d9efd", machineId.ToList()[0]);
Assert.AreEqual("vmId:d0cb93eb-214b-4c2b-bd3d-cc93e90d9efd", machineId.First(), $"Generated Machine id is : {machineId.First()}");
}
else
{
Assert.AreNotEqual("vmId:d0cb93eb-214b-4c2b-bd3d-cc93e90d9efd", machineId.ToList()[0]);
Assert.AreNotEqual("vmId:d0cb93eb-214b-4c2b-bd3d-cc93e90d9efd", machineId.First(), $"Generated Machine id is : {machineId.First()}");
}
}

Expand Down

0 comments on commit cb2a7b3

Please sign in to comment.