Пример #1
0
        public void AddAllRecords()
        {
            using (var file = new TempFile())
                using (var db = new LiteDbAdapter(file.Filename))
                {
                    foreach (var match in matches)
                    {
                        db.AddMatchInfo(match);
                    }

                    foreach (var match in matches)
                    {
                        var x = db.GetMatches().First(m => m.endpoint == match.endpoint && m.timestamp == match.timestamp);
                        var y = db.GetMatches(match.endpoint).First(m => m.timestamp == match.timestamp);
                        var z = db.GetMatchInfo(match.endpoint, match.timestamp);
                        match.ShouldBeEquivalentTo(x);
                        match.ShouldBeEquivalentTo(y);
                        match.ShouldBeEquivalentTo(z);
                    }
                }
        }
Пример #2
0
 public void AddAllRecords_Parallel()
 {
     for (var i = 0; i < 100; i++)
     {
         using (var file = new TempFile())
             using (var db = new LiteDbAdapter(file.Filename))
             {
                 Parallel.ForEach(matches, match =>
                 {
                     var rnd = new Random();
                     Thread.Sleep(rnd.Next(100));
                     db.AddMatchInfo(match);
                     Thread.Sleep(rnd.Next(100));
                     var x = db.GetMatches().First(m => m.endpoint == match.endpoint && m.timestamp == match.timestamp);
                     var y = db.GetMatches(match.endpoint).First(m => m.timestamp == match.timestamp);
                     var z = db.GetMatchInfo(match.endpoint, match.timestamp);
                     match.ShouldBeEquivalentTo(x);
                     match.ShouldBeEquivalentTo(y);
                     match.ShouldBeEquivalentTo(z);
                 });
             }
     }
 }