public void InsertResult() { var category = new PollCategory() { PollCategoryID = Guid.NewGuid(), Region = "Zimbabwae", ServerCategory = "Something awesome" }; var db = new UptimeDB(); db.PollCategories.Add(category); var value = new PollCategoryValue() { CategoryID = category.PollCategoryID, CreatedTime = DateTime.Now, Status = PollStatusType.Up }; db.PollCategoryValue.Add(value); var totalInserted = db.SaveChanges(); Assert.AreEqual(2, totalInserted); db.PollCategoryValue.Remove(value); db.PollCategories.Remove(category); db.SaveChanges(); }
private void ParseRegionElement(HtmlNode region) { var regionTitle = region.SelectSingleNode("h2").InnerText; foreach (var server in region.SelectNodes(".//div[@class=\"server\" or @class=\"server alt\"]")) { var serverName = server.SelectSingleNode(".//div[@class=\"server-name\"]").InnerText.Trim(); var pollCategoryValue = new PollCategoryValue(); var possibleCategoryMatch = Categories.FirstOrDefault(p => string.Compare(p.Region, regionTitle, true) == 0 && string.Compare(p.ServerCategory, serverName) == 0); if (possibleCategoryMatch == null) continue; pollCategoryValue.CategoryID = possibleCategoryMatch.PollCategoryID; pollCategoryValue.Status = PollStatusType.Unknown; pollCategoryValue.CreatedTime = DateTime.Now; foreach (var div in server.SelectNodes("div")) { if (div.OuterHtml.Contains("status-icon")) { pollCategoryValue.Status = div.OuterHtml.Contains("status-icon up") ? PollStatusType.Up : PollStatusType.Down; } } DB.InsertPollCategoryValue(pollCategoryValue); } }
public PollCategoryValueJSON(PollCategoryValue value) { _value = value; }
public void InsertPollCategoryValue(PollCategoryValue pollCategoryValue) { this.PollCategoryValue.Add(pollCategoryValue); }