6c93f5754ab4829615ed845ca15204d07c94529c
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Xaml / MarkupExtensions / TSDynamicResourceExtension.cs
1 using NUnit.Framework;
2 using System;
3 using Tizen.NUI.Xaml;
4
5 namespace Tizen.NUI.Devel.Tests
6 {
7     using tlog = Tizen.Log;
8
9     [TestFixture]
10     [Description("public/xaml/MarkupExtensions/DynamicResourceExtension")]
11     internal class PublicDynamicResourceExtensionTest
12     {
13         private const string tag = "NUITEST";
14         private static DynamicResourceExtension d1;
15         [SetUp]
16         public void Init()
17         {
18             tlog.Info(tag, "Init() is called!");
19             d1 = new DynamicResourceExtension();
20         }
21
22         [TearDown]
23         public void Destroy()
24         {
25             d1 = null;
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("DynamicResourceExtension Key")]
32         [Property("SPEC", "Tizen.NUI.DynamicResourceExtension.Key A")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "PRW")]
35         public void DynamicResourceExtensionKey()
36         {
37             tlog.Debug(tag, $"DynamicResourceExtensionKey START");
38
39             try
40             {
41                 string tmp = d1.Key;
42                 d1.Key = tmp;
43             }
44             catch (Exception e)
45             {
46                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
47                 Assert.Fail("Caught Exception" + e.ToString());
48             }
49
50             tlog.Debug(tag, $"DynamicResourceExtensionKey END (OK)");
51             Assert.Pass("DynamicResourceExtensionKey");
52         }
53
54         private class IServiceProviderimplement : IServiceProvider
55         {
56             public object GetService(Type serviceType)
57             {
58                 return null;
59             }
60         }
61
62         [Test]
63         [Category("P1")]
64         [Description("DynamicResourceExtension Key")]
65         [Property("SPEC", "Tizen.NUI.DynamicResourceExtension.Key A")]
66         [Property("SPEC_URL", "-")]
67         [Property("CRITERIA", "PRW")]
68         public void DynamicResourceExtensionProvideValue()
69         {
70             tlog.Debug(tag, $"DynamicResourceExtensionProvideValue START");
71
72             try
73             {
74                 IServiceProviderimplement serviceProviderimplement = new IServiceProviderimplement();
75                 d1.Key = "myKey";
76                 d1.ProvideValue(serviceProviderimplement);
77             }
78             catch (Exception e)
79             {
80                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
81                 Assert.Fail("Caught Exception" + e.ToString());
82             }
83
84             tlog.Debug(tag, $"DynamicResourceExtensionProvideValue END (OK)");
85             Assert.Pass("DynamicResourceExtensionProvideValue");
86         }
87     }
88 }