mirror of
https://github.com/Readarr/Readarr
synced 2025-12-30 12:13:55 +01:00
New: Add Extra Audio Format Unit Test
This commit is contained in:
parent
b34c1e5332
commit
f219e883ec
4 changed files with 42 additions and 9 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -63,7 +64,12 @@ public static string TrimEnd(this string text, string postfix)
|
|||
return text;
|
||||
}
|
||||
|
||||
public static string CleanSpaces(this string text)
|
||||
public static string Join(this IEnumerable<string> values, string separator)
|
||||
{
|
||||
return string.Join(separator, values);
|
||||
}
|
||||
|
||||
public static string CleanSpaces(this string text)
|
||||
{
|
||||
return CollapseSpace.Replace(text, " ").Trim();
|
||||
}
|
||||
|
|
@ -128,4 +134,4 @@ public static string FromOctalString(this string octalValue)
|
|||
return Encoding.ASCII.GetString(new [] { byteResult });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,14 @@ public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies)
|
|||
{
|
||||
if (responseStream != null)
|
||||
{
|
||||
data = responseStream.ToBytes();
|
||||
try
|
||||
{
|
||||
data = responseStream.ToBytes();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new WebException("Failed to read complete http response", ex, WebExceptionStatus.ReceiveFailure, httpWebResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
|
@ -37,7 +37,7 @@ public string GetSingleValue(string key)
|
|||
}
|
||||
if (values.Length > 1)
|
||||
{
|
||||
throw new ApplicationException(string.Format("Expected {0} to occur only once.", key));
|
||||
throw new ApplicationException($"Expected {key} to occur only once, but was {values.Join("|")}.");
|
||||
}
|
||||
|
||||
return values[0];
|
||||
|
|
@ -175,4 +175,4 @@ public static List<KeyValuePair<string, string>> ParseCookies(string cookies)
|
|||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Test.Common;
|
||||
|
|
@ -22,6 +22,26 @@ public void should_format_audio_format(string audioFormat, string expectedFormat
|
|||
MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(expectedFormat);
|
||||
}
|
||||
|
||||
[TestCase("MPEG Audio, A_MPEG/L2, , ", "droned.s01e03.swedish.720p.hdtv.x264-prince", "MP2")]
|
||||
[TestCase("Vorbis, A_VORBIS, , Xiph.Org libVorbis I 20101101 (Schaufenugget)", "DB Super HDTV", "Vorbis")]
|
||||
[TestCase("PCM, 1, , ", "DW DVDRip XviD-idTV", "PCM")] // Dubbed most likely
|
||||
[TestCase("TrueHD, A_TRUEHD, , ", "", "TrueHD")]
|
||||
[TestCase("WMA, 161, , ", "Droned.wmv", "WMA")]
|
||||
[TestCase("WMA, 162, Pro, ", "B.N.S04E18.720p.WEB-DL", "WMA")]
|
||||
public void should_format_audio_format(string audioFormatPack, string sceneName, string expectedFormat)
|
||||
{
|
||||
var split = audioFormatPack.Split(new string[] { ", " }, System.StringSplitOptions.None);
|
||||
var mediaInfoModel = new MediaInfoModel
|
||||
{
|
||||
AudioFormat = split[0],
|
||||
AudioCodecID = split[1],
|
||||
AudioProfile = split[2],
|
||||
AudioCodecLibrary = split[3]
|
||||
};
|
||||
|
||||
MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(expectedFormat);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_MP3_for_MPEG_Audio_with_Layer_3_for_the_profile()
|
||||
{
|
||||
|
|
@ -47,4 +67,4 @@ public void should_return_AudioFormat_by_default()
|
|||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue