feat: refactor audio extraction to reusable class
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AwesomeAssertions" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="xunit.v3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace StreamShorts.Library.Tests.Unit.Media.Audio;
|
||||
|
||||
public class AudioExtractorTests
|
||||
{
|
||||
private readonly AudioExtractor _sut = new();
|
||||
|
||||
[Fact]
|
||||
public async Task ExtractMp3FromMp4Async_WhenVideoIsNull_ItShouldThrow()
|
||||
{
|
||||
var action = async () => await _sut.ExtractMp3FromMp4Async(null!);
|
||||
|
||||
await action.Should().ThrowAsync<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExtractMp3FromMp4Async_WhenVideoIsNotReadable_ItShouldThrow()
|
||||
{
|
||||
var mockStream = new Mock<Stream>();
|
||||
mockStream.Setup(s => s.CanRead).Returns(false);
|
||||
|
||||
var action = async () => await _sut.ExtractMp3FromMp4Async(mockStream.Object);
|
||||
|
||||
await action.Should().ThrowAsync<ArgumentException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExtractMp3FromMp4Async_WhenVideoIsNotSeekable_ItShouldThrow()
|
||||
{
|
||||
var mockStream = new Mock<Stream>();
|
||||
mockStream.Setup(s => s.CanSeek).Returns(false);
|
||||
|
||||
var action = async () => await _sut.ExtractMp3FromMp4Async(mockStream.Object);
|
||||
|
||||
await action.Should().ThrowAsync<ArgumentException>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
global using AwesomeAssertions;
|
||||
|
||||
global using Moq;
|
||||
|
||||
global using StreamShorts.Library.Media.Audio;
|
||||
Reference in New Issue
Block a user