27cf8c8382d37d0a3f6163d135bb0f0e8e3d1e79
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / testcase / public / Common / TSPropertyArray.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("public/Common/PropertyArray")]
13     class TSPropertyArray
14     {
15         private const string tag = "NUITEST";
16
17         [SetUp]
18         public void Init()
19         {
20             tlog.Info(tag, "Init() is called!");
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("PropertyArray constructor")]
32         [Property("SPEC", "Tizen.NUI.PropertyArray.PropertyArray C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void PropertyArrayConstructor()
37         {
38             tlog.Debug(tag, $"PropertyArrayConstructor START");
39
40             var testingTarget = new PropertyArray();
41             Assert.IsNotNull(testingTarget, "should be not null");
42             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"PropertyArrayConstructor END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("PropertyArray Size")]
51         [Property("SPEC", "Tizen.NUI.PropertyArray.Size M")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "MR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void PropertyArraySize()
56         {
57             tlog.Debug(tag, $"PropertyArraySize START");
58
59             var testingTarget = new PropertyArray();
60             Assert.IsNotNull(testingTarget, "should be not null");
61             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
62
63             testingTarget.Reserve(3);
64             Assert.IsTrue(testingTarget.Size() == 0, "testingTarget's size should be 1");
65             var pValue = new PropertyValue(1);
66             testingTarget.PushBack(pValue);
67             Assert.IsTrue(testingTarget.Size() == 1, "testingTarget's size should be 1");
68
69             pValue.Dispose();
70             testingTarget.Dispose();
71             tlog.Debug(tag, $"PropertyArraySize END (OK)");
72         }
73
74         [Test]
75         [Category("P1")]
76         [Description("PropertyArray Count")]
77         [Property("SPEC", "Tizen.NUI.PropertyArray.Count M")]
78         [Property("SPEC_URL", "-")]
79         [Property("CRITERIA", "MR")]
80         [Property("AUTHOR", "guowei.wang@samsung.com")]
81         public void PropertyArrayCount()
82         {
83             tlog.Debug(tag, $"PropertyArrayCount START");
84
85             var testingTarget = new PropertyArray();
86             Assert.IsNotNull(testingTarget, "should be not null");
87             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
88             Assert.AreEqual(0, testingTarget.Count(), "Retrieved testingTarget.Count() should be equal to 0.");
89
90             testingTarget.Reserve(3);
91             var pValue = new PropertyValue(1);
92             testingTarget.PushBack(pValue);
93             Assert.IsTrue(testingTarget.Count() == 1, "testingTarget's count should be 1");
94
95             pValue.Dispose();
96             testingTarget.Dispose();
97             tlog.Debug(tag, $"PropertyArrayCount END (OK)");
98         }
99
100         [Test]
101         [Category("P1")]
102         [Description("PropertyArray Empty")]
103         [Property("SPEC", "Tizen.NUI.PropertyArray.Empty M")]
104         [Property("SPEC_URL", "-")]
105         [Property("CRITERIA", " MR")]
106         [Property("AUTHOR", "guowei.wang@samsung.com")]
107         public void PropertyArrayEmpty()
108         {
109             tlog.Debug(tag, $"PropertyArrayEmpty START");
110
111             var testingTarget = new PropertyArray();
112             Assert.IsNotNull(testingTarget, "should be not null");
113             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
114
115             testingTarget.Reserve(3);
116             Assert.IsTrue(testingTarget.Empty());
117
118             var pVal = new PropertyValue(1);
119             testingTarget.PushBack(pVal);
120             Assert.IsFalse(testingTarget.Empty());
121
122             pVal.Dispose();
123             testingTarget.Dispose();
124             tlog.Debug(tag, $"PropertyArrayEmpty END (OK)");
125         }
126
127         [Test]
128         [Category("P1")]
129         [Description("PropertyArray Clear")]
130         [Property("SPEC", "Tizen.NUI.PropertyArray.Clear M")]
131         [Property("SPEC_URL", "-")]
132         [Property("CRITERIA", "MR MCST")]
133         [Property("AUTHOR", "guowei.wang@samsung.com")]
134         public void PropertyArrayClear()
135         {
136             tlog.Debug(tag, $"PropertyArrayClear START");
137
138             var testingTarget = new PropertyArray();
139             Assert.IsNotNull(testingTarget, "should be not null");
140             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
141
142             testingTarget.Reserve(3);
143             var pValue = new PropertyValue(1);
144             testingTarget.PushBack(pValue);
145             Assert.IsFalse(testingTarget.Empty());
146
147             testingTarget.Clear();
148             Assert.IsTrue(testingTarget.Empty());
149
150             pValue.Dispose();
151             testingTarget.Dispose();
152             tlog.Debug(tag, $"PropertyArrayClear END (OK)");
153         }
154
155         [Test]
156         [Category("P1")]
157         [Description("PropertyArray Reserve")]
158         [Property("SPEC", "Tizen.NUI.PropertyArray.Reserve M")]
159         [Property("SPEC_URL", "-")]
160         [Property("CRITERIA", "MR MCST")]
161         [Property("AUTHOR", "guowei.wang@samsung.com")]
162         public void PropertyArrayReserve()
163         {
164             tlog.Debug(tag, $"PropertyArrayReserve START");
165
166             var testingTarget = new PropertyArray();
167             Assert.IsNotNull(testingTarget, "should be not null");
168             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
169             Assert.IsTrue(testingTarget.Capacity() == 0, "testingTarget's capacity should be 0");
170
171             testingTarget.Reserve(3);
172             Assert.IsTrue(testingTarget.Capacity() == 3, "testingTarget's capacity should be 3");
173
174             testingTarget.Dispose();
175             tlog.Debug(tag, $"PropertyArrayClear END (OK)");
176         }
177
178         [Test]
179         [Category("P1")]
180         [Description("PropertyArray Resize")]
181         [Property("SPEC", "Tizen.NUI.PropertyArray.Resize M")]
182         [Property("SPEC_URL", "-")]
183         [Property("CRITERIA", "MR MCST")]
184         [Property("AUTHOR", "guowei.wang@samsung.com")]
185         public void PropertyArrayResize()
186         {
187             tlog.Debug(tag, $"PropertyArrayResize START");
188
189             var testingTarget = new PropertyArray();
190             Assert.IsNotNull(testingTarget, "should be not null");
191             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
192
193             testingTarget.Resize(5);
194             var result = testingTarget.Count();
195             Assert.IsTrue(result == 5, "result should be 5");
196
197             testingTarget.Dispose();
198             tlog.Debug(tag, $"PropertyArrayResize END (OK)");
199         }
200
201         [Test]
202         [Category("P1")]
203         [Description("PropertyArray Capacity")]
204         [Property("SPEC", "Tizen.NUI.PropertyArray.Capacity M")]
205         [Property("SPEC_URL", "-")]
206         [Property("CRITERIA", "MR")]
207         [Property("AUTHOR", "guowei.wang@samsung.com")]
208         public void PropertyArrayCapacity()
209         {
210             tlog.Debug(tag, $"PropertyArrayCapacity START");
211
212             var testingTarget = new PropertyArray();
213             Assert.IsNotNull(testingTarget, "should be not null");
214             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
215
216             testingTarget.Reserve(6);
217             var result = testingTarget.Capacity();
218             Assert.IsTrue(result == 6, "result should be 6");
219
220             testingTarget.Dispose();
221             tlog.Debug(tag, $"PropertyArrayCapacity END (OK)");
222         }
223
224         [Test]
225         [Category("P1")]
226         [Description("PropertyArray PushBack")]
227         [Property("SPEC", "Tizen.NUI.PropertyArray.PushBack M")]
228         [Property("SPEC_URL", "-")]
229         [Property("CRITERIA", "MR MCST")]
230         [Property("AUTHOR", "guowei.wang@samsung.com")]
231         public void PropertyArrayPushBack()
232         {
233             tlog.Debug(tag, $"PropertyArrayPushBack START");
234
235             var testingTarget = new PropertyArray();
236             Assert.IsNotNull(testingTarget, "should be not null");
237             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
238
239             var pValue = new PropertyValue(4);
240             testingTarget.PushBack(pValue);
241             var result = testingTarget.Size();
242             Assert.IsTrue(result == 1, "result should be 1");
243
244             pValue.Dispose();
245             testingTarget.Dispose();
246             tlog.Debug(tag, $"PropertyArrayPushBack END (OK)");
247         }
248
249         [Test]
250         [Category("P1")]
251         [Description("PropertyArray Add. Add with property value")]
252         [Property("SPEC", "Tizen.NUI.PropertyArray.Add M")]
253         [Property("SPEC_URL", "-")]
254         [Property("CRITERIA", "MR")]
255         [Property("AUTHOR", "guowei.wang@samsung.com")]
256         public void PropertyArrayAddWithProperty()
257         {
258             tlog.Debug(tag, $"PropertyArrayAddWithProperty START");
259
260             var testingTarget = new PropertyArray();
261             Assert.IsNotNull(testingTarget, "should be not null");
262             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
263
264             var pValue = new PropertyValue(14.0f);
265             testingTarget.Add(pValue);
266             Assert.AreEqual(1, testingTarget.Size(), "Retrieved testingTarget.Size() should be equal to 1.");
267
268             var result = 0.0f;
269             testingTarget[0].Get(out result);
270             Assert.IsTrue(result == 14.0f, "result should be 14.0f");
271
272             pValue.Dispose();
273             testingTarget.Dispose();
274             tlog.Debug(tag, $"PropertyArrayAddWithProperty END (OK)");
275         }
276
277         [Test]
278         [Category("P1")]
279         [Description("PropertyArray Add. Add with key value")]
280         [Property("SPEC", "Tizen.NUI.PropertyArray.Add M")]
281         [Property("SPEC_URL", "-")]
282         [Property("CRITERIA", "MR")]
283         [Property("AUTHOR", "guowei.wang@samsung.com")]
284         public void PropertyArrayAddWithKey()
285         {
286             tlog.Debug(tag, $"PropertyArrayAddWithKey START");
287
288             var testingTarget = new PropertyArray();
289             Assert.IsNotNull(testingTarget, "should be not null");
290             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
291
292             var kValue = new KeyValue();
293             kValue.SingleValue = 14.0f;
294             testingTarget.Add(kValue);
295             Assert.AreEqual(1, testingTarget.Size(), "Retrieved testingTarget.Size() should be equal to 1.");
296             
297             var result = 0.0f;
298             testingTarget[0].Get(out result);
299             Assert.IsTrue(result == 14.0f, "result should be 14.0f");
300
301             kValue.Dispose();
302             testingTarget.Dispose();
303             tlog.Debug(tag, $"PropertyArrayAddWithKey END (OK)");
304         }
305
306         [Test]
307         [Category("P1")]
308         [Description("PropertyArray GetElementAt")]
309         [Property("SPEC", "Tizen.NUI.PropertyArray.GetElementAt M")]
310         [Property("SPEC_URL", "-")]
311         [Property("CRITERIA", "MR")]
312         [Property("AUTHOR", "guowei.wang@samsung.com")]
313         public void PropertyArrayGetElementAt()
314         {
315             tlog.Debug(tag, $"PropertyArrayGetElementAt START");
316
317             var testingTarget = new PropertyArray();
318             Assert.IsNotNull(testingTarget, "should be not null");
319             Assert.IsInstanceOf<PropertyArray>(testingTarget, "should be an instance of testing target class!");
320
321             var pValue = new PropertyValue(3.0f);
322             testingTarget.Add(pValue);
323
324             var result = 0.0f;
325             testingTarget.GetElementAt(0).Get(out result);
326             Assert.IsTrue(result == 3.0f, "result should be 3.0f");
327
328             pValue.Dispose();
329             testingTarget.Dispose();
330             tlog.Debug(tag, $"PropertyArrayGetElementAt END (OK)");
331         }
332     }
333 }