Skip to content

Commit 53f4109

Browse files
Added tests for smoothing time constant.
1 parent 1f596d3 commit 53f4109

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/IntegrationTests/AudioNodeTests/AnalyserNodeTest.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,59 @@ public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetHighe
309309
// Assert
310310
_ = await action.Should().ThrowAsync<IndexSizeErrorException>();
311311
}
312+
313+
[Test]
314+
[TestCase(0.8)]
315+
[TestCase(0)]
316+
public async Task GetSmoothingTimeConstantAsync_ShouldRetrieveSmoothingTimeConstant(double smoothingTimeConstant)
317+
{
318+
// Arrange
319+
await using AudioContext context = await GetAudioContextAsync();
320+
321+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context, new()
322+
{
323+
SmoothingTimeConstant = smoothingTimeConstant
324+
});
325+
326+
// Act
327+
double readSmoothingTimeConstant = await node.GetSmoothingTimeConstantAsync();
328+
329+
// Assert
330+
_ = readSmoothingTimeConstant.Should().Be(smoothingTimeConstant);
331+
}
332+
333+
[Test]
334+
[TestCase(0.8)]
335+
[TestCase(0)]
336+
public async Task SetSmoothingTimeConstantAsync_ShouldUpdateSmoothingTimeConstant(double smoothingTimeConstant)
337+
{
338+
// Arrange
339+
await using AudioContext context = await GetAudioContextAsync();
340+
341+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context);
342+
343+
// Act
344+
await node.SetSmoothingTimeConstantAsync(smoothingTimeConstant);
345+
346+
// Assert
347+
double readSmoothingTimeConstant = await node.GetSmoothingTimeConstantAsync();
348+
_ = readSmoothingTimeConstant.Should().Be(smoothingTimeConstant);
349+
}
350+
351+
[Test]
352+
[TestCase(-0.2)]
353+
[TestCase(1.2)]
354+
public async Task SetMinDecibelsAsync_ThrowsIndexSizeErrorException_WhenSetToValueOutsideRange(double smoothingTimeConstant)
355+
{
356+
// Arrange
357+
await using AudioContext context = await GetAudioContextAsync();
358+
359+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context);
360+
361+
// Act
362+
Func<Task> action = async () => await node.SetSmoothingTimeConstantAsync(smoothingTimeConstant);
363+
364+
// Assert
365+
_ = await action.Should().ThrowAsync<IndexSizeErrorException>();
366+
}
312367
}

0 commit comments

Comments
 (0)