fe0e806fd58828d678317359227bd343300b359c
[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     internal class PublicStaticResourceExtensionTest
13     {
14         private const string tag = "NUITEST";
15         private static StaticResourceExtension s1;
16         [SetUp]
17         public void Init()
18         {
19             tlog.Info(tag, "Init() is called!");
20             s1 = new StaticResourceExtension();
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             s1 = null;
27             tlog.Info(tag, "Destroy() is called!");
28         }
29
30         [Test]
31         [Category("P1")]
32         [Description("StaticResourceExtension Key")]
33         [Property("SPEC", "Tizen.NUI.StaticResourceExtension.Key A")]
34         [Property("SPEC_URL", "-")]
35         [Property("CRITERIA", "PRW")]
36         public void StaticResourceExtensionKey()
37         {
38             tlog.Debug(tag, $"StaticResourceExtensionKey START");
39             try
40             {
41                 string key = s1.Key;
42                 s1.Key = key;
43             }
44             catch (Exception e)
45             {
46                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
47                 Assert.Fail("Caught Exception" + e.ToString());
48             }
49             tlog.Debug(tag, $"StaticResourceExtensionKey END (OK)");
50             Assert.Pass("StaticResourceExtensionKey");
51         }
52
53         private class ServiceProviderImplementer : IServiceProvider
54         {
55             private static readonly object service = new object();
56
57             public object GetService(Type type)
58             {
59                 return service;
60             }
61         }
62
63         [Test]
64         [Category("P1")]
65         [Description("StaticResourceExtension ProvideValue")]
66         [Property("SPEC", "Tizen.NUI.StaticResourceExtension.ProvideValue M")]
67         [Property("SPEC_URL", "-")]
68         [Property("CRITERIA", "MR")]
69         public void StaticResourceExtensionProvideValue()
70         {
71             tlog.Debug(tag, $"StaticResourceExtensionProvideValue START");
72             try
73             {
74                 ServiceProviderImplementer ss = new ServiceProviderImplementer();
75
76                 s1.Key = "myKey";
77                 s1.ProvideValue(ss);
78             }
79             catch (Exception e)
80             {
81                 tlog.Debug(tag, e.Message.ToString());
82                 tlog.Debug(tag, $"StaticResourceExtensionProvideValue END (OK)");
83                 Assert.Pass("Caught Exception : passed!");
84             }
85         }
86
87         private class XmlLineInfoImplent : IXmlLineInfo
88         {
89             public int LineNumber => 16;
90
91             public int LinePosition => 8;
92
93             public bool HasLineInfo()
94             {
95                 return true;
96             }
97         }
98
99         [Test]
100         [Category("P1")]
101         [Description("StaticResourceExtension GetApplicationLevelResource")]
102         [Property("SPEC", "Tizen.NUI.StaticResourceExtension.GetApplicationLevelResource M")]
103         [Property("SPEC_URL", "-")]
104         [Property("CRITERIA", "MR")]
105         public void StaticResourceExtensionGetApplicationLevelResource()
106         {
107             tlog.Debug(tag, $"StaticResourceExtensionGetApplicationLevelResource START");
108             try
109             {
110                 XmlLineInfoImplent xx = new XmlLineInfoImplent();
111                 s1.GetApplicationLevelResource("mykey", xx);
112             }
113             catch (Exception e)
114             {
115                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
116                 Assert.Fail("Caught Exception" + e.ToString());
117             }
118             tlog.Debug(tag, $"StaticResourceExtensionGetApplicationLevelResource END (OK)");
119             Assert.Pass("StaticResourceExtensionGetApplicationLevelResource");
120         }
121     }
122 }