public void TestPrisonFilesystemListCellInstances() { using (ShimsContext.Create()) { Prison prison = new Prison(); prison.Tag = "uhtst"; Dictionary <RuleType, RuleInstanceInfo[]> rules = Prison.ListCellInstances(); Assert.IsTrue(rules[RuleType.Filesystem].Length == 0); } }
public void TestPrisonNetworkListCellInstances() { using (ShimsContext.Create()) { string username = "******"; PrisonTestsHelper.ListNetworkRuleFakes(username); Prison prison = new Prison(); prison.Tag = "uhtst"; Dictionary <RuleType, RuleInstanceInfo[]> rules = Prison.ListCellInstances(); Assert.AreEqual(username, rules[RuleType.Network][0].Name); } }
public void TestPrisonHttpsysListCellInstances() { using (ShimsContext.Create()) { PrisonTestsHelper.ListHttpsysRuleFakes(); Prison prison = new Prison(); prison.Tag = "uhtst"; Dictionary <RuleType, RuleInstanceInfo[]> rules = Prison.ListCellInstances(); Assert.AreEqual(1, rules[RuleType.Httpsys].Length); foreach (var url in rules[RuleType.Httpsys]) { Assert.IsTrue(url.Name.Contains(prison.Tag)); } } }
public void TestPrisonWindowStationkListCellInstances() { using (ShimsContext.Create()) { var fakedStations = new List <string>() { "WinSta0", "WinStaLalala" }; PrisonTestsHelper.ListWindowStationRuleFakes(fakedStations); Prison prison = new Prison(); prison.Tag = "uhtst"; Dictionary <RuleType, RuleInstanceInfo[]> rules = Prison.ListCellInstances(); Assert.AreEqual(fakedStations.Count, rules[RuleType.WindowStation].Length); foreach (var wstation in rules[RuleType.WindowStation]) { Assert.IsTrue(fakedStations.Contains(wstation.Name)); } } }
static void Main(string[] args) { string invokedVerb = null; object invokedVerbInstance = null; var options = new Options(); if (!CommandLine.Parser.Default.ParseArguments(args, options, (verb, subOptions) => { // if parsing succeeds the verb name and correct instance // will be passed to onVerbCommand delegate (string,object) invokedVerb = verb; invokedVerbInstance = subOptions; })) { Environment.Exit(CommandLine.Parser.DefaultExitCodeFail); } if (invokedVerb == "list") { var listSubOptions = (ListSubOptions)invokedVerbInstance; if (listSubOptions.Orphaned) { Dictionary <CellType, CellInstanceInfo[]> instances = Prison.ListCellInstances(); foreach (CellType cellType in instances.Keys) { TableBuilder tb = new TableBuilder(); tb.AddRow(cellType.ToString(), "Info"); tb.AddRow(new string('-', cellType.ToString().Length), "----"); foreach (CellInstanceInfo cellInstance in instances[cellType]) { tb.AddRow(cellInstance.Name, cellInstance.Info); } Console.Write(tb.Output()); Console.WriteLine(); } } } else if (invokedVerb == "list-users") { var listUsersSubOptions = (ListUsersSubOptions)invokedVerbInstance; if (string.IsNullOrWhiteSpace(listUsersSubOptions.Filter)) { PrisonUser[] users = PrisonUser.ListUsers(); TableBuilder tb = new TableBuilder(); tb.AddRow("Full Username", "Prefix"); tb.AddRow("-------------", "------"); foreach (PrisonUser user in users) { tb.AddRow(user.Username, user.UsernamePrefix); } Console.Write(tb.Output()); Console.WriteLine(); } } }