Skip to content

Commit 496f6a8

Browse files
Added tests for error cases of SetBufferAsync on ConvolverNode.
1 parent ffce264 commit 496f6a8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/IntegrationTests/AudioNodeTests/ConvolverNodeTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,47 @@ public async Task SetBufferAsync_WithNullArgument_ShouldClearBuffer()
9393
_ = readBuffer.Should().BeNull();
9494
}
9595

96+
[Test]
97+
[TestCase(3ul)]
98+
[TestCase(5ul)]
99+
public async Task SetBufferAsync_WithBufferThatHasUnsupportedNumberOfChannels_ThrowsNotSupportErrorException(ulong numberOfChannels)
100+
{
101+
// Arrange
102+
await using ConvolverNode node = await ConvolverNode.CreateAsync(JSRuntime, AudioContext);
103+
104+
await using AudioBuffer buffer = await AudioBuffer.CreateAsync(JSRuntime, new AudioBufferOptions()
105+
{
106+
Length = 1,
107+
SampleRate = await AudioContext.GetSampleRateAsync(),
108+
NumberOfChannels = numberOfChannels
109+
});
110+
111+
// Act
112+
Func<Task> action = async () => await node.SetBufferAsync(buffer);
113+
114+
// Assert
115+
_ = await action.Should().ThrowAsync<NotSupportedErrorException>();
116+
}
117+
118+
[Test]
119+
public async Task SetBufferAsync_WithBufferThatHasMismatchingSampleRate_ThrowsNotSupportErrorException()
120+
{
121+
// Arrange
122+
await using ConvolverNode node = await ConvolverNode.CreateAsync(JSRuntime, AudioContext);
123+
124+
await using AudioBuffer buffer = await AudioBuffer.CreateAsync(JSRuntime, new AudioBufferOptions()
125+
{
126+
Length = 1,
127+
SampleRate = await AudioContext.GetSampleRateAsync() + 100
128+
});
129+
130+
// Act
131+
Func<Task> action = async () => await node.SetBufferAsync(buffer);
132+
133+
// Assert
134+
_ = await action.Should().ThrowAsync<NotSupportedErrorException>();
135+
}
136+
96137
[Test]
97138
[TestCase(false)]
98139
[TestCase(true)]

0 commit comments

Comments
 (0)