Skip to content

Commit f69cbed

Browse files
Added tests for getting and setting minDecibel.
1 parent d76a07e commit f69cbed

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/IntegrationTests/AudioNodeTests/AnalyserNodeTest.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,63 @@ public async Task SetMaxDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetLower
248248
// Assert
249249
_ = await action.Should().ThrowAsync<IndexSizeErrorException>();
250250
}
251+
252+
[Test]
253+
[TestCase(-100)]
254+
[TestCase(-50)]
255+
public async Task GetMinDecibelsAsync_ShouldRetrieveMinDecibels(double minDecibels)
256+
{
257+
// Arrange
258+
await using AudioContext context = await GetAudioContextAsync();
259+
260+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context, new()
261+
{
262+
MinDecibels = minDecibels
263+
});
264+
265+
// Act
266+
double readMinDecibels = await node.GetMinDecibelsAsync();
267+
268+
// Assert
269+
_ = readMinDecibels.Should().Be(minDecibels);
270+
}
271+
272+
[Test]
273+
[TestCase(-100)]
274+
[TestCase(-50)]
275+
public async Task SetMinDecibelsAsync_ShouldUpdateMinDecibels(double minDecibels)
276+
{
277+
// Arrange
278+
await using AudioContext context = await GetAudioContextAsync();
279+
280+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context);
281+
282+
// Act
283+
await node.SetMinDecibelsAsync(minDecibels);
284+
285+
// Assert
286+
double readMinDecibels = await node.GetMinDecibelsAsync();
287+
_ = readMinDecibels.Should().Be(minDecibels);
288+
}
289+
290+
[Test]
291+
[TestCase(-100, -110)]
292+
[TestCase(50, 0)]
293+
public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetHigherThanMaxDecibels(double minDecibels, double maxDecibels)
294+
{
295+
// Arrange
296+
await using AudioContext context = await GetAudioContextAsync();
297+
298+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context, new()
299+
{
300+
MinDecibels = maxDecibels - 1,
301+
MaxDecibels = maxDecibels,
302+
});
303+
304+
// Act
305+
Func<Task> action = async () => await node.SetMinDecibelsAsync(minDecibels);
306+
307+
// Assert
308+
_ = await action.Should().ThrowAsync<IndexSizeErrorException>();
309+
}
251310
}

0 commit comments

Comments
 (0)