public async Task GetFileMediaMetaData_FileExists_CheckValues() { // Arrange string fileImage = PrepareFile(@"C:\Temp\Image.jpg"); var dateTimeTaken = DateTime.Now; var keywords = new [] { "K1", "K2" }; var readTagsResult = new Dictionary<Tags, object> { { Tags.MediaType, MediaType.Image }, { Tags.Comments, "Some comment" }, { Tags.DateTimeTaken, dateTimeTaken }, { Tags.Keywords, keywords }, { Tags.GpsLatitude, 1.234567f }, { Tags.GpsLongitude, 7.654321f }, }; _tagHelper.ReadTagsAsync(fileImage, Tags.All).Returns(Task.FromResult(readTagsResult)); var location = new Location { Country = "USA" }; _geolocHelper.FindGeolocationAsync(Arg.Any<Coordinate>()).Returns(Task.FromResult(location)); // Act var resultImage = await _target.GetFileMediaMetaDataAsync(fileImage); // Assert Assert.AreEqual(fileImage, resultImage.FileName); Assert.AreEqual(MediaType.Image, resultImage.MediaType); Assert.AreEqual("Some comment", resultImage.Comments); Assert.AreEqual(dateTimeTaken, resultImage.DateTaken); CollectionAssert.AreEquivalent(keywords.ToList(), resultImage.Tags.ToList()); Assert.AreEqual("USA", resultImage.Location.Country); }
private MediaMetaData PrepareMediaMetaData(string file, MediaType mediaType, DateTime dateTimeTaken, string comments, IEnumerable<string> tags, Location location, short rating = 3) { var mediaMetaData = new MediaMetaData { FileName = file, DateTaken = dateTimeTaken, Comments = comments, Tags = tags, MediaType = mediaType, Location = location, Rating = rating, }; _fileSystemHelper.GetFileMediaMetaDataAsync(file).Returns(Task.FromResult(mediaMetaData)); return mediaMetaData; }
private ClassifiableFile BuildClassifiableFile(string fileName, DateTime dateTaken, MediaType mediaType, Location location) { return new ClassifiableFile() { FileName = fileName, MediaType = mediaType, DateTaken = dateTaken, Location = location, }; }
private MediaMetaData PrepareMediaMetaData(string file) { MediaType mediaType = MediaType.Image; DateTime dateTimeTaken = DateTime.Now; string comments = "Comments"; IEnumerable<string> tags = new[] { "Key1", "Key2" }; Location location = new Location { AdministrativeArea = "AdministrativeArea", Coordinate = new Coordinate { Longitude = 1.234567, Latitude = 7.654321 }, Route = "Route", State = "State", Locality = "Locality", Country = "Country", }; short rating = 3; return PrepareMediaMetaData(file, mediaType, dateTimeTaken, comments, tags, location, rating); }
public async Task GetClassifiableFromFile_FileHasGpsCoordinate_ReturnNewClassifiableFileWithFilledLocation() { // Arrange var file = @"C:\Temp\File.jpg"; _file.Exists(file).Returns(true); _fileSystemHelper.GetMediaTypeAsync(file).Returns(Task.FromResult(MediaType.Image)); _fileSystemHelper.GetFileCoordinateAsync(file).Returns(Task.FromResult(new Coordinate())); var hierarchy = new[] { ClassificationType.Country }; var location = new Location(); _geolocationHelper.FindGeolocationAsync(Arg.Any<Coordinate>()).Returns(Task.FromResult(location)); // Act var result = await _target.GetClassifiableFromFileAsync(file, hierarchy); // Assert Assert.IsNotNull(result); Assert.AreSame(location, result.Location); }