void SetIPConfigurationInt(string interfaceToken, NetworkInterfaceSetConfiguration configuration, bool restore) { bool rebootNeeded = false; SoapMessage <WSD.HelloType> hello = null; try { hello = ReceiveHelloMessage( false, true, new Action(() => { Test.BeginStep(restore ? "Restore network settings" : "Set network interface"); if (!restore) { Test.LogStepEvent("interface token = " + interfaceToken); LogConfiguration(configuration); } rebootNeeded = SetNetworkInterface(interfaceToken, configuration); //if (!restore) { Test.LogStepEvent("reboot need = " + rebootNeeded); } Test.StepPassed(); if (rebootNeeded) { SystemReboot(); } })); } catch (AssertException) { // Assert: something wrong with receiving message (see DeviceDiscoveryTest.ReceiveMessageInternal) // SetNetworkInterface and SystemReboot don't throw AssertException. if (!rebootNeeded) { Test.LogStepEvent("Warning: no Hello within timeout"); StepPassed(); if (restore) { RaiseNetworkSettingsChangedEvent(AddressBackup); RestoreConnection(AddressBackup); return; } // should not occur, hack if (AddressBackup == null) { return; } BeginStep("No Hello - guessing right address"); string newServiceAddr = GuessAddress(configuration); Test.LogStepEvent("Selecting " + newServiceAddr); // raise event that network settings changed RaiseNetworkSettingsChangedEvent(newServiceAddr); ReConnectTo(newServiceAddr); StepPassed(); return; // no strict requirement for hello in this case } throw; } // catch if (!rebootNeeded) { if (hello == null) { return; // no strict requirement for hello in this case } } // no types verification - good for 2.1 RunNormal("Verifying Hello message", new Action(() => { MyAssert( LogAssert(hello, "hello") && LogAssert(hello.Object, "hello content") && LogAssert(hello.Object.EndpointReference, "hello endpoint") && LogAssert(hello.Object.EndpointReference.Address, "hello endpoint address") && LogAssert(hello.Object.EndpointReference.Address.Value, "hello endpoint address value") && LogLog("Endpoint Address = " + hello.Object.EndpointReference.Address.Value) && LogAssert(hello.Object.XAddrs, "hello service address(es) value") && LogLog("Service Address(es) = " + hello.Object.XAddrs), "Hello not verified", "Hello verified successfully"); })); { BeginStep("Identifying right address"); if (AddressBackup != null) { Test.LogStepEvent("Old address " + AddressBackup); } string[] addresses = hello.Object.XAddrs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string newServiceAddr = AddressBackup; int count = 0; foreach (string s in addresses) { int c = FindPrefixLength(s, AddressBackup); if (c > count) { newServiceAddr = s; count = c; } } Test.LogStepEvent("Selecting " + newServiceAddr); // raise event that network settings changed RaiseNetworkSettingsChangedEvent(newServiceAddr); ReConnectTo(newServiceAddr); StepPassed(); } }