public ITestProperty AssertSetObjectIsValid(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsFalse(field.ReturnSpec.IsParseable, "Drop(..) not allowed on value target field; use SetValue(..) instead"); INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't drop a {0} on to the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec)); INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject; IConsent valid; var spec = field as IOneToOneAssociationSpec; if (spec != null) { valid = spec.IsAssociationValid(nakedObjectAdapter, testNakedObjectAdapter); } else if (field is IOneToManyAssociationSpec) { valid = new Veto("Always disabled"); } else { throw new UnknownTypeException(field); } LastMessage = valid.Reason; Assert.IsFalse(valid.IsVetoed, string.Format("Cannot SetObject {0} in the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason)); return(this); }
public ITestProperty RemoveFromCollection(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsTrue(field is IOneToManyAssociationSpec, "Cannot remove from non collection"); var testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), $"Can't clear a {testObject.NakedObject.Spec.ShortName} from the {Name} field (which accepts {field.ReturnSpec})"); var nakedObjectAdapter = owningObject.NakedObject; if (!(field is IOneToManyAssociationSpec)) { throw new UnknownTypeException(field); } IConsent valid = new Veto("Always disabled"); Assert.IsFalse(valid.IsVetoed, $"Can't remove {testNakedObjectAdapter} from the field {field} within {nakedObjectAdapter}: {valid.Reason}"); return(this); }
public void Regex_Matches() { Veto veto = "/^C/"; var act = veto.Pattern.IsMatch("Corniel"); var exp = true; Assert.AreEqual(exp, act); }
//Make the veto json public static string MakeVetoJson(IList typeItems, List <VotingTypes> types) { Playlist p = new Playlist(); List <Veto> vList = new List <Veto>(); var t = typeItems; //Go through each selected item in the list foreach (ListBoxItem x in t) { Veto v = new Veto(); v.gametype.displayName = x.Content.ToString(); v.gametype.typeName = x.Content.ToString(); //Check if they match with any of the types in this.types foreach (VotingTypes y in types) { //If they do, do things if (y.displayName == v.gametype.displayName && y.typeName == v.gametype.typeName) { //Add commands to the veto v.gametype.commands = y.commands; foreach (Maps m in y.SpecificMaps) { //If a map in the list = a default map or not if (Defaults.defaultMaps.ContainsKey(m.displayName)) { v.map.displayName = m.displayName; v.map.mapName = Defaults.defaultMaps[m.displayName]; } else { v.map.displayName = m.displayName; v.map.mapName = m.displayName; } vList.Add(v); } } } } p.playlist = vList; if (vList.Count < 2) { MessageBox.Show("You need at least 2 gametypes selected."); } if (types.Count >= 2) { MessageBox.Show("No maps selected. Making a veto.json instead."); } return(JsonConvert.SerializeObject(p, Formatting.Indented)); }
//Grabs cards and hides them all. void Start() { //Grab all cards and place into array and hides them all cards = new GameObject[numCards]; for (int i = 0; i < numCards; i++) { cards[i] = GameObject.Find("Policy Card Fascist #" + (i + 1)); cards[i].GetComponent <Renderer>().enabled = false; } //Allows access to Functions/Methods from these Scripts Veto = GameObject.Find("VetoHolder").GetComponent <Veto>(); }
public IConsentFacade IsValid(IObjectFacade target, object value) { var t = ((ObjectFacade)target).WrappedNakedObject; IConsent consent; try { var v = GetValue(this, value); consent = WrappedSpec.IsValid(t, v); } catch (InvalidEntryException) { consent = new Veto(Resources.NakedObjects.InvalidEntry); } catch (Exception e) { consent = new Veto(e.Message); } return(new ConsentFacade(consent)); }
public IConsentFacade IsValid(IObjectFacade target, object value) { var t = ((ObjectFacade)target).WrappedNakedObject; IConsent consent; try { var v = GetValue(this, value); consent = nakedObjectActionParameter.IsValid(t, v); } catch (InvalidEntryException) { consent = new Veto("Invalid Entry"); // todo i18n } catch (Exception e) { consent = new Veto(e.Message); // todo i18n } return(new ConsentFacade(consent)); }
public ActionResult DoVeto(string ID, VetoViewModel form) { if (ID == null || form.veto.Comment == null) { return(RedirectToAction("Error", "Admin")); } TeacherRewardEntities db = new TeacherRewardEntities(); Veto newVeto = new Veto(); newVeto.ID = ID; newVeto.Comment = form.veto.Comment; try { db.Veto.Add(newVeto); db.SaveChanges(); return(RedirectToAction("ShowVeto", "Admin")); } catch (Exception) { return(RedirectToAction("Error", "Admin")); } }
public ITestProperty RemoveFromCollection(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsTrue(field is IOneToManyAssociationSpec, "Cannot remove from non collection"); INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't clear a {0} from the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec)); INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject; if (!(field is IOneToManyAssociationSpec)) { throw new UnknownTypeException(field); } IConsent valid = new Veto("Always disabled"); Assert.IsFalse(valid.IsVetoed, string.Format("Can't remove {0} from the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason)); return(this); }
public ITestProperty SetObject(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsFalse(field.ReturnSpec.IsParseable, "Drop(..) not allowed on value target field; use SetValue(..) instead"); INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't drop a {0} on to the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec)); INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject; IConsent valid; var associationSpec = field as IOneToOneAssociationSpec; if (associationSpec != null) { valid = associationSpec.IsAssociationValid(nakedObjectAdapter, testNakedObjectAdapter); } else if (field is IOneToManyAssociationSpec) { valid = new Veto("Always disabled"); } else { throw new UnknownTypeException(field); } LastMessage = valid.Reason; Assert.IsFalse(valid.IsVetoed, string.Format("Cannot SetObject {0} in the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason)); var spec = field as IOneToOneAssociationSpec; if (spec != null) { spec.SetAssociation(nakedObjectAdapter, testNakedObjectAdapter); } return this; }
public ITestProperty RemoveFromCollection(ITestObject testObject) { AssertIsVisible(); AssertIsModifiable(); ResetLastMessage(); Assert.IsTrue(field is IOneToManyAssociationSpec, "Cannot remove from non collection"); INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject; Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't clear a {0} from the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec)); INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject; if (!(field is IOneToManyAssociationSpec)) { throw new UnknownTypeException(field); } IConsent valid = new Veto("Always disabled"); Assert.IsFalse(valid.IsVetoed, string.Format("Can't remove {0} from the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason)); return this; }
private static FullMatch ParseMatchPage(Task <HttpResponseMessage> response, int id = 0) { var content = response.Result.Content; string htmlContent = content.ReadAsStringAsync().Result; HtmlDocument html = new HtmlDocument(); html.LoadHtml(htmlContent); HtmlNode document = html.DocumentNode; FullMatch model = new FullMatch(); model.Id = id; //Match date long date = long.Parse(document.QuerySelector(".timeAndEvent .date").Attributes["data-unix"].Value); model.Date = DateTimeFromUnixTimestampMillis(date); //Match format try { string preformattedText = document.QuerySelector(".preformatted-text").InnerText; model.Format = preformattedText.Split('\n', StringSplitOptions.RemoveEmptyEntries).First(); model.AdditionalInfo = preformattedText.Substring(preformattedText.IndexOf('\n') + 1); } catch (Exception) { model.Format = "Best of 1"; } //Team 1 Team team1 = new Team(); team1.Id = int.Parse(document.QuerySelectorAll(".team img.logo").First().Attributes["src"].Value.Split('/').Last()); team1.Name = document.QuerySelectorAll(".team img.logo").First().Attributes["title"].Value; model.Team1 = team1; //Team 2 Team team2 = new Team(); team2.Id = int.Parse(document.QuerySelectorAll(".team img.logo").Last().Attributes["src"].Value.Split('/').Last()); team2.Name = document.QuerySelectorAll(".team img.logo").Last().Attributes["title"].Value; model.Team2 = team2; //Winning team if (document.QuerySelector(".team1-gradient > div").HasClass("won")) { model.WinningTeam = team1; } if (document.QuerySelector(".team2-gradient > div").HasClass("won")) { model.WinningTeam = team2; } //Event Event matchEvent = new Event(); matchEvent.Name = document.QuerySelector(".timeAndEvent .event a").Attributes["title"].Value; matchEvent.Id = int.Parse(document.QuerySelector(".timeAndEvent .event a").Attributes["href"].Value.Split('/', StringSplitOptions.RemoveEmptyEntries)[1]); model.Event = matchEvent; //Maps var mapHolderNodes = document.QuerySelectorAll(".mapholder"); List <MapResult> mapResults = new List <MapResult>(); foreach (var mapHolderNode in mapHolderNodes) { MapResult mapResult = new MapResult(); mapResult.Name = mapHolderNode.QuerySelector(".mapname").InnerText; var resultsNode = mapHolderNode.QuerySelector(".results"); var scoreNodes = resultsNode.QuerySelectorAll(".results-team-score").ToList(); if (scoreNodes.Count > 0 && scoreNodes[0].InnerText != "-") { mapResult.Team1Score = int.Parse(scoreNodes[0].InnerText); mapResult.Team2Score = int.Parse(scoreNodes[1].InnerText); if (mapHolderNode.QuerySelector(".results-stats") != null) { mapResult.StatsId = int.Parse(mapHolderNode.QuerySelector(".results-stats").Attributes["href"].Value.Split('/', StringSplitOptions.RemoveEmptyEntries)[3]); } } mapResults.Add(mapResult); } model.Maps = mapResults.ToArray(); //Demos var demoNodes = document.QuerySelectorAll(".stream-box").Where(node => node.Attributes["data-stream-embed"] == null); List <Demo> demos = new List <Demo>(); foreach (var demoNode in demoNodes) { if (demoNode.QuerySelector("a") == null || !demoNode.QuerySelector("a").Attributes.Contains("href")) { continue; } Demo demo = new Demo(); string demoDownloadUrl = "https://www.hltv.org" + demoNode.QuerySelector("a").Attributes["href"].Value; demo.Name = demoNode.QuerySelector("a").InnerText; demo.Url = GetDemoDirectDownloadUrl(demoDownloadUrl); demos.Add(demo); } model.Demos = demos.ToArray(); //Veto var vetoNodes = document.QuerySelectorAll(".veto-box .padding > div"); List <Veto> vetos = new List <Veto>(); foreach (var vetoNode in vetoNodes) { Veto veto = new Veto(); string cleanVeto = Regex.Replace(vetoNode.InnerText.Trim(), @"^\d.", "").Trim(); bool containsPicked = vetoNode.InnerText.ToLower().Contains("picked"); bool containsRemoved = vetoNode.InnerText.ToLower().Contains("removed"); string teamName = ""; string mapName = ""; string action = containsPicked ? "picked" : "removed"; if (containsPicked) { teamName = cleanVeto.Split(" picked ")[0]; mapName = cleanVeto.Split(" picked ")[1]; } if (containsRemoved) { teamName = cleanVeto.Split(" removed ")[0]; mapName = cleanVeto.Split(" removed ")[1]; } if (mapName == "" || teamName == "") { mapName = cleanVeto.Split(" ", StringSplitOptions.RemoveEmptyEntries)[0]; action = "other"; } if (teamName != "") { veto.Team = team1.Name == teamName ? team1 : team2; } veto.Map = mapName; veto.Action = action; vetos.Add(veto); } model.Vetos = vetos.ToArray(); //Team 1 players var team1PlayersHolderNode = document.QuerySelectorAll("div.players").First(); var team1PlayersFlagAllignNodes = team1PlayersHolderNode.QuerySelectorAll(".flagAlign"); List <Player> team1Players = new List <Player>(); foreach (var flagAllignNode in team1PlayersFlagAllignNodes) { Player player = new Player(); player.Name = flagAllignNode.QuerySelector(".text-ellipsis").InnerText; if (flagAllignNode.ParentNode.Attributes["href"] != null && flagAllignNode.ParentNode.Attributes["href"].Value != null) { player.Id = int.Parse(flagAllignNode.ParentNode.Attributes["href"].Value.Split('/', StringSplitOptions.RemoveEmptyEntries)[1]); } team1Players.Add(player); } model.Team1Players = team1Players.ToArray(); //Team 2 players var team2PlayersHolderNode = document.QuerySelectorAll("div.players").Last(); var team2PlayersFlagAllignNodes = team2PlayersHolderNode.QuerySelectorAll(".flagAlign"); List <Player> team2Players = new List <Player>(); foreach (var flagAllignNode in team2PlayersFlagAllignNodes) { Player player = new Player(); player.Name = flagAllignNode.QuerySelector(".text-ellipsis").InnerText; if (flagAllignNode.ParentNode.Attributes["href"] != null && flagAllignNode.ParentNode.Attributes["href"].Value != null) { player.Id = int.Parse(flagAllignNode.ParentNode.Attributes["href"].Value.Split('/', StringSplitOptions.RemoveEmptyEntries)[1]); } team2Players.Add(player); } model.Team2Players = team2Players.ToArray(); return(model); }
public IConsentFacade IsValid(IObjectFacade target, object value) { var t = ((ObjectFacade) target).WrappedNakedObject; IConsent consent; try { var v = GetValue(this, value); consent = nakedObjectActionParameter.IsValid(t, v); } catch (InvalidEntryException) { consent = new Veto("Invalid Entry"); // todo i18n } catch (Exception e) { consent = new Veto(e.Message); // todo i18n } return new ConsentFacade(consent); }
public IConsentFacade IsValid(IObjectFacade target, object value) { var t = ((ObjectFacade) target).WrappedNakedObject; IConsent consent; try { var v = GetValue(this, value); consent = WrappedSpec.IsValid(t, v); } catch (InvalidEntryException) { consent = new Veto(Resources.NakedObjects.InvalidEntry); } catch (Exception e) { consent = new Veto(e.Message); } return new ConsentFacade(consent); }