Fix Tizen.System.SystemSettings unittest (#1519)
[platform/core/csapi/tizenfx.git] / test / Tizen.System.SystemSettings.UnitTest / SystemSettings.UnitTest / test / TSSoundNotificationRepetitionPeriodChangedEventArgs.cs
1 using System.Threading.Tasks;
2
3
4 namespace SystemSettingsUnitTest
5 {
6     //[TestFixture]
7     //[Description("Tizen.System.SoundNotificationRepetitionPeriodChangedEventArgs Tests")]
8     public static class SoundNotificationRepetitionPeriodChangedEventArgsTests
9     {
10         private static bool s_soundNotificationRepetitionPeriodCallbackCalled = false;
11         private static readonly int s_soundNotificationRepetitionPeriodValue = 300;
12         ////[Test]
13         //[Category("P1")]
14         //[Description("Check SoundNotificationRepetitionPeriodChangedEventArgs Value property")]
15         //[Property("SPEC", "Tizen.System.SoundNotificationRepetitionPeriodChangedEventArgs.Value A")]
16         //[Property("SPEC_URL", "-")]
17         //[Property("CRITERIA", "PRO")]
18         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
19         public static async Task Value_PROPERTY_READ_ONLY()
20         {
21             LogUtils.StartTest();
22             /*
23                 * PRECONDITION
24                 * 1. Assign event handler
25                 */
26             Tizen.System.SystemSettings.SoundNotificationRepetitionPeriodChanged += OnSoundNotificationRepetitionPeriodChangedValue;
27
28             int preValue = Tizen.System.SystemSettings.SoundNotificationRepetitionPeriod;
29             Tizen.System.SystemSettings.SoundNotificationRepetitionPeriod = s_soundNotificationRepetitionPeriodValue;
30             await Task.Delay(2000);
31             Assert.IsTrue(s_soundNotificationRepetitionPeriodCallbackCalled, "Value_PROPERTY_READ_ONLY: EventHandler added. Not getting called");
32
33             /*
34                 * POSTCONDITION
35                 * 1. Reset callback called flag
36                 * 2. Remove event handler
37                 * 3. Reset property value
38                 */
39             s_soundNotificationRepetitionPeriodCallbackCalled = false;
40             Tizen.System.SystemSettings.SoundNotificationRepetitionPeriodChanged -= OnSoundNotificationRepetitionPeriodChangedValue;
41             Tizen.System.SystemSettings.SoundNotificationRepetitionPeriod = preValue;
42             LogUtils.WriteOK();
43         }
44         private static void OnSoundNotificationRepetitionPeriodChangedValue(object sender, Tizen.System.SoundNotificationRepetitionPeriodChangedEventArgs e)
45         {
46             s_soundNotificationRepetitionPeriodCallbackCalled = true;
47             /* TEST CODE */
48             Assert.IsInstanceOf<int>(e.Value, "OnSoundNotificationRepetitionPeriodChangedValue: EventHandler added. Not getting called");
49             Assert.IsTrue(s_soundNotificationRepetitionPeriodValue.CompareTo(e.Value) == 0, "OnSoundNotificationRepetitionPeriodChangedValue: The callback should receive the latest value for the property.");
50         }
51     }
52 }