/// <summary> /// performs a specific run set /// </summary> /// <param name="server"> /// The WSUS Server /// </param> /// <param name="runSet"> /// A specific run set /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> private static void DoRunSet(IUpdateServer server, RunSet runSet, bool isTest) { Console.WriteLine("Performing Run Set: " + runSet.Name); // get the target group rules Configuration.CheckIsValidRunSet(server, runSet); var alreadyProcessed = new List <IComputerTargetGroup>(); if (runSet.TargetGroups.ElementInformation.IsPresent) { Console.WriteLine("Target Groups specified in Run Set."); TargetGroupCollection targetGroups = runSet.TargetGroups; foreach (TargetGroup targetGroup in targetGroups) { DoRunSetTargetGroup(server, targetGroup, isTest, alreadyProcessed); } } else if (runSet.AllTargetGroups.ElementInformation.IsPresent) { AllTargetGroups allTargetGroups = runSet.AllTargetGroups; DoRunSetAllTargetGroups(server, allTargetGroups, isTest, alreadyProcessed); } else { throw new ConfigurationErrorsException( "Couldn't find a \"targetGroup\" or \"allTargetGroups\" element in the runset."); } }
public void GetElementKeyTest() { TargetGroupCollection target = new TargetGroupCollection(); ConfigurationElement element = target.CreateNewElement(); object actual = target.GetElementKey(element); Assert.AreNotEqual(null, actual); }
public void TargetGroupsTest() { RunSet target = new RunSet(); TargetGroupCollection expected = new TargetGroupCollection(); target.TargetGroups = expected; TargetGroupCollection actual = target.TargetGroups; Assert.AreEqual(expected, actual); }
/// <summary> /// /// </summary> static private void CheckIsValidTargetGroups( Microsoft.UpdateServices.Administration.IUpdateServer server, TargetGroupCollection targetGroups, System.String runSetName ) { if (targetGroups.Count < 1) { throw new System.Configuration.ConfigurationErrorsException( "The \"TargetGroups\" section in runset \"" + runSetName + "\" must have at least 1 item." ); } foreach (TargetGroup targetGroup in targetGroups) { CheckIsValidTargetGroup(server, targetGroup, runSetName); } }
/// <summary> /// /// </summary> static public void CheckIsValidRunSet( Microsoft.UpdateServices.Administration.IUpdateServer server, RunSet runSet ) { TargetGroupCollection targetGroups = runSet.TargetGroups; AllTargetGroups allTargetGroups = runSet.AllTargetGroups; if ( targetGroups.Count == 0 && allTargetGroups.ElementInformation.IsPresent == false ) { throw new System.ArgumentException( "\"AllTargetGroups\" or \"TargetGroups\" missing from the runset \"" + runSet.Name + "\"." ); } if ( targetGroups.Count > 0 && allTargetGroups.ElementInformation.IsPresent ) { throw new System.ArgumentException( "\"AllTargetGroups\" and \"TargetGroups\" are both specified in runset \"" + runSet.Name + "\". You must specify one or the other." ); } if (targetGroups.Count > 0) { CheckIsValidTargetGroups(server, targetGroups, runSet.Name); } else { CheckIsValidAllTargetGroups(server, allTargetGroups, runSet.Name); } }
/// <summary> /// /// </summary> private static void CheckIsValidTargetGroups( Microsoft.UpdateServices.Administration.IUpdateServer server, TargetGroupCollection targetGroups, System.String runSetName ) { if (targetGroups.Count < 1) { throw new System.Configuration.ConfigurationErrorsException( "The \"TargetGroups\" section in runset \"" + runSetName + "\" must have at least 1 item." ); } foreach (TargetGroup targetGroup in targetGroups) { CheckIsValidTargetGroup(server, targetGroup, runSetName); } }
public void ItemTest() { TargetGroupCollection target = new TargetGroupCollection(); // TODO: Initialize to an appropriate value int index = 0; TargetGroup expected = new TargetGroup(); target.Add(expected); TargetGroup actual = target[index]; Assert.AreEqual(expected, actual); }
public void CreateNewElementTest() { TargetGroupCollection target = new TargetGroupCollection(); // TODO: Initialize to an appropriate value ConfigurationElement actual = target.CreateNewElement(); Assert.AreNotEqual(null, actual); }
public void TargetGroupCollectionConstructorTest() { TargetGroupCollection target = new TargetGroupCollection(); }