_ducking = new AudioDucking(AudioStreamType.Media);
}
+ [TearDown]
+ public void Destroy()
+ {
+ if (_ducking != null)
+ {
+ if (_ducking.IsDucked)
+ _ducking.Deactivate();
+
+ _ducking.Dispose();
+ }
+ }
+
[Test]
[Category("P1")]
[Description("AudioDucking Constructor")]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void AudioDucking_INIT()
{
+ AudioDucking ducking = null;
foreach (AudioStreamType type in Enum.GetValues(typeof(AudioStreamType)))
{
- Assert.That(() => new AudioDucking(type), Throws.Nothing);
+ Assert.That(() => { ducking = new AudioDucking(type); }, Throws.Nothing);
+ ducking.Dispose();
}
}
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void IsDucked_GET_DUCKED_STATE()
{
- using (_ducking)
- {
- _ducking.Activate(0, 0.5);
- Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
- _ducking.Deactivate();
- Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
- }
+ _ducking.Activate(0, 0.5);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ _ducking.Deactivate();
+ Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Activate_NO_EXCEPTION()
{
- using (_ducking)
- {
- Assert.That(() => _ducking.Activate(0, 0.5), Throws.Nothing);
- Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
- }
+ Assert.That(() => _ducking.Activate(0, 0.5), Throws.Nothing);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ _ducking.Deactivate();
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Activate_INVALID_OPERATION_EXCEPTION()
{
- using (_ducking)
- {
- _ducking.Activate(0, 0.5);
- Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<InvalidOperationException>());
- _ducking.Deactivate();
- }
+ _ducking.Activate(0, 0.5);
+ Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<InvalidOperationException>());
+ _ducking.Deactivate();
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Activate_ARGUMENT_OUT_OF_RANGE_EXCEPTION1()
{
- using (_ducking)
- {
- Assert.That(() => _ducking.Activate(5000, 0.5), Throws.TypeOf<ArgumentOutOfRangeException>());
- }
+ Assert.That(() => _ducking.Activate(5000, 0.5), Throws.TypeOf<ArgumentOutOfRangeException>());
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Activate_ARGUMENT_OUT_OF_RANGE_EXCEPTION2()
{
- using (_ducking)
- {
- Assert.That(() => _ducking.Activate(0, 2.0), Throws.TypeOf<ArgumentOutOfRangeException>());
- }
+ Assert.That(() => _ducking.Activate(0, 2.0), Throws.TypeOf<ArgumentOutOfRangeException>());
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Deactivate_CHECK()
{
- using (_ducking)
- {
- _ducking.Activate(0, 0.5);
- Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
- Assert.That(() => _ducking.Deactivate(), Throws.Nothing);
- Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
- }
+ _ducking.Activate(0, 0.5);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ Assert.That(() => _ducking.Deactivate(), Throws.Nothing);
+ Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
}
[Test]
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Deactivate_INVALID_OPERATION_EXCEPTION()
{
- using (_ducking)
- {
- _ducking.Activate(0, 0.5);
- _ducking.Deactivate();
- Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<InvalidOperationException>());
- }
+ _ducking.Activate(0, 0.5);
+ _ducking.Deactivate();
+ Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<InvalidOperationException>());
}
[Test]
public async Task DuckingStateChanged_CHECK_EVENT()
{
using (var eventAwaiter = EventAwaiter<AudioDuckingStateChangedEventArgs>.Create())
- using (_ducking)
{
_ducking.DuckingStateChanged += eventAwaiter;
_ducking.Activate(0, 0.5);
+
+ Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not raised");
+
_ducking.Deactivate();
- Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not rasied");
+ Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not raised");
_ducking.DuckingStateChanged -= eventAwaiter;
}
[Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
public void Dispose_CHECK()
{
- _ducking.Dispose();
+ AudioDucking ducking = new AudioDucking(AudioStreamType.Media);
+
+ ducking.Dispose();
- Assert.That(() => _ducking.IsDucked, Throws.TypeOf<ObjectDisposedException>());
- Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<ObjectDisposedException>());
- Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<ObjectDisposedException>());
+ Assert.That(() => ducking.IsDucked, Throws.TypeOf<ObjectDisposedException>());
+ Assert.That(() => ducking.Activate(0, 0.5), Throws.TypeOf<ObjectDisposedException>());
+ Assert.That(() => ducking.Deactivate(), Throws.TypeOf<ObjectDisposedException>());
}
}
}