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 Int64[] { 0, 1, 2, 3 }, recorded.Select(r => r.Index).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.FromIndex(2).Play().ToList(); Assert.AreEqual(2, recorded.Count); } }
public void StoreTest() { var bb = new SqliteBlackBox("TestStore.db3"); var sw = Stopwatch.StartNew(); bb.Record(CreateRecords()); sw.Stop(); Console.WriteLine("Created in {0}", sw.Elapsed); sw.Restart(); var cards = bb.Player.Play().ToList(); sw.Stop(); Console.WriteLine("Loaded in {0}", sw.Elapsed); Assert.IsTrue(true); }