1 using NUnit.Framework;
6 namespace Tizen.NUI.Devel.Tests
8 using tlog = Tizen.Log;
11 [Description("public/xaml/StaticResourceExtension")]
12 public class PublicStaticResourceExtensionTest
14 private const string tag = "NUITEST";
15 private static StaticResourceExtension resourceExtension;
17 internal class XmlLineInfoImplent : IXmlLineInfo
19 public int LineNumber => 16;
21 public int LinePosition => 8;
23 public bool HasLineInfo()
29 internal class ServiceProviderImplemente : IServiceProvider
31 private static readonly object service = new object();
33 public object GetService(Type type)
42 tlog.Info(tag, "Init() is called!");
43 resourceExtension = new StaticResourceExtension();
49 resourceExtension = null;
50 tlog.Info(tag, "Destroy() is called!");
55 [Description("StaticResourceExtension Key")]
56 [Property("SPEC", "Tizen.NUI.StaticResourceExtension.Key A")]
57 [Property("SPEC_URL", "-")]
58 [Property("CRITERIA", "PRW")]
59 [Property("AUTHOR", "guowei.wang@samsung.com")]
60 public void StaticResourceExtensionKey()
62 tlog.Debug(tag, $"StaticResourceExtensionKey START");
65 var result = resourceExtension.Key;
66 tlog.Debug(tag, "Key : " + result);
67 resourceExtension.Key = "size";
68 tlog.Debug(tag, "Key : " + result);
72 tlog.Debug(tag, "Caught Exception" + e.ToString());
73 Assert.Fail("Caught Exception : Failed!");
75 tlog.Debug(tag, $"StaticResourceExtensionKey END (OK)");
76 Assert.Pass("StaticResourceExtensionKey");
81 [Description("StaticResourceExtension ProvideValue")]
82 [Property("SPEC", "Tizen.NUI.StaticResourceExtension.ProvideValue M")]
83 [Property("SPEC_URL", "-")]
84 [Property("CRITERIA", "MR")]
85 public void StaticResourceExtensionProvideValue()
87 tlog.Debug(tag, $"StaticResourceExtensionProvideValue START");
91 ServiceProviderImplemente ss = new ServiceProviderImplemente();
93 resourceExtension.Key = "myKey";
94 resourceExtension.ProvideValue(ss);
98 tlog.Debug(tag, e.Message.ToString());
99 tlog.Debug(tag, $"StaticResourceExtensionProvideValue END (OK)");
100 Assert.Pass("Caught Exception : passed!");
106 [Description("StaticResourceExtension ProvideValue. Null serviceProvider.")]
107 [Property("SPEC", "Tizen.NUI.StaticResourceExtension.ProvideValue M")]
108 [Property("SPEC_URL", "-")]
109 [Property("CRITERIA", "MR")]
110 [Property("AUTHOR", "guowei.wang@samsung.com")]
111 public void StaticResourceExtensionProvideValueWithNullServiceProvder()
113 tlog.Debug(tag, $"StaticResourceExtensionProvideValueWithNullServiceProvder START");
116 resourceExtension.ProvideValue(null);
118 catch (ArgumentNullException e)
120 tlog.Debug(tag, e.Message.ToString());
121 tlog.Debug(tag, $"StaticResourceExtensionProvideValueWithNullServiceProvder END (OK)");
122 Assert.Pass("Caught ArgumentNullException : passed!");
128 [Description("StaticResourceExtension ProvideValue. Null Key.")]
129 [Property("SPEC", "Tizen.NUI.StaticResourceExtension.ProvideValue M")]
130 [Property("SPEC_URL", "-")]
131 [Property("CRITERIA", "MR")]
132 [Property("AUTHOR", "guowei.wang@samsung.com")]
133 public void StaticResourceExtensionProvideValueWithNullKey()
135 tlog.Debug(tag, $"StaticResourceExtensionProvideValueWithNullKey START");
137 var serviceProvider = new ServiceProviderImplemente();
138 Assert.IsNotNull(serviceProvider, "Can't create success object IServiceProvider");
139 Assert.IsInstanceOf<IServiceProvider>(serviceProvider, "Should be an instance of IServiceProvider type.");
141 resourceExtension.Key = null;
145 resourceExtension.ProvideValue(serviceProvider);
147 catch (XamlParseException e)
149 tlog.Debug(tag, $"StaticResourceExtensionProvideValueWithNullKey END (OK)");
150 Assert.Pass("Caught XamlParseException : passed!");
156 [Description("StaticResourceExtension GetApplicationLevelResource")]
157 [Property("SPEC", "Tizen.NUI.StaticResourceExtension.GetApplicationLevelResource M")]
158 [Property("SPEC_URL", "-")]
159 [Property("CRITERIA", "MR")]
160 public void StaticResourceExtensionGetApplicationLevelResource()
162 tlog.Debug(tag, $"StaticResourceExtensionGetApplicationLevelResource START");
166 XmlLineInfoImplent xx = new XmlLineInfoImplent();
167 resourceExtension.GetApplicationLevelResource("mykey", xx);
171 tlog.Debug(tag, $"StaticResourceExtensionGetApplicationLevelResource END (OK)");
172 Assert.Pass("StaticResource not found for key mykey : Passed!");