[MediaController] add missing exception (#495)
authorhsgwon <haesu.gwon@samsung.com>
Tue, 2 Oct 2018 08:23:51 +0000 (17:23 +0900)
committerGitHub <noreply@github.com>
Tue, 2 Oct 2018 08:23:51 +0000 (17:23 +0900)
* [MediaController] add missing exception

src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs
src/Tizen.Multimedia.Remoting/MediaController/MediaControlServer.cs
src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs

index 91e21bf..82730a3 100644 (file)
@@ -49,7 +49,7 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="receiverId">The receiver Id that receives command.</param>
         internal void SetRequestInformation(string receiverId)
         {
-            ReceiverId = receiverId;
+            ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId));
         }
 
         /// <summary>
@@ -59,8 +59,8 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="requestId">The request Id for each command.</param>
         internal void SetResponseInformation(string receiverId, string requestId)
         {
-            ReceiverId = receiverId;
-            _requestId = requestId;
+            ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId)); ;
+            _requestId = requestId ?? throw new ArgumentNullException(nameof(requestId)); ;
         }
 
         /// <summary>
index 2ac583a..cb36872 100644 (file)
@@ -326,6 +326,7 @@ namespace Tizen.Multimedia.Remoting
         /// Delete playlist.
         /// </summary>
         /// <param name="playlist">The name of playlist.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="playlist"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server is not running .<br/>
         ///     -or-<br/>
@@ -334,6 +335,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public static void RemovePlaylist(MediaControlPlaylist playlist)
         {
+            if (playlist == null)
+            {
+                throw new ArgumentNullException(nameof(playlist));
+            }
+
             Native.DeletePlaylist(Handle, playlist.Handle);
             playlist.Dispose();
         }
@@ -389,6 +395,9 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="command">A <see cref="Command"/> class.</param>
         /// <param name="clientId">The client Id to send command.</param>
         /// <returns><see cref="Bundle"/> represents the extra data from client and it can be null.</returns>
+        /// <exception cref="ArgumentNullException">
+        /// <paramref name="command"/> or <paramref name="clientId"/> is null.
+        /// </exception>
         /// <exception cref="InvalidOperationException">
         ///     The server has already been stopped.<br/>
         ///     -or-<br/>
@@ -397,6 +406,15 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public static async Task<Bundle> RequestAsync(Command command, string clientId)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+            if (clientId == null)
+            {
+                throw new ArgumentNullException(nameof(clientId));
+            }
+
             command.SetRequestInformation(clientId);
 
             var tcs = new TaskCompletionSource<MediaControllerError>();
@@ -434,6 +452,7 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="command">The command that return to client.</param>
         /// <param name="result">The result of <paramref name="command"/>.</param>
         /// <param name="bundle">The extra data.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server is not running .<br/>
         ///     -or-<br/>
@@ -442,6 +461,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public static void Response(Command command, int result, Bundle bundle)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+
             command.Response(Handle, result, bundle);
         }
 
@@ -450,6 +474,7 @@ namespace Tizen.Multimedia.Remoting
         /// </summary>
         /// <param name="command">The command that return to client.</param>
         /// <param name="result">The result of <paramref name="command"/>.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server is not running .<br/>
         ///     -or-<br/>
@@ -458,6 +483,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public static void Response(Command command, int result)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+
             command.Response(Handle, result, null);
         }
 
index 693d140..5a07cd5 100644 (file)
@@ -321,6 +321,7 @@ namespace Tizen.Multimedia.Remoting
         /// </remarks>
         /// <param name="command">A <see cref="Command"/> class.</param>
         /// <returns><see cref="Bundle"/> represents the extra data from server and it can be null.</returns>
+        /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server has already been stopped.<br/>
         ///     -or-<br/>
@@ -330,6 +331,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public async Task<Bundle> RequestAsync(Command command)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+
             ThrowIfStopped();
 
             command.SetRequestInformation(ServerAppId);
@@ -369,6 +375,7 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="command">The command that return to client.</param>
         /// <param name="result">The result of <paramref name="command"/>.</param>
         /// <param name="bundle">The extra data.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server is not running .<br/>
         ///     -or-<br/>
@@ -377,6 +384,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public void Response(Command command, int result, Bundle bundle)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+
             command.Response(Manager.Handle, result, bundle);
         }
 
@@ -385,6 +397,7 @@ namespace Tizen.Multimedia.Remoting
         /// </summary>
         /// <param name="command">The command that return to client.</param>
         /// <param name="result">The result of <paramref name="command"/>.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server is not running .<br/>
         ///     -or-<br/>
@@ -393,6 +406,11 @@ namespace Tizen.Multimedia.Remoting
         /// <since_tizen> 5 </since_tizen>
         public void Response(Command command, int result)
         {
+            if (command == null)
+            {
+                throw new ArgumentNullException(nameof(command));
+            }
+
             command.Response(Manager.Handle, result, null);
         }
 
@@ -559,6 +577,7 @@ namespace Tizen.Multimedia.Remoting
         /// </summary>
         /// <param name="action">A playback command.</param>
         /// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
+        /// <exception cref="ArgumentException"><paramref name="action"/> is not valid.</exception>
         /// <exception cref="InvalidOperationException">
         ///     The server has already been stopped.<br/>
         ///     -or-<br/>
@@ -570,6 +589,8 @@ namespace Tizen.Multimedia.Remoting
         {
             ThrowIfStopped();
 
+            ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), action, nameof(action));
+
             IntPtr playbackCapaHandle = IntPtr.Zero;
 
             try