public void RunSetsTest() { ApplicationSettings target = new ApplicationSettings(); RunSetCollection expected = new RunSetCollection(); target.RunSets = expected; RunSetCollection actual = target.RunSets; Assert.AreEqual(expected, actual); }
public void RunSetsTest() { ApplicationSettings target = new ApplicationSettings(); RunSetCollection expected = new RunSetCollection(); target.RunSets = expected; RunSetCollection actual = target.RunSets; Assert.AreEqual(expected, actual); }
/// <summary> /// This is run when there are a group of runsets in the app.config /// Run Sets allow for different options to be run on different occasions /// The runset is specified on the command line /// </summary> /// <param name="server"> /// The WSUS Server /// </param> /// <param name="runSets"> /// Group of runsets /// </param> /// <param name="commandLine"> /// Information on what was specified on the command line /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> private static void DoRunSets( // Model.ApplicationSettings settings, IUpdateServer server, RunSetCollection runSets, CommandLine commandLine, bool isTest) { // we need to work out which runset is being done // we'll limit the command line to one runset string requestedRunSet = commandLine.GetRunSetName(); RunSet requiredRunSet = runSets.Cast <RunSet>() .FirstOrDefault(runSet => requestedRunSet.Equals(runSet.Name, StringComparison.OrdinalIgnoreCase)); if (requiredRunSet == null) { throw new ArgumentException( "The RunSet '" + requestedRunSet + "' as requested on the command line is not defined in the app.config."); } DoRunSet(server, requiredRunSet, isTest); }
/// <summary> /// This is run when there are a group of runsets in the app.config /// Run Sets allow for different options to be run on different occasions /// The runset is specified on the command line /// </summary> /// <param name="server"> /// The WSUS Server /// </param> /// <param name="runSets"> /// Group of runsets /// </param> /// <param name="commandLine"> /// Information on what was specified on the command line /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> private static void DoRunSets( // Model.ApplicationSettings settings, IUpdateServer server, RunSetCollection runSets, CommandLine commandLine, bool isTest) { // we need to work out which runset is being done // we'll limit the command line to one runset string requestedRunSet = commandLine.GetRunSetName(); RunSet requiredRunSet = runSets.Cast<RunSet>() .FirstOrDefault(runSet => requestedRunSet.Equals(runSet.Name, StringComparison.OrdinalIgnoreCase)); if (requiredRunSet == null) { throw new ArgumentException( "The RunSet '" + requestedRunSet + "' as requested on the command line is not defined in the app.config."); } DoRunSet(server, requiredRunSet, isTest); }
/// <summary> /// The execute. /// </summary> /// <exception cref="UnauthorizedAccessException"> /// </exception> /// <exception cref="InvalidOperationException"> /// </exception> public void Execute() { ShowHeader(); string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); if (!args.Any()) { ShowHelp(); return; } var commandLine = new CommandLine(args); if (commandLine.GetWantsHelp()) { ShowHelp(); return; } // todo: add support for job monitoring // Check config file ApplicationSettings settings = LoadSettings(); // Connect to server IUpdateServer server = Server.Connect(settings.Server); // Check user has admin access UpdateServerUserRole role = server.GetCurrentUserRole(); if (role != UpdateServerUserRole.Administrator) { throw new UnauthorizedAccessException("You don't have administrator access on the WSUS server."); } // Get the default rule bool isTest = commandLine.GetIsTest(); RunSetCollection runSets = settings.RunSets; switch (commandLine.GetUseRunSet()) { case TriState.Yes: if (runSets == null || runSets.Count == 0) { throw new InvalidOperationException( "/runset specified on the command line. But there are no runsets defined in the config file."); } // we have run sets // this means our approval logic is more complex DoRunSets(server, runSets, commandLine, isTest); break; case TriState.No: DoNoRunSets(settings, server, isTest); break; default: if (runSets != null && runSets.Count > 0) { throw new InvalidOperationException( "RunSets exist in the application config. /norunset or /runset must be specified on the command line."); } break; } }
public void RunSetCollectionConstructorTest() { RunSetCollection target = new RunSetCollection(); }
public void ItemTest() { RunSetCollection target = new RunSetCollection(); int index = 0; RunSet expected = new RunSet(); target.Add(expected); RunSet actual = target[index]; Assert.AreEqual(expected, actual); }