[Radio][Non-ACR] Add new negative TCs 50/242050/1
authorHaesu Gwon <haesu.gwon@samsung.com>
Sat, 22 Aug 2020 09:18:42 +0000 (18:18 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Sat, 22 Aug 2020 09:18:42 +0000 (18:18 +0900)
Change-Id: Iaa13027b2f14d4994105f17d627c67b08b1f0b23

tct-suite-vs/Tizen.Radio.Tests/testcase/TSRadio.cs

index 73d54ac63959b488094bc825153c692eb7658f51..df9173800bd181067f2b065906c86e75e03c7879 100755 (executable)
@@ -148,6 +148,21 @@ namespace Tizen.Multimedia.Tests
             Assert.AreEqual(RadioState.Scanning, Radio.State, "state is not scanning");
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.State A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void State_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.State, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test Frequency property of radio.")]
@@ -232,6 +247,21 @@ namespace Tizen.Multimedia.Tests
             Assert.Throws<ArgumentOutOfRangeException>(() => Radio.Frequency = 86500);
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.Frequency A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Frequency_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.Frequency, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test SignalStrength property of radio.")]
@@ -249,6 +279,21 @@ namespace Tizen.Multimedia.Tests
             Assert.GreaterOrEqual(result, -128, "Signal strength is not greater or equal than -128dBm");
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.SignalStrength A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void SignalStrength_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.SignalStrength, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test IsMuted Property of radio.")]
@@ -287,6 +332,21 @@ namespace Tizen.Multimedia.Tests
             Assert.IsFalse(Radio.IsMuted, "Raio is muted, default is not muted");
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.IsMuted A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void IsMuted_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.IsMuted, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test ChannelSpacing property.")]
@@ -305,6 +365,21 @@ namespace Tizen.Multimedia.Tests
             Assert.Greater(result, 0, "ChannelSpacing should be greater than 0.");
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.ChannelSpacing A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void ChannelSpacing_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.ChannelSpacing, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test Volume property.")]
@@ -408,6 +483,21 @@ namespace Tizen.Multimedia.Tests
             Assert.Throws<ArgumentOutOfRangeException>(() => Radio.Volume = -1.0f);
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.Volume A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Volume_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.Volume, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test FrequencyRange property for min value.")]
@@ -442,6 +532,21 @@ namespace Tizen.Multimedia.Tests
             Assert.LessOrEqual(result.Max, 108000, "frequency should be lesser than or equal 108kHz");
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.FrequencyRange A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void FrequencyRange_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.That(() => Radio.FrequencyRange, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test StartScan method status.")]
@@ -484,6 +589,21 @@ namespace Tizen.Multimedia.Tests
             Assert.Throws<InvalidOperationException>(() => Radio.StartScan());
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.StartScan M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void StartScan_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.Throws<ObjectDisposedException>(() => Radio.StartScan(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test StopScan method status.")]
@@ -501,12 +621,20 @@ namespace Tizen.Multimedia.Tests
                  * 2. Start scanning.
                  */
                 Radio.ScanStopped += eventAwaiter;
-                Radio.StartScan();
-                await Task.Delay(300);
 
-                Radio.StopScan();
-                await eventAwaiter.IsRaisedAsync(_radioScanMaxTime);
-                Assert.AreEqual(RadioState.Ready, Radio.State, "state is not ready");
+                try
+                {
+                    Radio.StartScan();
+                    await Task.Delay(300);
+
+                    Radio.StopScan();
+                    await eventAwaiter.IsRaisedAsync(_radioScanMaxTime);
+                    Assert.AreEqual(RadioState.Ready, Radio.State, "state is not ready");
+                }
+                finally
+                {
+                    Radio.ScanStopped -= eventAwaiter;
+                }
             }
         }
 
@@ -522,6 +650,21 @@ namespace Tizen.Multimedia.Tests
             Assert.Throws<InvalidOperationException>(() => Radio.StopScan());
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.StopScan M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void StopScan_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.Throws<ObjectDisposedException>(() => Radio.StopScan(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test SeekUpAsync method return.")]
@@ -553,6 +696,21 @@ namespace Tizen.Multimedia.Tests
             Assert.ThrowsAsync<InvalidOperationException>(() => Radio.SeekUpAsync());
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.SeekUpAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void SeekUpAsync_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.ThrowsAsync<ObjectDisposedException>(() => Radio.SeekUpAsync(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test SeekDownAsync method return.")]
@@ -585,6 +743,21 @@ namespace Tizen.Multimedia.Tests
             Assert.ThrowsAsync<InvalidOperationException>(() => Radio.SeekDownAsync());
         }
 
+        [Test]
+        [Category("P2")]
+        [Description("Throws if radio object is already disposed.")]
+        [Property("SPEC", "Tizen.Multimedia.Radio.SeekDownAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void SeekDownAsync_THROWS_IF_DISPOSED()
+        {
+            Radio.Dispose();
+
+            Assert.ThrowsAsync<ObjectDisposedException>(() => Radio.SeekDownAsync(),
+                "Should throws proper exception");
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test ScanUpdated event.")]
@@ -602,9 +775,18 @@ namespace Tizen.Multimedia.Tests
                  * 2. Start Scanning.
                  */
                 Radio.ScanUpdated += eventAwaiter;
-                Radio.StartScan();
 
-                Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime), "The event should be raised.");
+                try
+                {
+                    Radio.StartScan();
+
+                    Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime),
+                        "The event should be raised.");
+                }
+                finally
+                {
+                    Radio.ScanUpdated -= eventAwaiter;
+                }
             }
         }
 
@@ -625,11 +807,20 @@ namespace Tizen.Multimedia.Tests
                  * 2. Start scanning.
                  */
                 Radio.ScanStopped += eventAwaiter;
-                Radio.StartScan();
-                await Task.Delay(300);
 
-                Radio.StopScan();
-                Assert.IsTrue(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime), "The event should be raised.");
+                try
+                {
+                    Radio.StartScan();
+                    await Task.Delay(300);
+
+                    Radio.StopScan();
+                    Assert.IsTrue(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime),
+                        "The event should be raised.");
+                }
+                finally
+                {
+                    Radio.ScanStopped -= eventAwaiter;
+                }
             }
         }
 
@@ -650,9 +841,16 @@ namespace Tizen.Multimedia.Tests
                  */
                 Radio.ScanCompleted += eventAwaiter;
 
-                Radio.StartScan();
+                try
+                {
+                    Radio.StartScan();
 
-                Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime));
+                    Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime));
+                }
+                finally
+                {
+                    Radio.ScanCompleted -= eventAwaiter;
+                }
             }
         }
 
@@ -674,12 +872,19 @@ namespace Tizen.Multimedia.Tests
                 Radio.Interrupted += eventAwaiter;
 
                 /* TESTCODE */
-                Radio.Start();
-                Radio2.Start();
-
-                Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime), "The event should be raised.");
+                try
+                {
+                    Radio.Start();
+                    Radio2.Start();
+
+                    Assert.That(await eventAwaiter.IsRaisedAsync(_radioScanMaxTime),
+                        "The event should be raised.");
+                }
+                finally
+                {
+                    Radio.Interrupted -= eventAwaiter;
+                }
             }
-
         }
     }
 }