public void BlockedOrganization_NoDuplicates() { const string DbFileName = "_BlockedOrganization_NoDuplicates_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.BlockedOrganizations.Add( new BlockedOrganization() { OrganizationName = "Fox News" }); dbcontext.BlockedOrganizations.Add( new BlockedOrganization() { OrganizationName = "Fox News" }); try { dbcontext.SaveChanges(); Assert.Fail("Database allowed duplicate BlockedOrganizations"); } catch (DbUpdateException) { } }
public void KeyValuePair_NoDuplicates() { const string DbFileName = "_KeyValuePair_NoDuplicates_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.KeyValuePairs.Add( new KeyValuePair() { Key = "testkey", Value = "testvalue" }); dbcontext.KeyValuePairs.Add( new KeyValuePair() { Key = "testkey", Value = "testvalue2" }); try { dbcontext.SaveChanges(); Assert.Fail("Database allowed duplicate KeyValuePairs"); } catch (DbUpdateException) { } }
public void SearchTerm_NoDuplicate() { const string DbFileName = "_SearchTerm_NoDuplicate_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.SearchTerms.Add( new SearchTerm() { SearchTermText = "climate change" }); dbcontext.SearchTerms.Add( new SearchTerm() { SearchTermText = "climate change" }); try { dbcontext.SaveChanges(); Assert.Fail("Database allowed duplicate SearchTerms"); } catch (DbUpdateException) { } }
public void BlockedTitleMatcher_NoDuplicates() { const string DbFileName = "_BlockedTitleMatcher_NoDuplicates_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.BlockedTitleMatchers.Add( new BlockedTitleMatcher("indicted")); dbcontext.BlockedTitleMatchers.Add( new BlockedTitleMatcher("indicted")); try { dbcontext.SaveChanges(); Assert.Fail("Database allowed duplicate BlockedTitleMatchers"); } catch (DbUpdateException) { } }
public void BlockedOrganization_Adds() { const string DbFileName = "_BlockedOrganization_Adds_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.BlockedOrganizations.Add( new BlockedOrganization() { OrganizationName = "CNN" }); dbcontext.SaveChanges(); DatabaseContext dbcontext2 = DbTestHelpers.CreateContext(DbFileName); var blocked_orgs = dbcontext2.BlockedOrganizations.ToList(); Assert.AreEqual(1, blocked_orgs.Count); Assert.AreEqual("CNN", blocked_orgs.First().OrganizationName); }
public void BlockedTitleMatcher_Adds() { const string DbFileName = "_BlockedTitleMatcher_Adds_test.sqlite"; File.Delete(DbFileName); string regex = "Cops:"; DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.BlockedTitleMatchers.Add( new BlockedTitleMatcher(regex)); dbcontext.SaveChanges(); DatabaseContext dbcontext2 = DbTestHelpers.CreateContext(DbFileName); var blocked_title_matchers = dbcontext2.BlockedTitleMatchers.ToList(); Assert.AreEqual(1, blocked_title_matchers.Count); Assert.AreEqual(regex, blocked_title_matchers.First().RegexText); }
public void NewsArticle_Adds() { const string DbFileName = "NewsArticle_Adds_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.NewsArticles.Add( new NewsArticle() { Title = "test title" }); dbcontext.SaveChanges(); DatabaseContext dbcontext2 = DbTestHelpers.CreateContext(DbFileName); var articles = dbcontext2.NewsArticles.ToList(); Assert.AreEqual(1, articles.Count); Assert.AreEqual("test title", articles.First().Title); }
public void KeyValuePair_Adds() { const string DbFileName = "_KeyValuePair_Adds_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.KeyValuePairs.Add( new KeyValuePair() { Key = "testkey", Value = "testvalue" }); dbcontext.SaveChanges(); DatabaseContext dbcontext2 = DbTestHelpers.CreateContext(DbFileName); var kvps = dbcontext2.KeyValuePairs.ToList(); Assert.AreEqual(1, kvps.Count); Assert.AreEqual("testkey", kvps.First().Key); }
public void SearchTerm_Adds() { const string DbFileName = "_SearchTerm_Adds_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.SearchTerms.Add( new SearchTerm() { SearchTermText = "climate change" }); dbcontext.SaveChanges(); DatabaseContext dbcontext2 = DbTestHelpers.CreateContext(DbFileName); var search_terms = dbcontext2.SearchTerms.ToList(); Assert.AreEqual(1, search_terms.Count); Assert.AreEqual("climate change", search_terms.First().SearchTermText); }
public void NewsArticle_NoDuplicateUrls() { const string DbFileName = "_NewsArticle_NoDuplicates_test.sqlite"; File.Delete(DbFileName); DatabaseContext dbcontext = DbTestHelpers.CreateContext(DbFileName); dbcontext.NewsArticles.Add( new NewsArticle( "Test title", "CNN", "https://cnn.com/", DateTime.MinValue)); dbcontext.NewsArticles.Add( new NewsArticle( "Test title", "CNN", "https://cnn.com/", DateTime.Now)); try { dbcontext.SaveChanges(); Assert.Fail("Database allowed duplicate NewsArticle URLs"); } catch (DbUpdateException) { } }