[Test]
[Category("P1")]
+ [Description("Thows nothing when RequestCommandAsync to client")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task RequestCommandAsync_RETURN_VALUE()
+ {
+ using (var manager = new MediaControllerManager())
+ {
+ var controller = manager.GetActiveControllers().Single(
+ c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId);
+ CustomCommand customCommand = null;
+
+ controller.CustomCommandReceived += (s, e) =>
+ {
+ customCommand = e.Command;
+
+ controller.Response(customCommand, (int)MediaControlResult.Timeout);
+ };
+
+ await Task.Run(async () =>
+ {
+ var resultValue = await MediaControlServer.RequestCommandAsync(new CustomCommand("CustomCommand"),
+ Application.Current.ApplicationInfo.ApplicationId);
+
+ Assert.AreEqual(resultValue.result, (int)MediaControlResult.Timeout);
+ });
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if client response with error")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task RequestCommandAsync_THROWS_INVALIDOPERATIONEXCEPTION()
+ {
+ using (var manager = new MediaControllerManager())
+ {
+ var controller = manager.GetActiveControllers().Single(
+ c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId);
+ CustomCommand customCommand = null;
+
+ controller.CustomCommandReceived += (s, e) =>
+ {
+ customCommand = e.Command;
+
+ controller.Response(customCommand, (int)MediaControlResult.Timeout);
+ };
+
+ await Task.Run(async () =>
+ {
+ MediaControlServer.Stop();
+
+ Assert.ThrowsAsync<InvalidOperationException>(async () =>
+ await MediaControlServer.RequestCommandAsync(new CustomCommand("CustomCommand"),
+ Application.Current.ApplicationInfo.ApplicationId));
+ });
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void RequestCommandAsync_THROWS_ARGUMENTNULLEXCEPTION()
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () =>
+ await MediaControlServer.RequestCommandAsync(null, Application.Current.ApplicationInfo.ApplicationId));
+
+ Assert.ThrowsAsync<ArgumentNullException>(async () =>
+ await MediaControlServer.RequestCommandAsync(new CustomCommand("CustomCommand"), null));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if server try to send not implemented command")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void RequestCommandAsync_THROWS_NOTIMPLEMENTEDEXCEPTION()
+ {
+ Assert.ThrowsAsync<NotImplementedException>(async () =>
+ await MediaControlServer.RequestCommandAsync(new ShuffleModeCommand(true),
+ Application.Current.ApplicationInfo.ApplicationId));
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Thows nothing when response to client")]
[Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MEX")]
[Property("COVPARAM", "Command, int, Bundle")]
[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
- public void Response_WITH_BUNDLE_THROWS_EXCEPTION()
+ public void Response_WITH_BUNDLE_THROWS_INVALIDOPERATIONEXCEPTION()
{
MediaControlServer.Stop();
Assert.That(() => MediaControlServer.Response(new CustomCommand("custom"), 0, new Bundle()),
Throws.InvalidOperationException);
+ }
+ [Test]
+ [Category("P2")]
+ [Description("Check whether Response throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "Command, int, Bundle")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void Response_WITH_BUNDLE_THROWS_ARGUMENTNULLEXCEPTION()
+ {
Assert.Throws<ArgumentNullException>(() => MediaControlServer.Response(null, 0, new Bundle()));
}
await Task.Run(() =>
{
- Assert.That(() => _controller.RequestAsync(_command), Throws.Nothing);
+ Assert.That(async () => await _controller.RequestAsync(_command), Throws.Nothing);
});
}
finally
await Task.Run(() =>
{
- Assert.That(() => _controller.RequestAsync(_command), Throws.InvalidOperationException);
+ Assert.ThrowsAsync<InvalidOperationException>(async () =>
+ await _controller.RequestAsync(_command));
});
}
finally
[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
public void RequestAsync_THROWS_EXCEPTION_NULL()
{
- Assert.That(() => _controller.RequestAsync(null), Throws.ArgumentNullException);
+ Assert.ThrowsAsync<ArgumentNullException>(async () =>
+ await _controller.RequestAsync(null));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Throws nothing when request to server")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task RequestCommandAsync_THROWS_NOTHING()
+ {
+ CustomCommand customCommand = null;
+ EventHandler<CustomCommandReceivedEventArgs> eventHandler = (s, e) =>
+ {
+ customCommand = e.Command;
+ Log.Info("Tizen.MediaController.Tests", $"e.Command.Action : {e.Command.Action}");
+
+ MediaControlServer.Response(customCommand, (int)MediaControlResult.Timeout);
+ };
+
+ try
+ {
+ MediaControlServer.CustomCommandReceived += eventHandler;
+
+ await Task.Run(() =>
+ {
+ var returnValue = _controller.RequestCommandAsync(_command);
+ Assert.AreEqual(returnValue.Result.result, (int)MediaControlResult.Timeout);
+ });
+ }
+ finally
+ {
+ MediaControlServer.CustomCommandReceived -= eventHandler;
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if server response with error")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public async Task RequestCommandAsync_THROWS_EXCEPTION()
+ {
+ CustomCommand customCommand = null;
+
+ EventHandler<CustomCommandReceivedEventArgs> eventHandler = (s, e) =>
+ {
+ customCommand = e.Command;
+
+ MediaControlServer.Response(customCommand, (int)MediaControlResult.Timeout);
+ };
+
+ try
+ {
+ MediaControlServer.CustomCommandReceived += eventHandler;
+
+ await Task.Run(async () =>
+ {
+ using (var eventWaiter = EventAwaiter<MediaControlServerStoppedEventArgs>.Create())
+ {
+ _manager.ServerStopped += eventWaiter;
+
+ MediaControlServer.Stop();
+
+ await eventWaiter.IsRaisedAsync();
+
+ Assert.ThrowsAsync<InvalidOperationException>(async () =>
+ await _controller.RequestCommandAsync(_command));
+
+ _manager.ServerStopped -= eventWaiter;
+ }
+ });
+ }
+ finally
+ {
+ MediaControlServer.CustomCommandReceived -= eventHandler;
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void RequestCommandAsync_THROWS_ARGUMENTNULLEXCEPTION()
+ {
+ Assert.ThrowsAsync<ArgumentNullException>(async () =>
+ await _controller.RequestCommandAsync(null));
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check whether RequestCommandAsync throws exception if parameter is null")]
+ [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestCommandAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+ public void RequestCommandAsync_THROWS_IF_OBJECT_IS_DISPOSED()
+ {
+ _manager.Dispose();
+
+ Assert.ThrowsAsync<ObjectDisposedException>(async () =>
+ await _controller.RequestCommandAsync(new ShuffleModeCommand(true)));
}
[Test]