public void GetVersion_CurrentVersionDoesNotExist_ReturnsUnknown() { Tuple <string, string, string>[] expectedCalls = { MakeVersionTuple(CurrentVersion, ""), }; TestRegistry registry = new TestRegistry(expectedCalls); Assert.AreEqual("unknown", OSHelpers.GetVersion(registry.GetStringValue)); Assert.AreEqual(1, registry.QueriesMade); }
public void Ctor_CreatesObjectWithExpectedProperties() { const string expectedInstrumentationKey = "My key"; string expectedVersion = OSHelpers.GetVersion(); TelemetryClient client = TelemetryClientFactory.GetClient(expectedInstrumentationKey); Assert.AreEqual(expectedInstrumentationKey, client.InstrumentationKey); Assert.AreEqual(expectedVersion, client.Context.Device.OperatingSystem); Assert.AreEqual("undefined", client.Context.Cloud.RoleInstance); }
public void GetVersion_AllDataExists_ReturnsCurrentVersionDotCurrentBuild() { Tuple <string, string, string>[] expectedCalls = { MakeVersionTuple(CurrentVersion, "99.88"), MakeVersionTuple(CurrentBuild, "77"), }; TestRegistry registry = new TestRegistry(expectedCalls); Assert.AreEqual("99.88.77", OSHelpers.GetVersion(registry.GetStringValue)); Assert.AreEqual(2, registry.QueriesMade); }
public void GetCurrentWindowsVersionForTelemetry_AllDataExists_ReturnsCurrentVersionDotCurrentBuild() { using (ShimsContext.Create()) { List <string> returnValues = new List <string> { "99.88", "77" }; int index = 0; ShimRegistry.GetValueStringStringObject = (_, __, def) => (++index > returnValues.Count ? def : returnValues[index - 1]); Assert.AreEqual("99.88.77", OSHelpers.GetVersion()); Assert.AreEqual(2, index); } }
public void GetCurrentWindowsVersionForTelemetry_CurrentVersionDoesNotExist_ReturnsUnknown() { using (ShimsContext.Create()) { List <string> returnValues = new List <string> { "" }; int index = 0; ShimRegistry.GetValueStringStringObject = (_, __, def) => (++index > returnValues.Count ? def : returnValues[index - 1]); Assert.AreEqual("unknown", OSHelpers.GetVersion()); Assert.AreEqual(1, index); } }
public void GetVersion_LiveData_ReturnsDataInCorrectFormat() { string version = OSHelpers.GetVersion(); string[] pieces = version.Split('.'); Assert.AreEqual(3, pieces.Length); int majorVersion = int.Parse(pieces[0]); int minorVersion = int.Parse(pieces[1]); int build = int.Parse(pieces[2]); // Validation here assumes a range of Windows OS versions. // Our lower bound is 6.1.7601 (Win 7 SP1) // Our upper bound is 6.3.99999 // At current Win10 cadence, that will last until about 2040 Assert.AreEqual(6, majorVersion); Assert.IsTrue(minorVersion >= 1 && minorVersion <= 3, "minorVersion is " + minorVersion); Assert.IsTrue(build >= 7601 && build <= 99999, "build is " + build); }