public async void GetContent_given_directory_returns_album_containing_supported_images_in_directory() { var dir = $"test_{GetType().Name}_GetContent_check_images"; var directory = Path.Combine(Directory.GetCurrentDirectory(), dir); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.Create(Path.Combine(directory, "file1.png")).Dispose(); File.Create(Path.Combine(directory, "file2.jPG")).Dispose(); File.Create(Path.Combine(directory, "file3.jpg")).Dispose(); File.Create(Path.Combine(directory, "file4.PNG")).Dispose(); File.Create(Path.Combine(directory, "file5.JPG")).Dispose(); var source = new LocalSource(); source.Settings = CreateSettings(); var result = await source.GetContent(directory); Assert.NotNull(result); Assert.Equal(3, result.Images.Count); Assert.NotNull(result.Images.FirstOrDefault(i => i.GetImageName().Result.ToLower() == "file2.jpg")); Assert.NotNull(result.Images.FirstOrDefault(i => i.GetImageName().Result.ToLower() == "file3.jpg")); Assert.NotNull(result.Images.FirstOrDefault(i => i.GetImageName().Result.ToLower() == "file5.jpg")); }
public static string GetDeviceName(LocalSource localDevice) { if (!localDevice.Name.Contains(':')) // cannot use : as it is seprator between audio:video parts { return(localDevice.Name); } else { return(localDevice.Id.Replace(":", "_")); // ffmpeg support selection by id } }
public SyncPhotos(IGoogleBearerTokenRetriever googleBearerTokenRetriever, LocalSource localSource, GoogleSource googleSource, CollectionSync collectionSync, ILogger <SyncPhotos> logger) { m_GoogleBearerTokenRetriever = googleBearerTokenRetriever; m_LocalSource = localSource; m_GoogleSource = googleSource; m_CollectionSync = collectionSync; m_Logger = logger; }
private void btnOpen_Click(object sender, EventArgs e) { if (fbdOpen.ShowDialog() == DialogResult.OK) { var source = new LocalSource("Local", fbdOpen.SelectedPath); collection.AddSource(source); foreach (var file in source.ListFiles()) { var item = new ListViewItem(new string[] { file.Title, file.Artist, file.Filename }); item.Tag = file; lstFiles.Items.Add(item); } } }
public async void GetContent_given_nonexistant_directory_returns_empty_album() { var dir = $"test_{GetType().Name}_{nameof(GetContent_given_empty_directory_returns_empty_album)}"; var directory = Path.Combine(Directory.GetCurrentDirectory(), dir); if (Directory.Exists(directory)) { Directory.Delete(directory); } var source = new LocalSource(); var result = await source.GetContent(directory); Assert.NotNull(result); Assert.Empty(result.Images); }
public async void GetContent_given_empty_directory_returns_empty_album() { var dir = $"test_{GetType().Name}_GetContent_empty_album"; var directory = Path.Combine(Directory.GetCurrentDirectory(), dir); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } //Ensure that the directory that we expect to be empty is actually empty before we do the test. Assert.Empty(Directory.GetFiles(directory, "*", SearchOption.AllDirectories)); var source = new LocalSource(); var result = await source.GetContent(directory); Assert.NotNull(result); Assert.Empty(result.Images); }
/** * All these tests have a bunch of boilerplate code, encapsulated in this method * @throws RrdException */ private void commonTest(long[] timestamps, double[] inValues, double percentile, double expectedResult, String comment){ Source src = new LocalSource("bar"); src.Timestamps = timestamps; src.Values = inValues; PercentileDef def = new PercentileDef("foo", src, percentile); Assert.IsNull(def.Values); def.Timestamps = timestamps; def.Calculate(0, timestamps.Length); //Must start from 0 to use the full list of values (otherwise the aggregation uses the last 9 values) double[] outValues = def.Values; Assert.IsNotNull(outValues); //Expect as many output values as we gave timestamps Assert.AreEqual(timestamps.Length, outValues.Length); foreach (double value in outValues) { Assert.AreEqual(expectedResult, value, 0.0,comment); } }
public CollectionDiff(LocalSource localSource, GoogleSource googleSource) { foreach (var localAlbum in localSource.PhotoAlbums) { var match = googleSource.Albums.SingleOrDefault(g => string.Equals(g.Title, localAlbum.Name, StringComparison.InvariantCultureIgnoreCase)); if (match == null) { NeverSyncedAlbums.Add(localAlbum); } else if (match.MediaItemsCount != localAlbum.TotalFiles) { PartialSyncedAlbums.Add(new LocalGooglePair(localAlbum, match)); } else { SameAlbumsCount++; } } }
internal bool YieldFromSwidtag(Package pkg, string searchKey) { if (pkg == null) { return(!IsCanceled); } var provider = pkg._swidtag; var fastPackageReference = LocalSource.Any() ? pkg.Location.LocalPath : pkg.Location.AbsoluteUri; var source = pkg.Source ?? fastPackageReference; var summary = pkg.Name; var targetFileName = pkg.Name; if (!LocalSource.Any()) { summary = new MetadataIndexer(provider)[Iso19770_2.Attributes.Summary.LocalName].FirstOrDefault(); targetFileName = provider.Links.Select(each => each.Attributes[Iso19770_2.Discovery.TargetFilename]).WhereNotNull().FirstOrDefault(); } if (YieldSoftwareIdentity(fastPackageReference, provider.Name, provider.Version, provider.VersionScheme, summary, source, searchKey, null, targetFileName) != null) { // yield all the meta/attributes if (provider.Meta.Any( m => { var element = AddMeta(fastPackageReference); var attributes = m.Attributes; return(attributes.Keys.Any(key => { var nspace = key.Namespace.ToString(); if (String.IsNullOrWhiteSpace(nspace)) { return AddMetadata(element, key.LocalName, attributes[key]) == null; } return AddMetadata(element, new Uri(nspace), key.LocalName, attributes[key]) == null; })); })) { return(!IsCanceled); } if (provider.Links.Any(link => AddLink(link.HRef, link.Relationship, link.MediaType, link.Ownership, link.Use, link.Media, link.Artifact) == null)) { return(!IsCanceled); } if (provider.Entities.Any(entity => AddEntity(entity.Name, entity.RegId, entity.Role, entity.Thumbprint) == null)) { return(!IsCanceled); } //installing a package from bootstrap site needs to prompt a user. Only auto-bootstrap is not prompted. var pm = PackageManagementService as PackageManagementService; string isTrustedSource = pm.InternalPackageManagementInstallOnly ? "false" : "true"; if (AddMetadata(fastPackageReference, "FromTrustedSource", isTrustedSource) == null) { return(!IsCanceled); } } return(!IsCanceled); }