From: Xie Ligang Date: Fri, 17 Aug 2018 02:37:36 +0000 (+0800) Subject: [Nlp][TCSACR-169][Upload the TCT for NLP program for the ACR.] X-Git-Tag: tct5.0_m2~50^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F186968%2F29;p=test%2Ftct%2Fcsharp%2Fapi.git [Nlp][TCSACR-169][Upload the TCT for NLP program for the ACR.] Change-Id: I7d20d77c0393920a61deffd498f7bfefb5ba9dd6 Signed-off-by: Xie Ligang --- diff --git a/tct-suite-vs/Tizen.Nlp.Tests/Program.cs b/tct-suite-vs/Tizen.Nlp.Tests/Program.cs new file mode 100755 index 0000000..87d9f97 --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/Program.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using System; +using NUnitLite.TUnit; +using AutoTemplate; + +namespace XamarinForTizen.Tizen +{ + + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + private static App _app; + protected override void OnCreate() + { + base.OnCreate(); + + Console.WriteLine("TCT : OnCreate()"); + _app = new App(); + LoadApplication(_app); + + TRunner t = new TRunner(); + t.LoadTestsuite(); + t.Execute(); + } + + public static App getApp() + { + return _app; + } + static void Main(string[] args) + { + Console.WriteLine("TCT : Main()"); + var app = new Program(); + global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); + app.Run(args); + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.csproj b/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.csproj new file mode 100755 index 0000000..7ad1c1d --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.csproj @@ -0,0 +1,39 @@ + + + + + Exe + tizen50 + + + + + true + + + + portable + + + None + + + + + + + + + + + Runtime + + + + + + + + + + diff --git a/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.sln b/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.sln new file mode 100755 index 0000000..bf713d7 --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/Tizen.Nlp.Tests.sln @@ -0,0 +1,72 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.15 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Nlp.Tests", "Tizen.Nlp.Tests.csproj", "{D92BEEAC-3B2A-45F8-8C53-53B92550404A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\nunit.framework\nunit.framework.csproj", "{B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\nunitlite.csproj", "{FDB8025A-C029-461F-895E-287B4C65939B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTemplate", "..\Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.NUI|Any CPU.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.NUI|Any CPU.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED382B91-9930-40B6-B3D7-362304C78680} + EndGlobalSection +EndGlobal diff --git a/tct-suite-vs/Tizen.Nlp.Tests/shared/res/Tizen.Nlp.Tests.png b/tct-suite-vs/Tizen.Nlp.Tests/shared/res/Tizen.Nlp.Tests.png new file mode 100755 index 0000000..9765b1b Binary files /dev/null and b/tct-suite-vs/Tizen.Nlp.Tests/shared/res/Tizen.Nlp.Tests.png differ diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLanguageDetectedResult.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLanguageDetectedResult.cs new file mode 100644 index 0000000..5ce3e3a --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLanguageDetectedResult.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.LanguageDetectedResult test")] + public class LanguageDetectedResultTests + { + + [SetUp] + public static void Init() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.LanguageDetectedResult.LanguageDetectedResult C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void LanguageDetectedResult_INIT() + { + /* TEST CODE */ + try + { + LanguageDetectedResult res = new LanguageDetectedResult(); + Assert.IsInstanceOf(res, "Expecting LanguageDetectedResult object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of LanguageDetectedResult Language is correct or not")] + [Property("SPEC", "Tizen.Nlp.LanguageDetectedResult.Language A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Language_RETURN_VALUE() + { + try + { + /* TEST CODE */ + NaturalLanguageProcess nlp = new NaturalLanguageProcess(); + await nlp.Connect(); + await Task.Delay(30); + LanguageDetectedResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.LanguageDetectAsync(msg); + Assert.IsTrue(res.Language.Equals("en"), "The return value of Language is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLemmatizeResult.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLemmatizeResult.cs new file mode 100644 index 0000000..295585f --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSLemmatizeResult.cs @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.LemmatizeResult test")] + public class LemmatizeResultTests + { + static NaturalLanguageProcess nlp = null; + + [SetUp] + public static void Init() + { + nlp = new NaturalLanguageProcess(); + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.LemmatizeResult.LemmatizeResult C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void LemmatizeResult_INIT() + { + /* TEST CODE */ + try + { + LemmatizeResult res = new LemmatizeResult(); + Assert.IsInstanceOf(res, "Expecting LemmatizeResult object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of LemmatizeResult Tags is correct or not")] + [Property("SPEC", "Tizen.Nlp.LemmatizeResult.Tags A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tags_RETURN_VALUE() + { + try + { + /* TEST CODE */ + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + Task task = nlp.Connect(); + await task; + await Task.Delay(100); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + LemmatizeResult res; + string msg = "raining"; + res = await nlp.LemmatizeaAsync(msg); + Assert.IsTrue(res.ActualWord.Equals("rain"), "The return value of tag is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNamedEntityRecognitionResult.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNamedEntityRecognitionResult.cs new file mode 100644 index 0000000..200f95c --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNamedEntityRecognitionResult.cs @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.NamedEntityRecognitionResult test")] + public class NamedEntityRecognitionResultTests + { + static NaturalLanguageProcess nlp = null; + [SetUp] + public static void Init() + { + nlp = new NaturalLanguageProcess(); + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.NamedEntityRecognitionResult.NamedEntityRecognitionResult C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void NamedEntityRecognitionResult_INIT() + { + /* TEST CODE */ + try + { + NamedEntityRecognitionResult res = new NamedEntityRecognitionResult(); + Assert.IsInstanceOf(res, "Expecting NamedEntityRecognitionResult object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of NamedEntityRecognitionResult Tags is correct or not")] + [Property("SPEC", "Tizen.Nlp.NamedEntityRecognitionResult.Tags A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tags_RETURN_VALUE() + { + try + { + /* TEST CODE */ + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + NamedEntityRecognitionResult res; + string msg = "This is a test case of the NLP project."; + res =await nlp.NamedEntityRecognitionAsync(msg); + IList rs_tag = new List(); + rs_tag.Add("DT"); + rs_tag.Add("VBZ"); + rs_tag.Add("DT"); + rs_tag.Add("NN"); + rs_tag.Add("NN"); + rs_tag.Add("IN"); + rs_tag.Add("DT"); + rs_tag.Add("NNP"); + rs_tag.Add("NN"); + rs_tag.Add("."); + for (int i = 0; i < res.Tags.Count; i++) + Assert.IsTrue(res.Tags[i].Equals(rs_tag[i]), "The return value of tag is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of NamedEntityRecognitionResult Tokens is correct or not")] + [Property("SPEC", "Tizen.Nlp.NamedEntityRecognitionResult.Tokens A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tokens_RETURN_VALUE() + { + try + { + /* TEST CODE */ + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + NamedEntityRecognitionResult res; + string msg = "This is a test case of the NLP project."; + res =await nlp.NamedEntityRecognitionAsync(msg); + IList rs_token = new List(); + rs_token.Add("This"); + rs_token.Add("is"); + rs_token.Add("a"); + rs_token.Add("test"); + rs_token.Add("case"); + rs_token.Add("of"); + rs_token.Add("the"); + rs_token.Add("NLP"); + rs_token.Add("project"); + rs_token.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + Assert.IsTrue(res.Tokens[1].Equals(rs_token[1]), "The return token value of token is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNaturalLanguageProcess.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNaturalLanguageProcess.cs new file mode 100755 index 0000000..2c5bb0e --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSNaturalLanguageProcess.cs @@ -0,0 +1,423 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.NaturalLanguageProcess test")] + public class NaturalLanguageProcessTests + { + static NaturalLanguageProcess nlp = null; + [SetUp] + public static void Init() + { + nlp = new NaturalLanguageProcess(); + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + public static void Disconnected(object s,EventArgs e) { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "disconnected"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.NaturalLanguageProcess C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void NaturalLanguageProcess_INIT() + { + /* TEST CODE */ + try + { + Assert.IsInstanceOf(nlp, "Expecting NaturalLanguageProcess object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP Disconnected for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.Disconnected E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EEX")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Disconnected_CHECK_EVENT_USING_PASSIVE_WITH_EXCEPTION() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + nlp.Disconnected += Disconnected; + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP Connect method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.Connect M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Connect_NO_EXCEPTION() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + ; + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP WordTokenizeAsync method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.WordTokenizeAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task WordTokenizeAsync_RETURN_VALUE() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + WordTokenizeResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.WordTokenizeAsync(msg); + IList rs_token = new List(); + rs_token.Add("This"); + rs_token.Add("is"); + rs_token.Add("a"); + rs_token.Add("test"); + rs_token.Add("case"); + rs_token.Add("of"); + rs_token.Add("the"); + rs_token.Add("NLP"); + rs_token.Add("project"); + rs_token.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + Assert.IsTrue(rs_token[i].Equals(res.Tokens[i]), "The return value of WordTokenizeAsyncTask is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP PosTagAsync method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.PosTagAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task PosTagAsync_RETURN_VALUE() + { + /* TEST CODE */ + try + { + + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + PosTagResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.PosTagAsync(msg); + IList rs_token = new List(); + IList rs_tag = new List(); + rs_token.Add("This"); + rs_tag.Add("DT"); + rs_token.Add("is"); + rs_tag.Add("VBZ"); + rs_token.Add("a"); + rs_tag.Add("DT"); + rs_token.Add("test"); + rs_tag.Add("NN"); + rs_token.Add("case"); + rs_tag.Add("NN"); + rs_token.Add("of"); + rs_tag.Add("IN"); + rs_token.Add("the"); + rs_tag.Add("DT"); + rs_token.Add("NLP"); + rs_tag.Add("NNP"); + rs_token.Add("project"); + rs_tag.Add("NN"); + rs_token.Add("."); + rs_tag.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + { + Assert.IsTrue(rs_token[i].Equals(res.Tokens[i]), "The return token value of WordTokenizeAsyncTask is correct"); + Assert.IsTrue(rs_tag[i].Equals(res.Tags[i]), "The return tag value of PosTagAsyncTask is correct"); + } + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP NamedEntityRecognitionAsync method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.NamedEntityRecognitionAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task NamedEntityRecognitionAsync_RETURN_VALUE() + { + /* TEST CODE */ + try { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + NamedEntityRecognitionResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.NamedEntityRecognitionAsync(msg); + IList rs_token = new List(); + IList rs_tag = new List(); + rs_token.Add("This"); + rs_tag.Add("DT"); + rs_token.Add("is"); + rs_tag.Add("VBZ"); + rs_token.Add("a"); + rs_tag.Add("DT"); + rs_token.Add("test"); + rs_tag.Add("NN"); + rs_token.Add("case"); + rs_tag.Add("NN"); + rs_token.Add("of"); + rs_tag.Add("IN"); + rs_token.Add("the"); + rs_tag.Add("DT"); + rs_token.Add("NLP"); + rs_tag.Add("NNP"); + rs_token.Add("project"); + rs_tag.Add("NN"); + rs_token.Add("."); + rs_tag.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + { + Assert.IsTrue(rs_token[i].Equals(res.Tokens[i]), "The return token value of NamedEntityRecognitionAsyncTask is correct"); + Assert.IsTrue(rs_tag[i].Equals(res.Tags[i]), "The return tag value of NamedEntityRecognitionAsyncTask is correct"); + } + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP LanguageDetectAsync method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.LanguageDetectAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task LanguageDetectAsync_RETURN_VALUE() + { + /* TEST CODE */ + try + { + + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + LanguageDetectedResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.LanguageDetectAsync(msg); + Assert.IsTrue(res.Language.Equals("en"), "The return tag value of LanguageDetectAsyncTask is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP LemmatizeaAsync method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.LemmatizeaAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task LemmatizeaAsync_RETURN_VALUE() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(100); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + LemmatizeResult res; + string msg = "raining"; + res = await nlp.LemmatizeaAsync(msg); + IList rs_token = new List(); + Assert.IsTrue(res.ActualWord.Equals("rain"), "The return value of tag is correct"); + nlp.Close(); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP Close method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.Close M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void Close_NO_EXCEPTION() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + nlp.Close(); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the working of NLP Dispose method for No Exception")] + [Property("SPEC", "Tizen.Nlp.NaturalLanguageProcess.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void Dispose_NO_EXCEPTION() + { + /* TEST CODE */ + try + { + if (nlp == null) + nlp = new NaturalLanguageProcess(); + nlp.Dispose(); + nlp = null; + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSPosTagResult.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSPosTagResult.cs new file mode 100644 index 0000000..3fa7b27 --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSPosTagResult.cs @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.PosTagResult test")] + public class PosTagResultTests + { + static NaturalLanguageProcess nlp = null; + + [SetUp] + public static void Init() + { + nlp = new NaturalLanguageProcess(); + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.PosTagResult.PosTagResult C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void PosTagResult_INIT() + { + /* TEST CODE */ + try + { + PosTagResult res = new PosTagResult(); + Assert.IsInstanceOf(res, "Expecting PosTagResult object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of PosTagResult Tags is correct or not")] + [Property("SPEC", "Tizen.Nlp.PosTagResult.Tags A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tags_RETURN_VALUE() + { + try + { + /* TEST CODE */ + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + PosTagResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.PosTagAsync(msg); + IList rs_tag = new List(); + rs_tag.Add("DT"); + rs_tag.Add("VBZ"); + rs_tag.Add("DT"); + rs_tag.Add("NN"); + rs_tag.Add("NN"); + rs_tag.Add("IN"); + rs_tag.Add("DT"); + rs_tag.Add("NNP"); + rs_tag.Add("NN"); + rs_tag.Add("."); + for (int i = 0; i < res.Tags.Count; i++) + Assert.IsTrue(res.Tags[i].Equals(rs_tag[i]), "The return value of tag is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of PosTagResult Tokens is correct or not")] + [Property("SPEC", "Tizen.Nlp.PosTagResult.Tokens A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tokens_RETURN_VALUE() + { + try + { + /* TEST CODE */ + if (nlp == null) + nlp = new NaturalLanguageProcess(); + try + { + var task = nlp.Connect(); + await task; + await Task.Delay(30); + } + catch + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "nlp has connected"); + } + PosTagResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.PosTagAsync(msg); + IList rs_token = new List(); ; + rs_token.Add("This"); + rs_token.Add("is"); + rs_token.Add("a"); + rs_token.Add("test"); + rs_token.Add("case"); + rs_token.Add("of"); + rs_token.Add("the"); + rs_token.Add("NLP"); + rs_token.Add("project"); + rs_token.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + Assert.IsTrue(res.Tokens[i].Equals(rs_token[i]), "The return token value of token is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSWordTokenizeResult.cs b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSWordTokenizeResult.cs new file mode 100644 index 0000000..5424165 --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/testcase/TSWordTokenizeResult.cs @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tizen; +using Tizen.Nlp; +using Tizen.Applications; +using Tizen.Applications.Messages; + +namespace Tizen.Nlp.Tests { + + [TestFixture] + [Description("Tizen.Nlp.WordTokenizeResult test")] + public class WordTokenizeResultTests + { + + [SetUp] + public static void Init() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST"); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Postconditions for each TEST"); + } + + [Test] + [Category("P1")] + [Description("Test: Check if constructor for the class returns correct object instance")] + [Property("SPEC", "Tizen.Nlp.WordTokenizeResult.WordTokenizeResult C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static void WordTokenizeResult_INIT() + { + /* TEST CODE */ + try + { + WordTokenizeResult res = new WordTokenizeResult(); + Assert.IsInstanceOf(res, "Expecting WordTokenizeResult object"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check the return value of WordTokenizeResult Tokens is correct or not")] + [Property("SPEC", "Tizen.Nlp.WordTokenizeResult.Tokens A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Xiaochun wang, xiaochn.wang@samsung.com")] + public static async Task Tokens_RETURN_VALUE() + { + /* TEST CODE */ + try + { + NaturalLanguageProcess nlp = new NaturalLanguageProcess(); + await nlp.Connect(); + await Task.Delay(30); + WordTokenizeResult res; + string msg = "This is a test case of the NLP project."; + res = await nlp.WordTokenizeAsync(msg); + IList rs_token = new List(); + rs_token.Add("This"); + rs_token.Add("is"); + rs_token.Add("a"); + rs_token.Add("test"); + rs_token.Add("case"); + rs_token.Add("of"); + rs_token.Add("the"); + rs_token.Add("NLP"); + rs_token.Add("project"); + rs_token.Add("."); + for (int i = 0; i < res.Tokens.Count; i++) + Assert.IsTrue(res.Tokens[i].Equals(rs_token[i]), "The return token value of token is correct"); + } + catch (Exception e) + { + Assert.Fail("Got Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Nlp.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.Nlp.Tests/tizen-manifest.xml new file mode 100755 index 0000000..d50e476 --- /dev/null +++ b/tct-suite-vs/Tizen.Nlp.Tests/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + Tizen.Nlp.Tests.png + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing + http://tizen.org/privilege/apphistory.read + + +