public void IList_Contains() { var array = new long[] { 1, 2, 3, 4, 5, 6, -10 }; IList <long> s = new ArraySegment <long> (array, 2, 3); Assert.IsFalse(s.Contains(2), "#1"); Assert.IsTrue(s.Contains(4), "#2"); }
protected override bool ExecuteParent(ArraySegment <string> arguments, ICommandSender sender, out string response) { if (sender.CheckPermission("ATC.main")) { if (arguments.Count == 0) { response = "You need to enter an argument\n<b>forcenextteam</b>\n<b>forceteam</b>\n<b>teamsalive</b>\n<b>reload</b>"; return(true); } else if (arguments.Contains("reload")) { if (sender.CheckPermission("ATC.reload")) { Instance.Config.LoadConfigs(); response = "Done"; return(true); } else { response = Instance.Translation.NoPermissions; return(false); } } else { response = "Invalid argument"; return(false); } } response = Instance.Translation.NoPermissions; return(false); }
public void IList_Contains () { var array = new long[] { 1, 2, 3, 4, 5, 6, -10 }; IList<long> s = new ArraySegment<long> (array, 2, 3); Assert.IsFalse (s.Contains (2), "#1"); Assert.IsTrue (s.Contains (4), "#2"); }
private static void OutputDifference(string[] FirstString, string[] SecondString) { if (FirstString == SecondString) { foreach (string word in FirstString) { string temp = word + " "; Console.Write(temp); WriteToLog(temp, true); } } else if ((FirstString.Length == 0) & (SecondString.Length != 0)) { Console.ForegroundColor = ConsoleColor.Green; foreach (string word in SecondString) { string temp = word + " "; Console.Write(temp); WriteToLog(temp + "(GREEN)", true); } Console.ResetColor(); } else if ((FirstString.Length != 0) & (SecondString.Length == 0)) { Console.ForegroundColor = ConsoleColor.Red; foreach (string word in FirstString) { string temp = word + " "; Console.Write(temp); WriteToLog(temp + "(RED)", true); } Console.ResetColor(); } else { string FirstWordFirstString = FirstString[0]; //Console.WriteLine($"WORD1: {FirstWordFirstString}"); string[] FirstRemaining = new ArraySegment <string>(FirstString, 1, FirstString.Length - 1).ToArray(); string FirstWordSecondString = SecondString[0]; //Console.WriteLine($"WORD2: {FirstWordSecondString}"); string[] SecondRemaining = new ArraySegment <string>(SecondString, 1, SecondString.Length - 1).ToArray(); bool FirstChecker = PresenceChecker(FirstRemaining, SecondString); //Console.WriteLine($"FirstChecker: {FirstChecker}"); bool SecondChecker = PresenceChecker(SecondRemaining, FirstString); //Console.WriteLine($"SecondChecker: {SecondChecker}"); if (FirstWordFirstString == FirstWordSecondString) { string temp = FirstWordFirstString + " "; Console.Write(temp); WriteToLog(temp, true); OutputDifference(FirstRemaining, SecondRemaining); } else if ((FirstWordFirstString != FirstWordSecondString) & (!(SecondRemaining.Contains(FirstWordFirstString)))) { Console.ForegroundColor = ConsoleColor.Red; string temp = FirstWordFirstString; Console.Write(temp + " "); WriteToLog(temp + "(RED)", true); Console.ResetColor(); OutputDifference(FirstRemaining, SecondString); } else if ((FirstWordFirstString != FirstWordSecondString) & (!(FirstRemaining.Contains(FirstWordSecondString)))) { Console.ForegroundColor = ConsoleColor.Green; string temp = FirstWordSecondString; Console.Write(temp + " "); WriteToLog(temp + "(GREEN)", true); Console.ResetColor(); OutputDifference(FirstString, SecondRemaining); } else if ((FirstWordFirstString != FirstWordSecondString) & (FirstChecker == true)) { Console.ForegroundColor = ConsoleColor.Green; string temp = FirstWordSecondString; Console.Write(temp + " "); WriteToLog(temp + "(GREEN)", true); // true = write; false = writeLINE Console.ResetColor(); OutputDifference(FirstString, SecondRemaining); } else if ((FirstWordFirstString != FirstWordSecondString) & (SecondChecker == true)) { Console.ForegroundColor = ConsoleColor.Green; string temp = FirstWordSecondString; Console.Write(temp + " "); WriteToLog(temp + "(GREEN)", true); // true = write; false = writeLINE Console.ResetColor(); OutputDifference(FirstString, SecondRemaining); } //else if (FirstWordFirstString != FirstWordSecondString) //DON'T FORGET TO ADD ADDING-TO-LOG LINES //{ // if((Match70 > 0)&(Match70 <= 2)) // { // if(FirstWordFirstString == SecondRemaining[0]) // { // Console.ForegroundColor = ConsoleColor.Green; // Console.Write(FirstWordSecondString + " "); // Console.ResetColor(); // OutputDifference(FirstString, SecondRemaining); // } // else if (FirstRemaining[0] == FirstWordSecondString) // { // Console.ForegroundColor = ConsoleColor.Red; // Console.Write(FirstWordFirstString + " "); // Console.ResetColor(); // OutputDifference(FirstRemaining, SecondString);////////////////// // } // } // else if (Match70 > 2) // { // Console.ForegroundColor = ConsoleColor.Green; // Console.Write(FirstWordSecondString + " "); // Console.ResetColor(); // OutputDifference(FirstString, SecondRemaining); // } // else // { // Console.ForegroundColor = ConsoleColor.Red; // Console.Write(FirstWordFirstString + " "); // Console.ResetColor(); // OutputDifference(FirstRemaining, SecondString); // } //} } }
public static void TestIList_Contains_Invalid() { IList <int> iList = new ArraySegment <int>(); Assert.Throws <InvalidOperationException>(() => iList.Contains(0)); // Array is null }
public static void TestIList_Contains_Invalid() { IList<int> iList = new ArraySegment<int>(); Assert.Throws<InvalidOperationException>(() => iList.Contains(0)); // Array is null }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { Player ply = Player.Get(((CommandSender)sender).Nickname); bool PlayerHasSwitched; EventHandlers.PlayerHasSwitched.TryGetValue(ply, out PlayerHasSwitched); IEnumerable <Player> PlayerList = Player.List.Where(x => x.Team == Team.SCP); if (arguments.Count < 1) { response = "Use the plugin like this: .switch {scp you want to switch to}"; return(false); } else if (!EventHandlers.RoundStarted) { response = "The round hasn't started."; return(false); } else if (ply.Team != Team.SCP) { response = "Only SCPs can use this command."; return(false); } else if (PlayerHasSwitched == true) { response = "You can only swap once."; } else if (!EventHandlers.CanSwitch) { response = "You can't switch anymore."; return(false); } else if (arguments.Contains("doctor") || arguments.Contains("doc") || arguments.Contains("49") || arguments.Contains("049")) { if (PlayerList.Where(x => x.Role == RoleType.Scp049).Count() < 1) { response = "Swapping to SCP-049"; Cassie.Message("Danger . SCP 0 4 9 containment breach detected ."); ply.SetRole(RoleType.Scp049); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else { response = "There's already an instance of SCP-049."; return(false); } } else if (arguments.Contains("pc") || arguments.Contains("computer") || arguments.Contains("79") || arguments.Contains("079")) { if (PlayerList.Where(x => x.Role == RoleType.Scp079).Count() < 1) { response = "Swapping to SCP-079"; Cassie.Message("Danger . SCP 0 7 9 containment breach detected ."); ply.SetRole(RoleType.Scp079); EventHandlers.PlayerHasSwitched.Add(ply, true); } else { response = "There's already an instance of SCP-079."; return(false); } } else if (arguments.Contains("shy") || arguments.Contains("guy") || arguments.Contains("shyguy") || arguments.Contains("96") || arguments.Contains("096")) { if (PlayerList.Where(x => x.Role == RoleType.Scp096).Count() < 1) { response = "Swapping to SCP-096"; Cassie.Message("Danger . SCP 0 9 6 containment breach detected ."); ply.SetRole(RoleType.Scp096); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else { response = "There's already an instance of SCP-096."; return(false); } } else if (arguments.Contains("peanut") || arguments.Contains("nut") || arguments.Contains("173")) { if (PlayerList.Where(x => x.Role == RoleType.Scp173).Count() < 1) { response = "Swapping to SCP-173"; Cassie.Message("Danger . SCP 1 7 3 containment breach detected ."); ply.SetRole(RoleType.Scp173); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else { response = "There's already an instance of SCP-173."; return(false); } } else if (arguments.Contains("larry") || arguments.Contains("old") || arguments.Contains("man") || arguments.Contains("106")) { if (PlayerList.Where(x => x.Role == RoleType.Scp106).Count() < 1) { response = "Swapping to SCP-106"; Cassie.Message("Danger . SCP 1 0 6 containment breach detected ."); ply.SetRole(RoleType.Scp106); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else { response = "There's already an instance of SCP-106."; return(false); } } else if (arguments.Contains("dog") || arguments.Contains("939")) { if (PlayerList.Where(x => x.Role == RoleType.Scp93953).Count() < 1) { response = "Swapping to SCP-939-53"; Cassie.Message("Danger . SCP 9 3 9 5 3 containment breach detected ."); ply.SetRole(RoleType.Scp93953); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else if (PlayerList.Where(x => x.Role == RoleType.Scp93989).Count() < 1) { response = "Swapping to SCP-939-89"; Cassie.Message("Danger . SCP 9 3 9 8 9 containment breach detected ."); ply.SetRole(RoleType.Scp93989); EventHandlers.PlayerHasSwitched.Add(ply, true); FreezePlayer(ply); } else { response = "There's already two instances of SCP-939."; return(false); } } else { response = "SCP not found, did you put the name / number in correctly? the plugin only works in all lowercase."; return(false); } return(true); }