public void GetAllTest() { IStoreRepository repository = new FileStoreRepository(); IEnumerable <Store> stores = repository.GetAll(); Assert.NotEmpty(stores); }
public void GetListOfStoresNamesTest() { IStoreRepository repository = new FileStoreRepository(); IEnumerable <string> stores = repository.GetlistofStoresNames(); Assert.NotEmpty(stores); }
private void AddCacheItems() { var items = FileStoreRepository.ListItems().OrderBy(l => l.Key).ToList(); comboCache.Items.Clear(); comboCache.Items.Add(string.Empty); comboCache.Items.AddRange(items.Select(i => i.Value).ToArray()); }
public void Repository_FileStoreRepository_ListItems_Test() { var target = FileStoreRepository.ListItems(); Assert.IsTrue(target.Count > 0); var keys = target.Keys.ToArray(); var specificObject = new FileStore(); Assert.IsTrue(keys.Contains(specificObject.Name)); }
public void GetOneStoresProductsTest() { IStoreRepository repository = new FileStoreRepository(); Store store = new Store(); store.Name = "Coop"; //Coop store already exists in database. var store1 = repository.GetOneStoreProducts(store); var result = store1.Products; Assert.NotEmpty(result); }
private static FileServer SetupFileServer(Options options, DlnaMediaTypes types, DirectoryInfo[] d) { var ids = new Identifiers( ComparerRepository.Lookup(options.Order), options.DescendingOrder); foreach (var v in options.Views) { try { ids.AddView(v); } catch (RepositoryLookupException) { throw new GetOptException("Invalid view " + v); } } var fs = new FileServer(types, ids, d); if (!string.IsNullOrEmpty(options.FriendlyName)) { fs.FriendlyName = options.FriendlyName; } try { if (options.FileStore != null) { fs.SetCacheFile(FileStoreRepository.Lookup(options.FileStore)); } fs.Load(); if (!options.Rescanning) { fs.Rescanning = false; } } catch (Exception) { fs.Dispose(); throw; } return(fs); }
private void StartFileServer() { if (!Description.Active) { state = State.Stopped; return; } var start = DateTime.Now; try { state = State.Loading; var ids = new Identifiers(ComparerRepository.Lookup(Description.Order), Description.OrderDescending); foreach (var v in Description.Views) { ids.AddView(v); } var dirs = (from i in Description.Directories let d = new DirectoryInfo(i) where d.Exists select d).ToArray(); if (dirs.Length == 0) { throw new InvalidOperationException("No remaining directories"); } fileServer = new FileServer(Description.Types, ids, dirs) { FriendlyName = Description.Name }; //#if !DEBUG if (!string.IsNullOrEmpty(Description.FileStore)) { fileServer.SetCacheFile(FileStoreRepository.Lookup(Description.FileStore)); } //if (cacheFile != null) { // fileServer.SetCacheFile(); //} //#endif fileServer.Changing += (o, e) => { state = State.Refreshing; }; fileServer.Changed += (o, e) => { state = Description.Active ? State.Running : State.Stopped; }; fileServer.Load(); var authorizer = new HttpAuthorizer(); if (Description.Ips.Length != 0) { authorizer.AddMethod(new IPAddressAuthorizer(Description.Ips)); } if (Description.Macs.Length != 0) { authorizer.AddMethod(new MacAuthorizer(Description.Macs)); } if (Description.UserAgents.Length != 0) { authorizer.AddMethod(new UserAgentAuthorizer(Description.UserAgents)); } fileServer.Authorizer = authorizer; server.RegisterMediaServer(fileServer); state = State.Running; var elapsed = DateTime.Now - start; LogManager.GetLogger("State").Logger.Log( GetType(), Level.Notice, string.Format( "{0} loaded in {1:F2} seconds", fileServer.FriendlyName, elapsed.TotalSeconds), null ); } catch (Exception ex) { server.Logger.ErrorFormat("Failed to start {0}, {1}", Description.Name, ex); Description.ToggleActive(); state = State.Stopped; } }
public void Repository_FileStoreRepository_Lookup_Test() { var target = FileStoreRepository.Lookup((new NMaier.SimpleDlna.FileStore.SQLite.FileStore()).Name); Assert.IsNotNull(target); }