2019-11-04 03:19:04 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Roadie.Library.Configuration;
|
|
|
|
|
using Roadie.Library.Data;
|
2019-11-17 14:10:17 +00:00
|
|
|
|
using Roadie.Library.Data.Context;
|
2019-11-04 03:19:04 +00:00
|
|
|
|
using Roadie.Library.FilePlugins;
|
2019-02-10 00:19:26 +00:00
|
|
|
|
using Roadie.Library.Imaging;
|
2019-11-04 03:19:04 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2019-02-10 00:19:26 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Roadie.Library.Tests
|
|
|
|
|
{
|
|
|
|
|
public class ImageHelperTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("artist.jpeg")]
|
|
|
|
|
[InlineData("artist.jpg")]
|
|
|
|
|
[InlineData("artist.png")]
|
|
|
|
|
[InlineData("Artist.Jpg")]
|
|
|
|
|
[InlineData("Artist.JPG")]
|
|
|
|
|
[InlineData("band.jpg")]
|
|
|
|
|
[InlineData("group.jpg")]
|
|
|
|
|
[InlineData("ARTIST.JPG")]
|
|
|
|
|
[InlineData("GrOup.jpg")]
|
2019-06-18 12:48:15 +00:00
|
|
|
|
[InlineData("photo.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("aRtist.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldBeArtistImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.True(ImageHelper.IsArtistImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("logo.jpeg")]
|
|
|
|
|
[InlineData("logo.jpg")]
|
|
|
|
|
[InlineData("logo.png")]
|
|
|
|
|
[InlineData("Logo.Jpg")]
|
2019-06-18 12:48:15 +00:00
|
|
|
|
[InlineData("logo.gif")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("artist_logo.jpg")]
|
|
|
|
|
[InlineData("Artist_logo.jpg")]
|
|
|
|
|
[InlineData("ARTIST_LOGO.JPG")]
|
|
|
|
|
[InlineData("artist 1.jpg")]
|
|
|
|
|
[InlineData("artist_01.jpg")]
|
|
|
|
|
[InlineData("artist 03.jpg")]
|
2019-06-18 12:48:15 +00:00
|
|
|
|
[InlineData("band 01.jpg")]
|
|
|
|
|
[InlineData("band_01.jpg")]
|
|
|
|
|
[InlineData("band 1.jpg")]
|
|
|
|
|
[InlineData("photo 1.jpg")]
|
|
|
|
|
[InlineData("photo1.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldBeArtistSecondaryImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.True(ImageHelper.IsArtistSecondaryImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("cover.jpeg")]
|
|
|
|
|
[InlineData("cover.jpg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("Cover.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("cover.png")]
|
|
|
|
|
[InlineData("Cover.Jpg")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("Cover.JPG")]
|
2019-06-15 22:33:24 +00:00
|
|
|
|
[InlineData("Cover.PNG")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("CvR.Jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Release.JPG")]
|
2019-06-02 04:27:17 +00:00
|
|
|
|
[InlineData("folder.JPG")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("front.jpg")]
|
|
|
|
|
[InlineData("FrOnt.jpg")]
|
2019-06-23 15:45:45 +00:00
|
|
|
|
[InlineData("Art.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Art - front.jpg")]
|
|
|
|
|
[InlineData("Art - Front.jpg")]
|
|
|
|
|
[InlineData("Art-Front.jpg")]
|
|
|
|
|
[InlineData("Art- Front.jpg")]
|
|
|
|
|
[InlineData("Art -Front.jpg")]
|
2019-08-11 19:11:29 +00:00
|
|
|
|
[InlineData("f.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("F1.jpg")]
|
|
|
|
|
[InlineData("F 1.jpg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("F-1.jpg")]
|
|
|
|
|
[InlineData("front_.jpg")]
|
|
|
|
|
[InlineData("BIG.JPg")]
|
2019-06-23 15:45:45 +00:00
|
|
|
|
[InlineData("bigart.JPg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("BIG.PNG")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldBeReleaseImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.True(ImageHelper.IsReleaseImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("cover.png")]
|
2019-06-15 22:33:24 +00:00
|
|
|
|
[InlineData("cover1.jpg")]
|
|
|
|
|
[InlineData("cover 1.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Cover.jpg")]
|
|
|
|
|
[InlineData("batman.txt")]
|
|
|
|
|
[InlineData("Song.mp3")]
|
|
|
|
|
[InlineData("batman.jpg")]
|
|
|
|
|
[InlineData("logo.jpg")]
|
|
|
|
|
[InlineData("Release.JPG")]
|
|
|
|
|
[InlineData("front.jpg")]
|
|
|
|
|
[InlineData("F1.jpg")]
|
|
|
|
|
[InlineData("logo.jpeg")]
|
|
|
|
|
[InlineData("logo.png")]
|
|
|
|
|
[InlineData("Logo.Jpg")]
|
|
|
|
|
[InlineData("artist_logo.jpg")]
|
|
|
|
|
[InlineData("Artist_logo.jpg")]
|
|
|
|
|
[InlineData("ARTIST_LOGO.JPG")]
|
|
|
|
|
[InlineData("Artist - Front.jpg")]
|
|
|
|
|
[InlineData("Artist Front.jpg")]
|
|
|
|
|
[InlineData("artist 1.jpg")]
|
|
|
|
|
[InlineData("artist_01.jpg")]
|
|
|
|
|
[InlineData("artist 03.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldNotBeArtistImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
var t = ImageHelper.IsArtistImage(new FileInfo(input));
|
|
|
|
|
Assert.False(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("artist.jpeg")]
|
|
|
|
|
[InlineData("artist.jpg")]
|
|
|
|
|
[InlineData("artist.png")]
|
|
|
|
|
[InlineData("Artist.Jpg")]
|
|
|
|
|
[InlineData("Artist.JPG")]
|
|
|
|
|
[InlineData("band.jpg")]
|
|
|
|
|
[InlineData("group.jpg")]
|
|
|
|
|
[InlineData("ARTIST.JPG")]
|
|
|
|
|
[InlineData("GrOup.jpg")]
|
|
|
|
|
[InlineData("aRtist.jpg")]
|
|
|
|
|
[InlineData("batman.txt")]
|
|
|
|
|
[InlineData("Song.mp3")]
|
|
|
|
|
[InlineData("batman.jpg")]
|
|
|
|
|
[InlineData("logo.jpg")]
|
|
|
|
|
[InlineData("cover 1.jpg")]
|
|
|
|
|
[InlineData("cover_01.jpg")]
|
|
|
|
|
[InlineData("cover 03.jpg")]
|
2019-06-02 04:27:17 +00:00
|
|
|
|
[InlineData("Dixieland-Front1.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldNotBeReleaseImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.False(ImageHelper.IsReleaseImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("label.jpeg")]
|
|
|
|
|
[InlineData("label.jpg")]
|
|
|
|
|
[InlineData("label.png")]
|
|
|
|
|
[InlineData("Label.Jpg")]
|
|
|
|
|
[InlineData("label.JPG")]
|
|
|
|
|
[InlineData("record_label.jpg")]
|
|
|
|
|
[InlineData("RecordLabel.jpg")]
|
|
|
|
|
[InlineData("RECORDLABEL.JPG")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldBeLabelImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.True(ImageHelper.IsLabelImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("artist.jpeg")]
|
|
|
|
|
[InlineData("artist.jpg")]
|
|
|
|
|
[InlineData("artist.png")]
|
|
|
|
|
[InlineData("Artist.Jpg")]
|
|
|
|
|
[InlineData("Artist.JPG")]
|
|
|
|
|
[InlineData("band.jpg")]
|
|
|
|
|
[InlineData("group.jpg")]
|
|
|
|
|
[InlineData("ARTIST.JPG")]
|
|
|
|
|
[InlineData("GrOup.jpg")]
|
|
|
|
|
[InlineData("aRtist.jpg")]
|
|
|
|
|
[InlineData("cover.jpeg")]
|
|
|
|
|
[InlineData("cover.jpg")]
|
|
|
|
|
[InlineData("cover.png")]
|
|
|
|
|
[InlineData("Cover.Jpg")]
|
|
|
|
|
[InlineData("Release.JPG")]
|
|
|
|
|
[InlineData("front.jpg")]
|
|
|
|
|
[InlineData("FrOnt.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldNotBeLabelImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.False(ImageHelper.IsLabelImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
|
|
|
|
|
[InlineData("Booklet-1.jpg")]
|
|
|
|
|
[InlineData("Booklet-10.jpg")]
|
2019-06-02 04:27:17 +00:00
|
|
|
|
[InlineData("Booklet_1.jpg")]
|
|
|
|
|
[InlineData("Booklet 3.jpg")]
|
2019-11-18 16:51:40 +00:00
|
|
|
|
[InlineData("Eagles - Long Road Out Of Eden - Booklet-6.jpg")]
|
|
|
|
|
[InlineData("Long Road Out Of Eden - Booklet-6.jpg")]
|
|
|
|
|
[InlineData("Long Road Out Of Eden Booklet-6.jpg")]
|
|
|
|
|
[InlineData("Booklet-6.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Booklet.jpg")]
|
|
|
|
|
[InlineData("Book.jpg")]
|
|
|
|
|
[InlineData("Book_3.jpg")]
|
2019-08-11 19:11:29 +00:00
|
|
|
|
[InlineData("Book 3.jpg")]
|
|
|
|
|
[InlineData("Book 99.jpg")]
|
|
|
|
|
[InlineData("book 99.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Book_03.jpg")]
|
|
|
|
|
[InlineData("Book-1.jpg")]
|
|
|
|
|
[InlineData("Book-01.jpg")]
|
|
|
|
|
[InlineData("Back.jpg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("BAcK.JPg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Cd.jpg")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("CD.JPG")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Cd1.jpg")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("CD-1.jpg")]
|
|
|
|
|
[InlineData("CD 1.jpg")]
|
|
|
|
|
[InlineData("CD_1.jpg")]
|
|
|
|
|
[InlineData("CD-5.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("CD3.jpg")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("Scan-1.jpg")]
|
|
|
|
|
[InlineData("Scan-12.jpg")]
|
2019-06-23 15:45:45 +00:00
|
|
|
|
[InlineData("Scan 1.jpg")]
|
|
|
|
|
[InlineData("sc 1.jpg")]
|
|
|
|
|
[InlineData("sc01.jpg")]
|
|
|
|
|
[InlineData("sc-01.jpg")]
|
|
|
|
|
[InlineData("sc 01.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("cover_01.jpg")]
|
|
|
|
|
[InlineData("cover 03.jpg")]
|
|
|
|
|
[InlineData("cover 1.jpg")]
|
2019-06-15 22:33:24 +00:00
|
|
|
|
[InlineData("cover1.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("Encartes (11).jpg")]
|
|
|
|
|
[InlineData("Encartes (1).png")]
|
|
|
|
|
[InlineData("Encartes.jpg")]
|
|
|
|
|
[InlineData("Art - Back.jpg")]
|
|
|
|
|
[InlineData("disc.jpg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("disc.png")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("inside.jpg")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("Inside1.jpg")]
|
|
|
|
|
[InlineData("Inside 1.jpg")]
|
|
|
|
|
[InlineData("Inside-1.jpg")]
|
|
|
|
|
[InlineData("in1.jpg")]
|
|
|
|
|
[InlineData("inlay.jpg")]
|
2019-02-10 00:19:26 +00:00
|
|
|
|
[InlineData("release 1.jpg")]
|
|
|
|
|
[InlineData("release-1.jpg")]
|
|
|
|
|
[InlineData("release_1.jpg")]
|
|
|
|
|
[InlineData("release 3.jpg")]
|
|
|
|
|
[InlineData("release 10.jpg")]
|
2019-06-02 04:27:17 +00:00
|
|
|
|
[InlineData("Dixieland-Label-Side 1.JPG")]
|
|
|
|
|
[InlineData("Dixieland-Label-Side 2.JPG")]
|
2019-06-02 23:52:09 +00:00
|
|
|
|
[InlineData("Hearing Is Believing-Inside 1.jpg")]
|
|
|
|
|
[InlineData("Booklet (2-3).jpg")]
|
|
|
|
|
[InlineData("Booklet (14-15).jpg")]
|
|
|
|
|
[InlineData("Booklet#2.jpg")]
|
|
|
|
|
[InlineData("traycard.png")]
|
|
|
|
|
[InlineData("Jewel Case.jpg")]
|
2019-06-04 01:04:59 +00:00
|
|
|
|
[InlineData("Matrix-1.jpg")]
|
|
|
|
|
[InlineData("Matrix 1.jpg")]
|
2019-06-18 12:48:15 +00:00
|
|
|
|
[InlineData("IMG_20160921_0004.jpg")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldBeReleaseSecondaryImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.True(ImageHelper.IsReleaseSecondaryImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("artist.jpeg")]
|
|
|
|
|
[InlineData("artist.jpg")]
|
|
|
|
|
[InlineData("artist.png")]
|
|
|
|
|
[InlineData("Artist.Jpg")]
|
|
|
|
|
[InlineData("Artist.JPG")]
|
|
|
|
|
[InlineData("band.jpg")]
|
|
|
|
|
[InlineData("group.jpg")]
|
|
|
|
|
[InlineData("ARTIST.JPG")]
|
|
|
|
|
[InlineData("GrOup.jpg")]
|
|
|
|
|
[InlineData("aRtist.jpg")]
|
|
|
|
|
[InlineData("cover.jpeg")]
|
|
|
|
|
[InlineData("cover.jpg")]
|
|
|
|
|
[InlineData("cover.png")]
|
|
|
|
|
[InlineData("Cover.Jpg")]
|
|
|
|
|
[InlineData("Release.JPG")]
|
|
|
|
|
[InlineData("front.jpg")]
|
|
|
|
|
[InlineData("FrOnt.jpg")]
|
|
|
|
|
[InlineData("label.jpeg")]
|
|
|
|
|
[InlineData("label.jpg")]
|
|
|
|
|
[InlineData("label.png")]
|
|
|
|
|
[InlineData("Label.Jpg")]
|
|
|
|
|
[InlineData("label.JPG")]
|
|
|
|
|
[InlineData("record_label.jpg")]
|
|
|
|
|
[InlineData("RecordLabel.jpg")]
|
|
|
|
|
[InlineData("RECORDLABEL.JPG")]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void TestShouldNotBeReleaseSecondaryImages(string input)
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.False(ImageHelper.IsReleaseSecondaryImage(new FileInfo(input)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void GetReleaseImageInFolder()
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
var folder = new DirectoryInfo(@"C:\roadie_dev_root\image_tests");
|
|
|
|
|
if(!folder.Exists)
|
|
|
|
|
{
|
|
|
|
|
Assert.True(true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var cover = ImageHelper.FindImageTypeInDirectory(folder, Enums.ImageType.Release);
|
|
|
|
|
Assert.NotNull(cover);
|
2019-06-04 01:04:59 +00:00
|
|
|
|
|
|
|
|
|
var secondaryImages = ImageHelper.FindImageTypeInDirectory(folder, Enums.ImageType.ReleaseSecondary, SearchOption.AllDirectories);
|
|
|
|
|
Assert.NotNull(secondaryImages);
|
2019-02-10 00:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2019-11-04 03:19:04 +00:00
|
|
|
|
public void GetArtistImageInFolder()
|
2019-02-10 00:19:26 +00:00
|
|
|
|
{
|
|
|
|
|
var folder = new DirectoryInfo(@"C:\roadie_dev_root\image_tests)");
|
|
|
|
|
if (!folder.Exists)
|
|
|
|
|
{
|
|
|
|
|
Assert.True(true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var artist = ImageHelper.FindImageTypeInDirectory(folder, Enums.ImageType.Artist);
|
|
|
|
|
Assert.NotNull(artist);
|
|
|
|
|
Assert.Single(artist);
|
|
|
|
|
Assert.Equal("artist.jpg", artist.First().Name);
|
|
|
|
|
}
|
2019-11-18 16:51:40 +00:00
|
|
|
|
|
2019-02-10 00:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|