[NUI] Add xaml and xamlbing testcases
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Xaml / TSXamlParseException.cs
1 using NUnit.Framework;
2 using System;
3 using System.Xml;
4 using Tizen.NUI.Xaml;
5
6 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("public/xaml/XamlParseException ")]
12     public class PublicXamlParseExceptionTest
13     {
14         private const string tag = "NUITEST";
15         private XamlParseException xamlParse;
16
17         internal class XmlLineInfoImpl : IXmlLineInfo
18         {
19             public int LineNumber => 0;
20             public int LinePosition => 0;
21             public bool HasLineInfo() => false;
22         }
23
24         [SetUp]
25         public void Init()
26         {
27             tlog.Info(tag, "Init() is called!");
28             xamlParse = new XamlParseException("myMessage");
29         }
30
31         [TearDown]
32         public void Destroy()
33         {
34             xamlParse = null;
35             tlog.Info(tag, "Destroy() is called!");
36         }
37
38         [Test]
39         [Category("P1")]
40         [Description("XamlParseException XamlParseException")]
41         [Property("SPEC", "Tizen.NUI.XamlParseException.XamlParseException C")]
42         [Property("SPEC_URL", "-")]
43         [Property("CRITERIA", "CONSTR")]
44         public void XamlParseExceptionConstructor()
45         {
46             tlog.Debug(tag, $"XamlParseExceptionConstructor START");
47
48             var testingTarget = new XamlParseException();
49             Assert.IsNotNull(testingTarget, "null XamlParseException");
50             Assert.IsInstanceOf<XamlParseException>(testingTarget, "Should return XamlParseException instance.");
51             
52             testingTarget = null;
53             tlog.Debug(tag, $"XamlParseExceptionConstructor END");
54         }
55
56         [Test]
57         [Category("P1")]
58         [Description("XamlParseException XamlParseException")]
59         [Property("SPEC", "Tizen.NUI.XamlParseException.XamlParseException C")]
60         [Property("SPEC_URL", "-")]
61         [Property("CRITERIA", "CONSTR")]
62         public void XamlParseExceptionConstructorWithMessage()
63         {
64             tlog.Debug(tag, $"XamlParseExceptionConstructorWithMessage START");
65
66             var testingTarget = new XamlParseException("myMessage", new Exception());
67             Assert.IsNotNull(testingTarget, "null XamlParseException");
68             Assert.IsInstanceOf<XamlParseException>(testingTarget, "Should return XamlParseException instance.");
69
70             testingTarget = null;
71             tlog.Debug(tag, $"XamlParseExceptionConstructorWithMessage END");
72         }
73         [Test]
74         [Category("P1")]
75         [Description("XamlParseException XamlParseException")]
76         [Property("SPEC", "Tizen.NUI.XamlParseException.XamlParseException C")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "CONSTR")]
79         public void XamlParseExceptionConstructor3()
80         {
81             tlog.Debug(tag, $"XamlParseExceptionConstructor START");
82
83             Exception e1 = new Exception();
84             XamlParseException x3 = new XamlParseException("myMessage", e1);
85             Assert.IsNotNull(x3, "null XamlParseException");
86             Assert.IsInstanceOf<XamlParseException>(x3, "Should return XamlParseException instance.");
87             x3 = null;
88             tlog.Debug(tag, $"XamlParseExceptionConstructor END");
89         }
90
91         [Test]
92         [Category("P1")]
93         [Description("XamlParseException XmlInfo ")]
94         [Property("SPEC", "Tizen.NUI.XamlParseException.XmlInfo A")]
95         [Property("SPEC_URL", "-")]
96         [Property("CRITERIA", "PRW")]
97         public void XamlParseExceptionXmlInfo()
98         {
99             tlog.Debug(tag, $"XamlParseExceptionXmlInfo START");
100
101             try
102             {
103                 var result = (XmlLineInfoImpl)xamlParse.XmlInfo;
104                 tlog.Debug(tag, "XmlInfo : " + result);
105             }
106             catch (Exception e)
107             {
108                 tlog.Debug(tag, e.Message.ToString());
109                 Assert.Fail("Caught Exception : Failed!");
110             }
111
112             tlog.Debug(tag, $"XamlParseExceptionXmlInfo END");
113         }
114
115         [Test]
116         [Category("P1")]
117         [Description("XamlParseException UnformattedMessage ")]
118         [Property("SPEC", "Tizen.NUI.XamlParseException.UnformattedMessage A")]
119         [Property("SPEC_URL", "-")]
120         [Property("CRITERIA", "PRW")]
121         public void XamlParseExceptionUnformattedMessage()
122         {
123             tlog.Debug(tag, $"XamlParseExceptionUnformattedMessage START");
124
125             try
126             {
127                 var result = xamlParse.UnformattedMessage;
128                 tlog.Debug(tag, "UnformattedMessage : " + result);
129             }
130             catch (Exception e)
131             {
132                 tlog.Debug(tag, e.Message.ToString());
133                 Assert.Fail("Caught Exception : Failed!");
134             }
135
136             tlog.Debug(tag, $"XamlParseExceptionUnformattedMessage END");
137         }
138     }
139 }