1c42de7e0dedcefe038f6fd798698b4c5b826688
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Xaml / TSExpandMarkupsVisitor.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections.Generic;
4 using System.Xml;
5 using Tizen.NUI.Xaml;
6 using static Tizen.NUI.Xaml.ExpandMarkupsVisitor;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Xaml/ExpandMarkupsVisitor")]
14     internal class PublicExpandMarkupsVisitorTest
15     {
16         private const string tag = "NUITEST";
17         private static ExpandMarkupsVisitor e1;
18
19         [SetUp]
20         public void Init()
21         {
22             tlog.Info(tag, "Init() is called!");
23             HydrationContext context = new HydrationContext();
24
25             e1 = new ExpandMarkupsVisitor(context);
26         }
27
28         [TearDown]
29         public void Destroy()
30         {
31             e1 = null;
32             tlog.Info(tag, "Destroy() is called!");
33         }
34
35         [Test]
36         [Category("P1")]
37         [Description("ExpandMarkupsVisitor ExpandMarkupsVisitor")]
38         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.ExpandMarkupsVisitor C")]
39         [Property("SPEC_URL", "-")]
40         [Property("CRITERIA", "CONSTR")]
41         public void ExpandMarkupsVisitorConstructor()
42         {
43             tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor START");
44
45             HydrationContext context = new HydrationContext();
46
47             ExpandMarkupsVisitor expandMarkupsVisitor = new ExpandMarkupsVisitor(context);
48
49             tlog.Debug(tag, $"ExpandMarkupsVisitorConstructor END (OK)");
50             Assert.Pass("ExpandMarkupsVisitorConstructor");
51         }
52
53         [Test]
54         [Category("P1")]
55         [Description("ExpandMarkupsVisitor Skips")]
56         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.Skips A")]
57         [Property("SPEC_URL", "-")]
58         [Property("CRITERIA", "PRW")]
59         public void ExpandMarkupsVisitorSkips()
60         {
61             tlog.Debug(tag, $"ExpandMarkupsVisitorSkips START");
62
63             try
64             {
65                 IList<XmlName> l1 = ExpandMarkupsVisitor.Skips;
66             }
67             catch (Exception e)
68             {
69                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
70                 Assert.Fail("Caught Exception" + e.ToString());
71             }
72
73             tlog.Debug(tag, $"ExpandMarkupsVisitorSkips END (OK)");
74             Assert.Pass("ExpandMarkupsVisitorSkips");
75         }
76
77         [Test]
78         [Category("P1")]
79         [Description("ExpandMarkupsVisitor VisitingMode")]
80         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.VisitingMode A")]
81         [Property("SPEC_URL", "-")]
82         [Property("CRITERIA", "PRW")]
83         public void ExpandMarkupsVisitorVisitingMode()
84         {
85             tlog.Debug(tag, $"ExpandMarkupsVisitorVisitingMode START");
86
87             try
88             {
89                 TreeVisitingMode t1 = e1.VisitingMode;
90             }
91             catch (Exception e)
92             {
93                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
94                 Assert.Fail("Caught Exception" + e.ToString());
95             }
96
97             tlog.Debug(tag, $"ExpandMarkupsVisitorVisitingMode END (OK)");
98             Assert.Pass("ExpandMarkupsVisitorVisitingMode");
99         }
100
101         [Test]
102         [Category("P1")]
103         [Description("ExpandMarkupsVisitor StopOnDataTemplate")]
104         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.StopOnDataTemplate A")]
105         [Property("SPEC_URL", "-")]
106         [Property("CRITERIA", "PRW")]
107         public void ExpandMarkupsVisitorStopOnDataTemplate()
108         {
109             tlog.Debug(tag, $"ExpandMarkupsVisitorStopOnDataTemplate START");
110
111             try
112             {
113                 bool b1 = e1.StopOnDataTemplate;
114             }
115             catch (Exception e)
116             {
117                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
118                 Assert.Fail("Caught Exception" + e.ToString());
119             }
120
121             tlog.Debug(tag, $"ExpandMarkupsVisitorStopOnDataTemplate END (OK)");
122             Assert.Pass("ExpandMarkupsVisitorStopOnDataTemplate");
123         }
124
125         [Test]
126         [Category("P1")]
127         [Description("ExpandMarkupsVisitor StopOnResourceDictionary")]
128         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.StopOnResourceDictionary A")]
129         [Property("SPEC_URL", "-")]
130         [Property("CRITERIA", "PRW")]
131         public void ExpandMarkupsVisitorStopOnResourceDictionary()
132         {
133             tlog.Debug(tag, $"ExpandMarkupsVisitorStopOnResourceDictionary START");
134
135             try
136             {
137                 bool b1 = e1.StopOnResourceDictionary;
138             }
139             catch (Exception e)
140             {
141                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
142                 Assert.Fail("Caught Exception" + e.ToString());
143             }
144
145             tlog.Debug(tag, $"ExpandMarkupsVisitorStopOnResourceDictionary END (OK)");
146             Assert.Pass("ExpandMarkupsVisitorStopOnResourceDictionary");
147         }
148
149         [Test]
150         [Category("P1")]
151         [Description("ExpandMarkupsVisitor VisitNodeOnDataTemplate")]
152         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.VisitNodeOnDataTemplate A")]
153         [Property("SPEC_URL", "-")]
154         [Property("CRITERIA", "PRW")]
155         public void ExpandMarkupsVisitorVisitNodeOnDataTemplate()
156         {
157             tlog.Debug(tag, $"ExpandMarkupsVisitorVisitNodeOnDataTemplate START");
158
159             try
160             {
161                 bool b1 = e1.VisitNodeOnDataTemplate;
162             }
163             catch (Exception e)
164             {
165                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
166                 Assert.Fail("Caught Exception" + e.ToString());
167             }
168
169             tlog.Debug(tag, $"ExpandMarkupsVisitorVisitNodeOnDataTemplate END (OK)");
170             Assert.Pass("ExpandMarkupsVisitorVisitNodeOnDataTemplate");
171         }
172
173         public class INodeImplement : INode
174         {
175             public global::System.Collections.Generic.List<string> IgnorablePrefixes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
176
177             public global::System.Xml.IXmlNamespaceResolver NamespaceResolver => throw new NotImplementedException();
178
179             public INode Parent { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
180
181             public void Accept(IXamlNodeVisitor visitor, INode parentNode)
182             {
183                 throw new NotImplementedException();
184             }
185
186             public INode Clone()
187             {
188                 throw new NotImplementedException();
189             }
190         }
191
192         [Test]
193         [Category("P1")]
194         [Description("ExpandMarkupsVisitor SkipChildren")]
195         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.SkipChildren M")]
196         [Property("SPEC_URL", "-")]
197         [Property("CRITERIA", "MR")]
198         public void ExpandMarkupsVisitorSkipChildren()
199         {
200             tlog.Debug(tag, $"ExpandMarkupsVisitorSkipChildren START");
201
202             try
203             {
204                 INodeImplement node = new INodeImplement();
205                 INodeImplement nodeParent = new INodeImplement();
206                 bool b1 = e1.SkipChildren(node, nodeParent);
207             }
208             catch (Exception e)
209             {
210                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
211                 Assert.Fail("Caught Exception" + e.ToString());
212             }
213
214             tlog.Debug(tag, $"ExpandMarkupsVisitorSkipChildren END (OK)");
215             Assert.Pass("ExpandMarkupsVisitorSkipChildren");
216         }
217
218         public class IXmlNamespaceResolverImplement : IXmlNamespaceResolver
219         {
220             public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
221             {
222                 throw new NotImplementedException();
223             }
224
225             public string LookupNamespace(string prefix)
226             {
227                 throw new NotImplementedException();
228             }
229
230             public string LookupPrefix(string namespaceName)
231             {
232                 throw new NotImplementedException();
233             }
234         }
235
236         [Test]
237         [Category("P1")]
238         [Description("ExpandMarkupsVisitor IsResourceDictionary")]
239         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.IsResourceDictionary M")]
240         [Property("SPEC_URL", "-")]
241         [Property("CRITERIA", "MR")]
242         public void ExpandMarkupsVisitorIsResourceDictionary()
243         {
244             tlog.Debug(tag, $"ExpandMarkupsVisitorIsResourceDictionary START");
245
246             try
247             {
248                 IList<XmlType> list = null;
249                 XmlType xmlType = new XmlType("myNameSpace", "myName", list);
250
251                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
252                 ElementNode n1 = new ElementNode(xmlType, "myNameSpace", i1);
253
254                 bool b1 = e1.IsResourceDictionary(n1);
255             }
256             catch (Exception e)
257             {
258                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
259                 Assert.Fail("Caught Exception" + e.ToString());
260             }
261
262             tlog.Debug(tag, $"ExpandMarkupsVisitorIsResourceDictionary END (OK)");
263             Assert.Pass("ExpandMarkupsVisitorIsResourceDictionary");
264         }
265
266         [Test]
267         [Category("P1")]
268         [Description("ExpandMarkupsVisitor Visit")]
269         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.Visit M")]
270         [Property("SPEC_URL", "-")]
271         [Property("CRITERIA", "MR")]
272         public void ExpandMarkupsVisitorVisit()
273         {
274             tlog.Debug(tag, $"ExpandMarkupsVisitorVisit START");
275
276             try
277             {
278                 IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
279                 MarkupNode markupnode = new MarkupNode("markup", i1);
280                 INodeImplement parentNode = new INodeImplement();
281                 e1.Visit(markupnode, parentNode);
282             }
283             catch (Exception e)
284             {
285                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
286                 Assert.Fail("Caught Exception" + e.ToString());
287             }
288
289             tlog.Debug(tag, $"ExpandMarkupsVisitorVisit END (OK)");
290             Assert.Pass("ExpandMarkupsVisitorVisit");
291         }
292
293         public class IServiceProviderImplement : IServiceProvider
294         {
295             public object GetService(Type serviceType)
296             {
297                 throw new NotImplementedException();
298             }
299         }
300
301         [Test]
302         [Category("P1")]
303         [Description("ExpandMarkupsVisitor Parse")]
304         [Property("SPEC", "Tizen.NUI.ExpandMarkupsVisitor.MarkupExpansionParser.Parse M")]
305         [Property("SPEC_URL", "-")]
306         [Property("CRITERIA", "MR")]
307         public void ExpandMarkupsVisitorParse()
308         {
309             tlog.Debug(tag, $"ExpandMarkupsVisitorParse START");
310
311             try
312             {
313                 MarkupExpansionParser markupExpansionParser = new MarkupExpansionParser();
314                 IServiceProviderImplement serviceProviderImplement = new IServiceProviderImplement();
315
316                 string s1 = new string('a', 4);
317                 markupExpansionParser.Parse("matchString", ref s1, serviceProviderImplement);
318             }
319             catch (Exception e)
320             {
321                 tlog.Debug(tag, e.Message.ToString());
322                 tlog.Debug(tag, $"ExpandMarkupsVisitorParse END (OK)");
323                 Assert.Pass("Caught Exception : passed!");
324             }
325         }
326     }
327 }