87f94eb5e33faa2879517a5350d56ea37531217d
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Xaml / TSCreateValuesVisitor.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections.Generic;
4 using System.Xml;
5 using Tizen.NUI.Xaml;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using Tizen.NUI.Binding.Internals;
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Xaml/CreateValuesVisitor")]
14     internal class PublicCreateValuesVisitorTest
15     {
16         private const string tag = "NUITEST";
17         private static CreateValuesVisitor c1;
18
19         [SetUp]
20         public void Init()
21         {
22             tlog.Info(tag, "Init() is called!");
23             HydrationContext context = new HydrationContext();
24             c1 = new CreateValuesVisitor(context);
25         }
26
27         [TearDown]
28         public void Destroy()
29         {
30             c1 = null;
31             tlog.Info(tag, "Destroy() is called!");
32         }
33
34         [Test]
35         [Category("P1")]
36         [Description("CreateValuesVisitor CreateValuesVisitor")]
37         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.CreateValuesVisitor C")]
38         [Property("SPEC_URL", "-")]
39         [Property("CRITERIA", "CONSTR")]
40         public void CreateValuesVisitorConstructor()
41         {
42             tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor START");
43
44             HydrationContext context = new HydrationContext();
45
46             CreateValuesVisitor createValuesVisitor = new CreateValuesVisitor(context);
47
48             tlog.Debug(tag, $"CreateValuesVisitorConstructor END (OK)");
49             Assert.Pass("CreateValuesVisitorConstructor");
50         }
51
52         [Test]
53         [Category("P1")]
54         [Description("CreateValuesVisitor VisitingMode")]
55         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.VisitingMode A")]
56         [Property("SPEC_URL", "-")]
57         [Property("CRITERIA", "PRW")]
58         public void CreateValuesVisitorVisitingMode()
59         {
60             tlog.Debug(tag, $"CreateValuesVisitorVisitingMode START");
61
62             try
63             {
64                 TreeVisitingMode t1 = c1.VisitingMode;
65             }
66             catch (Exception e)
67             {
68                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
69                 Assert.Fail("Caught Exception" + e.ToString());
70             }
71
72             tlog.Debug(tag, $"CreateValuesVisitorVisitingMode END (OK)");
73             Assert.Pass("CreateValuesVisitorVisitingMode");
74         }
75
76         [Test]
77         [Category("P1")]
78         [Description("CreateValuesVisitor StopOnDataTemplate")]
79         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.StopOnDataTemplate A")]
80         [Property("SPEC_URL", "-")]
81         [Property("CRITERIA", "PRW")]
82         public void CreateValuesVisitorStopOnDataTemplate()
83         {
84             tlog.Debug(tag, $"CreateValuesVisitorStopOnDataTemplate START");
85
86             try
87             {
88                 bool b1 = c1.StopOnDataTemplate;
89             }
90             catch (Exception e)
91             {
92                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
93                 Assert.Fail("Caught Exception" + e.ToString());
94             }
95
96             tlog.Debug(tag, $"CreateValuesVisitorStopOnDataTemplate END (OK)");
97             Assert.Pass("CreateValuesVisitorStopOnDataTemplate");
98         }
99
100         [Test]
101         [Category("P1")]
102         [Description("CreateValuesVisitor StopOnResourceDictionary ")]
103         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.StopOnResourceDictionary  A")]
104         [Property("SPEC_URL", "-")]
105         [Property("CRITERIA", "PRW")]
106         public void CreateValuesVisitorStopOnResourceDictionary()
107         {
108             tlog.Debug(tag, $"CreateValuesVisitorStopOnResourceDictionary START");
109
110             try
111             {
112                 bool b1 = c1.StopOnResourceDictionary;
113             }
114             catch (Exception e)
115             {
116                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
117                 Assert.Fail("Caught Exception" + e.ToString());
118             }
119
120             tlog.Debug(tag, $"CreateValuesVisitorStopOnResourceDictionary END (OK)");
121             Assert.Pass("CreateValuesVisitorStopOnResourceDictionary");
122         }
123
124         [Test]
125         [Category("P1")]
126         [Description("CreateValuesVisitor VisitNodeOnDataTemplate  ")]
127         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.VisitNodeOnDataTemplate   A")]
128         [Property("SPEC_URL", "-")]
129         [Property("CRITERIA", "PRW")]
130         public void CreateValuesVisitorVisitNodeOnDataTemplate()
131         {
132             tlog.Debug(tag, $"CreateValuesVisitorVisitNodeOnDataTemplate START");
133
134             try
135             {
136                 bool b1 = c1.VisitNodeOnDataTemplate;
137             }
138             catch (Exception e)
139             {
140                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
141                 Assert.Fail("Caught Exception" + e.ToString());
142             }
143
144             tlog.Debug(tag, $"CreateValuesVisitorVisitNodeOnDataTemplate END (OK)");
145             Assert.Pass("CreateValuesVisitorVisitNodeOnDataTemplate");
146         }
147
148         public class INodeImplement : INode
149         {
150             public global::System.Collections.Generic.List<string> IgnorablePrefixes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
151
152             public global::System.Xml.IXmlNamespaceResolver NamespaceResolver => throw new NotImplementedException();
153
154             public INode Parent { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
155
156             public void Accept(IXamlNodeVisitor visitor, INode parentNode)
157             {
158                 throw new NotImplementedException();
159             }
160
161             public INode Clone()
162             {
163                 throw new NotImplementedException();
164             }
165         }
166
167         [Test]
168         [Category("P1")]
169         [Description("CreateValuesVisitor SkipChildren")]
170         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.SkipChildren M")]
171         [Property("SPEC_URL", "-")]
172         [Property("CRITERIA", "MR")]
173         public void CreateValuesVisitorSkipChildren()
174         {
175             tlog.Debug(tag, $"CreateValuesVisitorSkipChildren START");
176
177             try
178             {
179                 INodeImplement node = new INodeImplement();
180                 INodeImplement nodeParent = new INodeImplement();
181                 bool b1 = c1.SkipChildren(node, nodeParent);
182             }
183             catch (Exception e)
184             {
185                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
186                 Assert.Fail("Caught Exception" + e.ToString());
187             }
188
189             tlog.Debug(tag, $"CreateValuesVisitorSkipChildren END (OK)");
190             Assert.Pass("CreateValuesVisitorSkipChildren");
191         }
192
193         public class IXmlNamespaceResolverImplement : IXmlNamespaceResolver
194         {
195             public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
196             {
197                 throw new NotImplementedException();
198             }
199
200             public string LookupNamespace(string prefix)
201             {
202                 throw new NotImplementedException();
203             }
204
205             public string LookupPrefix(string namespaceName)
206             {
207                 throw new NotImplementedException();
208             }
209         }
210
211         [Test]
212         [Category("P1")]
213         [Description("CreateValuesVisitor IsResourceDictionary")]
214         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.IsResourceDictionary M")]
215         [Property("SPEC_URL", "-")]
216         [Property("CRITERIA", "MR")]
217         public void CreateValuesVisitorIsResourceDictionary()
218         {
219             tlog.Debug(tag, $"CreateValuesVisitorIsResourceDictionary START");
220
221             try
222             {
223                 IList<XmlType> list = null;
224                 XmlType xmlType = new XmlType("myNameSpace", "myName", list);
225
226                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
227                 ElementNode n1 = new ElementNode(xmlType, "myNameSpace", i1);
228
229                 bool b1 = c1.IsResourceDictionary(n1);
230             }
231             catch (Exception e)
232             {
233                 tlog.Debug(tag, e.Message.ToString());
234                 tlog.Debug(tag, $"CreateValuesVisitorIsResourceDictionary END (OK)");
235                 Assert.Pass("Caught Exception : passed!");
236             }
237         }
238
239         public class RootNodeImplement : RootNode
240         {
241             public RootNodeImplement(XmlType xmlType, IXmlNamespaceResolver nsResolver) : base(xmlType, nsResolver)
242             {
243             }
244         }
245
246         [Test]
247         [Category("P1")]
248         [Description("CreateValuesVisitor Visit")]
249         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.Visit M")]
250         [Property("SPEC_URL", "-")]
251         [Property("CRITERIA", "MR")]
252         public void CreateValuesVisitorVisit1()
253         {
254             tlog.Debug(tag, $"CreateValuesVisitorVisit START");
255
256             try
257             {
258                 object o1 = new object();
259                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
260                 ValueNode node = new ValueNode(o1, i1);
261                 INodeImplement parentNode = new INodeImplement();
262                 c1.Visit(node, parentNode);
263             }
264             catch (Exception e)
265             {
266                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
267                 Assert.Fail("Caught Exception" + e.ToString());
268             }
269
270             tlog.Debug(tag, $"CreateValuesVisitorVisit END (OK)");
271             Assert.Pass("CreateValuesVisitorVisit");
272         }
273
274         [Test]
275         [Category("P1")]
276         [Description("CreateValuesVisitor Visit")]
277         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.Visit M")]
278         [Property("SPEC_URL", "-")]
279         [Property("CRITERIA", "MR")]
280         public void CreateValuesVisitorVisit2()
281         {
282             tlog.Debug(tag, $"CreateValuesVisitorVisit START");
283
284             try
285             {
286                 INodeImplement parentNode = new INodeImplement();
287
288                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
289                 IList<XmlType> list = null;
290                 XmlType xmlType = new XmlType("myNameSpace", "myName", list);
291
292                 ElementNode n1 = new ElementNode(xmlType, "myNameSpace", i1);
293
294                 c1.Visit(n1, parentNode);
295             }
296             catch (Exception e)
297             {
298                 tlog.Debug(tag, e.Message.ToString());
299                 tlog.Debug(tag, $"CreateValuesVisitorVisit END (OK)");
300                 Assert.Pass("Caught Exception : passed!");
301             }
302         }
303
304         [Test]
305         [Category("P1")]
306         [Description("CreateValuesVisitor Visit")]
307         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.Visit M")]
308         [Property("SPEC_URL", "-")]
309         [Property("CRITERIA", "MR")]
310         public void CreateValuesVisitorVisit3()
311         {
312             tlog.Debug(tag, $"CreateValuesVisitorVisit START");
313
314             try
315             {
316                 INodeImplement parentNode = new INodeImplement();
317                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
318                 IList<XmlType> list = null;
319                 XmlType xmlType = new XmlType("myNameSpace", "myName", list);
320                 RootNodeImplement rootNode = new RootNodeImplement(xmlType, i1);
321                 c1.Visit(rootNode, parentNode);
322             }
323             catch (Exception e)
324             {
325                 tlog.Debug(tag, e.Message.ToString());
326                 tlog.Debug(tag, $"CreateValuesVisitorVisit END (OK)");
327                 Assert.Pass("Caught Exception : passed!");
328             }
329
330         }
331
332         public class IElementNodeImplement : IElementNode
333         {
334             public Dictionary<XmlName, INode> Properties => throw new NotImplementedException();
335
336             public List<XmlName> SkipProperties => throw new NotImplementedException();
337
338             public INameScope Namescope => throw new NotImplementedException();
339
340             public XmlType XmlType => throw new NotImplementedException();
341
342             public string NamespaceURI => throw new NotImplementedException();
343
344             public List<INode> CollectionItems => throw new NotImplementedException();
345
346             public List<string> IgnorablePrefixes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
347
348             public IXmlNamespaceResolver NamespaceResolver => throw new NotImplementedException();
349
350             public INode Parent { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
351
352             public void Accept(IXamlNodeVisitor visitor, INode parentNode)
353             {
354                 throw new NotImplementedException();
355             }
356
357             public INode Clone()
358             {
359                 throw new NotImplementedException();
360             }
361         }
362
363         [Test]
364         [Category("P1")]
365         [Description("CreateValuesVisitor CreateFromParameterizedConstructor")]
366         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.CreateFromParameterizedConstructor M")]
367         [Property("SPEC_URL", "-")]
368         [Property("CRITERIA", "MR")]
369         public void CreateValuesVisitorCreateFromParameterizedConstructor()
370         {
371             tlog.Debug(tag, $"CreateValuesVisitorCreateFromParameterizedConstructor START");
372
373             try
374             {
375                 Type type = typeof(string);
376                 IElementNodeImplement i1 = new IElementNodeImplement();
377                 c1.CreateFromParameterizedConstructor(type, i1);
378             }
379             catch (Exception e)
380             {
381                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
382                 Assert.Fail("Caught Exception" + e.ToString());
383             }
384
385             tlog.Debug(tag, $"CreateValuesVisitorCreateFromParameterizedConstructor END (OK)");
386             Assert.Pass("CreateValuesVisitorCreateFromParameterizedConstructor");
387         }
388
389         [Test]
390         [Category("P1")]
391         [Description("CreateValuesVisitor CreateFromFactory")]
392         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.CreateFromFactory M")]
393         [Property("SPEC_URL", "-")]
394         [Property("CRITERIA", "MR")]
395         public void CreateValuesVisitorCreateFromFactory()
396         {
397             tlog.Debug(tag, $"CreateValuesVisitorCreateFromFactory START");
398
399             try
400             {
401                 Type type = typeof(string);
402                 IElementNodeImplement i1 = new IElementNodeImplement();
403                 c1.CreateFromFactory(type, i1);
404             }
405             catch (Exception e)
406             {
407                 tlog.Debug(tag, e.Message.ToString());
408                 tlog.Debug(tag, $"CreateValuesVisitorCreateFromFactory END (OK)");
409                 Assert.Pass("Caught Exception : passed!");
410             }
411         }
412
413         [Test]
414         [Category("P1")]
415         [Description("CreateValuesVisitor CreateArgumentsArray")]
416         [Property("SPEC", "Tizen.NUI.CreateValuesVisitor.CreateArgumentsArray M")]
417         [Property("SPEC_URL", "-")]
418         [Property("CRITERIA", "MR")]
419         public void CreateValuesVisitorCreateArgumentsArray()
420         {
421             tlog.Debug(tag, $"CreateValuesVisitorCreateArgumentsArray START");
422
423             try
424             {
425                 IElementNodeImplement i1 = new IElementNodeImplement();
426                 c1.CreateArgumentsArray(i1);
427             }
428             catch (Exception e)
429             {
430                 tlog.Debug(tag, e.Message.ToString());
431                 tlog.Debug(tag, $"CreateValuesVisitorCreateArgumentsArray END (OK)");
432                 Assert.Pass("Caught Exception : passed!");
433             }
434         }
435
436
437     }
438 }