[NUI] Add xaml and xamlbing testcases
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Xaml / MarkupExtensions / TSReferenceExtension.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using Tizen.NUI.Xaml;
7 using Tizen.NUI.Binding.Internals;
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("public/xaml/MarkupExtensions/ReferenceExtension")]
15     public class PublicReferenceExtensionTest
16     {
17         private const string tag = "NUITEST";
18         private Tizen.NUI.Xaml.ReferenceExtension reference;
19
20         internal class IServiceProviderImpl : IServiceProvider
21         {
22             public object GetService(Type serviceType) { return null; }
23         }
24
25         internal class IServiceProviderImpl2 : IServiceProvider
26         {
27             public object GetService(Type serviceType) { return new NameScopeProvider() { NameScope = new NameScope() { } }; }
28         }
29
30         [SetUp]
31         public void Init()
32         {
33             tlog.Info(tag, "Init() is called!");
34             reference = new Tizen.NUI.Xaml.ReferenceExtension();
35         }
36
37         [TearDown]
38         public void Destroy()
39         {
40             reference = null;
41             tlog.Info(tag, "Destroy() is called!");
42         }
43
44         [Test]
45         [Category("P1")]
46         [Description("ReferenceExtension Name")]
47         [Property("SPEC", "Tizen.NUI.ReferenceExtension.Name A")]
48         [Property("SPEC_URL", "-")]
49         [Property("CRITERIA", "PRW")]
50         public void ReferenceExtensionName()
51         {
52             tlog.Debug(tag, $"ReferenceExtensionName START");
53
54             try
55             {
56                 var name = reference.Name;
57                 reference.Name = name;
58                 Assert.AreEqual(name, reference.Name, "Should be equal");
59             }
60             catch (Exception e)
61             {
62                 tlog.Debug(tag, e.Message.ToString());
63                 Assert.Fail("Caught Exception : Failed!");
64             }
65
66             tlog.Debug(tag, $"ReferenceExtensionName END");
67         }
68
69         [Test]
70         [Category("P2")]
71         [Description("ReferenceExtension ProvideValue")]
72         [Property("SPEC", "Tizen.NUI.ReferenceExtension.ProvideValue M")]
73         [Property("SPEC_URL", "-")]
74         [Property("CRITERIA", "MR")]
75         public void ReferenceExtensionProvideValue()
76         {
77             tlog.Debug(tag, $"ReferenceExtensionProvideValue START");
78             Assert.Throws<ArgumentException>(() => reference.ProvideValue(new IServiceProviderImpl()));
79             tlog.Debug(tag, $"ReferenceExtensionProvideValue END");
80         }
81
82         [Test]
83         [Category("P2")]
84         [Description("ReferenceExtension ProvideValue")]
85         [Property("SPEC", "Tizen.NUI.ReferenceExtension.ProvideValue M")]
86         [Property("SPEC_URL", "-")]
87         [Property("CRITERIA", "MR")]
88         public void ReferenceExtensionProvideValue2()
89         {
90             tlog.Debug(tag, $"ReferenceExtensionProvideValue2 START");
91             Assert.Throws<ArgumentNullException>(() => reference.ProvideValue(null));
92             tlog.Debug(tag, $"ReferenceExtensionProvideValue2 END");
93         }
94     }
95 }