From: xb.teng Date: Tue, 15 Oct 2019 04:00:49 +0000 (+0800) Subject: [NUI][ACR-274] Add Disposable class to refactor dispose codes X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F215729%2F4;p=test%2Ftct%2Fcsharp%2Fapi.git [NUI][ACR-274] Add Disposable class to refactor dispose codes Change-Id: I56bbfc2b9d3d99456c0a827856fe920e300f2b6e --- diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSDisposable.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSDisposable.cs new file mode 100755 index 0000000..abc562d --- /dev/null +++ b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSDisposable.cs @@ -0,0 +1,141 @@ +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using Tizen.NUI; +using Tizen.NUI.Test; + +namespace Tizen.NUI.Tests +{ + [TestFixture] + [Description("Tizen.NUI.Disposable Tests")] + public class DisposableTests + { + private string TAG = "NUI"; + + [SetUp] + public void Init() + { + Tizen.Log.Info(TAG, " Init() is called!"); + App.MainTitleChangeText("DisposableTests"); + App.MainTitleChangeBackgroundColor(null); + } + + [TearDown] + public void Destroy() + { + Tizen.Log.Info(TAG, " Destroy() is called!"); + } + + [Test] + [Category("P1")] + [Description("Create a Disposable object.Check whether object is successfully created or not.")] + [Property("SPEC", "Tizen.NUI.Disposable.Disposable C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")] + public void Disposable_INIT() + { + /* TEST CODE */ + var disposable = new Disposable(); + + Assert.IsNotNull(disposable, "Can't create success object Disposable"); + Assert.IsInstanceOf(disposable, "Should be an instance of Disposable type."); + } + + [Test] + [Category("P1")] + [Description("Test Dispose, try to dispose the Disposable.")] + [Property("SPEC", "Tizen.NUI.Disposable.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")] + public void Dispose_TEST() + { + /* TEST CODE */ + try + { + Disposable disposable = new Disposable(); + disposable.Dispose(); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Dispose, try to dispose the Disposable.")] + [Property("SPEC", "Tizen.NUI.Disposable.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("COVPARAM", "DisposeTypes")] + [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")] + public void Dispose_Implicit_TEST_WITH_DISPOSETYPE() + { + /* TEST CODE */ + try + { + MyDisposable myDisposable = new MyDisposable(); + myDisposable.DisposeImplicit(); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Dispose, try to dispose the Disposable.")] + [Property("SPEC", "Tizen.NUI.Disposable.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("COVPARAM", "DisposeTypes")] + [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")] + public void Dispose_Explicit_TEST_WITH_DISPOSETYPE() + { + /* TEST CODE */ + try + { + MyDisposable myDisposable = new MyDisposable(); + myDisposable.DisposeExplicit(); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + } + + public class MyDisposable : Disposable + { + public void DisposeImplicit() + { + Dispose(DisposeTypes.Implicit); + } + + public void DisposeExplicit() + { + Dispose(DisposeTypes.Explicit); + } + + public bool Disposed + { + get + { + return disposed; + } + set + { + disposed = value; + } + } + } +}