Esempio n. 1
0
        public void Simple_performance_check()
        {
            const string BBFILENAME = "perftest.db3";
            if (File.Exists(BBFILENAME)) File.Delete(BBFILENAME);
            using (var bb = new SQliteBlackBox(BBFILENAME))
            {
                var sw = Stopwatch.StartNew();
                bb.Record(Create_many_events());
                sw.Stop();
                Console.WriteLine("Created in {0}", sw.Elapsed);

                sw.Restart();
                var cards = bb.Player.Play().ToList();
                sw.Stop();
                Console.WriteLine("Loaded {0} events in {1}", cards.Count, sw.Elapsed);
                Assert.IsTrue(true);
            }
        }
Esempio n. 2
0
        public void Acceptance()
        {
            const string BBFILENAME = "testbb.db3";

            if (File.Exists(BBFILENAME)) File.Delete(BBFILENAME);
            using (var sut = new SQliteBlackBox(BBFILENAME))
            {
                var recorded = new List<IRecordedEvent>();
                sut.OnRecorded += recorded.Add;

                sut.Record("a", "1", "d1");
                sut.Record("a", "2", "d2");
                sut.Record("b", "2", "d3");
                sut.Record("a", "3", "d4");

                Assert.AreEqual(4, recorded.Count);

                recorded = sut.Player.Play().ToList();
                Assert.AreEqual(4, recorded.Count);
                Assert.AreEqual(new[] { "000000000001", "000000000002", "000000000003", "000000000004" },
                                recorded.Select(r => r.Sequencenumber).ToArray());
                Assert.AreEqual(new[] {"d1", "d2", "d3", "d4"}, recorded.Select(r => r.Data).ToArray());

                recorded = sut.Player.ForEvent("a").Play().ToList();
                Assert.AreEqual(3, recorded.Count);

                recorded = sut.Player.WithContext("2").Play().ToList();
                Assert.AreEqual(2, recorded.Count);

                recorded = sut.Player.WithContext("1", "3").Play().ToList();
                Assert.AreEqual(2, recorded.Count);

                recorded = sut.Player.ForEvent("a").WithContext("2").Play().ToList();
                Assert.AreEqual(1, recorded.Count);

                recorded = sut.Player.FromSequenceNumber("000000000003").Play().ToList();
                Assert.AreEqual(2, recorded.Count);
            }
        }