From: sri Date: Fri, 8 May 2020 10:20:42 +0000 (+0530) Subject: [Tizen.System.PowerUsage.Tests][TCSACR-310]Addition of Tizen.System.PowerUsage.Tests X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33b5e4d69fa2622cc9e8cd0190925f567f929de4;p=test%2Ftct%2Fcsharp%2Fapi.git [Tizen.System.PowerUsage.Tests][TCSACR-310]Addition of Tizen.System.PowerUsage.Tests Change-Id: If6d294896b07d59fe81a4f3b79c4bcabb522ff5a --- diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs index 87d9f97..3373c7d 100755 --- a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2020 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. diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj index ed82ea6..de36166 100755 --- a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs index 49ea41d..af3924b 100755 --- a/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs @@ -17,14 +17,14 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; -using System.Collections.Generic; - -namespace Tizen.System.Tests +using System.Collections.Generic; + +namespace Tizen.System.Tests { [TestFixture] [Description("Tizen.System.PowerUsage Class Tests")] - public class PowerUsageTests + public class PowerUsageTests { static bool support = true; static DateTime startTime = DateTime.Now.AddDays(-2); @@ -54,34 +54,39 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, IList, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppForAllResources_CHECK_RESULT() - { + public void GetPowerUsage_CHECK_RESULT_BY_APP_FOR_ALL_RESOURCES() + { if (support) - { - try - { - object powerUsage; - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - - foreach (PowerUsageResourceType type in rtypes) - { - powerUsage = result[type]; - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the resources specified by the application in custom interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the resources specified by the application in custom interval"); - } - } - catch (Exception e) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); + { + try + { + object powerUsage; + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + + foreach (PowerUsageResourceType type in rtypes) + { + powerUsage = result[type]; + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the resources specified by the application in custom interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the resources specified by the application in custom interval"); + } + } + catch (InvalidOperationException) + { + Assert.Pass("No data record corresponding to given appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); } } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); } } @@ -91,30 +96,31 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, IList, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppForAllResources_CHECK_NOT_SUPPORTED_EXCEPTION() - { + public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() + { if (support) { Assert.Pass("Test skipped! Can't test not supported exception"); } else - { - try - { - IList rtypes = new List(); - foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType))) - { - rtypes.Add(rtype); - } - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); - } - } + { + try + { + IList rtypes = new List(); + foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType))) + { + rtypes.Add(rtype); + } + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } + } } [Test] @@ -123,56 +129,92 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, IList, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppForAllResources_CHECK_ARGUMENT_EXCEPTION() - { + public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() + { if (support) { - try - { - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); } } else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] [Category("P2")] - [Description("Check if GetPowerUsage() raises invalid operation exception")] + [Description("Check if GetPowerUsage() raises argument null exception")] [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, IList, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppForAllResources_CHECK_INVALID_OPERATION_EXCEPTION() - { - if (support) - { - try - { - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); - } - catch (Exception ex) + public void GetPowerUsage_CHECK_NULL_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() + { + if (support) + { + try + { + IList rtypes = new List(); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + Assert.IsTrue(false, "This operation should raise ArgumentNullException"); + } + catch (InvalidOperationException) { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + Assert.Pass("No data record corresponding to given appID"); } - } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException), "this operation should raise ArgumentNullException exception"); + } + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } + } + + [Test] + [Category("P2")] + [Description("Check if GetPowerUsage() raises invalid operation exception")] + [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, IList, DateTime, DateTime")] + [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] + public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() + { + if (support) + { + try + { + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -181,26 +223,31 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppPerResource_CHECK_RESULT() + public void GetPowerUsage_CHECK_RESULT_BY_APP_PER_RESOURCE() { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the specific resource for the given application in custom interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the specific resource for the given application in custom interval"); - } - catch (Exception e) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); - } - } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the specific resource for the given application in custom interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the specific resource for the given application in custom interval"); + } + catch (ArgumentException) + { + Assert.Pass("No data record corresponding to given resource type and appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); } } @@ -210,25 +257,26 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppPerResource_CHECK_NOT_SUPPORTED_EXCEPTION() - { + public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_PER_RESOURCE() + { if (support) { Assert.Pass("Test skipped! Can't test not supported exception"); } else - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); - } - } + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } + } } [Test] @@ -237,25 +285,26 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppPerResource_CHECK_ARGUMENT_EXCEPTION() - { + public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_PER_RESOURCE() + { if (support) { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); } } else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -264,25 +313,32 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByAppPerResource_CHECK_INVALID_OPERATION_EXCEPTION() - { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - } - } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_PER_RESOURCE() + { + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + } + catch (ArgumentException) + { + Assert.Pass("No data record corresponding to given resource type and appID"); + return; + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -291,54 +347,60 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByApp_CHECK_RESULT() + public void GetPowerUsage_CHECK_RESULT_BY_APP() { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value corresponding to app in double"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value corresponding to app"); - } - catch (Exception e) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); - } + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value corresponding to app in double"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value corresponding to app"); + } + catch (InvalidOperationException) + { + Assert.Pass("No data record corresponding to given appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); } - } - + } + [Test] [Category("P2")] [Description("Check if GetPowerUsage() raises not supported exception")] [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByApp_CHECK_NOT_SUPPORTED_EXCEPTION() - { + public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP() + { if (support) { Assert.Pass("Test skipped! Can't test not supported exception"); } else - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); - } - } + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } + } } [Test] @@ -347,25 +409,26 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByApp_CHECK_ARGUMENT_EXCEPTION() - { + public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP() + { if (support) { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); } } else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -374,25 +437,27 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByApp_CHECK_INVALID_OPERATION_EXCEPTION() - { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - } - } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP() + { + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -401,26 +466,27 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByResource_CHECK_RESULT() + public void GetPowerUsage_CHECK_RESULT_BY_RESOURCE() { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double by a resource for certain time interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value by a resource for certain time interval"); - } - catch (Exception e) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); - } + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double by a resource for certain time interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value by a resource for certain time interval"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); } } @@ -430,25 +496,26 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByResource_CHECK_NOT_SUPPORTED_EXCEPTION() - { + public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_RESOURCE() + { if (support) { Assert.Pass("Test skipped! Can't test not supported exception"); } else - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); - } - } + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } + } } [Test] @@ -457,25 +524,26 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByResource_CHECK_ARGUMENT_EXCEPTION() - { + public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_RESOURCE() + { if (support) { - try - { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); } } else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } [Test] @@ -484,25 +552,27 @@ namespace Tizen.System.Tests [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")] [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] - public void GetPowerUsageByResource_CHECK_INVALID_OPERATION_EXCEPTION() - { - if (support) - { - try - { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - } - } - else - { - Assert.Pass("Test skipped! Can't test due to not supported exception"); - } + public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_RESOURCE() + { + if (support) + { + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); + } + else + { + Assert.Pass("Test skipped! Can't test due to not supported exception"); + } } } -} +} \ No newline at end of file