public static void Setup() { BsonMapper.Global.RegisterType( serialize: entity => ParticipantLapTimes.ToBson(entity), deserialize: bson => ParticipantLapTimes.FromBson(bson)); BsonMapper.Global.RegisterType( serialize: entity => SessionEntry.ToBson(entity), deserialize: bson => SessionEntry.FromBson(bson)); BsonMapper.Global.RegisterType( serialize: entity => SessionTrackInfo.ToBson(entity), deserialize: bson => SessionTrackInfo.FromBson(bson)); }
[Test] public void StoreRetrieveLapTimes() { var lapTimeDic = new Dictionary <int, ParticipantLapTime> { { 0, new ParticipantLapTime(1, 2, 3, 4) }, { 1, new ParticipantLapTime(0.123, 0.456, 0.789, 1) } }; var lapTimes = new ParticipantLapTimes(Key.Create(), Key.Create(), SessionType.Practice, 0, lapTimeDic); var db = new LiteDatabase("test.db"); var store = new CollectionStore <ParticipantLapTimes>(db); store.DeleteAll(); store.Store(lapTimes); var result = store.LoadAll().First(); Assert.AreEqual(result.Id, lapTimes.Id); Assert.AreEqual(result.participantIndex, lapTimes.participantIndex); CollectionAssert.AreEqual(result.lapTimes.ToArray(), lapTimes.lapTimes.ToArray()); }