/// <summary> /// The main test method. /// </summary> public static void Test() { SqlCeArchivist archivist = new SqlCeArchivist("db.sdf"); archivist.Open(); archivist.TruncateData(); string dataDir = @"C:\Users\mads\Desktop\data"; DBSeeder.SeedDatabaseWithNews(archivist, dataDir, 500); // Mark sports category as interesting, business as uninteresting. List<Category> categories = archivist.GetCategories(); archivist.MarkCategoryInteresting(categories.First(p => p.Name.Equals("sports")), true); archivist.MarkCategoryInteresting(categories.First(p => p.Name.Equals("business")), false); _random = new Random(42); // Generate lists of news items. List<NewsMaterial> interestingNews = new List<NewsMaterial>(); for (int i = 0; i < 500; i++) { interestingNews.Add(GenerateNewsMaterial(true)); } List<NewsMaterial> uninterestingNews = new List<NewsMaterial>(); for (int i = 0; i < 500; i++) { uninterestingNews.Add(GenerateNewsMaterial(false)); } // Add news to db and save ids. List<int> interestingNewsIds = archivist.AddNews(interestingNews); List<int> uninterestingNewsIds = archivist.AddNews(uninterestingNews); List<int> allNewsIds = new List<int>(interestingNewsIds); allNewsIds.AddRange(uninterestingNewsIds); // Get news to filter. NewsQuery query = new NewsQuery(); query.Read = ReadStatus.Unread; List<NewsItem> news = archivist.GetNews(query); // Filter news. InterestFilter filter = new InterestFilter(); news = filter.Filter(archivist, news); int correctCount = 0; int falseCount = 0; // Compare ids and count number of correct values. foreach (NewsItem item in news) { if (interestingNewsIds.Contains(item.Id)) { correctCount++; } else if (uninterestingNewsIds.Contains(item.Id)) { falseCount++; } } Console.WriteLine("Through filter: {0}", news.Count); Console.WriteLine("False positive count: {0}", falseCount); // Print result in console. Console.WriteLine("{0}/{1}={2}%", correctCount, interestingNews.Count, (double) correctCount / (interestingNews.Count) * 100.0); Console.ReadLine(); }