public void RandomTest()
        {
            _context.Add(new DictionaryEntry()
            {
                Lemma      = "BabyPoeder",
                Definition = "Poeder voor baby's"
            });
            _context.SaveChanges();
            var entry = controller.Random().Value;

            Assert.AreEqual(entry.Lemma, "BabyPoeder");
        }
示例#2
0
        static void AddInitial()
        {
            var optionsBuilder = new DbContextOptionsBuilder <DictionaryContext>();

            optionsBuilder.UseSqlite("Data source=dict.db");
            var _context = new DictionaryContext(optionsBuilder.Options);

            using (var inputStream = new FileStream(@"Seeder\dictionary.dsl", FileMode.Open))
            {
                Parser p       = new Parser(inputStream);
                var    entries = p.ParseEntries();
                int    cnt     = 0;
                foreach (var entry in entries)
                {
                    _context.Add(entry);
                    Console.WriteLine($"Add {entry.Lemma}");
                    if (cnt % 1000 == 0)
                    {
                        _context.SaveChanges();
                    }
                    cnt++;
                }
                _context.SaveChanges();
            };
        }