public void PersistentCollectionsShouldBeUniquelyIdentifiedByFileName( ) { using (var first = MakeList <int> ( )) using (var second = MakeList <int> ( )) { Assert.AreSame(first, second); Assert.Throws <InvalidCastException> (() => MakeList <string> ( )); Assert.Throws <InvalidCastException> (() => PersistentSet <char> .Build(ListFileName)); Assert.DoesNotThrow(() => MakeSet <string> ( )?.Dispose( )); Assert.DoesNotThrow(() => MakeDictionary <string, string> ( )?.Dispose( )); } }
public TelegramBotData( ) { Users = PersistentSet <User> .Build( Path.Combine(FolderName, "TelegramBotUsers.json")); UserRoles = PersistentDictionary <int, UserRole> .Build( Path.Combine(FolderName, "TelegramUserRoles.json")); PercentChangeSubscriptions = PersistentSet <TelegramPercentChangeSubscription> .Build( Path.Combine(FolderName, "TelegramPercentChangeSubscriptions.json")); collections = new List <IPersistentCollection> { Users, UserRoles, PercentChangeSubscriptions }; foreach (var collection in collections) { collection.OnError += OnError; } }
private static PersistentSet <T> MakeSet <T> ( ) => PersistentSet <T> .Build(SetFileName);