private void StartPatchSettingTest(MockContext context, string patchSettingMode, bool enableAutomaticUpdates) { EnsureClientsInitialized(context); string rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); // The following variables are defined here to allow validation string autoLogonContent = null; var patchSetting = new PatchSettings { PatchMode = patchSettingMode }; Action <VirtualMachine> configureWindowsConfigurationPatchSetting = inputVM => { autoLogonContent = GetAutoLogonContent(5, inputVM.OsProfile.AdminUsername, inputVM.OsProfile.AdminPassword); SetWindowsConfigurationPatchSettings(patchSetting, enableAutomaticUpdates, autoLogonContent, inputVM); }; Action <VirtualMachine> validateWindowsConfigurationPatchSetting = outputVM => ValidateWinPatchSetting(patchSetting.PatchMode, enableAutomaticUpdates, autoLogonContent, outputVM); TestVMWithOSProfile( rgName: rgName, useWindowsProfile: true, vmCustomizer: configureWindowsConfigurationPatchSetting, vmValidator: validateWindowsConfigurationPatchSetting); }
protected void GeneratePatch(Rectangle dimensions, Point pos, PatchSettings patchSettings) { bool replace = patchSettings.replaceTiles != null; for (int i = 0; i < patchSettings.nBranches; i++) { Vector2 direction = Main.rand.NextVector2Unit(); Vector2 direction90 = new Vector2(direction.Y, -direction.X); float length = Main.rand.NextFloat(patchSettings.minBranchLength, patchSettings.maxBranchLength); float width = Main.rand.NextFloat(patchSettings.minBranchWidth, patchSettings.maxBranchWidth); float widthLimit = width + patchSettings.branchWidthLimitAdd; bool decreaseWidth = patchSettings.branchWidthLimitAdd < 0; for (int j = 0; j < length; j++) { float halfWidth = width / 2; for (float k = -halfWidth; k < -halfWidth + width; k++) { Vector2 vTilePos = (direction * j) + (direction90 * k); Point tilePos = new Point(dimensions.X + (int)Math.Round(pos.X + vTilePos.X), dimensions.Y + (int)Math.Round(pos.Y + vTilePos.Y)); if (dimensions.Contains(tilePos) && (!replace || patchSettings.replaceTiles.Contains(Main.tile[tilePos.X, tilePos.Y].type))) { PlaceTile(tilePos, patchSettings.type); } } width *= patchSettings.branchWidthMultiplier; if ((decreaseWidth && width <= widthLimit) || (!decreaseWidth && width >= widthLimit)) { break; } } } }
public void TestVMWithSettingWindowsConfigurationPatchSettingsAssessmentModeOfImageDefault() { using (MockContext context = MockContext.Start(this.GetType())) { var patchSetting = new PatchSettings { AssessmentMode = "ImageDefault", }; StartPatchSettingTest(context, patchSetting, false); } }
public void TestVMWithSettingWindowsConfigurationPatchSettingsValueOfAutomaticByOS() { using (MockContext context = MockContext.Start(this.GetType())) { var patchSetting = new PatchSettings { PatchMode = "AutomaticByOS", }; StartPatchSettingTest(context, patchSetting, true); } }
public void TestVMWithSettingWindowsConfigurationPatchSettingsValueOfManual() { using (MockContext context = MockContext.Start(this.GetType())) { var patchSetting = new PatchSettings { PatchMode = "Manual" }; StartPatchSettingTest(context, patchSetting, false); } }
private void ValidateWinPatchSetting(PatchSettings patchSetting, bool enableAutomaticUpdates, string autoLogonContent, VirtualMachine outputVM) { var osProfile = outputVM.OsProfile; Assert.Null(osProfile.LinuxConfiguration); Assert.NotNull(osProfile.WindowsConfiguration); Assert.True(osProfile.WindowsConfiguration.ProvisionVMAgent != null && osProfile.WindowsConfiguration.ProvisionVMAgent.Value); Assert.True(osProfile.WindowsConfiguration.EnableAutomaticUpdates != null && osProfile.WindowsConfiguration.EnableAutomaticUpdates.Value == enableAutomaticUpdates); // PatchSetting checks Assert.NotNull(osProfile.WindowsConfiguration.PatchSettings); if (patchSetting.PatchMode != null) { Assert.NotNull(osProfile.WindowsConfiguration.PatchSettings.PatchMode); Assert.Equal(osProfile.WindowsConfiguration.PatchSettings.PatchMode, patchSetting.PatchMode); } else { // By default in supported API versions, a value is provided in the VM model even if one is // not specified by the user. if (osProfile.WindowsConfiguration.EnableAutomaticUpdates == false) { Assert.Equal("Manual", osProfile.WindowsConfiguration.PatchSettings.PatchMode); } else { Assert.Equal("AutomaticByOS", osProfile.WindowsConfiguration.PatchSettings.PatchMode); } } if (patchSetting.AssessmentMode != null) { Assert.NotNull(osProfile.WindowsConfiguration.PatchSettings.AssessmentMode); Assert.Equal(osProfile.WindowsConfiguration.PatchSettings.AssessmentMode, patchSetting.AssessmentMode); } else { // By default in supported API versions, a value is provided in the VM model even if one is // not specified by the user. Assert.Equal("ImageDefault", osProfile.WindowsConfiguration.PatchSettings.AssessmentMode); } }
private void SetWindowsConfigurationPatchSettings(PatchSettings patchSetting, bool enableAutomaticUpdates, string autoLogonContent, VirtualMachine inputVM) { var osProfile = inputVM.OsProfile; osProfile.WindowsConfiguration = new WindowsConfiguration { ProvisionVMAgent = true, EnableAutomaticUpdates = enableAutomaticUpdates, PatchSettings = patchSetting, AdditionalUnattendContent = new List <AdditionalUnattendContent> { new AdditionalUnattendContent { PassName = OOBESystem, ComponentName = MicrosoftWindowsShellSetup, SettingName = AutoLogon, Content = autoLogonContent } }, }; }