8adfec0dee355ed042da47ca2f98177d3dccd526
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Xaml / TSStaticResourceExtension.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/StaticResourceExtension")]
12     public class PublicStaticResourceExtensionTest
13     {
14         private const string tag = "NUITEST";
15         private StaticResourceExtension staticRes;
16                 
17                 private class ServiceProviderImpl : IServiceProvider
18         {
19             private static readonly object service = new object();
20
21             public object GetService(Type type)
22             {
23                 return service;
24             }
25         }
26                 
27                 private class XmlLineInfoImplent : IXmlLineInfo
28         {
29             public int LineNumber => 16;
30
31             public int LinePosition => 8;
32
33             public bool HasLineInfo()
34             {
35                 return true;
36             }
37         }
38                 
39         [SetUp]
40         public void Init()
41         {
42             tlog.Info(tag, "Init() is called!");
43             staticRes = new StaticResourceExtension();
44         }
45
46         [TearDown]
47         public void Destroy()
48         {
49             staticRes = null;
50             tlog.Info(tag, "Destroy() is called!");
51         }
52
53         [Test]
54         [Category("P1")]
55         [Description("StaticResourceExtension Key")]
56         [Property("SPEC", "Tizen.NUI.Xaml.StaticResourceExtension.Key A")]
57         [Property("SPEC_URL", "-")]
58         [Property("CRITERIA", "PRW")]
59         public void StaticResourceExtensionKey()
60         {
61             tlog.Debug(tag, $"StaticResourceExtensionKey START");
62             try
63             {
64                 string key = staticRes.Key;
65                 staticRes.Key = key;
66                 Assert.AreEqual(key, staticRes.Key, "Should be equal");
67             }
68             catch (Exception e)
69             {
70                 tlog.Debug(tag, e.Message.ToString());
71                 Assert.Fail("Caught Exception : Failed!");
72             }
73             tlog.Debug(tag, $"StaticResourceExtensionKey END");
74         }
75
76         [Test]
77         [Category("P2")]
78         [Description("StaticResourceExtension Key")]
79         [Property("SPEC", "Tizen.NUI.Xaml.StaticResourceExtension.ProvideValue M")]
80         [Property("SPEC_URL", "-")]
81         [Property("CRITERIA", "MR")]
82         public void ProvideValueTest()
83         {
84             tlog.Debug(tag, $"ProvideValueTest START");
85
86             var sr = new StaticResourceExtension();
87             Assert.Throws<ArgumentNullException>(() => sr.ProvideValue(null));
88
89             tlog.Debug(tag, $"ProvideValueTest END");
90         }
91
92         [Test]
93         [Category("P2")]
94         [Description("StaticResourceExtension ProvideValue")]
95         [Property("SPEC", "Tizen.NUI.Xaml.StaticResourceExtension.ProvideValue M")]
96         [Property("SPEC_URL", "-")]
97         [Property("CRITERIA", "MR")]
98         public void ProvideValueTest2()
99         {
100             tlog.Debug(tag, $"ProvideValueTest2 START");
101
102             var sr = new StaticResourceExtension();
103             Assert.Throws<XamlParseException>(() => sr.ProvideValue(new ServiceProviderImpl()));
104
105             tlog.Debug(tag, $"ProvideValueTest2 END");
106         }
107
108         [Test]
109         [Category("P2")]
110         [Description("StaticResourceExtension ProvideValue")]
111         [Property("SPEC", "Tizen.NUI.Xaml.StaticResourceExtension.ProvideValue M")]
112         [Property("SPEC_URL", "-")]
113         [Property("CRITERIA", "MR")]
114         public void ProvideValueTest3()
115         {
116             tlog.Debug(tag, $"ProvideValueTest3 START");
117
118             var sr = new StaticResourceExtension();
119             sr.Key = "Key";
120             Assert.Throws<ArgumentException>(() => sr.ProvideValue(new ServiceProviderImpl()));
121
122             tlog.Debug(tag, $"ProvideValueTest3 END");
123         }
124
125         [Test]
126         [Category("P2")]
127         [Description("StaticResourceExtension GetApplicationLevelResource")]
128         [Property("SPEC", "Tizen.NUI.Xaml.StaticResourceExtension.GetApplicationLevelResource M")]
129         [Property("SPEC_URL", "-")]
130         [Property("CRITERIA", "MR")]
131         public void GetApplicationLevelResourceTest()
132         {
133             tlog.Debug(tag, $"GetApplicationLevelResourceTest START");
134
135             var sr = new StaticResourceExtension();
136             Assert.Throws<ArgumentNullException>(() => sr.GetApplicationLevelResource("key", null));
137
138             tlog.Debug(tag, $"GetApplicationLevelResourceTest END");
139         }
140     }
141 }