public void ProtectedModeAllAreTest(string testId, bool[] zones, bool expectedAllOn, bool expectedAllSame) { if (!OperatingSystem.IsWindows()) { return; } var protectedMode = new ProtectedMode(new ZoneListFactoryMock(zones)); Assert.AreEqual(expectedAllOn, protectedMode.AllAre(true), "AllOn for [" + testId + "]"); Assert.AreEqual(expectedAllSame, protectedMode.AllAreSame(), "AllSame for [" + testId + "]"); Assert.AreEqual(expectedAllSame && !expectedAllOn, protectedMode.AllAre(false), "AllOff for [" + testId + "]"); var state = protectedMode.State; Assert.AreEqual(4, state.Count); var index = 1; foreach (var entry in state) { Assert.AreEqual(3, entry.Count); Assert.AreEqual(index, entry[0]); Assert.AreEqual(zones[index - 1], entry[1]); Assert.AreEqual("User", entry[2]); index++; } }
public void SeleniumZoneTest() { // this test will fail if not all protected mode settings are the same var registry = new WindowsRegistry(); var protectedModes = new ProtectedMode(new ZoneListFactory(registry)); var same = protectedModes.AllAreSame(); Assert.IsTrue(same); }
public void SeleniumProtectedModesAreTest(string testId, bool[] zones, bool expectedAllOn, bool expectedAllSame) { // including deprecated functions here - don't want to duplicate the whole test. Hence also the #pragma warning disable 618 if (!OperatingSystem.IsWindows()) { return; } Selenium.ExceptionOnDeprecatedFunctions = false; var protectedMode = new ProtectedMode(new ZoneListFactoryMock(zones)); var property = _selenium.GetType().GetField("_protectedMode", BindingFlags.NonPublic | BindingFlags.Instance); Debug.Assert(property != null, nameof(property) + " != null"); property.SetValue(_selenium, protectedMode); if (expectedAllSame) { Assert.IsTrue(_selenium.ProtectedModesAre("Equal"), testId + " [AllSame - Are Equal]"); #pragma warning disable 618 Assert.IsTrue(_selenium.ProtectedModesAreEqual(), testId + " [AllSame - AreEqual]"); #pragma warning restore 618 if (expectedAllOn) { Assert.IsTrue(_selenium.ProtectedModesAre("On"), testId + " [All On - Are On]"); #pragma warning disable 618 Assert.IsTrue(_selenium.ProtectedModeIsOn(), testId + " [All On - IsOn - Deprecated]"); #pragma warning restore 618 ExpectStopTestExceptionFor(() => _selenium.ProtectedModesAre("Off"), testId, "All On - IsOff"); } else { Assert.IsTrue(_selenium.ProtectedModesAre("Off"), testId + " [All Off - IsOff]"); #pragma warning disable 618 Assert.IsTrue(_selenium.ProtectedModeIsOff(), testId + " [All Off - IsOff - Deprecated]"); #pragma warning restore 618 ExpectStopTestExceptionFor(() => _selenium.ProtectedModesAre("On"), testId, "All Off - IsOn"); } } else { ExpectStopTestExceptionFor(() => _selenium.ProtectedModesAre("Equal"), testId, "NotAllSame - AreEqual"); ExpectStopTestExceptionFor(() => _selenium.ProtectedModesAre("Off"), testId, "NotAllSame - IsOff"); ExpectStopTestExceptionFor(() => _selenium.ProtectedModesAre("On"), testId, "NotAllSame - IsOn"); } Selenium.ExceptionOnDeprecatedFunctions = true; var modes = _selenium.ProtectedModePerZone(); Assert.AreEqual(4, modes.Count); Assert.AreEqual(3, modes[0].Count); // the rest is already tested in ProtectedModeTest }