diff --git a/Common.Testing/Common.Testing.csproj b/Common.Testing/Common.Testing.csproj new file mode 100644 index 00000000..9f3dffe6 --- /dev/null +++ b/Common.Testing/Common.Testing.csproj @@ -0,0 +1,18 @@ + + + + net472 + Skyline.DataMiner.CICD.Validators.Common.Testing + + + + + + + + + ..\DLLs\QActionHelper.dll + + + + diff --git a/Common.Testing/ProtocolQActionHelperProvider.cs b/Common.Testing/ProtocolQActionHelperProvider.cs new file mode 100644 index 00000000..83bf33ba --- /dev/null +++ b/Common.Testing/ProtocolQActionHelperProvider.cs @@ -0,0 +1,71 @@ +namespace SLDisUnitTestsShared +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Text; + using System.Threading; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.Scripting; + + public class ProtocolQActionHelperProvider : IProtocolQActionHelperProvider + { + private const string AutoGeneratedCodeByDis = "// This is auto-generated code by DIS. Do not modify."; + private static readonly Mutex _mutex; + + static ProtocolQActionHelperProvider() + { + string mutexId = $"Global\\{typeof(ProtocolQActionHelperProvider).GUID}"; + _mutex = new Mutex(false, mutexId); + } + + public string GetProtocolQActionHelper(string protocolCode, bool ignoreErrors = false) + { + var tempPath = Path.GetTempPath(); + var tempName = Guid.NewGuid().ToString("N"); + var tempFile = Path.Combine(tempPath, tempName + ".txt"); + + List result; + + // prevent System.IO.IOException: The process cannot access the file 'C:\Skyline DataMiner\logging\SLQActionHelper.txt' + try + { + _mutex.WaitOne(); + result = QActionHelper.CreateProtocolQActionHelperFromString(protocolCode, tempPath, tempName); + } + finally + { + _mutex.ReleaseMutex(); + } + + if (!ignoreErrors && result != null && result.Count > 0) + { + StringBuilder error = new StringBuilder(); + error.Append("Couldn't generate QAction helper:"); + + foreach (var err in result) + { + error.Append("\n Line " + err.Line + ": " + err.Description); + } + + throw new Exception(error.ToString()); + } + + var csContent = new StringBuilder(); + csContent.AppendLine(AutoGeneratedCodeByDis); + + if (File.Exists(tempFile)) + { + csContent.Append(File.ReadAllText(tempFile)); + File.Delete(tempFile); + } + else + { + csContent.Append("namespace Skyline.DataMiner.Scripting { public class SLProtocolExt : SLProtocol { } }"); + } + + return csContent.ToString(); + } + } +} diff --git a/Common.Testing/ProtocolTestsHelper.cs b/Common.Testing/ProtocolTestsHelper.cs new file mode 100644 index 00000000..cee25838 --- /dev/null +++ b/Common.Testing/ProtocolTestsHelper.cs @@ -0,0 +1,80 @@ +namespace SLDisUnitTestsShared +{ + using System.IO; + using System.Reflection; + using System.Runtime.CompilerServices; + using System.Text; + + using Skyline.DataMiner.CICD.Models.Common; + using Skyline.DataMiner.CICD.Models.Protocol; + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Models.Protocol.Read.Interfaces; + using Skyline.DataMiner.CICD.Parsers.Common.Xml; + using Skyline.DataMiner.CICD.Validators.Common.Data; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using EditModel = Skyline.DataMiner.CICD.Models.Protocol.Edit; + using EditXml = Skyline.DataMiner.CICD.Parsers.Common.XmlEdit; + + public static class ProtocolTestsHelper + { + public static (IProtocolModel model, XmlDocument document, string protocolCode) ReadProtocol(string fileName, [CallerFilePath] string pathToClassFile = "") + { + string filePath = Path.Combine(Path.GetDirectoryName(pathToClassFile), fileName); + + string code; + var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); + using (var textReader = new StreamReader(fileStream)) + { + code = textReader.ReadToEnd(); + } + + return ParseProtocol(code); + } + + public static (IProtocolModel model, XmlDocument document, string protocolCode) ParseProtocol(string protocolCode) + { + Parser parser = new Parser(new StringBuilder(protocolCode)); + + return (new ProtocolModel(parser.Document), parser.Document, protocolCode); + } + + public static QActionCompilationModel GetQActionCompilationModel(string xmlCode) + { + var document = new Parser(xmlCode).Document; + var model = new ProtocolModel(document); + + return GetQActionCompilationModel(model, xmlCode); + } + + public static QActionCompilationModel GetQActionCompilationModel(IProtocolModel model, string xmlCode) + { + var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + baseDir = Path.GetFullPath(Path.Combine(baseDir, @"..\..\..\..\DLLs")); + + var dllImportResolver = new InternalFilesAssemblyResolver(baseDir); + var qactionHelperProvider = new ProtocolQActionHelperProvider(); + + string qactionHelperSourceCode = qactionHelperProvider.GetProtocolQActionHelper(xmlCode, ignoreErrors: true); + return new QActionCompilationModel(qactionHelperSourceCode, model, dllImportResolver); + } + + public static IProtocolInputData GetProtocolInputData(string fileName, [CallerFilePath] string pathToClassFile = "") + { + (IProtocolModel model, XmlDocument document, string protocolCode) = ReadProtocol(fileName, pathToClassFile); + + var qactionCompilationModel = GetQActionCompilationModel(model, protocolCode); + + return new ProtocolInputData(model, document, qactionCompilationModel); + } + + public static EditModel.Protocol GetEditProtocol(IProtocolModel model) + { + return new EditModel.Protocol(model.Protocol); + } + + public static EditModel.Protocol GetEditProtocol(IProtocolModel model, EditXml.XmlElement xmlElement) + { + return new EditModel.Protocol(model.Protocol, xmlElement); + } + } +} \ No newline at end of file diff --git a/Common/Common.csproj b/Common/Common.csproj index 7ce05521..34c59171 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -18,7 +18,7 @@ - + @@ -35,6 +35,7 @@ + diff --git a/Common/Model/ValidatorSettings.cs b/Common/Model/ValidatorSettings.cs index 9c8991f6..28010fc9 100644 --- a/Common/Model/ValidatorSettings.cs +++ b/Common/Model/ValidatorSettings.cs @@ -1,6 +1,7 @@ namespace Skyline.DataMiner.CICD.Validators.Common.Model { - using System.Collections.Generic; + using System; + using System.Collections.Generic; using Skyline.DataMiner.CICD.Common; using Skyline.DataMiner.XmlSchemas.Protocol; @@ -12,12 +13,25 @@ public class ValidatorSettings { private readonly List<(Category catergory, uint checkId)> testsToExecute; + /// + /// Initializes a new instance of the class. + /// Used for unit tests + /// + internal ValidatorSettings() + { + testsToExecute = new List<(Category catergory, uint checkId)>(); + UnitList = new UnitList(); + MinimumSupportedDataMinerVersion = new DataMinerVersion(new Version(10, 1, 0, 0), 9966); + } + /// /// Initializes a new instance of the class. /// public ValidatorSettings(DataMinerVersion minimumSupportedDataMinerVersion) { testsToExecute = new List<(Category catergory, uint checkId)>(); + + // TODO-MOD: Probably don't initialize it here just in case an error happens? Maybe only on the get of the property if the field is null still? UnitList = new UnitList(); MinimumSupportedDataMinerVersion = minimumSupportedDataMinerVersion; diff --git a/CommonTests/CommonTests.csproj b/CommonTests/CommonTests.csproj index 57ea5900..08f8c7e7 100644 --- a/CommonTests/CommonTests.csproj +++ b/CommonTests/CommonTests.csproj @@ -1,7 +1,7 @@  - net462;net6.0 + net472;net6.0 disable disable diff --git a/DLLs/Interop.SLDms.dll b/DLLs/Interop.SLDms.dll new file mode 100644 index 00000000..ba062a8b Binary files /dev/null and b/DLLs/Interop.SLDms.dll differ diff --git a/DLLs/Newtonsoft.Json.dll b/DLLs/Newtonsoft.Json.dll new file mode 100644 index 00000000..7af125a2 Binary files /dev/null and b/DLLs/Newtonsoft.Json.dll differ diff --git a/DLLs/QActionHelper.dll b/DLLs/QActionHelper.dll new file mode 100644 index 00000000..6de74a3d Binary files /dev/null and b/DLLs/QActionHelper.dll differ diff --git a/DLLs/QActionHelperBaseClasses.dll b/DLLs/QActionHelperBaseClasses.dll new file mode 100644 index 00000000..c35527b9 Binary files /dev/null and b/DLLs/QActionHelperBaseClasses.dll differ diff --git a/DLLs/SLLoggerUtil.dll b/DLLs/SLLoggerUtil.dll new file mode 100644 index 00000000..7c1d9a8a Binary files /dev/null and b/DLLs/SLLoggerUtil.dll differ diff --git a/DLLs/SLManagedAutomation.dll b/DLLs/SLManagedAutomation.dll new file mode 100644 index 00000000..87d1efff Binary files /dev/null and b/DLLs/SLManagedAutomation.dll differ diff --git a/DLLs/SLManagedScripting.dll b/DLLs/SLManagedScripting.dll new file mode 100644 index 00000000..85aaa085 Binary files /dev/null and b/DLLs/SLManagedScripting.dll differ diff --git a/DLLs/SLNetTypes.dll b/DLLs/SLNetTypes.dll new file mode 100644 index 00000000..e3a82189 Binary files /dev/null and b/DLLs/SLNetTypes.dll differ diff --git a/DLLs/Skyline.DataMiner.Storage.Types.dll b/DLLs/Skyline.DataMiner.Storage.Types.dll new file mode 100644 index 00000000..a400831a Binary files /dev/null and b/DLLs/Skyline.DataMiner.Storage.Types.dll differ diff --git a/DLLs/readme.txt b/DLLs/readme.txt new file mode 100644 index 00000000..b7cf60dd --- /dev/null +++ b/DLLs/readme.txt @@ -0,0 +1,4 @@ +This folder should contain files from latest main release: +S:\Public\DataMiner Software\DataMiner Files\Release\ + +These DLLs are only to be used for unit tests. They should never be included in the actual NuGet packages. \ No newline at end of file diff --git a/Protocol.Features/Protocol.Features.csproj b/Protocol.Features/Protocol.Features.csproj index 16d1a720..e203c9ac 100644 --- a/Protocol.Features/Protocol.Features.csproj +++ b/Protocol.Features/Protocol.Features.csproj @@ -35,5 +35,9 @@ + + + + diff --git a/Protocol.FeaturesTests/Features/10.0/DashboardTests.cs b/Protocol.FeaturesTests/Features/10.0/DashboardTests.cs new file mode 100644 index 00000000..61687ac9 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/DashboardTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class DashboardTests + { + private static Dashboard check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new Dashboard(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/DynamicParameterReplicationTests.cs b/Protocol.FeaturesTests/Features/10.0/DynamicParameterReplicationTests.cs new file mode 100644 index 00000000..54b0f2b4 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/DynamicParameterReplicationTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class DynamicParameterReplicationTests + { + private static DynamicParameterReplication check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new DynamicParameterReplication(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/ExposerTests.cs b/Protocol.FeaturesTests/Features/10.0/ExposerTests.cs new file mode 100644 index 00000000..309129b5 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/ExposerTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class ExposerTests + { + private static Exposer check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new Exposer(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + + var input = new ProtocolInputData(code); + var context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Topologies.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.cs b/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.cs new file mode 100644 index 00000000..34f44011 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.cs @@ -0,0 +1,46 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + using SLDisUnitTestsShared; + + [TestClass] + public class GetPkIdByTableIdTests + { + private static GetPkIdByTableId check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new GetPkIdByTableId(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "GetPkIdByTableIdTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.xml b/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.xml new file mode 100644 index 00000000..abe21b0f --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/GetPkIdByTableIdTests.xml @@ -0,0 +1,32 @@ + + Testing + 1.0.0.1 + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + protocol.NotifyProtocol(394, null, null); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnId.cs b/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnId.cs new file mode 100644 index 00000000..6a235ef9 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnId.cs @@ -0,0 +1,49 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Models.Protocol.Read.Interfaces; + using Skyline.DataMiner.CICD.Parsers.Common.Xml; + using Skyline.DataMiner.CICD.Validators.Common.Data; + using SLDisUnitTestsShared; + + [TestClass] + public class GetTableIdByColumnIdTests + { + private static GetTableIdByColumnId check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new GetTableIdByColumnId(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "GetTableIdByColumnIdTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnIdTests.xml b/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnIdTests.xml new file mode 100644 index 00000000..f46c9402 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/GetTableIdByColumnIdTests.xml @@ -0,0 +1,32 @@ + + Testing + 1.0.0.1 + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + protocol.NotifyProtocol(393, null, null); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.cs b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.cs new file mode 100644 index 00000000..a6e1d1f0 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.cs @@ -0,0 +1,47 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisUnitTestsShared; + + [TestClass] + public class HistorySets_FillArrayNoDelete_BulkTests + { + private static HistorySets_FillArrayNoDelete_Bulk check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new HistorySets_FillArrayNoDelete_Bulk(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "HistorySets_FillArrayNoDelete_BulkTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.xml b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.xml new file mode 100644 index 00000000..6e0105ea --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayNoDelete_BulkTests.xml @@ -0,0 +1,152 @@ + + Testing + 1.0.0.1 + + + TestTable + Test Table + array + + + + + Test Table + + + true + + + table + + + + TestTable_Index + Index (Test Table) + read + + This is the key used internally by DataMiner to identify the table entries. + + + other + string + next param + + + true + + + string + + + + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.NotifyProtocol(194, new object[] { 1234, true, time }, new object[0]); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.FillArrayNoDelete(1234, new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new QActionTable(protocol, 1324, "").FillArrayNoDelete(new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new TesttableQActionTable(protocol, 1000, "").FillArrayNoDelete(new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.cs b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.cs new file mode 100644 index 00000000..fd0b9c1b --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.cs @@ -0,0 +1,47 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisUnitTestsShared; + + [TestClass] + public class HistorySets_FillArrayWithColumn_BulkTests + { + private static HistorySets_FillArrayWithColumn_Bulk check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new HistorySets_FillArrayWithColumn_Bulk(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "HistorySets_FillArrayWithColumn_BulkTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.xml b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.xml new file mode 100644 index 00000000..ac141f85 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArrayWithColumn_BulkTests.xml @@ -0,0 +1,153 @@ + + Testing + 1.0.0.1 + + + TestTable + Test Table + array + + + + + Test Table + + + true + + + table + + + + TestTable_Index + Index (Test Table) + read + + This is the key used internally by DataMiner to identify the table entries. + + + other + string + next param + + + true + + + string + + + + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.NotifyProtocol((int)SLNetMessages.NotifyType.NT_FILL_ARRAY_WITH_COLUMN, new object[] { 1000, 1, new object[] { true, time } }, new object[] { null, null }); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.FillArrayWithColumn(1234, 1, new object[0], new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new QActionTable(protocol, 1324, "").SetColumn(1, new string[0], new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new TesttableQActionTable(protocol, 1000, "").SetColumn(1, new string[0], new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.cs b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.cs new file mode 100644 index 00000000..1b45c1a8 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.cs @@ -0,0 +1,47 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisUnitTestsShared; + + [TestClass] + public class HistorySets_FillArray_BulkTests + { + private static HistorySets_FillArray_Bulk check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new HistorySets_FillArray_Bulk(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "HistorySets_FillArray_BulkTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.xml b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.xml new file mode 100644 index 00000000..08e0976b --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/HistorySets_FillArray_BulkTests.xml @@ -0,0 +1,180 @@ + + Testing + 1.0.0.1 + + + TestTable + Test Table + array + + + + + Test Table + + + true + + + table + + + + TestTable_Index + Index (Test Table) + read + + This is the key used internally by DataMiner to identify the table entries. + + + other + string + next param + + + true + + + string + + + + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.NotifyProtocol(193, new object[] { 1234, true, time }, new object[0]); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.FillArray(1234, new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + protocol.FillArray(1234, new List(0), NotifyProtocol.SaveOption.Full, time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new QActionTable(protocol, 1324, "").FillArray(new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + DateTime time = new DateTime(2021, 4, 8, 8, 5, 13); + new TesttableQActionTable(protocol, 1000, "").FillArray(new object[0], time); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.cs b/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.cs new file mode 100644 index 00000000..19c38e64 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.cs @@ -0,0 +1,40 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + using SLDisUnitTestsShared; + + [TestClass] + public class ProtocolTtlSyntaxTests + { + private static ProtocolTtlSyntax check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ProtocolTtlSyntax(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string fileName = "ProtocolTtlSyntaxTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.xml b/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.xml new file mode 100644 index 00000000..1b54ffce --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/ProtocolTtlSyntaxTests.xml @@ -0,0 +1,9 @@ + + + + + infinite + + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/SkipInDiagramTests.cs b/Protocol.FeaturesTests/Features/10.0/SkipInDiagramTests.cs new file mode 100644 index 00000000..e630bbab --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/SkipInDiagramTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class SkipInDiagramTests + { + private static SkipInDiagram check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new SkipInDiagram(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Chains.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/TooltipTests.cs b/Protocol.FeaturesTests/Features/10.0/TooltipTests.cs new file mode 100644 index 00000000..bead2e03 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/TooltipTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class TooltipTests + { + private static Tooltip check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new Tooltip(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = "Test"; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.0/ValueMappingTests.cs b/Protocol.FeaturesTests/Features/10.0/ValueMappingTests.cs new file mode 100644 index 00000000..de4ca085 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.0/ValueMappingTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class ValueMappingTests + { + private static ValueMapping check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ValueMapping(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.cs b/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.cs new file mode 100644 index 00000000..500d5047 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.cs @@ -0,0 +1,47 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Validators.Common.Data; + using SLDisUnitTestsShared; + + [TestClass] + public class DeleteFolder_RecycleOptionTests + { + private static DeleteFolder_RecycleOption check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new DeleteFolder_RecycleOption(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "DeleteFolder_RecycleOptionTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.xml b/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.xml new file mode 100644 index 00000000..ab808cf0 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/DeleteFolder_RecycleOptionTests.xml @@ -0,0 +1,32 @@ + + Testing + 1.0.0.1 + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + protocol.NotifyDataMiner(182, "", false); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/DynamicUnitsTests.cs b/Protocol.FeaturesTests/Features/10.1/DynamicUnitsTests.cs new file mode 100644 index 00000000..42eb26c2 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/DynamicUnitsTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class DynamicUnitsTests + { + private static DynamicUnits check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new DynamicUnits(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.cs b/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.cs new file mode 100644 index 00000000..ee243459 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.cs @@ -0,0 +1,47 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisUnitTestsShared; + + [TestClass] + public class ExecuteScriptTests + { + private static ExecuteScript check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ExecuteScript(); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "ExecuteScriptTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.xml b/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.xml new file mode 100644 index 00000000..86340570 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/ExecuteScriptTests.xml @@ -0,0 +1,32 @@ + + Testing + 1.0.0.1 + + + +/// DataMiner QAction Class: Test. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + protocol.ExecuteScript(""); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/InternalLicenses.cs b/Protocol.FeaturesTests/Features/10.1/InternalLicenses.cs new file mode 100644 index 00000000..bb5f85b2 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/InternalLicenses.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class InternalLicensesTests + { + private static InternalLicenses check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new InternalLicenses(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.InternalLicenses.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/LoginMethod_CertificateTests.cs b/Protocol.FeaturesTests/Features/10.1/LoginMethod_CertificateTests.cs new file mode 100644 index 00000000..d98dd2eb --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/LoginMethod_CertificateTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class LoginMethod_CertificateTests + { + private static LoginMethod_Certificate check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new LoginMethod_Certificate(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.HTTP.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/MatrixLayoutTests.cs b/Protocol.FeaturesTests/Features/10.1/MatrixLayoutTests.cs new file mode 100644 index 00000000..567c4a29 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/MatrixLayoutTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class MatrixLayoutTests + { + private static MatrixLayout check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new MatrixLayout(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.cs b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.cs new file mode 100644 index 00000000..6f4ccdee --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.cs @@ -0,0 +1,61 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + + using SLDisUnitTestsShared; + + [TestClass] + public class ProfileHelperTests + { + private static ProfileHelper check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ProfileHelper(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string fileName = "ProfileHelperTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + Assert.IsTrue(result.FeatureItems.All(x => x is CSharpFeatureCheckResultItem)); + + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item.Node).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + + [TestMethod] + public void CheckIsUsed_FakeProfileHelper() + { + const string fileName = "ProfileHelperTests_Fake.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsFalse(result.IsUsed); + result.FeatureItems.Should().BeEmpty(); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.xml b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.xml new file mode 100644 index 00000000..22770559 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests.xml @@ -0,0 +1,31 @@ + + + + +/// DataMiner QAction Class: Profile Helper. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + ProfileHelper helper = new ProfileHelper((x) => protocol.SLNet.SendMessages(x)); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests_Fake.xml b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests_Fake.xml new file mode 100644 index 00000000..a0311667 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.1/ProfileHelperTests_Fake.xml @@ -0,0 +1,39 @@ + + + + +/// DataMiner QAction Class: Profile Helper. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + try + { + ProfileHelper helper = new ProfileHelper((x) => protocol.SLNet.SendMessages(x)); + } + catch (Exception ex) + { + protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Exception thrown:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging); + } + } +} + +public class ProfileHelper +{ + public ProfileHelper(Func messageHandler) + { + + } +}]]> + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.2/Chain_DefaultSelectionFieldTests.cs b/Protocol.FeaturesTests/Features/10.2/Chain_DefaultSelectionFieldTests.cs new file mode 100644 index 00000000..7aa82eb7 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.2/Chain_DefaultSelectionFieldTests.cs @@ -0,0 +1,43 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + + + [TestClass] + public class Chain_DefaultSelectionFieldTests + { + private static Chain_DefaultSelectionField check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new Chain_DefaultSelectionField(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Chains.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.2/Chain_GroupingNameTests.cs b/Protocol.FeaturesTests/Features/10.2/Chain_GroupingNameTests.cs new file mode 100644 index 00000000..9fb039d3 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.2/Chain_GroupingNameTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class Chain_GroupingNameTests + { + private static Chain_GroupingName check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new Chain_GroupingName(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Chains.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.2/FlushPerDatagramTests.cs b/Protocol.FeaturesTests/Features/10.2/FlushPerDatagramTests.cs new file mode 100644 index 00000000..1451d8f3 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.2/FlushPerDatagramTests.cs @@ -0,0 +1,56 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class FlushPerDatagramTests + { + private static FlushPerDatagram check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new FlushPerDatagram(); + } + + [TestMethod] + public void CheckIsUsed_PortSettings() + { + const string code = "true"; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = new FeatureCheckResultItem(context.Model.Protocol.PortSettings); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckIsUsed_Ports() + { + const string code = "true"; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Ports.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.3/QActionIDisposable.cs b/Protocol.FeaturesTests/Features/10.3/QActionIDisposable.cs new file mode 100644 index 00000000..03b39469 --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.3/QActionIDisposable.cs @@ -0,0 +1,60 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Collections; + using System.Linq; + + using FluentAssertions; + using FluentAssertions.Equivalency; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using SLDisUnitTestsShared; + + [TestClass] + public class QActionDisposableTests + { + private static QActionIDisposable check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new QActionIDisposable(); + } + + [TestMethod] + public void CheckIsUsed_QActionIDisposable() + { + const string code = @" + + "; + + var qactionCompilationModel = ProtocolTestsHelper.GetQActionCompilationModel(code); + var input = new ProtocolInputData(code, qactionCompilationModel); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + var result = check.CheckIfUsed(context); + var qaction = context.Model.Protocol.QActions.First(); + var expected = new FeatureCheckResultItem(qaction); + + Assert.IsTrue(result.IsUsed); + + result.FeatureItems.Should().HaveCount(1); + result.FeatureItems.First().Should().BeEquivalentTo(expected, option => option.IgnoringCyclicReferences()); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/10.4/ExportRule_whereAttribute.cs b/Protocol.FeaturesTests/Features/10.4/ExportRule_whereAttribute.cs new file mode 100644 index 00000000..73af11dd --- /dev/null +++ b/Protocol.FeaturesTests/Features/10.4/ExportRule_whereAttribute.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class ExportRule_whereAttributeTests + { + private static ExportRule_whereAttribute check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ExportRule_whereAttribute(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.ExportRules.Select(rule => new FeatureCheckResultItem(rule)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/8.0 (Main + Feature)/ParameterDateTimeTests.cs b/Protocol.FeaturesTests/Features/8.0 (Main + Feature)/ParameterDateTimeTests.cs new file mode 100644 index 00000000..ded8a232 --- /dev/null +++ b/Protocol.FeaturesTests/Features/8.0 (Main + Feature)/ParameterDateTimeTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class ParameterDateTimeTests + { + private static ParameterDateTime check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ParameterDateTime(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/8.5 (Main + Feature)/DefaultValueTests.cs b/Protocol.FeaturesTests/Features/8.5 (Main + Feature)/DefaultValueTests.cs new file mode 100644 index 00000000..85486dd2 --- /dev/null +++ b/Protocol.FeaturesTests/Features/8.5 (Main + Feature)/DefaultValueTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class DefaultValueTests + { + private static DefaultValue check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new DefaultValue(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.cs b/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.cs new file mode 100644 index 00000000..c207d35d --- /dev/null +++ b/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.cs @@ -0,0 +1,40 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + using SLDisUnitTestsShared; + + [TestClass] + public class ConditionalShowHidePageTests + { + private static ConditionalShowHidePage check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ConditionalShowHidePage(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string fileName = "ConditionalShowHidePageTests.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Display.Pages.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.xml b/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.xml new file mode 100644 index 00000000..6ffb814e --- /dev/null +++ b/Protocol.FeaturesTests/Features/9.5/ConditionalShowHidePageTests.xml @@ -0,0 +1,9 @@ + + + + + BALABL + + + + \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/9.5/InfiniteLoopTests.cs b/Protocol.FeaturesTests/Features/9.5/InfiniteLoopTests.cs new file mode 100644 index 00000000..64d6901c --- /dev/null +++ b/Protocol.FeaturesTests/Features/9.5/InfiniteLoopTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class InfiniteLoopTests + { + private static InfiniteLoop check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new InfiniteLoop(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = "Success"; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/9.6/ParameterSaveIntervalTests.cs b/Protocol.FeaturesTests/Features/9.6/ParameterSaveIntervalTests.cs new file mode 100644 index 00000000..a044ab2a --- /dev/null +++ b/Protocol.FeaturesTests/Features/9.6/ParameterSaveIntervalTests.cs @@ -0,0 +1,41 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + [TestClass] + public class ParameterSaveIntervalTests + { + private static ParameterSaveInterval check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ParameterSaveInterval(); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Features/ExampleTests.cs b/Protocol.FeaturesTests/Features/ExampleTests.cs new file mode 100644 index 00000000..8cf3d058 --- /dev/null +++ b/Protocol.FeaturesTests/Features/ExampleTests.cs @@ -0,0 +1,98 @@ +namespace SLDisDmFeatureCheckUnitTests.Features +{ + using System.Collections.Generic; + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Validators.Common.Data; + + using SLDisDmFeatureCheck.Common; + using SLDisDmFeatureCheck.Common.Interfaces; + using SLDisDmFeatureCheck.Common.Results; + using SLDisDmFeatureCheck.Features; + + using SLDisUnitTestsShared; + + //[TestClass] + public class ExampleTests + { + private static ParameterDateTime check; + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + check = new ParameterDateTime(); + } + + [TestMethod] + public void CheckReleaseNotes() /* Optional */ + { + List expected = new List { 6046 }; + check.ReleaseNotes.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckDescription() /* Optional */ + { + string expected = "The parameter will be displayed as a DateTime. The value represents a decimal number indicating the total number of days that have passed since midnight 1899-12-30. The Interprete/Decimals tag of this parameter needs to be set to 8 to avoid rounding errors."; + check.Description.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckTitle() /* Optional */ + { + string expected = "Parameter DateTime"; + check.Title.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckIsUsed() + { + const string code = ""; + var input = new ProtocolInputData(code); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckIsUsed_File() + { + const string fileName = "FileName.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + var result = check.CheckIfUsed(context); + var expected = context.Model.Protocol.Params.Select(x => new FeatureCheckResultItem(x)); + + Assert.IsTrue(result.IsUsed); + result.FeatureItems.Should().BeEquivalentTo(expected); + } + + [TestMethod] + public void CheckIsUsed_CSharp() + { + const string fileName = "FileName.xml"; + var input = ProtocolTestsHelper.GetProtocolInputData(fileName); + + FeatureCheckContext context = new FeatureCheckContext(input, false); + + IFeatureCheckResult result = check.CheckIfUsed(context); + + Assert.IsTrue(result.IsUsed); + var ids = result.FeatureItems.Select(item => ((IQActionsQAction)item).Id.Value); + var expectedIds = context.Model.Protocol.QActions.Select(qaction => qaction.Id.Value); + ids.Should().BeEquivalentTo(expectedIds); + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Generic/GenericFeatureTests.cs b/Protocol.FeaturesTests/Generic/GenericFeatureTests.cs new file mode 100644 index 00000000..c0f562eb --- /dev/null +++ b/Protocol.FeaturesTests/Generic/GenericFeatureTests.cs @@ -0,0 +1,199 @@ +namespace SLDisDmFeatureCheckUnitTests.Generic +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisDmFeatureCheck.Common.Attributes; + using SLDisDmFeatureCheck.Common.Interfaces; + + [TestClass] + public class GenericFeatureTests + { + private static List<(IFeatureCheck feature, MinDataMinerVersionsAttribute minVersion, MaxDataMinerVersionsAttribute maxVersion)> features; + + [ClassInitialize] + public static void Initialize(TestContext context) + { + features = new List<(IFeatureCheck feature, MinDataMinerVersionsAttribute minVersion, MaxDataMinerVersionsAttribute maxVersion)>(); + + // TODO: Can be tweaked later, maybe with inheritance? + var minFeatures = MinDataMinerVersionsAttribute.GetFeatures(); + var maxFeatures = MaxDataMinerVersionsAttribute.GetFeatures(); + + foreach ((IFeatureCheck feature, MinDataMinerVersionsAttribute version) in minFeatures) + { + // Not ideal, but we'll need to see if we implement a comparer or something that makes it unique. + var temp = maxFeatures.FirstOrDefault(x => x.feature?.Title == feature.Title); + + // temp will not be null, but the inner 'fields' will be default + features.Add((feature, version, temp.version)); + } + } + + [TestMethod] + public void CheckValidVersion() + { + List invalidFeatures = new List(); + foreach ((IFeatureCheck feature, MinDataMinerVersionsAttribute minVersions, MaxDataMinerVersionsAttribute maxVersions) in features) + { + if (minVersions.MainRelease?.Version == null || minVersions.FeatureRelease?.Version == null) + { + invalidFeatures.Add(feature); + continue; + } + + if (maxVersions != null && (maxVersions.MainRelease?.Version == null || maxVersions.FeatureRelease?.Version == null)) + { + invalidFeatures.Add(feature); + } + } + + if (invalidFeatures.Count <= 0) + { + return; + } + + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(Environment.NewLine + "Features with invalid DataMiner version(s):"); + + foreach (IFeature f in invalidFeatures) + { + sb.AppendLine("\t" + f.GetType().Name); + } + + Assert.Fail(sb.ToString()); + } + + [TestMethod] + public void CheckValidBuildNumber() + { + List missingBuildNumbers = new List(); + foreach ((IFeatureCheck feature, MinDataMinerVersionsAttribute minVersions, MaxDataMinerVersionsAttribute maxVersions) in features) + { + if (minVersions.MainRelease != null && minVersions.MainRelease.Iteration == 0) + { + missingBuildNumbers.Add(feature); + continue; + } + + if (minVersions.FeatureRelease != null && minVersions.FeatureRelease.Iteration == 0) + { + missingBuildNumbers.Add(feature); + continue; + } + + if (maxVersions == null) + { + continue; + } + + if (maxVersions.MainRelease != null && maxVersions.MainRelease.Iteration == 0) + { + missingBuildNumbers.Add(feature); + continue; + } + + if (maxVersions.FeatureRelease != null && maxVersions.FeatureRelease.Iteration == 0) + { + missingBuildNumbers.Add(feature); + } + } + + if (missingBuildNumbers.Count <= 0) + { + return; + } + + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(Environment.NewLine + "Features with missing build number(s):"); + + foreach (IFeature f in missingBuildNumbers) + { + sb.AppendLine("\t" + f.GetType().Name); + } + + Assert.Inconclusive(sb.ToString()); + } + + [TestMethod] + public void CheckDescription() + { + List invalidFeatures = new List(); + foreach ((IFeatureCheck feature, _, _) in features) + { + try + { + // Will check if null, throwing exception or just empty + if (feature.Description.Equals(String.Empty)) + { + invalidFeatures.Add(feature); + } + } + catch (Exception e) when (e is NullReferenceException || e is NotImplementedException) + { + invalidFeatures.Add(feature); + } + } + + if (invalidFeatures.Count > 0) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(Environment.NewLine + "Features with not implemented descriptions:"); + + foreach (IFeature f in invalidFeatures) + { + sb.AppendLine("\t" + f.GetType().Name); + } + + Assert.Fail(sb.ToString()); + } + } + + [TestMethod] + public void CheckReleaseNotes() + { + List invalidFeatures = new List(); + foreach ((IFeatureCheck feature, _, _) in features) + { + // We currently didn't manage to find RNs for Class Library Ranges. + // JanS should be able to provide us with those but didn't fine the time of it yet. + if (feature.Title?.StartsWith("Class Library Range") == true) + { + continue; + } + + try + { + // Will check if null, throwing exception or just empty + if (feature.ReleaseNotes.Count == 0) + { + invalidFeatures.Add(feature); + } + } + catch (Exception e) when (e is NullReferenceException || e is NotImplementedException) + { + invalidFeatures.Add(feature); + } + } + + if (invalidFeatures.Count > 0) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(Environment.NewLine + "Features with not implemented release notes:"); + + foreach (IFeature f in invalidFeatures) + { + sb.AppendLine("\t" + f.GetType().Name); + } + + Assert.Fail(sb.ToString()); + } + } + } +} \ No newline at end of file diff --git a/Protocol.FeaturesTests/Protocol.FeaturesTests.csproj b/Protocol.FeaturesTests/Protocol.FeaturesTests.csproj new file mode 100644 index 00000000..21ad171a --- /dev/null +++ b/Protocol.FeaturesTests/Protocol.FeaturesTests.csproj @@ -0,0 +1,26 @@ + + + + net472;net6.0 + disable + disable + + false + true + + + + + + + + + + + + + + + + + diff --git a/Protocol/Legacy/CheckRTDisplayTrue.cs b/Protocol/Legacy/CheckRTDisplayTrue.cs new file mode 100644 index 00000000..f46af3ac --- /dev/null +++ b/Protocol/Legacy/CheckRTDisplayTrue.cs @@ -0,0 +1,120 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Xml; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + public partial class ProtocolChecks + { + /// + /// Checks the RTDisplay. + /// + /// The protocol document. + /// List of results. + public List CheckRTDisplayTrue(XmlDocument xDoc) // M + { + List resultMsg = new List(); + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", "http://www.skyline.be/protocol"); + + // Checks for parameters that MUST have RTDisplay = true + RtdCheckDependencyValues(xDoc, xmlNsm, ref resultMsg); + + return resultMsg; + } + + /// + /// Check on DependencyValues. + /// + /// The protocol document. + /// The namespace. + /// Set of allowed parameters. + /// List of results. + private void RtdCheckDependencyValues(XmlDocument xDoc, XmlNamespaceManager xmlNsm, ref List resultMsg) + { + XmlNodeList xnlParams = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param[slc:Measurement/slc:Discreets/slc:Discreet/@dependencyValues]", xmlNsm); + foreach (XmlNode xnParam in xnlParams) + { + string sParamId = xnParam.Attributes?["id"].InnerXml; + LineNum = xnParam.Attributes?["QA_LNx"].InnerXml; + + // Check Parameter Type (only write parameters) + XmlNode xnParamType = xnParam.SelectSingleNode("./slc:Type", xmlNsm); + string sParamType = xnParamType?.InnerXml; + if (!String.Equals(sParamType, "write")) + { + string sLineNum = xnParamType?.Attributes?["QA_LNx"].InnerXml ?? LineNum; + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(sLineNum), + ErrorId = 5302, + DescriptionFormat = "DependencyValues is only allowed on write parameters.", + DescriptionParameters = null, + TestName = "RtdCheckDependencyValues", + Severity = Severity.Major + }); + } + + // Get Parameter Name + string sParamName = xnParam.SelectSingleNode("./slc:Name", xmlNsm)?.InnerXml; + + if (!String.IsNullOrWhiteSpace(sParamName) && sParamName.EndsWith("_ContextMenu")) + { + // Context Menu Parameter => Only ParameterId with placeholders. (1005;1005?;1005:default;1005?:default;1005:[value:1005];1005?:[value:1005]) + // All transfered to new validator already + } + else + { + // No ContextMenu + // Check if Discreets has dependencyId attribute + XmlNode xnDiscreets = xnParam.SelectSingleNode("./slc:Measurement/slc:Discreets", xmlNsm); + string sDependencyId = xnDiscreets?.Attributes["dependencyId"]?.InnerXml; + if (xnDiscreets == null || sDependencyId == null) + { + string sLineNum = xnDiscreets?.Attributes?["QA_LNx"].InnerXml ?? LineNum; + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(sLineNum), + ErrorId = 5301, + DescriptionFormat = "Required attribute '{0}' is missing.", + DescriptionParameters = new object[] { "dependencyId" }, + TestName = "RtdCheckDependencyValues", + Severity = Severity.Major + }); + } + + // Check if all discreets have the dependencyValues attribute + XmlNodeList xnDiscreetList = xnDiscreets?.ChildNodes; + foreach (XmlNode xnDiscreet in xnDiscreetList) + { + string sLineNum = xnDiscreet?.Attributes?["QA_LNx"].InnerXml ?? LineNum; + + // Get dependencyValues attribute + string sDependencyValues = xnDiscreet?.Attributes?["dependencyValues"]?.InnerXml; + + if (String.IsNullOrWhiteSpace(sDependencyValues)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(sLineNum), + ErrorId = 5301, + DescriptionFormat = "Required attribute '{0}' is missing.", + DescriptionParameters = new object[] { "dependencyValues" }, + TestName = "RtdCheckDependencyValues", + Severity = Severity.Major + }); + } + } + + // No need to check the value from the DependencyValues attribute as it can contain anything. + // Maybe later => If DependencyId refers to Discreet parameter => Check if dependencyValues match with one of the discreets? + } + } + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/InternalError.cs b/Protocol/Legacy/InternalError.cs new file mode 100644 index 00000000..2e343d8e --- /dev/null +++ b/Protocol/Legacy/InternalError.cs @@ -0,0 +1,195 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + /// + /// Validation Result properties. + /// + /// + [DataContract] + public class InternalError : IValidationResult + { + public List SubResults { get; set; } + + /// + /// Gets the result. + /// Information, Warning or Error. + /// + [DataMember(Order = 3)] + public Severity Severity { get; set; } + + public Source Source => Source.Validator; + + public List<(string Message, bool AutoFixPopup)> AutoFixWarnings { get; } = new List<(string Message, bool AutoFixPopup)>(0); + + /// + /// Gets or sets the line number in xml file. + /// + [DataMember(Order = 4)] + public int Line { get; set; } + + /// + /// Gets or sets the unique identifier for the test. + /// + public string FullId { get; set; } + + /// + /// Gets the unique identifier for the error type. + /// + [DataMember(Order = 0)] + public uint ErrorId { get; set; } + + /// Get the check ID. + public uint CheckId { get; } + + /// + /// Gets the format for the error description. + /// + [DataMember(Order = 1)] + public string DescriptionFormat { get; set; } + + /// + /// Gets or sets the name of the test. + /// + public string TestName { get; set; } + + /// + /// Gets or sets the parameters to fill in DescriptionFormat. + /// + [DataMember(Order = 2)] + public object[] DescriptionParameters { get; set; } + + /// + /// Gets the position of the result in the xml file. + /// + public int Position => -1; + + public Category Category + { + get + { + return Category.Undefined; + } + } + + public Certainty Certainty + { + get + { + return Certainty.Certain; + } + } + + public FixImpact FixImpact + { + get + { + return FixImpact.Undefined; + } + } + + public string GroupDescription + { + get + { + return String.Empty; + } + } + + public string Description + { + get + { + return String.Empty; + } + } + + public string HowToFix + { + get + { + return String.Empty; + } + } + + public string ExampleCode + { + get + { + return String.Empty; + } + } + + public string Details + { + get + { + return String.Empty; + } + } + + public IReadable ReferenceNode + { + get + { + return null; + } + } + + public IReadable PositionNode + { + get + { + return null; + } + } + + public bool HasCodeFix + { + get + { + return false; + } + } + + [DataMember(Order = 5)] + public (int TablePid, string Name)? DveExport { get; set; } + + /// + /// The internal error format. + /// + private const string InternalErrorFormat = "Internal Application Error : Error in {0}. ({1})."; + + /// + /// Initializes a new instance of the class. + /// + public InternalError() + { + Severity = Severity.Critical; + ErrorId = 1001; + DescriptionFormat = InternalErrorFormat; + } + + /// + /// Initializes a new instance of the class. + /// + /// The line number. + /// Name of the test. + /// The description parameters. + public InternalError(int line, string testName, object[] descriptionParameters) + { + Severity = Severity.Critical; + ErrorId = 1001; + DescriptionFormat = InternalErrorFormat; + this.Line = line; + this.TestName = testName; + this.DescriptionParameters = descriptionParameters; + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/ParameterInfo.cs b/Protocol/Legacy/ParameterInfo.cs new file mode 100644 index 00000000..3d1acb8a --- /dev/null +++ b/Protocol/Legacy/ParameterInfo.cs @@ -0,0 +1,254 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Xml; + + /// + /// Holds info on the parameter and its s. + /// + /// + public class ParameterInfo : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// The parameter id. + /// The parameter name. + /// The description. + /// The parameter type. + /// Type of the interprete. + /// RawType of the interprete. + /// The type of the measurement. + /// If set to true [rt display]. + /// The line number. + /// Type of the length. + /// The length type identifier. + /// If set to true [trended]. + /// If set to true [alarmed]. + /// If set to true [virtualsource]. + /// The element. + /// The position. + public ParameterInfo(int pid, string name, string description, string type, string intType, string intRawType, string meastype, bool rtDisplay, string linenum, string lengthType, string lengthTypeId, bool trended, bool alarmed, bool virtualsource, XmlNode element, params Position[] position) + { + Pid = pid; + Name = name; + Description = description; + Type = type; + IntType = intType; + IntRawType = intRawType; + MeasType = meastype; + Positions = position; + RTDisplay = rtDisplay; + LineNum = linenum; + LengthType = lengthType; + LengthTypeId = lengthTypeId; + Trended = trended; + Alarmed = alarmed; + VirtualSource = virtualsource; + Element = element; + } + + public int? DuplicateAs { get; set; } + + /// + /// Gets a value indicating whether a Parameter is alarmed. + /// + public bool Alarmed { get; } + + /// + /// Gets the Parameter description. + /// + public string Description { get; } + + /// + /// Gets the element. + /// + public XmlNode Element { get; } + + /// + /// Gets the Parameter interprete type : string, double, ... + /// + public string IntType { get; } + + /// + /// Gets the Parameter interprete raw type : other, numeric, ... + /// + public string IntRawType { get; } + + /// + /// Gets the length type. + /// + public string LengthType { get; } + + /// + /// Gets the length type id. + /// + public string LengthTypeId { get; } + + /// + /// Gets the line number. + /// + public string LineNum { get; } + + /// + /// Gets the Parameter measurement type : string, number, discreet, ... + /// + public string MeasType { get; } + + /// + /// Gets the Parameter name. + /// + public string Name { get; } + + /// + /// Gets the Parameter id. + /// + public int Pid { get; } + + /// + /// Gets the positions. + /// + public Position[] Positions { get; } + + /// + /// Gets a value indicating whether a Parameter is needed in SLElement. + /// + public bool RTDisplay { get; } + + /// + /// Gets a value indicating whether a Parameter is trended. + /// + public bool Trended { get; } + + /// + /// Gets the Parameter type: read, write, ... + /// + public string Type { get; } + + /// + /// Gets a value indicating whether a Parameter type has virtual=source attribute. + /// + public bool VirtualSource { get; } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// + /// True if the current object is equal to the parameter; otherwise, false. + /// + public bool Equals(ParameterInfo other) + { + if (other == null) + { + return false; + } + + bool positioncomparer = true; + if (Positions.Length == other.Positions.Length) + { + for (int i = 0; i < Positions.Length; i++) + { + positioncomparer &= Positions[i].Equals(other.Positions[i]); + } + } + else + { + positioncomparer = false; + } + + if (Pid == other.Pid && Name == other.Name && Description == other.Description && + Type == other.Type && IntType == other.IntType && MeasType == other.MeasType && + positioncomparer && RTDisplay == other.RTDisplay && LineNum == other.LineNum && + LengthType == other.LengthType && LengthTypeId == other.LengthTypeId && + Trended == other.Trended && Alarmed == other.Alarmed && IntRawType == other.IntRawType && + VirtualSource == other.VirtualSource && Element == other.Element) + { + return true; + } + else + { + return false; + } + } + + /// + /// Determines whether the specified , is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return Equals(obj as ParameterInfo); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + // Overflow is fine, just wrap + unchecked + { + int hash = 17; + + // Suitable nullity checks etc, of course :) + hash = (hash * 23) + Pid.GetHashCode(); + hash = (hash * 23) + Name.GetHashCode(); + hash = (hash * 23) + Description.GetHashCode(); + hash = (hash * 23) + Type.GetHashCode(); + hash = (hash * 23) + IntType.GetHashCode(); + hash = (hash * 23) + IntRawType.GetHashCode(); + hash = (hash * 23) + MeasType.GetHashCode(); + hash = (hash * 23) + Positions.GetHashCode(); + hash = (hash * 23) + RTDisplay.GetHashCode(); + hash = (hash * 23) + LineNum.GetHashCode(); + hash = (hash * 23) + LengthType.GetHashCode(); + hash = (hash * 23) + LengthTypeId.GetHashCode(); + hash = (hash * 23) + Trended.GetHashCode(); + hash = (hash * 23) + Alarmed.GetHashCode(); + hash = (hash * 23) + VirtualSource.GetHashCode(); + hash = (hash * 23) + Element.GetHashCode(); + return hash; + } + } + } + + /// + /// Compare two objects. + /// + /// + public class ParameterInfoComparer : IEqualityComparer + { + /// + /// Determines whether the specified objects are equal. + /// + /// The first object of type to compare. + /// The second object of type to compare. + /// + /// True if the specified objects are equal; otherwise, false. + /// + public bool Equals(ParameterInfo x, ParameterInfo y) + { + return x.Equals(y); + } + + /// + /// Returns a hash code for this instance. + /// + /// The object. + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public int GetHashCode(ParameterInfo obj) + { + return obj.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/Position.cs b/Protocol/Legacy/Position.cs new file mode 100644 index 00000000..0304136a --- /dev/null +++ b/Protocol/Legacy/Position.cs @@ -0,0 +1,185 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + + /// + /// Info on parameter positions. + /// + /// + public class Position : IEquatable + { + /// + /// Initializes a new instance of the class. This will be empty. + /// + public Position() + { + Page = String.Empty; + Row = "-1"; + Column = "-1"; + Export = 0; + } + + /// + /// Initializes a new instance of the class without export (defaults to 0). + /// + /// The page. + /// The row. + /// The column. + public Position(string page, string row, string column) + { + Page = page; + Row = row; + Column = column; + Export = 0; + } + + /// + /// Initializes a new instance of the class with export. + /// + /// The page. + /// The row. + /// The column. + /// Pid of the exported table. + public Position(string page, string row, string column, int export) + { + Page = page; + Row = row; + Column = column; + Export = export; + } + + /// + /// Gets or sets the column. + /// + public string Column { get; set; } + + /// + /// Gets or sets the export. + /// Pid of the exported table if present, 0 if not exported, -1 if export = true. + /// + public int Export { get; set; } + + /// + /// Gets or sets the page. + /// + public string Page { get; set; } + + /// + /// Gets or sets the row. + /// + public string Row { get; set; } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + public bool Equals(Position other) + { + if (other == null) + { + return false; + } + + if (Page == other.Page && Row == other.Row && Column == other.Column && Export == other.Export) + { + return true; + } + else + { + return false; + } + } + + /// + /// Determines whether the specified , is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return Equals(obj as Position); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + // Overflow is fine, just wrap + unchecked + { + int hash = 17; + + // Suitable nullity checks etc, of course :) + hash = (hash * 23) + Page.GetHashCode(); + hash = (hash * 23) + Row.GetHashCode(); + hash = (hash * 23) + Column.GetHashCode(); + hash = (hash * 23) + Export.GetHashCode(); + return hash; + } + } + + /// + /// Returns true if the is valid. + /// + /// + /// true if this instance is valid; otherwise, false. + /// + public bool IsValid() + { + return Page != String.Empty && Row != String.Empty && Column != String.Empty; + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return String.Format("Page: {0} Column: {1} Row: {2} Export: {3}", Page, Column, Row, Export); + } + } + + /// + /// Compare two objects. + /// + /// + public class PositionComparer : IEqualityComparer + { + /// + /// Determines whether the specified objects are equal. + /// + /// The first object of type to compare. + /// The second object of type to compare. + /// + /// true if the specified objects are equal; otherwise, false. + /// + public bool Equals(Position x, Position y) + { + return x.Equals(y); + } + + /// + /// Returns a hash code for this instance. + /// + /// The object. + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public int GetHashCode(Position obj) + { + return obj.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/ProtocolChecks.cs b/Protocol/Legacy/ProtocolChecks.cs new file mode 100644 index 00000000..5e1429d7 --- /dev/null +++ b/Protocol/Legacy/ProtocolChecks.cs @@ -0,0 +1,4365 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Net; + using System.Text.RegularExpressions; + using System.Xml; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + public partial class ProtocolChecks + { + #region fields and properties + /// + /// Generic line number, used for lineNum estimates in case a ProtocolChecks test fails. + /// + public string LineNum { get; set; } = "-1"; + + /// + /// List of all duplicated parameters. + /// Key = Duplicate parameter Id. + /// Value = real Parameter Id. + /// + private readonly Dictionary DuplicateParameterDictionary = new Dictionary(); + + /// + /// The groups dictionary. + /// + private readonly Dictionary GroupsDictionary = new Dictionary(); + + /// + /// List of all parameter id's in the protocol. + /// + private readonly HashSet ParameterIdSet = new HashSet(); + + /// + /// Parameter Info for all parameters. + /// Key = Parameter Id. + /// Value = ParameterInfo. + /// + private readonly Dictionary ParameterInfoDictionary = new Dictionary(); + #endregion + + /// + /// Checks the content of the attributes. + /// + /// The protocol document. + /// List of results. + public List CheckAttributesContent(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + // Add xmlNameSpaceManager + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + // Re factored into separate methods to make code more readable + CheckActionAttributes(xDoc, resultMsg, xmlNsm); + CheckChainAttributes(xDoc, resultMsg, xmlNsm); + CheckPairAttributes(xDoc, resultMsg, xmlNsm); + CheckParamAttributes(xDoc, resultMsg, xmlNsm); + CheckQActionAttributes(xDoc, resultMsg, xmlNsm); + CheckRelationAttributes(xDoc, resultMsg, xmlNsm); + CheckResponseAttributes(xDoc, resultMsg, xmlNsm); + + return resultMsg; + } + + /// + /// Checks the copy action. + /// + /// The protocol document. + /// List of results. + public List CheckCopyAction(XmlDocument xDoc) + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlCopyActions = xDoc.SelectNodes("/slc:Protocol/slc:Actions/slc:Action[slc:Type='copy']|.//slc:Actions/slc:Action[slc:Type='Copy']", xmlNsm); + if (xnlCopyActions == null) + { + return resultMsg; + } + + foreach (XmlNode xnCopyAction in xnlCopyActions) + { + LineNum = xnCopyAction.Attributes?["QA_LNx"].InnerXml; + string typeIdRawValue = xnCopyAction.SelectSingleNode("./slc:Type", xmlNsm)?.Attributes?["id"]?.InnerXml; + + if (String.IsNullOrEmpty(typeIdRawValue)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3103, + DescriptionFormat = "Type id attribute empty or not present in Copy Action", + DescriptionParameters = new object[] { typeIdRawValue }, + TestName = "CheckCopyAction", + Severity = Severity.Minor + }); + } + else + { + if (!Int32.TryParse(typeIdRawValue, out int typeId) + || !ParameterInfoDictionary.TryGetValue(typeId, out ParameterInfo paramInfo) + || paramInfo?.Element == null) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3103, + DescriptionFormat = "Attribute 'Action/Type@id' references a non-existing Param with ID '" + typeIdRawValue + "'.", + DescriptionParameters = new object[] { typeIdRawValue }, + TestName = "CheckCopyAction", + Severity = Severity.Major + }); + + continue; + } + + XmlNode xnFromParam = paramInfo.Element; + string rawType = xnFromParam.SelectSingleNode(".//slc:Interprete/slc:RawType", xmlNsm)?.InnerXml; + string lengthType = xnFromParam.SelectSingleNode(".//slc:Interprete/slc:LengthType", xmlNsm)?.InnerXml; + + // Fixed and unsigned number + if (String.Equals(rawType, "unsigned number", StringComparison.OrdinalIgnoreCase) && String.Equals(lengthType, "fixed", StringComparison.OrdinalIgnoreCase)) + { + // Get value + XmlNode xnValue = xnFromParam.SelectSingleNode(".//slc:Interprete/slc:Value", xmlNsm); + if (xnValue != null) + { + LineNum = xnValue.Attributes?["QA_LNx"].InnerXml; + string sValue = xnValue.InnerXml; + const string RegexUnsignedNumber = "(0[xX][0-9a-fA-F])+"; + if (!Regex.IsMatch(sValue, RegexUnsignedNumber)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3102, + DescriptionFormat = "Unsigned Number value '{0}' is not written in format 0xFF.", + DescriptionParameters = new object[] { sValue }, + TestName = "CheckCopyAction", + Severity = Severity.Minor + }); + } + + if (sValue.Contains("0x00")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3101, + DescriptionFormat = + "Copy from Param with ID {0} may fail because the value contains 0x00.", + DescriptionParameters = new object[] { typeIdRawValue }, + TestName = "CheckCopyAction", + Severity = Severity.Minor + }); + } + } + } + } + } + + return resultMsg; + } + + /// + /// Checks the DVE column option. + /// Check if DVE exported table has exactly one columnoption with options=;element. + /// + /// The procotol document. + /// List of results. + public List CheckDveColumnOptionElement(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + // Get exported table parameter ID's + Dictionary exportedTables = GetDveTables(xDoc); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlParam = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param", xmlNsm); + + foreach (XmlNode xnParam in xnlParam) + { + string parameterId = xnParam.Attributes?.GetNamedItem("id")?.InnerXml; + LineNum = xnParam.Attributes?.GetNamedItem("QA_LNx")?.InnerXml; + + XmlNodeList xnlColumnOption = xnParam.SelectNodes("./slc:ArrayOptions/slc:ColumnOption", xmlNsm); + + // Count number of columns with element option + int elementCounter = 0; + + foreach (XmlNode columnOption in xnlColumnOption) + { + string sOptions = columnOption.Attributes?["options"]?.InnerXml; + if (String.IsNullOrWhiteSpace(sOptions)) { continue; } + + string[] asOptions = sOptions.Split(sOptions[0]); + foreach (string option in asOptions) + { + if (option == "element") + { + elementCounter++; + } + } + } + + // If element option is not present, generate error if param id is in exportedTable list + if (elementCounter == 0 && exportedTables.Keys.Count != 0 && exportedTables.Keys.Contains(parameterId)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2001, + DescriptionFormat = "There is no column with element option in exported table {0}", + DescriptionParameters = new object[] { parameterId }, + TestName = "CheckDVEColumnOptionElement", + Severity = Severity.Major + }); + } + + // If exactly one element option is present and param is not in exported tables list, generate an error. + if (elementCounter == 1 && !exportedTables.Keys.Contains(parameterId)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2003, + DescriptionFormat = "There is no export table defined for table {0}", + DescriptionParameters = new object[] { parameterId }, + TestName = "CheckDVEColumnOptionElement", + Severity = Severity.Major + }); + } + + if (elementCounter > 1) + { + // Generate error for multiple columns with element option + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2002, + DescriptionFormat = "There are multiple columns with element option in exported table {0}", + DescriptionParameters = new object[] { parameterId }, + TestName = "CheckDVEColumnOptionElement", + Severity = Severity.Major + }); + + // Generate error if table param is not in exportedTables list. + if (!exportedTables.Keys.Contains(parameterId)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2003, + DescriptionFormat = "There is no export table defined for table {0}", + DescriptionParameters = new object[] { parameterId }, + TestName = "CheckDVEColumnOptionElement", + Severity = Severity.Major + }); + } + } + } + + return resultMsg; + } + + /// + /// Checks on group Settings. + /// + /// The protocol document. + /// List of results. + public List CheckGroupSettings(XmlDocument xDoc) + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + string protocolType = xDoc.SelectSingleNode("/slc:Protocol/slc:Type", xmlNsm)?.InnerXml; + bool bVirtual = String.Equals(protocolType, "virtual", StringComparison.OrdinalIgnoreCase); + + bool bMultithreaded = false; + XmlNodeList xnlTimers = xDoc.SelectNodes("./slc:Timers/slc:Timer", xmlNsm); + foreach (XmlNode xnTimer in xnlTimers) + { + string sOptions = xnTimer?.Attributes?["options"]?.InnerXml; + if (String.IsNullOrEmpty(sOptions)) { continue; } + + if (sOptions.StartsWith("ip:", StringComparison.InvariantCulture) || sOptions.Contains(";ip:")) + { + bMultithreaded = true; + } + } + + XmlNodeList xnlGroups = xDoc.SelectNodes("/slc:Protocol/slc:Groups/slc:Group", xmlNsm); + foreach (XmlNode xnGroup in xnlGroups) + { + XmlNode xnContent = xnGroup.SelectSingleNode("./slc:Content", xmlNsm); + if (xnContent == null) + { + if (!bVirtual && !bMultithreaded) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1901, + DescriptionFormat = + "Group with missing Content tag. This should only be used in virtual protocols or when using a multithreaded timer.", + DescriptionParameters = null, + TestName = "CheckGroupSettings", + Severity = Severity.Minor + }); + } + } + } + + return resultMsg; + } + + /// + /// Checks the Interprete Measurement. + /// + /// The protocol document. + /// List of results. + public List CheckInterpreteMeasurement(XmlDocument xDoc) + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + foreach (ParameterInfo pi in ParameterInfoDictionary.Values) + { + XmlNode xnRawType = pi.Element.SelectSingleNode("./slc:Interprete/slc:RawType", xmlNsm); + if (xnRawType == null) { continue; } + + string rawType = xnRawType.InnerXml; + string type = pi.IntType; + string measurementType = pi.MeasType; + + // 3 Main Types, String, Number or Table + string simpleType = null; + switch (measurementType) + { + case "string": + case "pagebutton": + simpleType = "string"; + break; + + case "number": + case "analog": + case "chart": + case "digital threshold": + case "progress": + case "table": + case "matrix": + // Matrix now handled in Validator2 + simpleType = null; + break; + case "button": + case "discreet": + case "togglebutton": + { + bool allNumbers = true; + XmlNode xnDiscreets = pi.Element.SelectSingleNode("./slc:Measurement/slc:Discreets", xmlNsm); + if (xnDiscreets != null) + { + // Check if Discreets Tag has dependencyId + XmlAttribute xaDependencyId = xnDiscreets.Attributes?["dependencyId"]; + + if (xaDependencyId == null) + { + foreach (XmlNode innerDiscreet in xnDiscreets.SelectNodes("./slc:Discreet/slc:Value", xmlNsm)) + { + if (!Double.TryParse(innerDiscreet.InnerXml, NumberStyles.Any, CultureInfo.InvariantCulture, out _)) + { + allNumbers = false; + break; + } + } + } + else + { + // Has dependencyId => String + allNumbers = false; + } + } + + if (allNumbers) + { + simpleType = "double"; + } + else + { + simpleType = "string"; + } + } + break; + } + + if (simpleType == null) { continue; } + + if (simpleType != type) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 5001, + DescriptionFormat = "Verify Measurement - Interprete Combination for {0} : {1}", + DescriptionParameters = new object[] { measurementType, type }, + TestName = "CheckInterpreteMeasurement", + Severity = Severity.Minor + }); + } + + if (measurementType != "table" && measurementType != "matrix" && + (rawType == "other" && type != "string") || (rawType == "numeric text" && type != "double")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 5002, + DescriptionFormat = "Verify Interprete RawType - Type Combination: {0} - {1}", + DescriptionParameters = new object[] { rawType, type }, + TestName = "CheckInterpreteMeasurement", + Severity = Severity.Minor + }); + } + } + + return resultMsg; + } + + /// + /// Checks the port settings. + /// + /// The protocol document. + /// List of results. + public List CheckPortSettings(XmlDocument xDoc) // SR + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList nlType = xDoc.SelectNodes("slc:Protocol/slc:Type", xmlNsm); + foreach (XmlNode xnType in nlType) + { + LineNum = xnType.Attributes?["QA_LNx"].InnerXml; + + // Check relative timers exists and is true + if (xnType.Attributes?["relativeTimers"] != null) + { + if (!xnType.Attributes["relativeTimers"].InnerXml.ToLower().Contains("true")) + { + // Relative timers exists but is not true + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1802, + DescriptionFormat = "Main Type tag attribute relativeTimers is not set to 'true'.", + DescriptionParameters = null, + TestName = "CheckPortSettings", + Severity = Severity.Minor + }); + } + } + else + { + // Relative timers does not exist + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1803, + DescriptionFormat = "Main Type tag attribute relativeTimers must exist and be set to 'true'.", + DescriptionParameters = null, + TestName = "CheckPortSettings", + Severity = Severity.Minor + }); + } + } + + return resultMsg; + } + + /// + /// Checks the positions. + /// + /// The protocol document. + /// List of results. + public List CheckPositions(XmlDocument xDoc) // M + { + List resultMsg = new List(); + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + Dictionary> dictUniquePositions = new Dictionary>(); + foreach (ParameterInfo pi in ParameterInfoDictionary.Values) + { + LineNum = pi.LineNum; + + if (pi.Positions != null && pi.RTDisplay) + { + foreach (Position po in pi.Positions) + { + if (!po.IsValid()) { continue; } + + if (!dictUniquePositions.ContainsKey(po)) + { + dictUniquePositions.Add(po, new List { Convert.ToString(pi.Pid) }); + } + else + { + dictUniquePositions[po].Add(Convert.ToString(pi.Pid)); + } + } + } + } + + // Check duplicate positions + foreach (Position position in dictUniquePositions.Keys) + { + List pids = dictUniquePositions[position]; + + if (pids.Count >= 2) + { + bool error = true; + if (pids.Count == 2) + { + ParameterInfo pi1 = ParameterInfoDictionary[Convert.ToInt32(pids[0])]; + ParameterInfo pi2 = ParameterInfoDictionary[Convert.ToInt32(pids[1])]; + if (pi1.Description == pi2.Description) + { + // Descriptions are the same, check if types are allowed combinations + // Allowed combinations: + // read - write + // array - write + // read bit - write bit + // read bit - write + + string type1 = pi1.Type; + if (type1.StartsWith("write", StringComparison.InvariantCulture)) + { + type1 = "write"; + } + else + { + type1 = "read"; + } + + string type2 = pi2.Type; + if (type2.StartsWith("write", StringComparison.InvariantCulture)) + { + type2 = "write"; + } + else + { + type2 = "read"; + } + + if (type1 != type2) + { + // Types are read/write pair + error = false; + } + } + // Else error: different param descriptions on same position + } + + // If more than two parameters or different descriptions, or illegal combination, generate an error + if (error) + { + foreach (string spid in pids) + { + int ipid = Convert.ToInt32(spid); + ParameterInfo pi = ParameterInfoDictionary[ipid]; + + // Types are the same, these cannot be on the same position. Generate Error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2201, + DescriptionFormat = "There are multiple parameters on position {0}. Parameter {1} with description {2}", + DescriptionParameters = new object[] { position.ToString(), pi.Pid, pi.Description }, + TestName = "CheckPositions", + Severity = Severity.Major + }); + } + } + } + } + + return resultMsg; + } + + /// + /// Checks the protocol name. + /// + /// The protocol document. + /// List of results. + public List CheckProtocolNames(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + string name = null; + // Main protocol name + XmlNode xnProtocolName = xDoc.SelectSingleNode("./slc:Protocol/slc:Name", xmlNsm); + if (xnProtocolName != null) + { + name = xnProtocolName.InnerXml; + } + + // Exported protocols + List exportProtocolNames = new List(); + + // Get exported protocols from type tag + XmlNode xnTypeOptions = xDoc.SelectSingleNode("./slc:Protocol/slc:Type/@options", xmlNsm); + if (xnTypeOptions != null) + { + string options = xnTypeOptions.InnerXml; + string[] alloptions = options.Split(';'); + foreach (string option in alloptions) + { + if (option.StartsWith("exportProtocol", StringComparison.InvariantCulture)) + { + string[] s = option.Split(':'); + string exportprotocolname = s[1]; + exportProtocolNames.Add(exportprotocolname); + } + } + } + + // Get exported protocols from DVEs/DveProtocols/DveProtocol tags + XmlNodeList xnlDveProtocol = xDoc.SelectNodes("slc:Protocol/slc:DVEs/slc:DVEProtocols/slc:DVEProtocol", xmlNsm); + foreach (XmlNode dveProtocol in xnlDveProtocol) + { + LineNum = dveProtocol.Attributes?["QA_LNx"]?.InnerXml; + string dveName = dveProtocol.Attributes?["name"]?.InnerXml; + exportProtocolNames.Add(dveName); + } + + foreach (string exportProtocolName in exportProtocolNames) + { + List badChars = CheckBadCharacters(exportProtocolName); + if (badChars.Count > 0) + { + string chars = String.Join(", ", badChars); + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4902, + DescriptionFormat = "Exported protocol name {0} contains illegal characters {1}.", + DescriptionParameters = new object[] { exportProtocolName, chars }, + TestName = "CheckProtocolNames", + Severity = Severity.Major + }); + } + + if (!exportProtocolName.StartsWith(name + " - ", StringComparison.InvariantCulture) || exportProtocolName.Trim() == (name + " -") || exportProtocolName.Trim() == (name + "-")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4903, + DescriptionFormat = "Exported protocol name \"{0}\" has incorrect format. Expected format is \"[Mother Protocol Name] - [Name]\"", + DescriptionParameters = new object[] { exportProtocolName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + return resultMsg; + } + + /// + /// Parameters with RawType double should have fixed LengthType, or be changed to numeric text. + /// + /// The protocol document. + /// List of results. + public List CheckRawTypeDouble(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlInterprete = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param/slc:Interprete", xmlNsm); + foreach (XmlNode xnInterprete in xnlInterprete) + { + LineNum = xnInterprete.Attributes?["QA_LNx"].InnerXml; + string lengthType = String.Empty; + XmlNode xnRawType = xnInterprete.SelectSingleNode("./slc:RawType", xmlNsm); + if (xnRawType == null) { continue; } + + LineNum = xnRawType.Attributes?["QA_LNx"].InnerXml; + string rawType = xnRawType.InnerXml; + + if (!String.Equals(rawType, "double", StringComparison.OrdinalIgnoreCase)) { continue; } + + XmlNode xnLengthType = xnInterprete.SelectSingleNode("./slc:LengthType", xmlNsm); + if (xnLengthType != null) + { + LineNum = xnLengthType.Attributes?["QA_LNx"].InnerXml; + lengthType = xnLengthType.InnerXml; + } + + if (String.Equals(lengthType, "next param", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2601, + DescriptionFormat = "RawType double is used with LengthType {0}. Change LengthType to fixed or RawType to numeric text", + DescriptionParameters = new object[] { lengthType }, + TestName = "CheckSNMPRawTypeDouble", + Severity = Severity.Major + }); + } + else if (String.Equals(lengthType, "fixed", StringComparison.OrdinalIgnoreCase)) + { + XmlNode xnLength = xnInterprete.SelectSingleNode("./slc:Length", xmlNsm); + if (xnLength == null) + { + //// Covered by 2.74.1 + ////LineNum = xnInterprete.Attributes?["QA_LNx"].InnerXml; + ////resultMsg.Add(new ValidationResult + ////{ + //// Line = Convert.ToInt32(LineNum), + //// ErrorId = 2603, + //// DescriptionFormat = "RawType double has no length definition.", + //// DescriptionParameters = null, + //// TestName = "CheckSNMPRawTypeDouble", + //// Severity = Severity.Major + ////}); + } + else + { + LineNum = xnLength.Attributes?["QA_LNx"].InnerXml; + string sLength = xnLength.InnerXml; + if (sLength != "4" && sLength != "8") + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2602, + DescriptionFormat = "RawType double has length {0}. Length should be 4 or 8.", + DescriptionParameters = new object[] { sLength }, + TestName = "CheckSNMPRawTypeDouble", + Severity = Severity.Major + }); + } + } + } + } + + return resultMsg; + } + + /// + /// Checks the recursive page buttons. + /// + /// The protocol document. + /// List of results. + public List CheckRecursivePageButtons(XmlDocument xDoc) + { + // Check that pageButtons are not used within a pageButton page. This crashes IE and is against design agreements. + List resultMsg = new List(); + List pbPageNames = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + // Find all pageButton pages and add to list + // .NET framework uses XPath 1.0. upper-case/lower-case are not supported, so need to use translate to perform case-insensitive check. + XmlNodeList xnlPageButtons = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param/slc:Measurement[translate(slc:Type,'PAGEBUTON','pagebuton')=\"pagebutton\"]", xmlNsm); + + foreach (XmlNode pageButton in xnlPageButtons) + { + LineNum = pageButton.Attributes?["QA_LNx"].InnerXml; + XmlNodeList pageButtonValues = pageButton.SelectNodes("./slc:Discreets/slc:Discreet/slc:Value", xmlNsm); + foreach (XmlNode pageButtonValue in pageButtonValues) + { + if (pageButtonValue == null) { continue; } + + LineNum = pageButtonValue.Attributes?["QA_LNx"].InnerXml; + string pbPageName = pageButtonValue.InnerXml; + if (!pbPageNames.Contains(pbPageName)) + { + pbPageNames.Add(pbPageName); + } + } + } + + // Select all pageButton parameters + XmlNodeList pageButtonParameters = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param[translate(slc:Measurement/slc:Type,'PAGEBUTON','pagebuton')=\"pagebutton\"]", xmlNsm); + foreach (XmlNode pageButtonParameter in pageButtonParameters) + { + LineNum = pageButtonParameter.Attributes?["QA_LNx"]?.InnerXml; + string id = pageButtonParameter.Attributes?["id"]?.InnerXml; + + // Get parameter position pages + XmlNodeList xnlPages = pageButtonParameter.SelectNodes("./slc:Display/slc:Positions/slc:Position/slc:Page", xmlNsm); + foreach (XmlNode xnPage in xnlPages) + { + if (xnPage == null) { continue; } + + LineNum = xnPage.Attributes?["QA_LNx"].InnerXml; + string page = xnPage.InnerXml; + if (pbPageNames.Contains(page)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3401, + DescriptionFormat = "PageButton Parameter {0} is included on pageButton page {1}.", + DescriptionParameters = new object[] { id, page }, + TestName = "CheckRecursivePageButtons", + Severity = Severity.Minor + }); + } + } + } + + return resultMsg; + } + + /// + /// Checks the content of the response. + /// + /// The protocol document. + /// List of results. + public List CheckResponseContent(XmlDocument xDoc) // M + { + List resultMsg = new List(); + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlResponses = xDoc.SelectNodes("slc:Protocol/slc:Responses/slc:Response", xmlNsm); + if (xnlResponses != null) + { + foreach (XmlNode xnResponse in xnlResponses) + { + LineNum = xnResponse.Attributes?["QA_LNx"].InnerXml; + string responseId = xnResponse.Attributes?["id"].InnerXml; + + // List of parameterInfo for all pids in response, using the same order (may contain duplicates) + List responseParams = new List(); + XmlNodeList xnlRParams = xnResponse.SelectNodes("./slc:Content/slc:Param", xmlNsm); + foreach (XmlNode xnRParam in xnlRParams) + { + string pid = xnRParam?.InnerXml; + + // ValV2 Fixed after issue found during QA of DCP97933 + if (!String.IsNullOrEmpty(pid)) + { + var paramId = Convert.ToInt32(pid); + if (!ParameterInfoDictionary.ContainsKey(paramId)) + { + continue; + } + + responseParams.Add(ParameterInfoDictionary[paramId]); + } + } + + // Check if all parameters have fixed length + bool allfixed = responseParams.All(a => a.LengthType == "fixed"); + + // AllFixed = OK, no further tests needed + if (!allfixed) + { + bool prevNextParam = false; + bool prevTrailer = false; + string prevNpLtId = String.Empty; + string prevNpId = String.Empty; + string lengthParam = String.Empty; + for (int i = 0; i < responseParams.Count; i++) + { + ParameterInfo pi = responseParams[i]; + bool b_last = i == responseParams.Count - 2; + bool last = i == responseParams.Count - 1; + if (pi.Type == "length") + { + lengthParam = Convert.ToString(pi.Pid); + } + + if (pi.LengthType == "fixed") + { + if (prevNextParam) + { + // Parameter should be fixed + if (prevNpLtId == String.Empty) + { + if (pi.Type != "fixed" && pi.Type != "trailer") + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4701, + DescriptionFormat = + "Next Param {0}. in response {1} is not followed by a fixed parameter or trailer.", + DescriptionParameters = new object[] { prevNpId, responseId }, + TestName = "CheckResponseContent", + Severity = Severity.Major + }); + } + else if (pi.Type == "fixed" || pi.Type == "trailer") + { + // Response part is closed by fixed param. Clear variables, response OK up to here + prevNextParam = false; + prevNpLtId = String.Empty; + prevNpId = String.Empty; + } + } + else // There is a lenghttype pid, loop until a fixed parameter is found + { + if (pi.Type == "fixed" || pi.Type == "trailer") + { + // Check if lengthType parameter matches + if (Convert.ToString(pi.Pid) == prevNpLtId) + { + // Matching parameter found, clear variables, response OK up to here + prevNextParam = false; + prevNpLtId = String.Empty; + prevNpId = String.Empty; + } + else // No match, throw error + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4702, + DescriptionFormat = + "ID of fixed or trailer parameter {0} does not match lengthType id {1} in preceding Next Parameter ({2}) in response {3}.", + DescriptionParameters = new object[] { pi.Pid, prevNpLtId, prevNpId, responseId }, + TestName = "CheckResponseContent", + Severity = Severity.Major + }); + } + } + else // Not a fixed parameter + { + if (last) // Response is not closed by fixed parameter, throw error + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4703, + DescriptionFormat = "Next Param {0} with lengthType id {1} followed by fixed length param is not followed by a fixed or trailer parameter in response {2}.", + DescriptionParameters = new object[] { prevNpId, prevNpLtId, responseId }, + TestName = "CheckResponseContent", + Severity = Severity.Major + }); + } + } + } + } + } + else if (pi.LengthType == "next param" || pi.LengthType == "last next param") + { + if (prevNextParam) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4704, + DescriptionFormat = "Next Param {0} in response {1} is followed by another next param {2} without fixed separator.", + DescriptionParameters = new object[] { prevNpId, responseId, pi.Pid }, + TestName = "CheckResponseContent", + Severity = Severity.Major + }); + } + + if (!last) + { + prevNextParam = true; + prevNpId = Convert.ToString(pi.Pid); + if (pi.LengthTypeId != String.Empty) + { + prevNpLtId = pi.LengthTypeId; + } + } + } + + if (b_last && pi.Type == "trailer") + { + prevTrailer = true; + } + + if (last) + { + bool check = pi.Type == "trailer" || lengthParam != String.Empty || prevTrailer && pi.Type == "crc"; + if (!check) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4705, + DescriptionFormat = "Response {0} has no length parameter and is not closed by a trailer parameter. This will cause the communication to wait for timeout.", + DescriptionParameters = new object[] { responseId }, + TestName = "CheckResponseContent", + Severity = Severity.Minor + }); + } + } + } + } + } + } + + return resultMsg; + } + + /// + /// Checks the table column exports. + /// + /// The protocol document. + /// List of results. + public List CheckTableColumnExports(XmlDocument xDoc) // M + { + // TODO: Check on viewTables + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + var allTables = GetAllTables(xDoc); + foreach (XmlNode xnTable in allTables) + { + if (xnTable == null) { continue; } + + string tableId = xnTable.Attributes?["id"].InnerXml; + LineNum = xnTable.Attributes?["QA_LNx"].InnerXml; + + XmlAttribute xaExports = xnTable.Attributes?["export"]; + if (xaExports == null) { continue; } + + string sExports = xaExports.InnerXml; + string[] sTableExports = sExports.Split(';'); + for (int i = 0; i < sTableExports.Length; i++) + { + if (sTableExports[i] == "true") + { + sTableExports[i] = "-1"; + } + } + + HashSet tableExports = new HashSet(sTableExports); + tableExports.Remove("false"); + + Dictionary columns = GetColumnPids(xDoc, tableId); + foreach (string column in columns.Keys) + { + int columnPid = Convert.ToInt32(column); + if (!ParameterInfoDictionary.TryGetValue(columnPid, out ParameterInfo pi)) + { + pi = ParameterInfoDictionary.Values.FirstOrDefault(x => x.DuplicateAs == columnPid); + } + + if (pi == null) + { + // Invalid Column Pid (New validator should throw error for that) + continue; + } + + LineNum = pi.LineNum; + HashSet columnExports = new HashSet(); + foreach (Position cpo in pi.Positions) + { + if (cpo.Export != 0) + { + columnExports.Add(cpo.Export.ToString()); + } + } + + if (!tableExports.SetEquals(columnExports)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 4801, + DescriptionFormat = "Table Column {0} has different exports from table {1}.", + DescriptionParameters = new object[] { column, tableId }, + TestName = "CheckTableColumnExports", + Severity = Severity.Major + }); + } + } + } + + return resultMsg; + } + + /// + /// Check dynamic table columns parameter are set correctly, including DVE tables. + /// + /// The protocol document. + /// List of results. + public List CheckTableColumnParams(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + // Concatenate both lists + var allTables = GetAllTables(xDoc); + + // Gather data for DVE check + Dictionary exportedRootTables = GetDveTables(xDoc); + List allowedTables = new List(exportedRootTables.Keys); + + // Check for tables with relations to exported tables + XmlNodeList xnlRelations = xDoc.SelectNodes("slc:Protocol/slc:Relations/slc:Relation", xmlNsm); + foreach (XmlNode xnRel in xnlRelations) + { + LineNum = xnRel.Attributes?["QA_LNx"].InnerXml; + XmlNode xnPath = xnRel.Attributes?["path"]; + if (xnPath == null) { continue; } + + string path = xnPath.InnerXml; + string[] relTables = path.Split(';'); + bool exportfound = false; + foreach (string s in relTables) + { + if (exportfound) + { + allowedTables.Add(s); + } + + if (exportedRootTables.ContainsKey(s)) + { + exportfound = true; + } + } + } + + foreach (XmlNode xnParam in allTables) + { + LineNum = xnParam.Attributes?.GetNamedItem("QA_LNx").InnerXml; + string sTablePid = xnParam.Attributes?.GetNamedItem("id")?.InnerXml; + + Dictionary pidsToCheck = GetColumnPids(xDoc, sTablePid, resultMsg); + + // Check if all columns in measurement are in the table. + HashSet measPids = GetTableMeasurementPids(xnParam, false); + foreach (int i in measPids) + { + if (!pidsToCheck.Keys.Contains(i.ToString())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1705, + DescriptionFormat = "Parameter {0} is included in the table measurement but not in the table definition.", + DescriptionParameters = new object[] { i }, + TestName = "CheckTableColumnParams", + Severity = Severity.Major + }); + } + } + + // Check if measurement type is table + string measType = xnParam.SelectSingleNode("./slc:Measurement/slc:Type", xmlNsm)?.InnerXml; + LineNum = xnParam.SelectSingleNode("./slc:Measurement/slc:Type", xmlNsm)?.Attributes?["QA_LNx"].InnerXml; + if (measType != null && !String.Equals(measType, "table", StringComparison.OrdinalIgnoreCase) && !String.Equals(measType, "matrix", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1706, + DescriptionFormat = "Measurement type for array is not table or matrix.", + DescriptionParameters = null, + TestName = "CheckTableColumnParams", + Severity = Severity.Major + }); + } + + // Find foreignKeys + // Find tables with foreignKey to exported table that are not in a relation, in this case the table rows will be exported as standalone parameters. + XmlNodeList xnlCOoptions = xnParam.SelectNodes("./slc:ArrayOptions/slc:ColumnOption/@options", xmlNsm); + foreach (XmlNode options in xnlCOoptions) + { + string sOptions = options?.InnerXml; + if (String.IsNullOrEmpty(sOptions)) { continue; } + + string[] allOptions = sOptions.Split(new[] { sOptions[0] }, StringSplitOptions.RemoveEmptyEntries); + foreach (string option in allOptions) + { + if (option.StartsWith("foreignkey=", StringComparison.InvariantCultureIgnoreCase)) + { + string fkTable = option.Substring("foreignkey=".Length); + if (exportedRootTables.Keys.Contains(fkTable)) + { + allowedTables.Add(sTablePid); + } + } + } + } + + // Check on table columns + foreach (string sPidToCheck in pidsToCheck.Keys) + { + if (Int32.TryParse(sPidToCheck, out int iPidToCheck)) + { + ParameterInfo piTable = ParameterInfoDictionary[Convert.ToInt32(sTablePid)]; + + // In case sPidToCheck relates to a parameter made by the duplicateAs attribute (meant to be used in case of viewTables) + int iRealPidToCheck = GetRealPid(iPidToCheck); + if (!ParameterIdSet.Contains(Convert.ToString(iRealPidToCheck))) + { + // Retrieve correct Line Number of ColumnOption. Current LineNum is from Measurement Type Tag. + if (!Int32.TryParse(xnParam.SelectSingleNode("./slc:ArrayOptions/slc:ColumnOption[@pid='" + iPidToCheck + "']", xmlNsm)?.Attributes?["QA_LNx"].InnerXml, out int iTempLineNum)) + { + // For some reason ColumnOption tag can't be found. Assign Table LineNumber. + iTempLineNum = Convert.ToInt32(piTable.LineNum); + } + + continue; + } + + ParameterInfo pi = ParameterInfoDictionary[iRealPidToCheck]; + bool columnPositionAllowed = allowedTables.Contains(sTablePid); + bool tableDisplayedInExport = piTable.Positions.Any(x => x.Export != 0); + bool validPosition = pi.Positions.Any(x => x.IsValid()); + + if (!validPosition) + { + continue; + } + + if (columnPositionAllowed && !tableDisplayedInExport) + { + continue; + } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 1701, + DescriptionFormat = "Table column parameter {0} should not contain Positions tag unless exported as standalone parameter.", + DescriptionParameters = new object[] { pi.Pid }, + TestName = "CheckTableColumnParams", + Severity = Severity.Major + }); + } + } + } + + return resultMsg; + } + + /// + /// Checks the table index sequence. + /// + /// The protocol document. + /// List of results. + public List CheckTableIndexSequence(XmlDocument xDoc) // M + { + // Check that all table column indexes are sequential + + List resultMsg = new List(); + + XmlNameTable nt = xDoc.NameTable; + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(nt); + xmlNsm.AddNamespace("slc", _Uri); + + // Params with arrayOptions = table + XmlNodeList xnlArrayOptions = xDoc.GetElementsByTagName("ArrayOptions"); + + foreach (XmlNode xnArrayOptions in xnlArrayOptions) + { + LineNum = xnArrayOptions.Attributes?["QA_LNx"]?.InnerXml; + XmlNodeList xnlColumnOptions = xnArrayOptions.SelectNodes("slc:ColumnOption", xmlNsm); + + List typePids = new List(); + List idxList = new List(); + List types = new List(); + int indexTypeIdx = -1; + + if (xnArrayOptions.Attributes?["index"] != null) + { + // Get column parameter id's in Type Tag + string id = xnArrayOptions.ParentNode?.SelectSingleNode(".//slc:Type", xmlNsm)?.Attributes?["id"]?.InnerXml; + if (id != null) + { + string[] typeIds = id.Split(';'); + foreach (string s in typeIds) + { + if (Int32.TryParse(s, out int i)) + { + typePids.Add(i); + } + } + } + + // Get column parameter id's , indexes and types in columnOptions + foreach (XmlNode columnOption in xnlColumnOptions) + { + string sIdx = columnOption.Attributes?["idx"]?.InnerXml; + string sPid = columnOption.Attributes?["pid"]?.InnerXml; + string type = columnOption.Attributes?["type"]?.InnerXml; + + if (type != null) + { + types.Add(type); + if (type == "index" && indexTypeIdx == -1) + { + indexTypeIdx = Convert.ToInt32(sIdx); + } + } + + if (Int32.TryParse(sIdx, out int iIdx) && Int32.TryParse(sPid, out int iPid)) + { + idxList.Add(iIdx); + } + } + + // Perform Checks + bool warn = false; + bool error = false; + + int typeCounter = typePids.Count; + for (int i = 0; i < idxList.Count - 1; i++) // Avoid out of range exception on last item + { + if (idxList[i] > idxList[i + 1]) + { + error = true; + break; + } + } + + for (int i = 0; i < idxList.Count; i++) + { + if (idxList[i] != i + typeCounter) + { + if (typeCounter == 0) + { + error = true; + break; + } + + if (idxList[i] != i) + { + typeCounter--; + } + + warn = true; + } + } + + if (error) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3501, + DescriptionFormat = "Indexes of table are not sequential.", + DescriptionParameters = null, + TestName = "CheckTableIndexSequence", + Severity = Severity.Major + }); + } + else if (warn) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3502, + DescriptionFormat = "Parameter indexes in Type and ColumnOptions are not consecutive. This is unconventional.", + DescriptionParameters = null, + TestName = "CheckTableIndexSequence", + Severity = Severity.Minor + }); + } + } + + // Check for type="index": can occur only once + int indexCount = types.Count(a => a == "index"); + if (indexCount > 1) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3503, + DescriptionFormat = "There is more than one ColumnOption with type=\"index\"", + DescriptionParameters = null, + TestName = "CheckTableIndexSequence", + Severity = Severity.Major + }); + } + else if (indexCount == 1) + { + // Check for type="index": only allowed on SNMP and WMI tables + XmlNode xnSnmp = xnArrayOptions.ParentNode?.SelectSingleNode("./slc:SNMP", xmlNsm); + if (xnSnmp == null) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3504, + DescriptionFormat = "ColumnOption with type=\"index\" is used on a non-SNMP table", + DescriptionParameters = null, + TestName = "CheckTableIndexSequence", + Severity = Severity.Minor + }); + } + + // Verify that index defined in ArrayOptions matches ColumnOption with index + // Get index column + string sIndex = xnArrayOptions?.Attributes?["index"]?.InnerXml; + if (sIndex != indexTypeIdx.ToString()) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3505, + DescriptionFormat = "ColumnOption with type=\"index\" does not match table index idx.", + DescriptionParameters = null, + TestName = "CheckTableIndexSequence", + Severity = Severity.Minor + }); + } + } + } + + return resultMsg; + } + + /// + /// Checks the timers. + /// + /// The protocol document. + /// List of results. + public List CheckTimers(XmlDocument xDoc) + { + List resultMsg = new List(); + + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlTimers = xDoc.SelectNodes("/slc:Protocol/slc:Timers/slc:Timer", xmlNsm); + + List lsTimes = new List(); + foreach (XmlNode xnTimer in xnlTimers) + { + LineNum = xnTimer.Attributes?["QA_LNx"].InnerXml; + + // Check duplicate speeds + string speed = xnTimer.SelectSingleNode("./slc:Time", xmlNsm)?.InnerXml; + if (!lsTimes.Contains(speed)) + { + lsTimes.Add(speed); + } + + // Check that last group is a poll group. + XmlNode xnLastGroup = xnTimer.SelectSingleNode(".//slc:Content/slc:Group[last()]", xmlNsm); + string sType = String.Empty; + bool emptyTimer = false; + if (xnLastGroup == null) + { + emptyTimer = true; + } + else + { + string groupId = xnLastGroup.InnerXml; + if (!String.IsNullOrWhiteSpace(groupId) && Int32.TryParse(groupId, out int iGroupId)) + { + if (GroupsDictionary.TryGetValue(iGroupId, out XmlNode xnGroup)) + { + XmlNode xnType = xnGroup.SelectSingleNode(".//slc:Type", xmlNsm); + if (xnType != null) + { + sType = xnType.InnerXml; + } + else + { + XmlNode xnContent = xnGroup.SelectSingleNode("./slc:Content", xmlNsm); + if (xnContent != null) + { + int paramCounter = 0; + int pairCounter = 0; + int sessionCounter = 0; + XmlNodeList xnlContent = xnContent.ChildNodes; + int count = 0; + foreach (XmlNode xnContentChild in xnlContent) + { + if (xnContentChild.NodeType != XmlNodeType.Comment) + { + count++; + switch (xnContentChild.Name) + { + case "Param": + paramCounter++; + break; + + case "Pair": + pairCounter++; + break; + + case "Session": + sessionCounter++; + break; + } + } + } + + if (paramCounter == count) + { + sType = "_allParams"; + } + else if (pairCounter == count) + { + sType = "_allPairs"; + } + else if (sessionCounter == count) + { + sType = "_allSessions"; + } + } + } + } + } + } + + List pollTypes = new List { "poll", "poll action", "poll trigger" }; + + if (!pollTypes.Contains(sType.ToLower()) && sType != "_allParams" && sType != "_allPairs" && sType != "_allSessions" && !emptyTimer) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3202, + DescriptionFormat = "The last group in the timer is not a poll group.", + DescriptionParameters = null, + TestName = "CheckTimers", + Severity = Severity.Minor + }); + } + + // Check that non-threaded timers contain no empty groups + string timerOptions = xnTimer.Attributes?["options"]?.InnerXml?.ToLower(); + + bool threaded = !String.IsNullOrEmpty(timerOptions) && timerOptions.Contains("threadpool"); + + if (!threaded) + { + // Get groups + bool empty = false; + List emptyIDs = new List(); + XmlNodeList xnlTGroups = xnTimer.SelectNodes("./slc:Content/slc:Group", xmlNsm); + foreach (XmlNode xnTGroup in xnlTGroups) + { + if (xnTGroup == null) { continue; } + + string groupId = xnTGroup.InnerXml; + + if (!Int32.TryParse(groupId, out int iGroupId)) + { + continue; + } + + if (!GroupsDictionary.TryGetValue(iGroupId, out XmlNode xnGroup)) + { + continue; + } + + if (xnGroup == null) { continue; } + + XmlNode xnContent = xnGroup.SelectSingleNode("./slc:Content", xmlNsm); + if (xnContent == null || xnContent.ChildNodes.Count == 0) + { + empty = true; + emptyIDs.Add(groupId); + } + else + { + foreach (XmlNode xnContentChild in xnContent.ChildNodes) + { + if (xnContentChild.NodeType == XmlNodeType.Comment) { continue; } + + if (xnContentChild.InnerXml == String.Empty) + { + empty = true; + emptyIDs.Add(groupId); + break; + } + } + } + } + + if (empty) + { + string groups = String.Join(", ", emptyIDs); + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 3203, + DescriptionFormat = "Timer contains empty Group(s) {0}.", + DescriptionParameters = new object[] { groups }, + TestName = "CheckTimers", + Severity = Severity.Major + }); + } + } + } + + return resultMsg; + } + + /// + /// Check that there is no alarming or trending on write parameters. + /// Check that parameters with explicit trending = true have RTDisplay = true. + /// + /// The protocol document. + /// List of results. + public List CheckTrendAlarm(XmlDocument xDoc) // M + { + List resultMsg = new List(); + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + // Concatenate both lists + var allTables = GetAllTables(xDoc); + + List columnids = new List(); + foreach (XmlNode xnTable in allTables) + { + string id = xnTable.Attributes?["id"].InnerXml; + Dictionary columns = GetColumnPids(xDoc, id); + foreach (string s in columns.Keys) + { + columnids.Add(s); + } + } + + foreach (ParameterInfo pi in ParameterInfoDictionary.Values) + { + LineNum = pi.LineNum; + if (pi.Trended && pi.Alarmed && pi.Type.Contains("write")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2405, + DescriptionFormat = "Write Parameter is trended and alarmed", + DescriptionParameters = null, + TestName = "CheckTrendAlarm", + Severity = Severity.Major + }); + } + else if (pi.Trended && pi.Type.Contains("write")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2401, + DescriptionFormat = "Write Parameter is trended", + DescriptionParameters = null, + TestName = "CheckTrendAlarm", + Severity = Severity.Major + }); + } + else if (pi.Alarmed && pi.Type.Contains("write")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2402, + DescriptionFormat = "Write Parameter is alarmed", + DescriptionParameters = null, + TestName = "CheckTrendAlarm", + Severity = Severity.Major + }); + } + + // Check positions + bool anyPosition = pi.Positions.Any(x => x.IsValid()); + + // Check if table column + bool displayed = pi.RTDisplay && (anyPosition || columnids.Contains(Convert.ToString(pi.Pid))); + if (pi.Trended && pi.Alarmed && !displayed && pi.Type.Contains("read")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2406, + DescriptionFormat = "Parameter {0} has trending=\"true\" and is alarmed but is not displayed on any page, which is inconsistent, please verify.", + DescriptionParameters = new object[] { pi.Pid }, + TestName = "CheckTrendAlarm", + Severity = Severity.Minor + }); + } + else if (pi.Trended && !displayed && pi.Type.Contains("read")) + { + string value = pi.Element.Attributes?["trending"]?.Value; + + if (String.Equals(value, "true", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult() + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2403, + DescriptionFormat = "Parameter {0} has trending=\"true\" but is not displayed on any page, which is inconsistent, please verify.", + DescriptionParameters = new object[] { pi.Pid }, + TestName = "CheckTrendAlarm", + Severity = Severity.Major + }); + } + } + else if (pi.Alarmed && !displayed && pi.Type.Contains("read")) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(pi.LineNum), + ErrorId = 2404, + DescriptionFormat = "Parameter {0} is alarmed but is not displayed on any page, which is inconsistent, please verify.", + DescriptionParameters = new object[] { pi.Pid }, + TestName = "CheckTrendAlarm", + Severity = Severity.Minor + }); + } + } + + return resultMsg; + } + + /// + /// Checks the action attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckActionAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + string[] operators = { "<", ">", "==", "<=", ">=", "!=", "<", ">", "<=", ">=" }; + + // Action.On => done in CheckResponsePairGroup + // Action.Type options: semicolon separated. + XmlNodeList xnlActionTypes = xDoc.SelectNodes("slc:Protocol/slc:Actions/slc:Action/slc:Type[@options]", xmlNsm); + foreach (XmlNode xnActionType in xnlActionTypes) + { + LineNum = xnActionType.Attributes?["QA_LNx"].InnerText; + XmlNode xnActionTypeOptions = xnActionType.Attributes?.GetNamedItem("options"); + if (xnActionTypeOptions == null) { continue; } + + string actiontype = xnActionType.InnerXml.ToLower(); + if (actiontype == "aggregate") + { + string[] aggregateOptions = { "type", "groupby", "groupbytable", "equation", "equationvalue", "return", "result", "allowvalues", "ignorevalues", "threaded", "filter", "avoidzeroinresult", "join", "status", "defaultvalue", "defaultif", "weight", "deletehistory" }; + string[] aggregateTypes = { "pct", "avg", "max", "min", "most", "range", "stddev", "count", "sum", "most count", "meandev", "dbmv", "db", "avg extended" }; + string sActionTypeOptions = xnActionTypeOptions.InnerXml; + sActionTypeOptions = WebUtility.HtmlDecode(sActionTypeOptions); + string[] actionTypeOptions = sActionTypeOptions.Split(';'); + string optionName = String.Empty; + foreach (string actionTypeOption in actionTypeOptions) + { + bool starter = false; + foreach (string option in aggregateOptions) + { + if (actionTypeOption.StartsWith(option, StringComparison.InvariantCultureIgnoreCase)) + { + starter = true; + optionName = option; + } + } + + if (!starter) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Action Type Aggregation", actionTypeOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + else + { + string[] optionContent = actionTypeOption.Split(':'); + switch (optionName) + { + case "type": + { + // Check if the aggregation type is known + string aggregateType = optionContent[1].ToLower(); + if (!aggregateTypes.Contains(aggregateType)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2902, + DescriptionFormat = "Unknown or malformed {0} type {1}.", + DescriptionParameters = new object[] { actiontype, aggregateType }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + case "groupby": + { + // These are column indexes: should be a number or a comma separated id list of numbers. + string groupby = optionContent[1].ToLower(); + string[] idxs = groupby.Split(','); + + // Check that values are numeric + if (idxs.All(a => Int32.TryParse(a, out int id))) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "{0} option contains an invalid separator or character. This should be a single column index or a comma separated list of column indexes.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + + case "allowValues": + case "ignoreValues": + { + // These should be a single id or a comma separated id list. + string groupby = optionContent[1].ToLower(); + string[] values = groupby.Split(','); + foreach (string value in values) + { + if (!value.Contains('/')) { continue; } + + string[] columnTest = value.Split('/'); + if (IsInteger(columnTest[0])) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2966, + DescriptionFormat = "{0} option contains an invalid separator or character. This should be comma separated list of \"idx/value\" pairs.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "return": + { + // These should be a single id or a comma separated id list. + string returnPids = optionContent[1].ToLower(); + string[] pids = returnPids.Split(','); + foreach (string pid in pids) + { + if (IsInteger(pid)) // Check if value is single number + { + if (ParameterIdSet.Contains(pid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + // Create invalid id error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2904, + DescriptionFormat = "{0} option contains an invalid character. This should be a single parameter ID.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + case "groupbyTable": + case "result": + case "status": + case "weight": + { + // These should contain a single id . + string pid = optionContent[1].ToLower(); + if (IsInteger(pid)) // Check if value is single number + { + if (ParameterIdSet.Contains(pid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + // Create invalid id error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2904, + DescriptionFormat = "{0} option contains an invalid character. This should be a single parameter ID.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "equation": + { + // Format should be Operator - comma - pid + string equation = optionContent[1].ToLower(); + string[] operatorPid = equation.Split(','); + if (operatorPid.Length == 2) + { + string op = operatorPid[0]; + string pid = operatorPid[1]; + if (!operators.Contains(op)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2905, + DescriptionFormat = "Equation operator {0} is invalid.", + DescriptionParameters = new object[] { op }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + if (Int32.TryParse(pid, out int id)) // Check if value is single number + { + if (ParameterIdSet.Contains(pid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + // Create invalid id error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "ID {0} in equation is not correctly formatted.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + // Format is generally incorrect + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2907, + DescriptionFormat = "Equation is not correctly formatted. Format should be \"Operator - Comma - PID\".", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "equationvalue": + { + string equationvalue = optionContent[1].ToLower(); + string[] equationvalues = equationvalue.Split(','); + if (equationvalues.Length != 4 && equationvalues.Length != 3) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2904, + DescriptionFormat = "{0} action {1} contains {2} parameters. 3 or 4 Parameters are expected.", + DescriptionParameters = new object[] { actiontype, optionName, equationvalues.Length }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + string op = equationvalues[0]; + ////string compareto = equationvalues[1]; + string pid = equationvalues[2]; + ////string instance = equationvalues[3]; + + if (!operators.Contains(op)) + { + // Create invalid operator error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2905, + DescriptionFormat = "Equation operator {0} is invalid.", + DescriptionParameters = new object[] { op }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + if (!ParameterIdSet.Contains(pid)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + case "JOIN": + { + // These should be a a comma separated id list. + string groupby = optionContent[1].ToLower(); + + string[] ids = groupby.Split(','); + if (ids.All(a => IsInteger(a))) + { + foreach (string id in ids) + { + if (ParameterIdSet.Contains(id)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { id }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2908, + DescriptionFormat = "JOIN option contains an invalid separator or character. This should be a comma separated list of ID's.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "threaded": + case "avoidzeroinresult": + { + if (optionContent.Length > 1) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2911, + DescriptionFormat = "Option {0} does not require a value.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "defaultvalue": + { + string[] pidValue = optionContent[1].Split(','); + string spid = pidValue[0]; + if (Int32.TryParse(spid, out int pid)) + { + if (ParameterIdSet.Contains(spid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Aggregation action {0} contains non-existing parameter id '{1}'.", + DescriptionParameters = new object[] { optionName, pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "ID {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { pid, optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "defaultif": + { + string[] idxValue = optionContent[1].Split(','); + string idx = idxValue[0]; + if (IsInteger(idx)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "index {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { idx, optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + } + } + } + } + else if (actiontype == "merge") + { + string[] mergeOptions = { "remoteelements", "trigger", "destination", "destinationfindpk", "resolve", "type", "mergeresult", "deletehistory", "defaultvalue", "defaultif", "limitresult" }; + List mergeTypes = new List { "pct", "avg", "max", "min", "most", "range", "stddev", "count", "sum", "most count", "meandev", "dbmv", "db", "avg extended" }; + string sActionTypeOptions = xnActionTypeOptions.InnerXml; + sActionTypeOptions = WebUtility.HtmlDecode(sActionTypeOptions); + string[] actionTypeOptions = sActionTypeOptions.Split(';'); + string optionName = String.Empty; + foreach (string actionTypeOption in actionTypeOptions) + { + bool starter = false; + foreach (string option in mergeOptions) + { + if (actionTypeOption.StartsWith(option, StringComparison.InvariantCultureIgnoreCase)) + { + starter = true; + optionName = option; + } + } + + if (!starter) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Action Type Merge", actionTypeOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + else + { + string type = String.Empty; + string[] optionContent = actionTypeOption.Split(new[] { ':' }, 2); + switch (optionName) + { + case "type": + { + // Check if the aggregation type is known + type = optionContent[1].ToLower(); + if (mergeTypes.Contains(type)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2902, + DescriptionFormat = "Unknown or malformed {0} type {1}.", + DescriptionParameters = new object[] { actiontype, type }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + + case "destination": + { + if (type == "avg extended") // 4 column pids expected + { + string content = optionContent[1]; + if (content.Contains(',')) + { + string[] ids = content.Split(','); + if (ids.Length == 4) + { + foreach (string id in ids) + { + string pid = id; + + // Check for 1:200 format + if (id.Contains(':')) + { + pid = id.Split(':')[1]; + } + + if (ParameterIdSet.Contains(pid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Aggregation action destination contains non-existing parameter id '{0}'.", + DescriptionParameters = new object[] { pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2904, + DescriptionFormat = "Aggregation action destination contains {0} parameters for avg extended aggregation type. Exactly 4 Parameters are expected.", + DescriptionParameters = new object[] { ids.Length }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else // Single pid expected + { + string pid = content; + + // Check for 1:200 format + if (content.Contains(':')) + { + pid = content.Split(':')[1]; + } + + if (ParameterIdSet.Contains(pid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Merge action {0} contains non-existing parameter id '{1}'.", + DescriptionParameters = new object[] { optionName, pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + case "limitresult": // Single pid required + case "remoteelements": + { + if (IsInteger(optionContent[1])) + { + if (ParameterIdSet.Contains(optionContent[1])) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Aggregation action {0} contains non-existing parameter id '{1}'.", + DescriptionParameters = new object[] { optionName, optionContent[1] }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "ID {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { optionContent[1], optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "destinationfindpk": // One or more pid's, comma separated + { + string findpkContent = optionContent[1]; + string[] findpkPids = findpkContent.Split(','); + foreach (string findpkPid in findpkPids) + { + if (Int32.TryParse(optionContent[1], out int pid)) + { + if (ParameterIdSet.Contains(findpkPid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Aggregation action {0} contains non-existing parameter id '{1}'.", + DescriptionParameters = new object[] { optionName, pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "ID {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { optionContent[1], optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + case "defaultvalue": + { + string[] pidValue = optionContent[1].Split(','); + string spid = pidValue[0]; + if (Int32.TryParse(spid, out int pid)) + { + if (ParameterIdSet.Contains(spid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2903, + DescriptionFormat = "Aggregation action {0} contains non-existing parameter id '{1}'.", + DescriptionParameters = new object[] { optionName, pid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "ID {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { spid, optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "defaultif": + { + string[] idxValue = optionContent[1].Split(','); + string sidx = idxValue[0]; + if (!Int32.TryParse(sidx, out int idx)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2906, + DescriptionFormat = "index {0} in merge action {1} option is not correctly formatted.", + DescriptionParameters = new object[] { sidx, optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + } + } + } + } + } + } + + /// + /// Checks the chain attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckChainAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + // Chain options: ?? + + // Chain.Field options: options for CPE environment, under construction + XmlNodeList xnlFields = xDoc.SelectNodes("slc:Protocol/slc:Chains/slc:Chain/slc:Field[@options]", xmlNsm); + foreach (XmlNode xnField in xnlFields) + { + LineNum = xnField.Attributes?["QA_LNx"].InnerXml; + XmlNode xnFieldOptions = xnField.Attributes?["options"]; + if (xnFieldOptions == null) { continue; } + + string sFieldOptions = xnFieldOptions.InnerXml.ToLower(); + if (sFieldOptions == String.Empty) { continue; } + + string[] asFieldOptions = sFieldOptions.Split(';'); + foreach (string sOption in asFieldOptions) + { + string option = sOption.ToLower(); + string starter = sOption.Split(':', '=')[0]; + switch (starter) + { + // No details needed + case "displayinfilter": + case "hidediagramalarmcolors": + case "ignoreemptyfiltervalues": + case "noloadonfilter": + case "readonly": + case "showcpechilds": + case "showsiblings": + case "showbubbleupandinstancealarmlevel": + case "showtree": + case "tilelist": + break; + + case "chain": + case "chainfilter": + case "details": + case "detailtabs": + case "displayinfiltercombo": + case "filter": + case "filtercombo": + case "maxdiagrampid": + case "statustabs": + case "taborder": + case "tabs": + case "topologychains": + case "diagramsort": + { + string[] sOptionSplit = option.Split(':'); + if (sOptionSplit.Length < 2) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Field", sOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + case "filtermode": + { + string[] sOptionSplit = option.Split('='); + if (sOptionSplit[1] != "edit" && sOptionSplit[1] != "combo") + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Field", sOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + case "fixedposition": // Can be empty or contain value with = + { + string[] sOptionSplit = option.Split('='); + if (sOptionSplit.Length > 2) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Field", sOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Field", sOption }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + break; + } + } + + /// + /// Checks the pair attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckPairAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + // Pair options: separator is semicolon, no leading character separator. + XmlNodeList xnlPair = xDoc.SelectNodes("slc:Protocol/slc:Pairs/slc:Pair[@options]", xmlNsm); + foreach (XmlNode xnPair in xnlPair) + { + LineNum = xnPair.Attributes?["QA_LNx"].InnerXml; + string pairOptions = xnPair.Attributes?["options"]?.InnerXml; + if (!String.IsNullOrEmpty(pairOptions)) + { + // This is a semicolon separated list + string[] asPairOptions = pairOptions.Split(';'); + + // Count connections used in protocol - used when checking connections, retrieved outside loop for performance + XmlNodeList xnPortSettings = xDoc.SelectNodes("slc:Protocol/slc:Ports/slc:PortSettings", xmlNsm); + int connectionsCount = xnPortSettings.Count; + if (xDoc.SelectSingleNode("slc:Protocol/slc:PortSettings", xmlNsm) != null) + { + connectionsCount++; + } + + foreach (string pairOption in asPairOptions) + { + string[] asOptionContent = pairOption.Split(':'); + string optionName = asOptionContent[0].ToLower(); + switch (optionName) + { + case "onebyte": + case "commbreak": + case "receiveinterval": + case "retries": + { + // A single numeric value is needed + if (Int32.TryParse(asOptionContent[1], out _)) { continue; } + + // Create invalid id error + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2909, + DescriptionFormat = "Option {0} value is not correctly formatted. A single integer value is expected.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + + case "connection": + { + // A single numeric value is needed + if (!Int32.TryParse(asOptionContent[1], out int connectionId)) // Check if value is single number + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2909, + DescriptionFormat = "Option {0} value is not correctly formatted. A single integer value is expected.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + if (connectionId >= connectionsCount) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2910, + DescriptionFormat = "Connection number does not match number of ports in PortSettings.", + DescriptionParameters = null, + TestName = "CheckAtributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "ignoretimeout": + { + // No further details needed + if (asOptionContent.Length > 1) // MichielV: added 16/01/2014. Caused index out of bounds error without this check. + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2911, + DescriptionFormat = "Option {0} does not require a value.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Pair", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + } + } + + /// + /// Checks the parameter attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckParamAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + #region Param@options + + // Param options + XmlNodeList xnlParam = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param[@options]", xmlNsm); + foreach (XmlNode xnParam in xnlParam) + { + LineNum = xnParam.Attributes?["QA_LNx"].InnerXml; + XmlNode xnParamOptions = xnParam.Attributes?["options"]; + if (xnParamOptions == null) { continue; } + + string sParamOptions = xnParamOptions.InnerXml.ToLower(); + string[] paramOptions = { String.Empty, "snmpset", "snmpsetandgetwithwait", "snmpsetwithwait" }; + if (!paramOptions.Contains(sParamOptions)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option {1}.", + DescriptionParameters = new object[] { "Param", sParamOptions }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + + #endregion Param@options + + #region Param.Alarm + + // Param.Alarm options: separator is semicolon. Used with linked tables + XmlNodeList xnlParamAlarm = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param/slc:Alarm[@*]", xmlNsm); + foreach (XmlNode xnParamAlarm in xnlParamAlarm) + { + LineNum = xnParamAlarm.Attributes?["QA_LNx"].InnerXml; + XmlNode xnParamAlarmType = xnParamAlarm.Attributes?["type"]; + if (xnParamAlarmType != null) + { + string sType = xnParamAlarmType.InnerXml.ToLower(); + string nominalId = String.Empty; + string multiplier = String.Empty; + + // The type attribute may contain additional normalization settings + string[] typeSplit = sType.Split(':'); + string type = typeSplit[0]; + if (type != "nominal" && type != "absolute" && type != "relative") + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2912, + DescriptionFormat = "Unknown alarm type '{0}'.", + DescriptionParameters = new object[] { type }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + if (typeSplit.Length == 2) + { + // Should be single pid or 2 comma separated pids + string sPids = typeSplit[1]; + if (!Int32.TryParse(sPids, out int iPid)) + { + string[] pids = typeSplit[1].Split(','); + if (pids.Length == 2) + { + nominalId = pids[0]; + multiplier = pids[1]; + } + + if (!Int32.TryParse(nominalId, out iPid) || !Int32.TryParse(multiplier, out iPid)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2913, + DescriptionFormat = "{0} attribute is not correctly formatted. Expected format is 'valuepid' or 'valuepid,multiplierpid'.", + DescriptionParameters = new object[] { "Alarm Type" }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else if (!ParameterIdSet.Contains(nominalId)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { nominalId }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + } + + XmlNode xnActiveTime = xnParamAlarm.Attributes?["activeTime"]; + if (xnActiveTime != null) + { + string sActiveTime = xnActiveTime.InnerXml; + + if (!Int32.TryParse(sActiveTime, out int time)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2915, + DescriptionFormat = "Alarm activeTime value is not correctly formatted. Expected integer value.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + XmlNode xnOptions = xnParamAlarm.Attributes?["options"]; + if (xnOptions != null) + { + string[] asOptions = xnOptions.InnerXml.Split(';'); + int properties = 0; + foreach (string sOption in asOptions) + { + char[] colon = { ':' }; + string[] asOptionContent = sOption.Split(colon, 2); // MVT 25/06/2014, limited to two results to handle colons in the option content. + string optionName = asOptionContent[0].ToLower(); + + switch (optionName) + { + case "threshold": // Two parameter id's must be specified, comma separated + { + string[] tresholdParams = asOptionContent[1].Split(','); + if (tresholdParams.All(a => Int32.TryParse(a, out int pid))) + { + foreach (string pId in tresholdParams) + { + if (ParameterIdSet.Contains(pId)) + { + continue; // OK + } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { pId }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2916, + DescriptionFormat = "Option {0} is not correctly formatted. Expected format is 2 comma separated Parameter ID's.", + DescriptionParameters = new object[] { "treshold" }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "propertynames": // Property labels: one or more names separated by a comma + { + // This is free text, no check. labels are counted to use in "properties" test. + string[] names = asOptionContent[1].Split(','); + properties = names.Length; + } + break; + + case "properties": // Format of the added properties, first character is separator(pipe as default) + { + char splitter = asOptionContent[1][0]; + if (splitter != '|') // Pipe character is the default, show a warning if another character is used. + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2917, + DescriptionFormat = "Alarm properties are split by first character '{0}'. Use of pipe character '|' is recommended.", + DescriptionParameters = new object[] { splitter }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + + string sOContent = asOptionContent[1].TrimStart(splitter); + string[] asProperties = sOContent.Split(splitter); + if (asProperties.Length > properties) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2961, + DescriptionFormat = "There are more alarm properties than propertyNames.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + else if (asProperties.Length < properties) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2962, + DescriptionFormat = "There are more propertyNames than alarm properties.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Alarm", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + } + + #endregion Param.Alarm + + #region Param.ArrayOptions + + // Param.ArrayOptions SNMP Index: semicolon separated + + // Param.ArrayOptions options: first character = separator + XmlNodeList xnlParamArrayOptions = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param/slc:ArrayOptions[@options]", xmlNsm); + foreach (XmlNode xnArrayOptions in xnlParamArrayOptions) + { + LineNum = xnArrayOptions.Attributes?["QA_LNx"].InnerXml; + + string optionContent = xnArrayOptions.Attributes?["options"]?.InnerXml; + if (String.IsNullOrWhiteSpace(optionContent)) + { + continue; + } + + char[] splitter = { ';' }; + string trimmed = optionContent.Trim(splitter); + + string[] asOptions = trimmed.Split(splitter); + foreach (string option in asOptions) + { + string[] asOption = option.Split('='); + string optionName = asOption[0].ToLower(); + string optionDetails = asOption.Length == 2 ? asOption[1] : String.Empty; + + optionName = optionName.Split(':')[0]; // Quick dirty fix since some options use "=" and some ":" as separator. + + switch (optionName) + { + case "autoadd": + case "customdatabasename": + case "database": + case "databasename": + case "databasenameprotocol": + case "directview": // Detailed check to be implemented + case "interrupttrend": + case "naming": // Detailed check to be implemented + case "onlyfiltereddirectview": // Possible check: only use if direct view is already present. + case "pkcaseinsensitive": // Not in documentation anymore + case "preserve state": + case "propertytable": + case "processingorder": + case "querytablepid": + case "resolvedpk": // Not in documentation anymore + case "savecolumns": // Not in documentation anymore + case "sizehint": + case "volatile": + case "view": // Detailed check to be implemented + break; + + case "discreetdestination": + if (!optionDetails.EndsWith(".xml", StringComparison.InvariantCulture)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2966, + DescriptionFormat = "DiscreetDestination is not an xml file.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + + case "filterchange": + { + string[] filterpairs = optionDetails.Split(','); + foreach (string pair in filterpairs) + { + string[] pids = pair.Split('-'); + if (pids.Length == 2) + { + string sLocalPid = pids[0]; + if (!ParameterIdSet.Contains(sLocalPid)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2968, + DescriptionFormat = "Local pid {0} in filterchange pair not found.", + DescriptionParameters = new object[] { sLocalPid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + string foreingPid = pids[1]; + if (!IsInteger(foreingPid)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2969, + DescriptionFormat = "Foreign pid {0} in filterchange pair is not a valid integer number.", + DescriptionParameters = new object[] { foreingPid }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2967, + DescriptionFormat = "Filterchange pair {0} is not correctly formatted.", + DescriptionParameters = new object[] { pair }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "ArrayOptions", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + + // Param.ArrayOptions.ColumnOptions + // Value: comma separated + // Options: first character separated + XmlNodeList xnlColumnOption = xDoc.SelectNodes(".//slc:ColumnOption[@*]", xmlNsm); // Select all ColumnOptions with attributes + foreach (XmlNode xnColumnOption in xnlColumnOption) + { + LineNum = xnColumnOption.Attributes?["QA_LNx"].InnerXml; + + // Check type + XmlNode xnType = xnColumnOption.Attributes?["type"]; + if (xnType != null) + { + string sColumnOptionType = xnType.InnerXml.ToLower(); + + // Check if option is allowed + string[] columnOptionTypes = { "concatenation", "state", "autoincrement", "index", "custom", "retrieved", "snmp", "displaykey", "viewtablekey" }; + if (!columnOptionTypes.Contains(sColumnOptionType)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2920, + DescriptionFormat = "Unknown ColumnOption Type '{0}'", + DescriptionParameters = new object[] { sColumnOptionType }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + // Check on retrieved columns in SNMP table (DCP 16252) + if (sColumnOptionType == "retrieved") + { + XmlNode param = xnColumnOption.SelectSingleNode("ancestor::slc:Param", xmlNsm); + string id = param?.SelectSingleNode("./slc:Type/@id", xmlNsm)?.InnerXml; + if (!String.IsNullOrEmpty(id)) + { + XmlNode xnSnmp = param.SelectSingleNode("./slc:SNMP", xmlNsm); + if (xnSnmp != null) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2963, + DescriptionFormat = "Retrieved ColumnOption in SNMP table. All columnOptions should be explicitly defined with SNMP type.", + DescriptionParameters = new object[] { sColumnOptionType }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + } + + XmlNode xnValue = xnColumnOption.Attributes?["value"]; + + // Number of comma separated list of numbers. + string sValues = xnValue?.InnerXml; + if (!String.IsNullOrWhiteSpace(sValues)) + { + string[] asValues = sValues.Split(','); + foreach (string value in asValues) + { + if (!Int32.TryParse(value, out int iValue)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2921, + DescriptionFormat = "ColumnOption attribute value not correctly formatted. Expected int or comma separated list of int values.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + + XmlNode xnOptions = xnColumnOption.Attributes?["options"]; + if (xnOptions != null) + { + string sOptions = xnOptions.InnerXml; + if (sOptions != String.Empty) + { + char[] splitter = { sOptions[0] }; + if (splitter[0] != ';') + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2922, + DescriptionFormat = "ColumnOption options are separated by first character '{0}'. Using semicolon ';' is recommended.", + DescriptionParameters = new object[] { splitter[0] }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + + string[] asOptions = sOptions.Split(splitter, StringSplitOptions.RemoveEmptyEntries); + foreach (string option in asOptions) + { + string[] asOptionContent = option.Split('=', ':'); + string optionName = asOptionContent[0].ToLower(); + switch (optionName) + { + case "cpedummycolumn": + case "delete": + case "delta": + case "displayicon": + case "displayelementalarm": + case "displayservicealarm": + case "displayviewalarm": + case "disableheaderavg": + case "disableheadermax": + case "disableheadermin": + case "disableheadersum": + case "disableheatmap": + case "disablehistogram": + case "dynamicdata": + case "enableheaderavg": + case "enableheadermax": + case "enableheadermin": + case "enableheadersum": + case "enableheatmap": + case "enablehistogram": + case "element": + case "foreignkey": + case "groupby": + case "hidden": + case "hidekpi": + case "hidekpiwhennotinitialized": // Not in documentation anymore + case "indexcolumn": + case "kpihidewrite": + case "kpishowdisplaykey": // Not in documentation anymore + case "linkelement": + case "rowtextcoloring": + case "save": + case "selectionsetvar": + case "selectionsetcardvar": + case "selectionsetpagevar": + case "selectionsetworkspacevar": + case "separator": // Not in documentation anymore + case "setontable": + case "severity": + case "severitycolumn": + case "severitycolumnindex": + case "showreadaskpi": + case "space": + case "subtitle": + case "view": + case "viewimpact": + case "volatile": + case "xpos": // Not in documentation anymore + case "ypos": // Not in documentation anymore + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "ColumnOption", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + } + } + + #endregion Param.ArrayOptions + + #region Param.CRC.Type + + // Param.CRC.Type options: separator is semicolon. + XmlNodeList xnlParamCrcType = xDoc.SelectNodes("/slc:Protocol/slc:Param/slc:CRC/slc:Type[@options]", xmlNsm); + foreach (XmlNode paramCrcType in xnlParamCrcType) + { + LineNum = paramCrcType.Attributes?["QA_LNx"]?.InnerXml; + string options = paramCrcType.Attributes?["options"]?.InnerXml?.ToLower(); + if (String.IsNullOrEmpty(options)) { continue; } + + string[] combinations = { "ones complement", "or totaloffset", "ones complement;or totaloffset", "or totaloffset;ones complement" }; + if (!combinations.Contains(options)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2923, + DescriptionFormat = "Unknown CRC Type option {0}. Expected semicolon separated combination of \"ones complement\" and \"or totaloffset\"", + DescriptionParameters = new object[] { options }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + #endregion Param.CRC.Type + + #region Param.Display + + // Param.Display.Parametersview options: pipe-separated list of options. + XmlNodeList xnlParametersView = xDoc.SelectNodes("/slc:Protocol/slc:Param/slc:Display/slc:ParametersView", xmlNsm); + foreach (XmlNode xnParametersView in xnlParametersView) + { + LineNum = xnParametersView.Attributes?["QA_LNx"].InnerXml; + + XmlNode xnType = xnParametersView.Attributes?["type"]; + if (xnType != null) + { + string sType = xnType.InnerXml; + string[] asTypes = { "column", "pie", "row", "stackedarea" }; + if (!asTypes.Contains(sType.ToLower())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2924, + DescriptionFormat = "Unknown ParametersView type {0}. Expected 'Column', 'Pie', 'Row' or 'StackedArea'.", + DescriptionParameters = new object[] { sType }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + XmlNode xnOptions = xnParametersView.Attributes?["options"]; + if (xnOptions != null) + { + string sOptions = xnOptions.InnerXml.ToLower(); + string[] asOptions = sOptions.Split('|'); + foreach (string optionName in asOptions) + { + if (!optionName.StartsWith("height=", StringComparison.InvariantCultureIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "ParametersView", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + } + } + + // Param.Display.Parametersview.Parameters.Parameter options: not yet implemented + + #endregion Param.Display + + #region Param.Interprete.Type + + // Param.Interprete.Type (trim) + XmlNodeList xnlParamInterpreteType = xDoc.SelectNodes("/slc:Protocol/slc:Param/slc:Interprete/slc:Type[@trim]", xmlNsm); + foreach (XmlNode xnParamInterpreteType in xnlParamInterpreteType) + { + LineNum = xnParamInterpreteType.Attributes?["QA_LNx"].InnerXml; + XmlNode xnTrim = xnParamInterpreteType.Attributes?["trim"]; + if (xnTrim == null) { continue; } + + string sTrim = xnTrim.InnerXml; + string[] trims = { "left", "right", "left;right", "right;left" }; + if (!trims.Contains(sTrim.ToLower())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2925, + DescriptionFormat = "Unknown Interprete type trim {0}. Expected semicolon separated combination of 'left' and 'right'.", + DescriptionParameters = new object[] { sTrim }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + #endregion Param.Interprete.Type + + // Param.Measurement.Discreets.Discreet dependency values: semicolon separated list + // Param.Measurement.Discreets.Discreet options + + #region Param.Measurement.Type + + // Param.Measurement.Type options + XmlNodeList xnlParamMeasurementType = xDoc.SelectNodes("/slc:Protocol/slc:Param/slc:Measurement/slc:Type[@options]", xmlNsm); + foreach (XmlNode xnParamMeasurementType in xnlParamMeasurementType) + { + LineNum = xnParamMeasurementType.Attributes?["QA_LNx"].InnerXml; + string type = xnParamMeasurementType.InnerXml; + XmlNode xnOptions = xnParamMeasurementType.Attributes?["options"]; + string sOptions = xnOptions.InnerXml; + sOptions = new string(sOptions.Where(c => !Char.IsWhiteSpace(c)).ToArray()); + + switch (type.ToLower()) + { + case "number": + { + // If number: time, time:minute, time:hour + string[] asOptionsNumeric = { "time", "time:minute", "time:hour" }; + if (!asOptionsNumeric.Contains(sOptions.ToLower())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2926, + DescriptionFormat = "Unknown option for Measurement Type number. Possible values are 'time', 'time:minute' or 'time:hour'.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "string": + { + // If string: lines, case, options: semicolon separated + string[] asCaseString = { "upper", "lower" }; + + string lines = xnParamMeasurementType.Attributes?["lines"]?.InnerXml; + if (!String.IsNullOrEmpty(lines)) + { + if (!Int32.TryParse(lines, out int iLines)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2927, + DescriptionFormat = "Attribute {0} value '{1}' is not formatted correctly. Expected integer number.", + DescriptionParameters = new object[] { "Lines", lines }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + string caseAttribute = xnParamMeasurementType.Attributes?["case"]?.InnerXml.ToLower(); + if (!String.IsNullOrEmpty(caseAttribute) && !asCaseString.Contains(caseAttribute)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2928, + DescriptionFormat = "Case value is not correctly formatted. Expected 'upper' or 'lower'.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + // Options tag + string[] asOptions = sOptions.Split(';'); + foreach (string option in asOptions) + { + string[] asContent = option.Split('='); + string optionName = asContent[0].ToLower(); + switch (optionName) + { + case "hscroll": + case "fixedfont": + case "password": + break; + + case "number": + { + string value = asContent[1]; + string[] checkValues = { "true", "false" }; + if (!checkValues.Contains(value)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2929, + DescriptionFormat = "Number value is not correctly formatted. Expected \"true\" or \"false\".", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "tab": + { + string sValues = asContent[1]; + if (!String.IsNullOrEmpty(sValues)) + { + string[] asValues = sValues.Split(','); + foreach (string value in asValues) + { + if (Int32.TryParse(value, out int iValue)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2930, + DescriptionFormat = "Tab option value not correctly formatted. Expected int or comma separated list of int values.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2931, + DescriptionFormat = "Unknown option {0} for Measurement Type String.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + } + } + } + break; + + case "title": + { + // If title: options: semicolon separated + string[] asCheckValues = { "begin", "end", "end;connect", "begin;connect" }; + if (!asCheckValues.Contains(sOptions.ToLower())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Measurement Type", sOptions }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + case "analog": + { + // If analog: options: hscroll + if (!String.Equals(sOptions, "hscroll", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "ArrayOptions", sOptions }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + case "table": + { + string[] asOptions = sOptions.Split('='); + string optionName = asOptions[0].ToLower(); + string optionValue = asOptions[1].ToLower(); + + // Get columns in table definition + string tablePid = xnParamMeasurementType.ParentNode.ParentNode.Attributes?["id"].InnerXml; + Dictionary columnPids = GetColumnPids(xDoc, tablePid); + int displayedColumns = 0; + + if (optionName == "tab") + { + // Correct option for Type table, continue test + string[] asContent = optionValue.Split(','); + foreach (string content in asContent) + { + string[] asInternal = content.Split(':'); + string internalName = asInternal[0]; + string internalValue = String.Empty; + if (asInternal.Length == 2) + { + internalValue = asInternal[1]; + } + + switch (internalName) + { + case "columns": + { + string[] asColumns = internalValue.Split('-'); + displayedColumns = asColumns.Length; + + foreach (string sColumn in asColumns) + { + string trimColumn = sColumn.Trim(); + string[] asColumnDetails = trimColumn.Split('|'); + string columnPID = asColumnDetails[0]; + string columnIndex = String.Empty; + if (asColumnDetails.Length == 2) + { + columnIndex = asColumnDetails[1]; + } + + // Check that values are numbers. This will also cause an error if illegal separators have been used. + if (!Int32.TryParse(columnPID, out int iColumnPid)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2932, + DescriptionFormat = "Column Parameter ID {0} is not correctly formatted. Expected integer number.", + DescriptionParameters = new object[] { columnPID }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + if (!ParameterIdSet.Contains(columnPID)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2952, + DescriptionFormat = "Parameter with ID {0} not found.", + DescriptionParameters = new object[] { columnPID }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + if (columnIndex != String.Empty) + { + if (!Int32.TryParse(columnIndex, out int iColumnIndex)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2933, + DescriptionFormat = "Column Index {0} is not correctly formatted. Expected integer number.", + DescriptionParameters = new object[] { columnIndex }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + // Check that index - pid combination is correct, and that they are in table definition. + if (columnPids.Keys.Contains(columnPID)) + { + string index = String.Empty; + if (columnIndex != index) + { + // Pid-index combination is incorrect, generate an error. + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2934, + DescriptionFormat = "Combination of Parameter ID {0} with table index {1} is incorrect. Check table definition.", + DescriptionParameters = new object[] { columnPID, columnIndex }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + // Column pid is in column order, but not in table definition, generate an error. + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2935, + DescriptionFormat = "Parameter ID {0} not found in table definition.", + DescriptionParameters = new object[] { columnPID }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + } + break; + + case "lines": + { + if (!Int32.TryParse(internalValue, out int iLines)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2927, + DescriptionFormat = "Attribute {0} value '{1}' is not formatted correctly. Expected integer number.", + DescriptionParameters = new object[] { "Lines", optionValue }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "width": + { + string[] asWidth = internalValue.Split('-'); + int iWidths = asWidth.Length; + + // Check that length equals number of columns + if (iWidths != displayedColumns) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2936, + DescriptionFormat = "The number of width items does not match the number of columns items.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + // Check that all values are numeric + foreach (string sWidth in asWidth) + { + if (!Int32.TryParse(sWidth, out int iWidth)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2927, + DescriptionFormat = "Attribute {0} value '{1}' is not formatted correctly. Expected integer number.", + DescriptionParameters = new object[] { "Width", sWidth }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + case "sort": + { + string[] asSort = internalValue.Split('-'); + + // Check that number of sort statements is less or equal than number of columns. + if (asSort.Length > displayedColumns) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2937, + DescriptionFormat = "The number of sort statements is larger than the number of columns.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + // Check that all values are "int" or "string". + foreach (string sort in asSort) + { + string sLowerCaseSort = sort.ToLower(); + string[] asSortTypes = { "int", "string", "ip" }; + string[] asSortOrders = { "asc", "desc" }; + if (!asSortTypes.Contains(sLowerCaseSort)) + { + string[] asSortContent = sLowerCaseSort.Split('|'); + if (asSortContent.Length >= 2 && asSortContent.Length < 4) // Order is included + { + string sortOrder = asSortContent[1]; + if (!asSortOrders.Contains(sortOrder)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2938, + DescriptionFormat = "Unknown or malformed sort statement '{0}'.", + DescriptionParameters = new object[] { sort }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + + if (asSortContent.Length == 3) + { + string sortdetail = asSortContent[2]; + if (!Int32.TryParse(sortdetail, out int detail)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2938, + DescriptionFormat = "Unknown or malformed sort statement '{0}'.", + DescriptionParameters = new object[] { sort }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2938, + DescriptionFormat = "Unknown or malformed sort statement '{0}'.", + DescriptionParameters = new object[] { sort }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + } + } + break; + + case "filter": + { + string[] asFilterValues = { "true", "false" }; + if (!asFilterValues.Contains(internalValue.ToLower())) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2939, + DescriptionFormat = "Unknown or malformed filter value '{0}'. Expected 'true' or 'false'.", + DescriptionParameters = new object[] { internalValue }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Measurement tab", internalName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + else // Unknown option for type table + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2940, + DescriptionFormat = "Unknown or malformed Measurement Type option {0} for Type table.", + DescriptionParameters = new object[] { optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + } + } + + #endregion Param.Measurement.Type + + #region Param.SNMP.OID + + // Param.SNMP.OID options: semicolon separated + XmlNodeList xnlParamSnmpOid = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param/slc:SNMP/slc:OID[@options]", xmlNsm); + foreach (XmlNode xnParamSnmpOid in xnlParamSnmpOid) + { + LineNum = xnParamSnmpOid.Attributes?["QA_LNx"].InnerXml; + XmlNode xnOptions = xnParamSnmpOid.Attributes?["options"]; + if (xnOptions != null) + { + string sOptions = xnOptions.InnerXml.ToLower(); + if (sOptions != String.Empty) + { + string trimmed = sOptions.Trim(';'); + string[] asOptions = trimmed.Split(';'); + foreach (string option in asOptions) + { + string[] asContent = option.Split(':'); + string optionName = asContent[0]; + switch (optionName) + { + case "column": + case "instance": + case "multiplegetnext": + case "subtable": + case "partialsnmp": + break; + + case "bulk": + case "multipleget": + case "multiplegetbulk": + { + if (asContent.Length > 1) // Bulk options can be used without value specified. + { + if (!Int32.TryParse(asContent[1], out _)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2947, + DescriptionFormat = "Option {0} value '{1}' is not formatted correctly, expected integer number.", + DescriptionParameters = new object[] { optionName, asContent[1] }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "SNMP OID", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + } + } + + #endregion Param.SNMP.OID + + // Param.SNMP.TrapOid + + #region Param.Type + + // Param.Type + // Distribution: values with colons + XmlNodeList xnlParamTypeDistribution = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param/slc:Type[@distribution]", xmlNsm); + foreach (XmlNode xnType in xnlParamTypeDistribution) + { + LineNum = xnType.Attributes?["QA_LNx"].InnerXml; + XmlNode xnDistribution = xnType.Attributes?["distribution"]; + string sDistribution = xnDistribution.InnerXml; + string[] asDistribution = sDistribution.Split(';'); + + foreach (string distribution in asDistribution) + { + string[] asContent = distribution.Split(':'); + string distributionName = asContent[0]; + switch (distributionName.ToLower()) + { + case "protocol": + case "version": + case "pollingip": + case "pollingipport": + case "busaddress": + case "pid": + case "remote": + break; + + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2948, + DescriptionFormat = "Unknown setting {0} in Param Type distribution attribute.", + DescriptionParameters = new object[] { distributionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + break; + } + } + } + + // Options:semicolon separated + XmlNodeList xnlParamTypeOptions = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param/slc:Type[@options]", xmlNsm); + foreach (XmlNode xnType in xnlParamTypeOptions) + { + LineNum = xnType.Attributes?["QA_LNx"].InnerXml; + XmlNode xnOptions = xnType.Attributes?["options"]; + string sOptions = xnOptions.InnerXml; + string[] asOptions = sOptions.Split(';'); + foreach (string option in asOptions) + { + string[] asContent = option.Split('='); + string optionName = asContent[0]; + switch (optionName.ToLower()) + { + case "dynamic snmp get": + case "linkalarmvalue": + case "ssh username": + case "ssh pwd": + case "ssh options": + break; + + case "headertrailerlink": + // Covered already in new validator + break; + + case "loadoid": + { + if (String.Equals(xnType.InnerXml, "array", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2964, + DescriptionFormat = "loadOID option is not allowed on table parameters.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "connection": + { + if (!Int32.TryParse(asContent[1], out int iConnection)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2947, + DescriptionFormat = "Option {0} value '{1}' is not formatted correctly, expected integer number.", + DescriptionParameters = new object[] { optionName, asContent[1] }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + break; + + case "dimensions": + break; + + case "columntypes": + break; + + default: + { + // Filter for dynamic ip + string regex = @"dynamic\x20(ip\x20\d*)?"; + if (!Regex.IsMatch(optionName, regex)) + { + // If no match, create unknown error. + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "Parameter Type", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + } + break; + } + } + } + + #endregion Param.Type + } + + /// + /// Checks the QAction attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckQActionAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + // QAction dllImport: semicolon separated -- check by XSD restriction? ([^\/:*?"<>|;]+\.dll)(;[^\/:*?"<>|;]+\.dll)* (in xsd: ([^\/:*?"><|;]+\.dll)(;[^\/:*?"><|;]+\.dll)*) + // Get all QAction id's + HashSet qActionIds = new HashSet(); + XmlNodeList xnlQAction = xDoc.SelectNodes("/slc:Protocol/slc:QActions/slc:QAction", xmlNsm); + foreach (XmlNode xnQaction in xnlQAction) + { + XmlNode xnQaId = xnQaction?.Attributes?.GetNamedItem("id"); + if (xnQaId == null) + { + continue; // No error generated as this should be enforced by XSD + } + + qActionIds.Add(xnQaId.InnerXml); + } + + XmlNodeList xnlQActionDll = xDoc.SelectNodes("/slc:Protocol/slc:QActions/slc:QAction[@dllImport]", xmlNsm); + foreach (XmlNode xnQAction in xnlQActionDll) + { + LineNum = xnQAction.Attributes?["QA_LNx"].InnerXml; + XmlNode xnDll = xnQAction.Attributes?["dllImport"]; + + if (xnDll == null) { continue; } + + string sDll = xnDll.InnerXml; + List allDll = sDll.Split(';').ToList(); + foreach (string dll in allDll) + { + const string ProtocolString = "[ProtocolName].[ProtocolVersion].QAction."; + if (dll.StartsWith(ProtocolString, StringComparison.InvariantCulture)) + { + string dllid = dll.Substring(ProtocolString.Length, dll.LastIndexOf('.') - ProtocolString.Length); + if (qActionIds.Contains(dllid)) { continue; } + + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2972, + DescriptionFormat = "Non existing QAction dll reference {0}.", + DescriptionParameters = new object[] { dll }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + + // QAction inputParameters + XmlNodeList xnlQActionInputParameters = xDoc.SelectNodes("/slc:Protocol/slc:QActions/slc:QAction[@inputParameters]", xmlNsm); + foreach (XmlNode xnQAction in xnlQActionInputParameters) + { + LineNum = xnQAction.Attributes?["QA_LNx"].InnerXml; + XmlNode xnQActionInputParameter = xnQAction.Attributes?["inputParameters"]; + XmlNode xnQActionId = xnQAction.Attributes?["id"]; + string sQActionId = xnQActionId?.InnerXml; + if (xnQActionInputParameter == null) { continue; } + + string sInputParams = xnQActionInputParameter.InnerXml; + List lInputParams = sInputParams.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + + foreach (string inputParam in lInputParams) + { + int inputParamPid; + if (!Int32.TryParse(inputParam, out inputParamPid)) + { + continue; + } + + // Is a parameter inside the protocol + if (!ParameterInfoDictionary.TryGetValue(inputParamPid, out ParameterInfo parameterInfo)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2971, + DescriptionFormat = "InputParameter parameter {0} does not exist.", + DescriptionParameters = new object[] { inputParam }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + // Check if it's a table + if (String.Equals(parameterInfo.Type, "array", StringComparison.OrdinalIgnoreCase)) + { + // Check if it has an Interprete + if (String.IsNullOrWhiteSpace(parameterInfo.IntRawType) || String.IsNullOrWhiteSpace(parameterInfo.IntType)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(parameterInfo.LineNum), + ErrorId = 2973, + DescriptionFormat = "Table ({0}), that is being used as inputParameter on QAction {1}, has no valid Interprete tag defined.", + DescriptionParameters = new object[] { parameterInfo.Pid, sQActionId }, + TestName = "CheckAttributesContent", + Severity = Severity.Critical // This can have a lot of impact on the system. + }); + } + else + { + // Check if it's the correct Interprete + if (!String.Equals(parameterInfo.IntRawType, "other", StringComparison.OrdinalIgnoreCase) || !String.Equals(parameterInfo.IntType, "double", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(parameterInfo.LineNum), + ErrorId = 2974, + DescriptionFormat = "Table ({0}), that is being used as inputParameter on QAction {1}, has an incorrect Interprete tag defined. (Should be 'other'-'double')", + DescriptionParameters = new object[] { parameterInfo.Pid, sQActionId }, + TestName = "CheckAttributesContent", + Severity = Severity.Critical // This can have a lot of impact on the system. + }); + } + } + } + } + } + } + + // QAction options + XmlNodeList xnlQactionOptions = xDoc.SelectNodes("/slc:Protocol/slc:QActions/slc:QAction[@options]", xmlNsm); + foreach (XmlNode xnQAction in xnlQactionOptions) + { + LineNum = xnQAction.Attributes?["QA_LNx"].InnerXml; + XmlNode options = xnQAction.Attributes?["options"]; + if (options == null) { continue; } + + string sOptions = options.InnerXml; + string[] asOptions = sOptions.Split(';'); + foreach (string option in asOptions) + { + string[] asContent = option.Split('='); + string optionName = asContent[0]; + switch (optionName.ToLower()) + { + case "binary": + case "debug": + case "group": + case "precompile": + case "queued": + case "dllname": + case "": + break; + default: + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2901, + DescriptionFormat = "Unknown or malformed {0} option '{1}'.", + DescriptionParameters = new object[] { "QAction", optionName }, + TestName = "CheckAttributesContent", + Severity = Severity.Minor + }); + } + break; + } + } + } + } + + /// + /// Checks the relation attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckRelationAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + // Relations.Relation options + XmlNodeList xnlRelationOptions = xDoc.SelectNodes("/slc:Protocol/slc:Relations/slc:Relation[@options]", xmlNsm); + List topologyNames = new List(); + foreach (XmlNode xnRelation in xnlRelationOptions) + { + LineNum = xnRelation.Attributes?["QA_LNx"].InnerXml; + string sOption = xnRelation.Attributes?["options"].InnerXml.ToLower(); + if (String.IsNullOrWhiteSpace(sOption)) { continue; } + + string[] asOptions = sOption.Split(':'); + if (asOptions[0] != "includeinalarms") + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2953, + DescriptionFormat = "The first part in the relation option must be 'includeinalarms'.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + if (asOptions.Length == 2) + { + if (topologyNames.Contains(asOptions[1])) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2954, + DescriptionFormat = "Topology name \"{0}\" is not unique.", + DescriptionParameters = new object[] { asOptions[1] }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + else + { + topologyNames.Add(asOptions[1]); + } + } + + if (asOptions.Length == 3 && !String.Equals(asOptions[2], "righttoplevel", StringComparison.OrdinalIgnoreCase)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2955, + DescriptionFormat = "The third part in the relation option must be 'righttoplevel'.", + DescriptionParameters = null, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + } + + /// + /// Checks the response attributes. + /// + /// The protocol document. + /// List of results. + /// The namespace. + private void CheckResponseAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) + { + // Response options + XmlNodeList xnlResponseOption = xDoc.SelectNodes("/slc:Protocol/slc:Responses/slc:Response[@options]", xmlNsm); + foreach (XmlNode xnResponse in xnlResponseOption) + { + LineNum = xnResponse.Attributes?["QA_LNx"].InnerXml; + string sOptions = xnResponse.Attributes?["options"]?.InnerXml; + string sRegex = @"connection:\d+"; + if (sOptions != null && !Regex.IsMatch(sOptions.ToLower(), sRegex)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2956, + DescriptionFormat = "Response option {0} does not match format 'connection:XX'.", + DescriptionParameters = new object[] { sOptions }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + + // Response.Content optional + XmlNodeList xnlResponseContentOptional = xDoc.SelectNodes(".//slc:Responses/slc:Response/slc:Content[@optional]", xmlNsm); + foreach (XmlNode xnContent in xnlResponseContentOptional) + { + LineNum = xnContent.Attributes?["QA_LNx"]?.InnerXml; + string sOptional = xnContent.Attributes?["optional"]?.InnerXml; + string[] asOptional = sOptional?.Split(';'); + string sRegex = @"\d+\++|\d+\*?"; + int lastnr = -1; + if (asOptional == null) { continue; } + + foreach (string optional in asOptional) + { + if (!Regex.IsMatch(optional, sRegex)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2957, + DescriptionFormat = "Optional response definition {0} is not correctly formatted.", + DescriptionParameters = new object[] { optional }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + string sNumber = optional.Trim('*', '+'); + if (Int32.TryParse(sNumber, out int newnr)) + { + // Check if number is larger than previous + if (newnr <= lastnr) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2958, + DescriptionFormat = "The order of optional responses is incorrect.{0} comes after {1}.", + DescriptionParameters = new object[] { newnr, lastnr }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 2959, + DescriptionFormat = "Invalid substring '{0}' in optional response definition.", + DescriptionParameters = new object[] { sNumber }, + TestName = "CheckAttributesContent", + Severity = Severity.Major + }); + } + + lastnr = newnr; + } + } + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/ProtocolValidator.cs b/Protocol/Legacy/ProtocolValidator.cs new file mode 100644 index 00000000..193d7eec --- /dev/null +++ b/Protocol/Legacy/ProtocolValidator.cs @@ -0,0 +1,382 @@ +//#define DebugValidator +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Threading; + using System.Xml; + + using Skyline.DataMiner.CICD.Validators.Common.Data; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using XmlEdit = Skyline.DataMiner.CICD.Parsers.Common.XmlEdit; + + /// + /// Methods for validating a DataMiner Protocol. + /// + public class Validator : IValidator + { + /// + /// Runs the validator tests + /// + /// List of results. + public IList RunValidate(IProtocolInputData input, ValidatorSettings validatorSettings, CancellationToken cancellationToken) + { + var results = new List(); + + // validate main protocol + results.AddRange(ValidateProtocol(input)); + + // validate exported protocols, if any + foreach (var ep in input.Model.GetAllExportedProtocols()) + { + var exportInput = new ProtocolInputData(ep.Model, ep.Document, null); + var exportResults = ValidateProtocol(exportInput); + + // indicate for which DVE these results were created + foreach (IValidationResult exportResult in exportResults) + { + exportResult.WithDveExport(ep.TablePid, ep.Name); + } + + results.AddRange(exportResults); + } + + return results; + } + + private IList ValidateProtocol(IProtocolInputData input) + { + var validationResult = new List(); + + var protocolChecks = new ProtocolChecks(); + + // Add line numbers to XML file + bool linesLoaded; + XmlDocument xDoc; + try + { + xDoc = protocolChecks.LoadWithLineNums(input.Document.GetXml()); + linesLoaded = true; + } + catch (Exception ex) + { + xDoc = null; + linesLoaded = false; + + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + TestName = "LoadLineNums", + DescriptionParameters = new object[] { "loading line numbers", ex.ToString() }, + }); + } + + // Run tests + if (linesLoaded) + { + try + { + protocolChecks.CollectParameterInfo(xDoc); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Collecting Parameter Info", ex.ToString() }, + TestName = "collectParameterInfo", + }); + } + + try + { + protocolChecks.GetDuplicatedParams(xDoc); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Get duplicated parameters.", ex.ToString() }, + TestName = "getDuplicatedParams" + }); + } +#if DebugValidator + sw.Stop(); + log.WriteLog("collect parameter info done in " + sw.Elapsed.ToString()); + sw.Reset(); + sw.Start(); +#endif + + try + { + validationResult.AddRange(protocolChecks.CheckTableColumnParams(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Table Column Parameters", ex.ToString() }, + TestName = "CheckTableColumnParams" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckPortSettings(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Port Settings", ex.ToString() }, + TestName = "CheckPortSettings" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckGroupSettings(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Group Settings", ex.ToString() }, + TestName = "CheckGroupSettings" + }); + } + + try + { + if (input.Model.MainProtocolModel == null) + { + validationResult.AddRange(protocolChecks.CheckDveColumnOptionElement(xDoc)); + } + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check DVE Column Option Element", ex.ToString() }, + TestName = "CheckDVEColumnOptionElement" + }); + } + +#if DebugValidator + sw.Stop(); + log.WriteLog("CheckDVEColumnOptionElement done in " + sw.Elapsed.ToString()); + sw.Reset(); + sw.Start(); +#endif + + try + { + validationResult.AddRange(protocolChecks.CheckPositions(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Positions", ex.ToString() }, + TestName = "CheckPositions" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckTrendAlarm(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Trend Alarm", ex.ToString() }, + TestName = "CheckTrendAlarm" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckRawTypeDouble(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Raw Type Double", ex.ToString() }, + TestName = "CheckRawTypeDouble" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckAttributesContent(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Attributes Content", ex.ToString() }, + TestName = "CheckAttributesContent" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckCopyAction(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Copy Action", ex.ToString() }, + TestName = "CheckCopyAction" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckTimers(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Timers", ex.ToString() }, + TestName = "CheckTimers" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckRecursivePageButtons(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Recursive Page Buttons", ex.ToString() }, + TestName = "CheckRecursivePageButtons" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckTableIndexSequence(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Table Index Sequence", ex.ToString() }, + TestName = "CheckTableIndexSequence" + }); + } + +#if DebugValidator + sw.Stop(); + log.WriteLog("CheckTableIndexSequence done in " + sw.Elapsed.ToString()); + sw.Reset(); + sw.Start(); +#endif + + try + { + validationResult.AddRange(protocolChecks.CheckRTDisplayTrue(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check RTDisplay", ex.ToString() }, + TestName = "CheckRTDisplayTrue" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckResponseContent(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Response Content", ex.ToString() }, + TestName = "CheckResponseContent" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckTableColumnExports(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Table Column Exports", ex.ToString() }, + TestName = "CheckTableColumnExports" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckProtocolNames(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Protocol Names", ex.ToString() }, + TestName = "CheckProtocolNames" + }); + } + + try + { + validationResult.AddRange(protocolChecks.CheckInterpreteMeasurement(xDoc)); + } + catch (Exception ex) + { + validationResult.Add(new InternalError + { + Line = Convert.ToInt32(protocolChecks.LineNum), + DescriptionParameters = new object[] { "Check Interprete Measurement", ex.ToString() }, + TestName = "CheckProtocolNames" + }); + } + } + + return validationResult; + } + + public ICodeFixResult ExecuteCodeFix(XmlEdit.XmlDocument document, Skyline.DataMiner.CICD.Models.Protocol.Edit.Protocol protocol, IValidationResult result, ValidatorSettings validatorSettings) + { + throw new NotSupportedException(); + } + + public IList RunCompare(IProtocolInputData newCode, IProtocolInputData previousCode, ValidatorSettings validatorSettings, CancellationToken cancellationToken) + { + throw new NotSupportedException(); + } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/ValidationResult.cs b/Protocol/Legacy/ValidationResult.cs new file mode 100644 index 00000000..46a520d6 --- /dev/null +++ b/Protocol/Legacy/ValidationResult.cs @@ -0,0 +1,169 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + /// + /// Validation Result properties. + /// + /// + [DataContract] + public class ValidationResult : IValidationResult + { + public List SubResults { get; set; } + + /// + /// Gets or sets the result. + /// Information, Warning or Error. + /// + [DataMember(Order = 3)] + public Severity Severity { get; set; } + + public Source Source + { + get + { + return Source.Validator; + } + } + + public List<(string Message, bool AutoFixPopup)> AutoFixWarnings { get; } = new List<(string Message, bool AutoFixPopup)>(0); + + /// + /// Gets or sets the line number in XML file. + /// + [DataMember(Order = 4)] + public int Line { get; set; } + + /// + /// Gets or sets the unique identifier for the test. + /// + public string FullId { get; set; } + + /// + /// Gets or sets the unique identifier for the error type. + /// + [DataMember(Order = 0)] + public uint ErrorId { get; set; } + + public uint CheckId { get; set; } + + /// + /// Gets or sets the format for the error description. + /// + [DataMember(Order = 1)] + public string DescriptionFormat { get; set; } + + /// + /// Gets or sets the name of the test. + /// + public string TestName { get; set; } + + /// + /// Gets or sets the parameters to fill in DescriptionFormat. + /// + [DataMember(Order = 2)] + public object[] DescriptionParameters { get; set; } + + /// + /// Gets or sets the position of the result in XML file. + /// + public int Position { get; set; } + + public Category Category + { + get + { + return Category.Undefined; + } + } + + public Certainty Certainty + { + get + { + return Certainty.Certain; + } + } + + public FixImpact FixImpact + { + get + { + return FixImpact.Undefined; + } + } + + public string GroupDescription + { + get + { + return String.Empty; + } + } + + public string Description + { + get + { + return String.Empty; + } + } + + public string HowToFix + { + get + { + return String.Empty; + } + } + + public string ExampleCode + { + get + { + return String.Empty; + } + } + + public string Details + { + get + { + return String.Empty; + } + } + + public IReadable ReferenceNode + { + get + { + return null; + } + } + + public IReadable PositionNode + { + get + { + return null; + } + } + + public bool HasCodeFix + { + get + { + return false; + } + } + + [DataMember(Order = 5)] + public (int TablePid, string Name)? DveExport { get; set; } + } +} \ No newline at end of file diff --git a/Protocol/Legacy/ValidationResultExtensions.cs b/Protocol/Legacy/ValidationResultExtensions.cs new file mode 100644 index 00000000..628bcc70 --- /dev/null +++ b/Protocol/Legacy/ValidationResultExtensions.cs @@ -0,0 +1,33 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + + internal static class ValidationResultExtensions + { + public static IValidationResult WithDveExport(this IValidationResult result, int tablePid, string name) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (result is ValidationResult classResult) + { + classResult.DveExport = (tablePid, name); + + if (classResult.SubResults != null) + { + foreach (var sr in classResult.SubResults) + { + // Apply recursively to sub results. + sr.WithDveExport(tablePid, name); + } + } + } + + return result; + } + } +} diff --git a/Protocol/Legacy/ValidatorHelperMethods.cs b/Protocol/Legacy/ValidatorHelperMethods.cs new file mode 100644 index 00000000..603c1040 --- /dev/null +++ b/Protocol/Legacy/ValidatorHelperMethods.cs @@ -0,0 +1,888 @@ +namespace Skyline.DataMiner.ProtocolValidator +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + using System.Xml.Linq; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + public partial class ProtocolChecks + { + private const string _Uri = "http://www.skyline.be/protocol"; + + /// + /// Check if any characters not allowed as element or protocol names are present in a string. + /// + /// String to test. + /// List of not allowed characters used in the string. + public List CheckBadCharacters(string s) + { + char[] notAllowed = { '<', '>', ':', '"', '/', '\\', '|', '?', '*', ';', '°' }; + List badChars = new List(); + foreach (char ch in notAllowed) + { + if (s.Contains(ch)) + { + badChars.Add(ch); + } + } + + return badChars; + } + + /// + /// Collects the parameter information. + /// + /// The protocol document. + /// List of results. + public void CollectParameterInfo(XmlDocument xDoc) + { + // Clear any old data + ParameterInfoDictionary.Clear(); + GroupsDictionary.Clear(); + ParameterIdSet.Clear(); + + // Collect new data + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlParam = xDoc.SelectNodes("/slc:Protocol/slc:Params/slc:Param", xmlNsm); + if (xnlParam != null) + { + foreach (XmlNode xnParam in xnlParam) + { + LineNum = xnParam.Attributes["QA_LNx"].InnerXml; + + XmlNode xnId = xnParam.Attributes.GetNamedItem("id"); + if (xnId != null) + { + string sPid = xnParam.Attributes.GetNamedItem("id").InnerXml; + ParameterIdSet.Add(sPid); + + if (Int32.TryParse(sPid, out int iPid)) + { + string sName = String.Empty; + string sDescription = String.Empty; + string sType = String.Empty; + string sIntType = String.Empty; + string sIntRawType = String.Empty; + string sMType = String.Empty; + string sPage = String.Empty; + string sColumn = String.Empty; + string sRow = String.Empty; + string sLineNum = String.Empty; + string sLengthType = String.Empty; + string sLengthTypeId = String.Empty; + + int? duplicateAs = null; + + bool bRTDisplay = false; + bool bTrend = false; + bool bAlarmed = false; + bool bVirtualSource = false; + List exports = new List(); + bool singleExport = false; + + // Get exports if present + string sExport = xnParam.Attributes.GetNamedItem("export")?.InnerXml; + if (!String.IsNullOrEmpty(sExport)) + { + string[] sExports = sExport.Split(';'); + foreach (string export in sExports) + { + if (Int32.TryParse(export, out int x)) + { + if (!exports.Contains(x)) + { + exports.Add(x); + } + } + else if (export == "true") + { + singleExport = true; + } + } + } + + string sDuplicateAs = xnParam.Attributes.GetNamedItem("duplicateAs")?.InnerXml; + if (!String.IsNullOrEmpty(sExport) && Int32.TryParse(sDuplicateAs, out int d)) + { + duplicateAs = d; + } + + // Get name + XmlNode xnName = xnParam.SelectSingleNode("./slc:Name", xmlNsm); + if (xnName != null) + { + LineNum = xnName.Attributes["QA_LNx"].InnerXml; + sName = xnName.InnerXml; + } + + // Get description + XmlNode xnDescription = xnParam.SelectSingleNode("./slc:Description", xmlNsm); + if (xnDescription != null) + { + LineNum = xnDescription.Attributes["QA_LNx"].InnerXml; + sDescription = xnDescription.InnerXml; + } + + // Get parameter type + virtual attribute + XmlNode xnType = xnParam.SelectSingleNode("./slc:Type", xmlNsm); + if (xnType != null) + { + LineNum = xnType.Attributes["QA_LNx"].InnerXml; + sType = xnType.InnerXml.ToLower(); + XmlNode xnVirtual = xnType.Attributes["virtual"]; + if (xnVirtual != null) + { + string sv = xnVirtual.InnerText; + if (sv.ToLower() == "source") + { + bVirtualSource = true; + } + } + } + + // Get parameter RTDisplay + XmlNode xnRTDisplay = xnParam.SelectSingleNode("./slc:Display/slc:RTDisplay", xmlNsm); + if (xnRTDisplay != null) + { + LineNum = xnRTDisplay.Attributes["QA_LNx"].InnerXml; + bRTDisplay = Boolean.TryParse(xnRTDisplay.InnerText, out bool result) && result; // In case of empty RTDisplay tag + } + + // Get trending + XmlNode xnTrend = xnParam.Attributes["trending"]; + if (xnTrend != null) + { + string trending = xnTrend.InnerXml; + bTrend = Boolean.Parse(trending); + } + else + { + // When trending isn't defined, it takes the value from the RTDisplay tag. + if (bRTDisplay) + { + bTrend = bRTDisplay; + } + + // Capture write and write bit => Default false when write parameter. + if (sType.ToLower().Contains("write")) + { + bTrend = false; + } + } + + // Get interprete type + XmlNode xnIntType = xnParam.SelectSingleNode("./slc:Interprete/slc:Type", xmlNsm); + if (xnIntType != null) + { + LineNum = xnIntType.Attributes["QA_LNx"].InnerXml; + sIntType = xnIntType.InnerXml.ToLower(); + } + + // Get interprete raw type + XmlNode xnIntRawType = xnParam.SelectSingleNode("./slc:Interprete/slc:RawType", xmlNsm); + if (xnIntRawType != null) + { + LineNum = xnIntRawType.Attributes["QA_LNx"].InnerXml; + sIntRawType = xnIntRawType.InnerXml.ToLower(); + } + + // Get parameter measurement type + XmlNode xnMType = xnParam.SelectSingleNode("./slc:Measurement/slc:Type", xmlNsm); + if (xnMType != null) + { + LineNum = xnMType.Attributes["QA_LNx"].InnerXml; + sMType = xnMType.InnerXml.ToLower(); + } + + // Get parameter lengthType + XmlNode xnLengthType = xnParam.SelectSingleNode("./slc:Interprete/slc:LengthType", xmlNsm); + if (xnLengthType != null) + { + LineNum = xnLengthType.Attributes["QA_LNx"].InnerXml; + sLengthType = xnLengthType.InnerXml.ToLower(); + + // Get parameter lengthType ID + XmlNode xnLengthTypeId = xnLengthType.SelectSingleNode("./@id", xmlNsm); + if (xnLengthTypeId != null) + { + sLengthTypeId = xnLengthTypeId.InnerXml; + } + } + + // Get parameter LineNumber + XmlNode xnLineNum = xnParam.Attributes["QA_LNx"]; + if (xnLineNum != null) + { + sLineNum = xnLineNum.InnerXml; + } + + // Get alarm monitored + XmlNode xnAlarm = xnParam.SelectSingleNode("./slc:Alarm/slc:Monitored", xmlNsm); + if (xnAlarm != null) + { + string monitored = xnAlarm.InnerXml; + bAlarmed = Convert.ToBoolean(monitored); + } + + // Get parameter positions + XmlNodeList xnlPosition = xnParam.SelectNodes("./slc:Display/slc:Positions/slc:Position", xmlNsm); + if (xnlPosition.Count != 0) + { + List poslist = new List(); + foreach (XmlNode xnPosition in xnlPosition) + { + LineNum = xnPosition.Attributes["QA_LNx"].InnerXml; + XmlNode xnPage = xnPosition.SelectSingleNode("./slc:Page", xmlNsm); + if (xnPage != null) + { + LineNum = xnPage.Attributes["QA_LNx"].InnerXml; + sPage = xnPage.InnerXml; + } + + XmlNode xnRow = xnPosition.SelectSingleNode("./slc:Row", xmlNsm); + if (xnRow != null) + { + LineNum = xnRow.Attributes["QA_LNx"].InnerXml; + sRow = xnRow.InnerXml; + } + + XmlNode xnColumn = xnPosition.SelectSingleNode("./slc:Column", xmlNsm); + if (xnColumn != null) + { + LineNum = xnColumn.Attributes["QA_LNx"].InnerXml; + sColumn = xnColumn.InnerXml; + } + + if (!String.IsNullOrEmpty(sPage) && !String.IsNullOrEmpty(sRow) && !String.IsNullOrEmpty(sColumn)) // Position data is OK + { + if (exports.Count == 0 && !singleExport) + { + poslist.Add(new Position(sPage, sRow, sColumn)); + } + else + { + if (singleExport) + { + Position position = new Position + { + Page = sPage, + Row = sRow, + Column = sColumn, + Export = -1 + }; + poslist.Add(position); + } + else + { + foreach (int export in exports) + { + // Need to use new position, else the same object will be added to list twice. + Position position = new Position + { + Page = sPage, + Row = sRow, + Column = sColumn, + Export = export + }; + + poslist.Add(position); + } + } + } + } + else // No position data, add positions for exports + { + if (singleExport) + { + Position position = new Position + { + Export = -1 + }; + poslist.Add(position); + } + + if (exports.Count > 0) + { + foreach (int export in exports) + { + // Need to use new position, else the same object will be added to list multiple times. + Position newposition = new Position + { + Export = export + }; + poslist.Add(newposition); + } + } + } + } + + Position emptyPosition = new Position(); + while (poslist.Count > 1 && poslist.Contains(emptyPosition)) + { + poslist.Remove(emptyPosition); + } + + ParameterInfo pi2 = new ParameterInfo(iPid, sName, sDescription, sType, sIntType, sIntRawType, sMType, + bRTDisplay, sLineNum, sLengthType, sLengthTypeId, bTrend, bAlarmed, bVirtualSource, xnParam, + poslist.ToArray()); + + pi2.DuplicateAs = duplicateAs; + + if (ParameterInfoDictionary.ContainsKey(Convert.ToInt32(sPid))) + { + continue; + } + + ParameterInfoDictionary.Add(Convert.ToInt32(sPid), pi2); + } + else + { + List poslist = new List(); + + if (singleExport) + { + Position position = new Position + { + Export = -1 + }; + poslist.Add(position); + } + + if (exports.Count > 0) + { + foreach (int export in exports) + { + Position newposition = new Position + { + Export = export + }; + poslist.Add(newposition); + } + } + + ParameterInfo pi = new ParameterInfo(iPid, sName, sDescription, sType, sIntType, sIntRawType, sMType, + bRTDisplay, sLineNum, sLengthType, sLengthTypeId, bTrend, bAlarmed, bVirtualSource, xnParam, + poslist.ToArray()); + + pi.DuplicateAs = duplicateAs; + + if (ParameterInfoDictionary.ContainsKey(Convert.ToInt32(sPid))) + { + continue; + } + + ParameterInfoDictionary.Add(Convert.ToInt32(sPid), pi); + } + } + } + } + } + + XmlNodeList xnlGroup = xDoc.SelectNodes("/slc:Protocol/slc:Groups/slc:Group", xmlNsm); + foreach (XmlNode xnGroup in xnlGroup) + { + if (xnGroup != null) + { + LineNum = xnGroup.Attributes["QA_LNx"].InnerXml; + string groupId = xnGroup.Attributes.GetNamedItem("id").InnerXml; + + if (GroupsDictionary.ContainsKey(Convert.ToInt32(groupId))) + { + continue; + } + + GroupsDictionary.Add(Convert.ToInt32(groupId), xnGroup); + } + } + } + + /// + /// Gets all tables. + /// + /// The protocol document. + /// List of tables. + public List GetAllTables(XmlDocument xDoc) + { + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNodeList xnlTables = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param[slc:Type='array']", xmlNsm); + XmlNodeList xnlTables2 = xDoc.SelectNodes("slc:Protocol/slc:Params/slc:Param[slc:Type='ARRAY']", xmlNsm); + var allTables = xnlTables.Cast().Concat(xnlTables2.Cast()).ToList(); + return allTables; + } + + /// + /// Gets the duplicated parameters. + /// + /// The protocol document. + /// List of results. + public List GetDuplicatedParams(XmlDocument xDoc) // M + { + List resultMsg = new List(); + + DuplicateParameterDictionary.Clear(); + + XmlNodeList xnlParam = xDoc.GetElementsByTagName("Param"); + foreach (XmlNode xnParam in xnlParam) + { + LineNum = xnParam.Attributes?["QA_LNx"]?.InnerXml; + string sPid = xnParam.Attributes?.GetNamedItem("id")?.InnerText; + + if (Int32.TryParse(sPid, out int iPid)) + { + string sDuplicateAs = xnParam.Attributes?.GetNamedItem("duplicateAs")?.InnerText; + if (!String.IsNullOrEmpty(sDuplicateAs)) + { + string[] asDuplicateAsPids = sDuplicateAs.Split(','); + foreach (string sDuplicateAsPid in asDuplicateAsPids) + { + if (Int32.TryParse(sDuplicateAsPid, out int iDuplicateAsPid)) + { + DuplicateParameterDictionary.Add(iDuplicateAsPid, iPid); + } + else + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1001, + DescriptionFormat = "Internal Application Error : Error in {0}. Could not parse sDuplicateAsPid '{1}' to an integer.", + DescriptionParameters = new object[] { "GetDuplicatedParams", sDuplicateAsPid }, + TestName = "GetDuplicatedParams", + Severity = Severity.Critical + }); + } + } + } + } + } + + return resultMsg; + } + + /// + /// Gets the real pid. + /// + /// The duplicated pid. + /// The real pid. + public int GetRealPid(int iDuplicatedPid) + { + if (!DuplicateParameterDictionary.TryGetValue(iDuplicatedPid, out int iRealPid)) + { + iRealPid = iDuplicatedPid; + } + + return iRealPid; + } + + /// + /// Determines whether the specified string is an . + /// + /// The string. + /// + /// true if the specified string is an integer; otherwise, false. + /// + public bool IsInteger(string s) + { + return Int32.TryParse(s, out int i); + } + + /// + /// Loads the line numbers. + /// + /// The protocol document. + public XmlDocument LoadWithLineNums(string xml) // S + { + // Add line numbers + XDocument xInput = XDocument.Parse(xml, LoadOptions.SetLineInfo); + XElement root = xInput.Root; + XNamespace skylineProtocol = "http://www.skyline.be/protocol"; + + // Add root namespace if needed + if (root.GetDefaultNamespace() != skylineProtocol) + { + root.Name = skylineProtocol.GetName(root.Name.LocalName); + foreach (XElement el in root.Descendants()) + { + if (el.GetDefaultNamespace() != skylineProtocol) + { + el.Name = skylineProtocol.GetName(el.Name.LocalName); + } + + if (el.NodeType == XmlNodeType.Element) + { + // Add lineInfo + IXmlLineInfo ili = el; + if (ili.HasLineInfo()) + { + int line = ili.LineNumber; + XAttribute xline = new XAttribute("QA_LNx", line); + el.Add(xline); + } + } + } + } + else + { + foreach (XElement xni in xInput.Descendants()) + { + if (xni.NodeType == XmlNodeType.Element) + { + // Add lineInfo + IXmlLineInfo ili = xni; + if (ili.HasLineInfo()) + { + int line = ili.LineNumber; + XAttribute xline = new XAttribute("QA_LNx", line); + xni.Add(xline); + } + } + } + } + + XmlDocument xDoc = new XmlDocument(); + xDoc.LoadXml(xInput.ToString()); + + return xDoc; + } + + /// + /// Returns a Dictionary with (PID, index) pairs. For columns in the type tag, indexes are auto-incremented, skipping indexes defined in ColumnOptions. + /// + /// The protocol document. + /// Table Parameter ID. + /// Optional resultMsg for errors, should only be used when calling from 17xx tests. + /// Dictionary with (PID, index) pairs. + private Dictionary GetColumnPids(XmlDocument xDoc, string tablePid, List resultMsg = default(List)) + { + Dictionary columnPids = new Dictionary(); + + // Add xmlNameSpaceManager + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + XmlNode xnParam = ParameterInfoDictionary[Convert.ToInt32(tablePid)].Element; + + if (xnParam == null) { return columnPids; } + + LineNum = xnParam.Attributes?["QA_LNx"].InnerXml; + + // Add id's in ColumnOption tags to pidsToCheck List + XmlNodeList xnlColumnOptions = xnParam.SelectNodes(".//slc:ColumnOption", xmlNsm); + foreach (XmlNode xnColumnOption in xnlColumnOptions) + { + LineNum = xnColumnOption.Attributes?["QA_LNx"].InnerXml; + string columnOptionPid = xnColumnOption.Attributes?["pid"]?.InnerXml; + if (columnOptionPid == null) { continue; } + + string columnOptionIdx = xnColumnOption.Attributes?["idx"]?.InnerXml; + if (columnOptionIdx == null) { continue; } + + if (!columnPids.Keys.Contains(columnOptionPid)) + { + columnPids.Add(columnOptionPid, columnOptionIdx); + } + else if (resultMsg != default(List)) // Generate error only once + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1703, + DescriptionFormat = "Table Column Parameter {0} is added to table {1} more than once.", + DescriptionParameters = new object[] { columnOptionPid, tablePid }, + TestName = "CheckTableColumnParams", + Severity = Severity.Critical + }); + } + } + + // Add id's in type tag to columnPids List + XmlNode xnType = xnParam.SelectSingleNode("slc:Type", xmlNsm); + if (xnType != null && String.Equals(xnType.InnerXml, "array", StringComparison.OrdinalIgnoreCase) && xnType.Attributes?["id"] != null) + { + LineNum = xnType.Attributes?["QA_LNx"].InnerXml; + string sId = xnType.Attributes["id"].InnerXml; + string[] ids = sId.Split(';'); + int counter = 0; + foreach (string id in ids) + { + if (String.IsNullOrEmpty(id)) { continue; } + + while (columnPids.Values.Contains(counter.ToString())) + { + counter++; + } + + if (!columnPids.Keys.Contains(id)) + { + columnPids.Add(id, counter.ToString()); + } + else if (resultMsg != default(List)) + { + resultMsg.Add(new ValidationResult + { + Line = Convert.ToInt32(LineNum), + ErrorId = 1703, + DescriptionFormat = "Table Column Parameter {0} is added to table {1} more than once.", + DescriptionParameters = new object[] { id, tablePid }, + TestName = "CheckTableColumnParams", + Severity = Severity.Critical + }); + } + + counter++; + } + } + + return columnPids; + } + + /// + /// Get a list of exported table pids for main tables. + /// + /// Skyline DataMiner protocol XmlDocument. + /// List of exported tables. + private Dictionary GetDveTables(XmlDocument xDoc) // M + { + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(xDoc.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + + Dictionary exportedTables = new Dictionary(); + + XmlNodeList xnlType = xDoc.GetElementsByTagName("Type"); + XmlNode xnType = xnlType.Item(0); + LineNum = xnType?.Attributes?["QA_LNx"]?.InnerXml; + string typeOptions = xnType?.Attributes?.GetNamedItem("options")?.InnerXml; + + if (!String.IsNullOrEmpty(typeOptions) && typeOptions.Contains("exportProtocol")) + { + string[] options = typeOptions.Split(';'); + + foreach (string option in options) + { + string[] optionDetails = option.Split(':'); + if (optionDetails.Length >= 3 && optionDetails[0] == "exportProtocol") + { + exportedTables.Add(optionDetails[2], optionDetails[1]); + } + } + } + + XmlNodeList xnlDveProtocol = xDoc.SelectNodes("slc:Protocol/slc:DVEs/slc:DVEProtocols/slc:DVEProtocol", xmlNsm); + foreach (XmlNode dveProtocol in xnlDveProtocol) + { + LineNum = dveProtocol.Attributes?["QA_LNx"]?.InnerXml; + string name = dveProtocol.Attributes?["name"]?.InnerXml; + string tablePid = dveProtocol.Attributes?["tablePID"]?.InnerXml; + if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(tablePid)) + { + exportedTables.Add(tablePid, name); + } + } + + return exportedTables; + } + + /// + /// Gets the inner XML or CData. + /// + /// The node. + /// Inner XML as string. + private string GetInnerXmlOrCData(XmlNode node) + { + // Get string or CDATA content + string content = String.Empty; + if (!node.HasChildNodes) // No child nodes, just return innerXML + { + return node.InnerXml; + } + + foreach (XmlNode child in node.ChildNodes) + { + if (child.NodeType == XmlNodeType.Comment) + { + continue; // We're not interested in comments + } + + if (child.NodeType == XmlNodeType.CDATA) + { + content = child.InnerText; + break; // First CDATA node will be used (there should only be one) + } + else // No CDATA content, just read innerXml + { + content = node.InnerXml; + break; + } + } + + return content; + } + + /// + /// Gets the read pid for a write pid. + /// + /// Write parameter id. + /// Corresponding read parameter id, -1 if no read parameter id is found. + private int GetReadPid(int writePid) + { + int readPid = -1; // Default if no write exists. + string writeDescription = ParameterInfoDictionary[writePid].Description; + ParameterInfo piRead = ParameterInfoDictionary.Values.FirstOrDefault(pi => pi.Description == writeDescription && pi.Type == "read"); + if (piRead != null) + { + readPid = Convert.ToInt32(piRead.Pid); + } + + return readPid; + } + + /// + /// Gets the table foreign keys. + /// + /// The table. + /// The namespace. + /// List of table ids. + private List GetTableForeignKeys(XmlNode table, XmlNamespaceManager xmlNsm) + { + List keys = new List(); + + // Return empty list immediately if node is not an element + if (table.NodeType != XmlNodeType.Element) + { + return keys; + } + + // Find foreignKeys + // Find tables with foreignKey to exported table that are not in a relation, in this case the table will be exported. + XmlNodeList xnlCOoptions = table.SelectNodes("./slc:ArrayOptions/slc:ColumnOption/@options", xmlNsm); + if (xnlCOoptions != null) + { + foreach (XmlNode options in xnlCOoptions) + { + string sOptions = options.InnerXml; + if (!String.IsNullOrEmpty(sOptions)) + { + string[] asAllOptions = sOptions.Split(new[] { sOptions[0] }, StringSplitOptions.RemoveEmptyEntries); + foreach (string option in asAllOptions) + { + if (option.StartsWith("foreignkey=", StringComparison.InvariantCultureIgnoreCase)) + { + string fkTable = option.Substring("foreignkey=".Length); + if (Int32.TryParse(fkTable, out int iTable)) + { + keys.Add(iTable); + } + } + } + } + } + } + + return keys; + } + + /// + /// Gets the table measurement pids. + /// + /// The table parameter. + /// If set to true [Duplicated as to main]. + /// HashSet of Pids. + private HashSet GetTableMeasurementPids(XmlNode tableParam, bool bDuplicatedAsToMain = true) + { + XmlNamespaceManager xmlNsm = new XmlNamespaceManager(tableParam.OwnerDocument.NameTable); + xmlNsm.AddNamespace("slc", _Uri); + HashSet result = new HashSet(); + + // Get all column parameters in measurement + XmlAttribute measurementTypeOptions = (XmlAttribute)tableParam.SelectSingleNode("./slc:Measurement/slc:Type/@options", xmlNsm); + if (measurementTypeOptions == null) + { + return result; + } + + LineNum = measurementTypeOptions.OwnerElement?.Attributes["QA_LNx"].InnerXml; + string options = measurementTypeOptions.InnerXml; + options = options.TrimStart(';'); + string[] asOptions = options.Split(';'); + foreach (string s in asOptions) + { + const string Tab = "tab="; + if (s.StartsWith(Tab, StringComparison.InvariantCulture)) + { + string taboption = s.Substring(s.IndexOf(Tab, StringComparison.InvariantCulture) + Tab.Length); + string[] asTabOptions = taboption.Split(','); + foreach (string stab in asTabOptions) + { + const string Col = "columns:"; + if (stab.StartsWith(Col, StringComparison.InvariantCulture)) + { + string columns = stab.Substring(stab.IndexOf(Col, StringComparison.InvariantCulture) + Col.Length); + string[] asColumns = columns.Split('-'); + foreach (string column in asColumns) + { + string sPid; + if (column.Contains('|')) + { + // Format PID|IDX is used + sPid = column.Substring(0, column.IndexOf('|')); + } + else + { + // Content is parameter id + sPid = column; + } + + if (Int32.TryParse(sPid, out int iPid)) + { + int iRealPid; + if (bDuplicatedAsToMain) + { + // If parameter id a duplicated parameter, run check on original parameter + iRealPid = GetRealPid(iPid); + } + else + { + iRealPid = iPid; + } + + result.Add(iRealPid); + } + } + } + } + } + } + + return result; + } + + /// + /// Gets the write pid for a read pid. + /// + /// Read parameter id. + /// Corresponding write parameter id, -1 if no write parameter id is found. + private int GetWritePid(int readPid) + { + int writePid = -1; // Default if no write exists. + if (ParameterInfoDictionary.ContainsKey(readPid)) + { + string readDescription = ParameterInfoDictionary[readPid].Description; + ParameterInfo piWrite = ParameterInfoDictionary.Values.FirstOrDefault(pi => pi.Description == readDescription && pi.Type == "write"); + if (piWrite != null) + { + writePid = Convert.ToInt32(piWrite.Pid); + } + } + + return writePid; + } + } +} \ No newline at end of file diff --git a/Protocol/Protocol.csproj b/Protocol/Protocol.csproj index 7af7356f..265f636c 100644 --- a/Protocol/Protocol.csproj +++ b/Protocol/Protocol.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0 disable disable Skyline.DataMiner.CICD.Validators.Protocol @@ -37,5 +37,13 @@ + + + + + + + + diff --git a/Protocol/Tests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet.cs b/Protocol/Tests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet.cs index 2c2a0eca..92e279c3 100644 --- a/Protocol/Tests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet.cs +++ b/Protocol/Tests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet.cs @@ -63,8 +63,10 @@ public List Validate(ValidatorContext context) internal class QActionAnalyzer : CSharpAnalyzerBase { - private static readonly System.Type ThreadType = typeof(Thread); - private static readonly string ThreadAssemblyName = ThreadType.Assembly.GetName().Name; + private static readonly System.Type ThreadType = typeof(Thread); + + // QActions are in .NET Framework + private const string ThreadAssemblyName = "mscorlib"; private readonly List results; private readonly IValidate test; diff --git a/ProtocolTests.SchemaGenerator/Program.cs b/ProtocolTests.SchemaGenerator/Program.cs new file mode 100644 index 00000000..084ea885 --- /dev/null +++ b/ProtocolTests.SchemaGenerator/Program.cs @@ -0,0 +1,43 @@ +namespace SLDisValidatorUnitTestsSchemaGenerator +{ + using System; + using System.IO; + using System.Reflection; + + internal class Program + { + private static void Main(string[] args) + { + string solutionDir = String.Join(" ", args); + + var assembly = typeof(SchemaGenerator).Assembly; + var buildConfigurationName = assembly.GetCustomAttribute()?.Configuration; + + var projectName = assembly.GetName().Name; + string schema; + + try + { + string path = Path.Combine(solutionDir, projectName, "bin", buildConfigurationName, "net472", "Skyline", "XSD", "protocol.xsd"); + SchemaGenerator generator = new SchemaGenerator(path); + schema = generator.CreateSchema(); + } + catch (Exception e) + { + Console.WriteLine(e); + Environment.Exit(-1); + return; + } + + try + { + File.WriteAllText(Path.Combine(solutionDir, "ProtocolTests", "ValidatorUnitTestProtocols.g.xsd"), schema); + } + catch (Exception e) + { + Console.WriteLine(e); + Environment.Exit(-2); + } + } + } +} \ No newline at end of file diff --git a/ProtocolTests.SchemaGenerator/ProtocolTests.SchemaGenerator.csproj b/ProtocolTests.SchemaGenerator/ProtocolTests.SchemaGenerator.csproj new file mode 100644 index 00000000..3a7911ec --- /dev/null +++ b/ProtocolTests.SchemaGenerator/ProtocolTests.SchemaGenerator.csproj @@ -0,0 +1,18 @@ + + + + Exe + net472 + $(MSBuildProjectName) + $(MSBuildProjectName) + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests.SchemaGenerator/SchemaGenerator.cs b/ProtocolTests.SchemaGenerator/SchemaGenerator.cs new file mode 100644 index 00000000..34d51dc2 --- /dev/null +++ b/ProtocolTests.SchemaGenerator/SchemaGenerator.cs @@ -0,0 +1,238 @@ +namespace SLDisValidatorUnitTestsSchemaGenerator +{ + using System; + using System.Reflection; + using System.Xml; + + public class SchemaGenerator + { + private const string TargetNamespace = "http://www.skyline.be/validatorProtocolUnitTest"; + + private readonly string inputFile = ""; + + private XmlDocument doc; + private XmlNamespaceManager nsmgr; + + public SchemaGenerator(string inputFile) + { + if (string.IsNullOrEmpty(inputFile)) + { + throw new ArgumentException("Input file parameter must not be null or empty.", "inputFile"); + } + + this.inputFile = inputFile; + } + + /// + /// Creates XML Schema to be used for creating unit tests for the protocol validator. + /// + /// The complete XSD. + /// The loosened XSD. + public string CreateSchema() + { + try + { + doc = new XmlDocument(); + doc.Load(inputFile); + + nsmgr = new XmlNamespaceManager(doc.NameTable); + nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); + + UpdateNamespaces(); + + UpdateSchemaLocation(); + + MakeElementsOptional(); + MakeAttributesOptional(); + + RemoveKeysAndKeyReferences(); + + return doc.OuterXml; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + return ""; + } + } + + /// + /// Updates the namespaces. + /// + private void UpdateNamespaces() + { + XmlNodeList targetNamespaceAttr = doc.DocumentElement.SelectNodes("./@targetNamespace"); + if (targetNamespaceAttr.Count > 0) + { + foreach (XmlNode attr in targetNamespaceAttr) + { + attr.Value = TargetNamespace; + } + } + + XmlAttribute disnsAttr = doc.CreateAttribute("xmlns:dis"); + disnsAttr.Value = TargetNamespace; + + XmlAttribute xmlnsAttr = doc.CreateAttribute("xmlns"); + xmlnsAttr.Value = TargetNamespace; + + doc.DocumentElement.Attributes.Append(xmlnsAttr); + doc.DocumentElement.Attributes.Append(disnsAttr); + } + + private void UpdateSchemaLocation() + { + XmlNodeList elementList = doc.DocumentElement.SelectNodes(".//xs:include", nsmgr); + + var assembly = typeof(SchemaGenerator).Assembly; + var buildConfigurationName = assembly.GetCustomAttribute()?.Configuration; + + var projectName = assembly.GetName().Name; + foreach (XmlNode node in elementList) + { + var result = node.Attributes["schemaLocation"]; + if (result != null) + { + result.Value = $@".\..\{projectName}\bin\{buildConfigurationName}\net472\Skyline\XSD\" + result.Value; + } + } + } + + /// + /// Makes the elements optional. + /// + private void MakeElementsOptional() + { + XmlNodeList elementList = doc.DocumentElement.SelectNodes(".//xs:element", nsmgr); + + foreach (XmlNode node in elementList) + { + XmlNodeList minOccursAttrs = node.SelectNodes("./@minOccurs"); + if (minOccursAttrs.Count > 0) + { + bool isHttpRequestNode = IsHttpRequestNode(node); + bool isExposerNode = IsExposerNode(node); + + if (!isHttpRequestNode && !isExposerNode) + { + foreach (XmlNode minOccursAttr in minOccursAttrs) + { + if (!minOccursAttr.Value.Equals("0")) + { + minOccursAttr.Value = "0"; + } + } + } + } + else + { + bool isRootNode = node.Attributes["name"].Value == "Protocol" && node.ParentNode.Name == "xs:schema"; + + if (!isRootNode) + { + XmlAttribute minOccursAttr = doc.CreateAttribute("minOccurs"); + minOccursAttr.Value = "0"; + + node.Attributes.Append(minOccursAttr); + } + } + } + } + + /// + /// Determines whether the specified node is an Exposer node, as these cannot be made optional as otherwise the content model would become ambiguous rendering the XML Schema invalid. + /// + /// + private bool IsExposerNode(XmlNode node) + { + bool result = false; + + string name = node.Attributes["name"].Value; + + if (name.Equals("Exposer")) + { + result = true; + } + + return result; + } + + /// + /// Determines whether the specified node is an HTTP request node, as these cannot be made optional as otherwise the content model would become ambiguous rendering the XML Schema invalid. + /// + /// + private bool IsHttpRequestNode(XmlNode node) + { + bool result = false; + + string name = node.Attributes["name"].Value; + + var typeAttr = node.Attributes["type"]; + + if (typeAttr != null) + { + string type = node.Attributes["type"].Value; + + if ((name.Equals("Headers") || name == "Parameters" || name == "Data") && (type == "HttpRequestHeaders" || type == "HttpRequestData" || type == "HttpRequestParameters")) + { + result = true; + } + } + + return result; + } + + + /// + /// Makes the attributes optional. + /// + private void MakeAttributesOptional() + { + XmlNodeList attributeList = doc.DocumentElement.SelectNodes(".//xs:attribute", nsmgr); + + foreach (XmlNode node in attributeList) + { + XmlNodeList minOccursAttrs = node.SelectNodes("./@use"); + if (minOccursAttrs.Count > 0) + { + foreach (XmlNode minOccursAttr in minOccursAttrs) + { + if (!minOccursAttr.Value.Equals("optional")) + { + minOccursAttr.Value = "optional"; + } + } + } + else + { + XmlAttribute minOccursAttr = doc.CreateAttribute("use"); + minOccursAttr.Value = "optional"; + + node.Attributes.Append(minOccursAttr); + } + } + } + + /// + /// Removes the key reference constraints. + /// + private void RemoveKeysAndKeyReferences() + { + XmlNodeList keyRefList = doc.DocumentElement.SelectNodes(".//xs:keyref", nsmgr); + + foreach (XmlNode node in keyRefList) + { + XmlNode parent = node.ParentNode; + parent.RemoveChild(node); + } + + XmlNodeList keyList = doc.DocumentElement.SelectNodes(".//xs:key", nsmgr); + + foreach (XmlNode node in keyList) + { + XmlNode parent = node.ParentNode; + parent.RemoveChild(node); + } + } + } +} diff --git a/ProtocolTests/CheckUnitTests.cs b/ProtocolTests/CheckUnitTests.cs new file mode 100644 index 00000000..22b4d21c --- /dev/null +++ b/ProtocolTests/CheckUnitTests.cs @@ -0,0 +1,1729 @@ +namespace SLDisValidatorUnitTests +{ + using System; + using System.Collections.Generic; + using System.Collections.Immutable; + using System.IO; + using System.Linq; + using System.Reflection; + using System.Text; + using System.Text.RegularExpressions; + using System.Xml; + using System.Xml.Schema; + + using FluentAssertions; + + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.FindSymbols; + using Microsoft.CodeAnalysis.MSBuild; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.CSharpAnalysis; + using Skyline.DataMiner.CICD.CSharpAnalysis.Classes; + using Skyline.DataMiner.CICD.CSharpAnalysis.Enums; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2; + using SLDisValidator2.Common; + using SLDisValidator2.Common.Attributes; + using SLDisValidator2.Interfaces; + + [TestClass] + [Ignore("TODO: Fix")] + public class CheckTests + { + /// + /// Checks if there is a namespace for each test. + /// + [TestMethod] + public void CheckTestsForUnitTest_Validate() + { + // Get all tests + var allTests = TestCollector.GetAllValidateTests().Tests; + + // Get all namespaces + var namespaces = Assembly + .GetAssembly(typeof(CheckTests)) + .GetTypes() + .Select(type => type.Namespace) + .ToList(); + + List testNamespaces = new List(); + foreach ((IValidate test, TestAttribute _) in allTests) + { + // Get test name + Type temp = test.GetType(); + + string newNamespace = temp.Namespace?.Replace("SLDisValidator2.Tests", "SLDisValidatorUnitTests"); + + if (!namespaces.Contains(newNamespace)) + { + testNamespaces.Add(newNamespace?.Remove(0, "SLDisValidatorUnitTests.".Length)); + } + } + + // Check if UnitTest already exists + testNamespaces.Should().BeEmpty(); + } + + /// + /// Checks if there is a namespace for each test. + /// + [TestMethod] + public void CheckTestsForUnitTest_Compare() + { + // Get all tests + var allTests = TestCollector.GetAllCompareTests().Tests; + + // Get all namespaces + var namespaces = Assembly + .GetAssembly(typeof(CheckTests)) + .GetTypes() + .Select(type => type.Namespace) + .ToList(); + + List testNamespaces = new List(); + foreach ((ICompare test, TestAttribute _) in allTests) + { + // Get test name + Type temp = test.GetType(); + + string newNamespace = temp.Namespace?.Replace("SLDisValidator2.Tests", "SLDisValidatorUnitTests"); + + if (!namespaces.Contains(newNamespace)) + { + testNamespaces.Add(newNamespace?.Remove(0, "SLDisValidatorUnitTests.".Length)); + } + } + + // Check if UnitTest already exists + testNamespaces.Should().BeEmpty(); + } + + [TestMethod] + public void CheckNamespacesOfUnitTests() + { + // Get all namespaces + var namespaces = Assembly + .GetAssembly(typeof(CheckTests)) + .GetTypes() + .Select(x => x.Namespace.Replace("SLDisValidatorUnitTests.", String.Empty)); + + // Get all Files + var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + var files = Directory + .GetParent(currentDirectory) + .Parent + .Parent + .GetFiles("*.cs", SearchOption.AllDirectories); + + files.Should().NotBeEmpty(); + + List lsWrongFiles = new List(); + + string[] asExcludeDirectories = + { + "bin", "obj", "Generic Tests", "Software Parameters", + }; + + foreach (var item in files) + { + if (String.Equals(item.Directory.Name, "ProtocolTests")) + { + // No need to check generic stuff. + continue; + } + + List lsParents = new List(); + bool bStillGoing = true; + var directory = item.Directory; + while (bStillGoing) + { + if (String.Equals(directory.Name, "ProtocolTests") + || directory.Parent == null) + { + bStillGoing = false; + } + else if (asExcludeDirectories.Contains(directory.Name)) + { + lsParents.Clear(); + bStillGoing = false; + } + else + { + lsParents.Add(directory.Name); + directory = directory.Parent; + } + } + + if (lsParents.Count == 0) + { + continue; + } + + lsParents.Reverse(); + + string newNamespace = String.Join(".", lsParents); + + if (!namespaces.Contains(newNamespace)) + { + lsWrongFiles.Add(String.Join("/", lsParents)); + } + } + + lsWrongFiles.Should().BeEmpty(); + } + + [TestMethod] + public void CheckNamespacesOfTests() + { + // Get all namespaces + var namespaces = Assembly + .GetAssembly(typeof(Validator)) + .GetTypes() + .Where(x => !String.IsNullOrWhiteSpace(x.Namespace) && x.Namespace.StartsWith("SLDisValidator2.Tests")) + .Select(x => x.Namespace.Replace("SLDisValidator2.Tests.", String.Empty)); + + var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string solutiondir = Directory.GetParent(currentDirectory).Parent.Parent.Parent.FullName; + + string newPath = Path.Combine(solutiondir, "Protocol", "Tests"); + + // Get all Files + var files = Directory + .GetFiles(newPath, "*.cs", SearchOption.AllDirectories); + + List lsWrongFiles = new List(); + + string[] asExcludeDirectories = new string[] + { + "bin", "obj" + }; + + foreach (var temp in files) + { + var item = new FileInfo(temp); + + List lsParents = new List + { + item.Name.Replace(".cs", String.Empty) + }; + bool bStillGoing = true; + var directory = item.Directory; + while (bStillGoing) + { + if (String.Equals(directory.Name, "Tests")) + { + bStillGoing = false; + } + else if (asExcludeDirectories.Contains(directory.Name)) + { + lsParents.Clear(); + bStillGoing = false; + } + else + { + lsParents.Add(directory.Name); + directory = directory.Parent; + } + } + + if (lsParents.Count == 1) + { + continue; + } + + lsParents.Reverse(); + string newNamespace = String.Join(".", lsParents); + + if (!namespaces.Contains(newNamespace)) + { + lsWrongFiles.Add(String.Join("/", lsParents)); + } + } + + lsWrongFiles.Should().BeEmpty(); + } + + /// + /// Checks if the unit tests don't have failing QActions. + /// Will also fail if any have MinDmaVersion tag in the compliancies (currently it isn't possible to validate newer C#) + /// + [TestMethod] + public void CheckQActionCompilation() + { + var test = new SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpQActionCompilation.CSharpQActionCompilation(); + + // Search for Protocol directory which is the root folder of all unit tests + if (!Files.TryGetProtocolDirectory(out DirectoryInfo protocolDirectory)) + { + Assert.Fail("Protocol folder not found."); + } + + // Get all XML files + List<(string fileName, string fileLocation, Generic.TestType testType)> allFiles = protocolDirectory + .GetFiles("*.xml", SearchOption.AllDirectories) + .Select(GetFileData) + .ToList(); + + allFiles.Should().NotBeEmpty(); + + List failedTests = new List(); + foreach ((string fileName, string fileLocation, Generic.TestType testType) in allFiles) + { + if (fileName == null || fileLocation.Contains("CSharpQActionCompilation")) + { + continue; + } + + try + { + Generic.ValidateData data = new Generic.ValidateData + { + ExpectedResults = new List(), + FileName = fileName, + TestType = testType, + }; + + Generic.Validate(test, data, fileLocation); + } + catch (AssertFailedException /*afEx*/) + { + Regex r = new Regex(@".*\\[SLDisValidatorUnitTests]+\\(.*)"); + + var location = r.Match(fileLocation).Groups[1].Value; + + //failedTests.Add($"{location}{testType}\\{fileName}|\n{afex.Message}"); + failedTests.Add($"{location}{testType}\\{fileName}"); + } + catch (Exception ex) + { + failedTests.Add($"EXCEPTION: {ex.Message}"); + } + } + + if (failedTests.Any()) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine(); + foreach (var item in failedTests) + { + sb.AppendLine($"=> {item}"); + } + + Assert.Fail(sb.ToString()); + } + + (string, string, Generic.TestType) GetFileData(FileInfo fileInfo) + { + Generic.TestType testType = Generic.TestType.Invalid; + DirectoryInfo directory = fileInfo.Directory; + while (!String.Equals(directory.Name, "Samples")) + { + if (String.Equals(directory.Name, "Compare") || String.Equals(directory.Name, "Codefix", StringComparison.OrdinalIgnoreCase)) + { + return (null, null, testType); + } + + if (String.Equals(directory.Name, "Valid")) + { + testType = Generic.TestType.Valid; + } + + directory = directory.Parent; + } + + return (fileInfo.Name, $"{directory.Parent.FullName}\\", testType); + } + } + } + + [TestClass] + public class BasicChecks + { + /// + /// Will fail when a check throws an error/exception when the protocol tag or Params, Groups, Triggers, ... is missing + /// + [TestMethod] + public void CheckBasics() + { + // Get all tests + var allTests = TestCollector.GetAllValidateTests().Tests; + + var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string solutiondir = Directory.GetParent(currentDirectory).Parent.Parent.FullName; + + // Need to add the backslashes as it doesn't recognize it as a directory. + string fileLocation = Path.Combine(solutiondir, "Generic Tests\\"); + + List failedTests = new List(); + foreach ((IValidate test, TestAttribute attribute) in allTests) + { + if (attribute.CheckId == 1 /* Protocol Tag itself */ && attribute.Category == Category.Protocol) + { + continue; + } + + try + { + // No Protocol Tag + Generic.ValidateData data = new Generic.ValidateData + { + ExpectedResults = new List(), + FileName = "NoProtocol", + TestType = Generic.TestType.Valid, + }; + + Generic.Validate(test, data, fileLocation); + + if (attribute.Category > Category.Protocol) + { + // No Params, Groups, Triggers, Actions, Timers, ... + Generic.ValidateData data2 = new Generic.ValidateData + { + ExpectedResults = new List(), + FileName = "NoSubChildren", + TestType = Generic.TestType.Valid, + }; + + Generic.Validate(test, data2, fileLocation); + } + } + catch (AssertFailedException) + { + failedTests.Add($"{Convert.ToString(attribute.Category)}.{test.GetType().Name}"); + } + catch (NullReferenceException) + { + failedTests.Add($"NULL REF: {Convert.ToString(attribute.Category)}.{test.GetType().Name}"); + } + catch (Exception e) + { + failedTests.Add($"EXCEPTION: {attribute.Category}.{test.GetType().Name} ({e.Message})"); + } + } + + failedTests.Should().BeEmpty(); + } + + [TestMethod] + public void ValidatorChecksShouldNotStoreData() + { + var tests = TestCollector.GetAllValidateTests().Tests; + + foreach ((IValidate test, TestAttribute _) in tests) + { + var type = test.GetType(); + + var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + foreach (var fi in fields) + { + // Exception for Regex + if (fi.FieldType == typeof(Regex)) + { + continue; + } + + bool isConstant = fi.IsLiteral && !fi.IsInitOnly; + if (!isConstant) + { + Assert.Fail("Check contains fields: " + type.FullName); + } + } + + var props = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + if (props.Any()) + { + Assert.Fail("Check contains properties: " + type.FullName); + } + } + } + } + + [TestClass] + [Ignore("TODO: Fix")] + public class RoslynUnitTests + { + private static Solution solution; + private static Project valProject; + private static Project testProject; + private static Compilation compilationVal2; + private static Compilation compilationUnitTest; + + [ClassInitialize] + public static void ClassInit(TestContext context) + { + solution = Roslyn.GetSolution(); + + valProject = solution.Projects.Single(x => x.Name == "Protocol"); + testProject = solution.Projects.Single(x => x.Name == "ProtocolTests(net472)"); + + // SDK style projects don't have each file mentioned in the csproj anymore + valProject = valProject.WithAllSourceFiles(); + testProject = testProject.WithAllSourceFiles(); + + compilationVal2 = valProject.GetCompilationAsync().Result; + compilationUnitTest = testProject.GetCompilationAsync().Result; + + compilationVal2.SyntaxTrees.Should().NotBeEmpty(); + compilationUnitTest.SyntaxTrees.Should().NotBeEmpty(); + } + + [ClassCleanup] + public static void ClassClean() + { + solution = null; + + valProject = null; + testProject = null; + + compilationVal2 = null; + compilationUnitTest = null; + } + + [TestMethod] + [Ignore("TODO")] + public void Testing() + { + List errors = new List(); + + foreach (var tree in compilationVal2.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("SLDisValidator2", "Tests"))) + { + continue; + } + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + var analyzer = new TestAnalyzer(errors); + + RoslynVisitor visitor = new RoslynVisitor(analyzer); + visitor.Visit(rootSyntaxNode); + } + + if (errors.Count > 0) + { + Assert.Fail(String.Join(Environment.NewLine, errors)); + } + } + + private class TestAnalyzer : CSharpAnalyzerBase + { + private readonly List errors; + + public TestAnalyzer(List errors) + { + this.errors = errors; + } + + public override void CheckClass(ClassClass classClass) + { + if (CoverCheckClass(classClass)) + { + return; + } + + if (classClass.Access == AccessModifier.Public) + { + errors.Add($"'{classClass.Name}' has public access but shouldn't have."); + } + } + + private bool CoverCheckClass(ClassClass classClass) + { + if (!classClass.Name.StartsWith("Check") && !classClass.Name.StartsWith("CSharp")) + { + return false; + } + + if (classClass.Access != AccessModifier.Public) + { + errors.Add($"'{classClass.Name}' has no public access."); + } + + if (classClass.Attributes.All(attribute => attribute.Name != "Test")) + { + errors.Add($"'{classClass.Name}' has no {nameof(TestAttribute)}."); + } + + string[] interfaces = + { + nameof(IValidate), + nameof(ICodeFix), + nameof(ICompare) + }; + + if (!classClass.InheritanceItems.Any(x => interfaces.Contains(x))) + { + errors.Add($"'{classClass.Name}' has no valid interfaces."); + } + + string[] methods = new[] + { + nameof(IValidate.Validate), + nameof(ICodeFix.Fix), + nameof(ICompare.Compare) + }; + + var remainingMethods = classClass.Methods.Where(methodClass => !methods.Contains(methodClass.Name)) + .Select(methodClass => methodClass.Name) + .ToList(); + if (remainingMethods.Any()) + { + errors.Add($"'{classClass.Name}' has extra methods: {String.Join(", ", remainingMethods)}."); + } + + return true; + } + } + + /// + /// Check if all the unit tests are correct. + /// Will fail when an unit test is encountered that doesn't have any ExpectedResults. + /// Will fail when an unit test is encountered that has results, but is ignored. + /// Will fail when an unit test is encountered without the TestMethod attribute. + /// + [TestMethod] + public void CheckUnitTests() + { + HashSet ignoredTests = new HashSet(); + HashSet testsWithoutAttribute = new HashSet(); + HashSet emptyTests = new HashSet(); + + foreach (var tree in compilationUnitTest.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("SLDisValidatorUnitTests", "Protocol"))) + { + continue; + } + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + + // Get Namespace + string ns = Roslyn.GetNamespace(rootSyntaxNode); + + // Remove the first and second part of the namespace + ns = ns.Replace("SLDisValidatorUnitTests.", String.Empty); + + // Find Validate/Compare/CodeFix Class + foreach (ClassDeclarationSyntax @class in rootSyntaxNode.GetClasses("Validate", "Compare", "CodeFix")) + { + // Find all the UnitTest Methods + foreach (MethodDeclarationSyntax method in @class.GetMethods()) + { + bool isIgnored = false; + bool? isIgnoredWithReason = null; + bool isTestMethod = false; + bool hasErrorMessages = false; + bool isInvalidType = false; + + // Check Attributes + foreach (AttributeSyntax attr in method.GetAttributes()) + { + switch (attr.Name.ToString()) + { + case "TestMethod": + case "DataTestMethod": + isTestMethod = true; + break; + + case "Ignore": + isIgnored = attr.ArgumentList?.Arguments.Count != 1; + isIgnoredWithReason = !isIgnored; + break; + } + } + + // Check if using ErrorMessages + foreach (var item in method.DescendantNodes().OfType()) + { + var left = item.Left.ToString(); + var right = item.Right.ToString(); + + if (String.Equals(left, "ExpectedResults") && item.Right is ObjectCreationExpressionSyntax list && list.Initializer?.Expressions.Any() == true) + { + hasErrorMessages = true; + } + else if (String.Equals(left, "TestType") && String.Equals(right, "Generic.TestType.Invalid")) + { + isInvalidType = true; + } + } + + if (isTestMethod) + { + if (isIgnoredWithReason.GetValueOrDefault()) + { + // Test is ignored for a reason. This needs to be checked manual. + continue; + } + + if (hasErrorMessages && isIgnored) + { + ignoredTests.Add($"{ns}.{method.Identifier.Text}"); + } + + if (!hasErrorMessages && !isIgnored && isInvalidType) + { + emptyTests.Add($"{ns}.{method.Identifier.Text}"); + } + + // Doesn't have error messages and is ignored => New tests + } + else + { + testsWithoutAttribute.Add($"{ns}.{method.Identifier.Text}"); + } + } + } + } + + StringBuilder sb = new StringBuilder(); + + if (ignoredTests.Count > 0) + { + sb + .AppendLine($"{ignoredTests.Count} ignored UnitTests with ErrorMessages:") + .AppendLine(String.Join(Environment.NewLine, ignoredTests)) + .AppendLine(); + } + + if (testsWithoutAttribute.Count > 0) + { + sb + .AppendLine($"{testsWithoutAttribute.Count} UnitTests without TestMethod attribute:") + .AppendLine(String.Join(Environment.NewLine, testsWithoutAttribute)) + .AppendLine(); + } + + if (emptyTests.Count > 0) + { + sb + .AppendLine($"{emptyTests.Count} UnitTests without ErrorMessages:") + .AppendLine(String.Join(Environment.NewLine, emptyTests)); + } + + string message = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + /// + /// Checks if all the error messages are being used in an unit test. + /// Will fail when an error message is encountered that has no reference in an unit test. + /// Will fail when an error message is encountered that has no references at all. (Needs to be improved on) + /// TODO: Expand so it checks the ErrorMessages class. + /// + [TestMethod] + public void CheckErrorMessages() + { + HashSet unusedErrorMessages = new HashSet(); + HashSet untestedErrorMessages = new HashSet(); + + foreach (var tree in compilationVal2.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("SLDisValidator2", "Error Messages"))) + { + continue; + } + + // Get Semantic Model + var semantic = compilationVal2.GetSemanticModel(tree); + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + + // Get Namespace + string ns = Roslyn.GetNamespace(rootSyntaxNode); + + // Remove the first and second part of the namespace (So it starts with Protocol.) + ns = ns.Replace("SLDisValidator2.Tests.", String.Empty); + + string expectedClassName = ns.Substring(ns.LastIndexOf('.') + 1); + + // Find Error Class + foreach (ClassDeclarationSyntax @class in rootSyntaxNode.GetClasses("Error")) + { + // Find all the ErrorMessage Methods + foreach (MethodDeclarationSyntax method in @class.GetMethods()) + { + ISymbol symbol = Roslyn.GetSymbol(semantic, method); + var callers = SymbolFinder.FindCallersAsync(symbol, solution).Result; + + foreach (var reference in callers) + { + string errorMessageFullPath = $"{ns}.{method.Identifier.Text}"; + + if (!reference.Locations.Any()) + { + // Check if corresponding class has TestAttribute + // Find class in the same namespace with the correct name and see if it has correct attribute(s) + ClassDeclarationSyntax checkClass = Roslyn.FindClass(compilationVal2, ns, expectedClassName); + + if (checkClass == null) + { + unusedErrorMessages.Add(errorMessageFullPath); + } + else + { + // Find TestAttribute + bool hasTestAttribute = false; + foreach (AttributeSyntax attr in checkClass.GetAttributes()) + { + switch (attr.Name.ToString()) + { + case "Test": + hasTestAttribute = true; + break; + } + } + + if (hasTestAttribute) + { + unusedErrorMessages.Add(errorMessageFullPath); + } + } + } + + foreach (var location in reference.Locations) + { + // Check if reference is in UnitTest project + if (!reference.CallingSymbol.ContainingAssembly.Name.StartsWith(testProject.DefaultNamespace)) + { + continue; + } + + var testMethods = location.SourceTree.GetRoot().DescendantNodes(location.SourceSpan).OfType().ToList(); + + foreach (MethodDeclarationSyntax testMethod in testMethods) + { + // Check if it has TestMethod attribute and not the Ignore attribute? + bool isTestMethod = false; + bool isIgnored = false; + + foreach (AttributeSyntax attr in testMethod.GetAttributes()) + { + switch (attr.Name.ToString()) + { + case "TestMethod": + case "DataTestMethod": + isTestMethod = true; + break; + + case "Ignore": + // Ignore with argument means that there is a reason why it's ignored. + // These need to be looked at manually. + isIgnored = attr.ArgumentList?.Arguments.Count != 1; + break; + } + } + + if (isIgnored || !isTestMethod) + { + untestedErrorMessages.Add(errorMessageFullPath); + } + } + } + } + } + } + } + + StringBuilder sb = new StringBuilder(); + + if (untestedErrorMessages.Count > 0) + { + sb + .AppendLine($"{untestedErrorMessages.Count} ErrorMessages that aren't tested:") + .AppendLine(String.Join(Environment.NewLine, untestedErrorMessages)) + .AppendLine(); + } + + if (unusedErrorMessages.Count > 0) + { + sb + .AppendLine($"{unusedErrorMessages.Count} ErrorMessages that aren't used anywhere:") + .AppendLine(String.Join(Environment.NewLine, unusedErrorMessages)); + } + + string message = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + /// + /// Checks the checks themselves. + /// Will fail when a check is encountered that has no Test attribute but has one or more error messages. + /// Will fail when a check is encountered that doesn't match the name from the namespace. + /// [Disabled] Will fail when a check is encountered that has a Test attribute but has no error messages. + /// + [TestMethod] + public void CheckChecks() + { + HashSet inactiveChecks = new HashSet(); + HashSet wrongNamedClasses = new HashSet(); + HashSet emptyChecks = new HashSet(); + + foreach (var tree in compilationVal2.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("Protocol", "Tests"))) + { + continue; + } + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + + // Get Namespace + string ns = Roslyn.GetNamespace(rootSyntaxNode); + + // Remove the first and second part of the namespace (So it starts with Protocol.) + ns = ns.Replace("SLDisValidator2.Tests.", String.Empty); + + string expectedClassName = ns.Substring(ns.LastIndexOf('.') + 1); + + // Find Check Class + bool foundClass = false; + foreach (ClassDeclarationSyntax @class in rootSyntaxNode.GetClasses(expectedClassName)) + { + foundClass = true; + + // See if any have the TestAttribute + bool hasTestAttribute = false; + foreach (AttributeSyntax attr in @class.GetAttributes()) + { + switch (attr.Name.ToString()) + { + case "Test": + hasTestAttribute = true; + break; + } + } + + bool hasMessages = false; + foreach (var node in @class.DescendantNodes().OfType()) + { + if (node.Expression is MemberAccessExpressionSyntax maes && maes.Expression is IdentifierNameSyntax ins && + (ins.Identifier.Text == "Error" || ins.Identifier.Text == "ErrorCompare")) + { + hasMessages = true; + break; + } + } + + if (hasMessages && !hasTestAttribute) + { + inactiveChecks.Add(ns); + } + + //if (!hasMessages && hasTestAttribute) + //{ + // emptyChecks.Add(ns); + //} + } + + if (!foundClass) + { + wrongNamedClasses.Add(ns); + } + } + + StringBuilder sb = new StringBuilder(); + + if (inactiveChecks.Count > 0) + { + sb + .AppendLine($"{inactiveChecks.Count} Inactive Checks:") + .AppendLine(String.Join(Environment.NewLine, inactiveChecks)) + .AppendLine(); + } + + if (emptyChecks.Count > 0) + { + sb + .AppendLine($"{emptyChecks.Count} Empty Checks:") + .AppendLine(String.Join(Environment.NewLine, emptyChecks)) + .AppendLine(); + } + + if (wrongNamedClasses.Count > 0) + { + sb + .AppendLine($"{wrongNamedClasses.Count} WrongNamed Checks:") + .AppendLine(String.Join(Environment.NewLine, wrongNamedClasses)); + } + + string message = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + /// + /// Checks if there should be a code fix and checks if there is an unit test for it. + /// + [TestMethod] + [Ignore("Currently this one is giving errors (fix is ignored) on CodeFixes that aren't implemented yet.")] + public void CheckUnitTestsForCodeFix() + { + HashSet ignoredUnitTest = new HashSet(); + HashSet notUnitTest = new HashSet(); + HashSet messagesNotTested = new HashSet(); + + var docsUnitTest = testProject.Documents.ToImmutableHashSet(); + foreach (var tree in compilationVal2.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("Protocol", "Error Messages"))) + { + continue; + } + + // Get Semantic Model + var semantic = compilationVal2.GetSemanticModel(tree); + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + + // Get Namespace + string ns = Roslyn.GetNamespace(rootSyntaxNode); + + // Remove the first and second part of the namespace + ns = ns.Replace("SLDisValidator2.Tests.", String.Empty); + + // Find Error Class + foreach (ClassDeclarationSyntax @class in rootSyntaxNode.GetClasses("Error")) + { + // Find all the UnitTest Methods + foreach (MethodDeclarationSyntax method in @class.GetMethods()) + { + if (!CodeFixRoslyn.HasCodeFix(method)) + { + continue; + } + + ISymbol symbol = Roslyn.GetSymbol(semantic, method); + + // Only search in UnitTests + var references = SymbolFinder.FindReferencesAsync(symbol, solution, docsUnitTest).Result; + + foreach (var reference in references) + { + if (!reference.Locations.Any()) + { + continue; + } + + foreach (var location in reference.Locations) + { + var unitTestMethods = location.Location.SourceTree.GetRoot().DescendantNodesAndSelf(location.Location.SourceSpan).OfType(); + + var semanticUnitTest = compilationUnitTest.GetSemanticModel(location.Location.SourceTree); + + // Prepare list with current implemented code fixes. + List existingCodeFixes = new List(); + foreach (ClassDeclarationSyntax unitTestClass in location.Location.SourceTree.GetRoot().GetClasses()) + { + if (!String.Equals(unitTestClass.Identifier.Text, "CodeFix")) + { + continue; + } + + foreach (MethodDeclarationSyntax codeFixMethod in unitTestClass.GetMethods()) + { + bool isNewWay = codeFixMethod.ExpressionBody == null; + + string fileName = null; + + if (isNewWay) + { + foreach (var item in codeFixMethod.DescendantNodes().OfType()) + { + var left = item.Left.ToString(); + + if (String.Equals(left, "FileNameBase")) + { + fileName = item.Right.ToString().Replace("\"", String.Empty).Replace(".xml", String.Empty); + break; + } + } + } + else + { + // FileName is based on name + fileName = codeFixMethod.Identifier.Text.Split('_').Last(); + } + + bool isTestMethod = false; + bool isIgnored = false; + + foreach (AttributeSyntax attr in codeFixMethod.GetAttributes()) + { + var name = semanticUnitTest.GetTypeInfo(attr).Type.Name; + + switch (name) + { + case "TestMethod": + case "DataTestMethod": + isTestMethod = true; + break; + + case "Ignore": + // Ignore with argument means that there is a reason why it's ignored. + // These need to be looked at manually. + isIgnored = attr.ArgumentList?.Arguments.Count != 1; + break; + } + + if (isIgnored && isTestMethod) + { + ignoredUnitTest.Add(codeFixMethod.Identifier.Text); + } + + if (isTestMethod) + { + existingCodeFixes.Add(fileName); + } + else + { + notUnitTest.Add(codeFixMethod.Identifier.Text); + } + } + } + } + + foreach (MethodDeclarationSyntax testMethod in unitTestMethods) + { + bool isNewWay = testMethod.ExpressionBody == null; + + string fileName = null; + + if (isNewWay) + { + foreach (var item in testMethod.DescendantNodes().OfType()) + { + var left = item.Left.ToString(); + + if (String.Equals(left, "FileName")) + { + fileName = item.Right.ToString().Replace("\"", String.Empty).Replace(".xml", String.Empty); + break; + } + } + } + else + { + // FileName is based on name + fileName = testMethod.Identifier.Text.Split('_').Last(); + } + + // Check if CodeFix unittest exists with that FileName as name or inside the method + if (!existingCodeFixes.Contains(fileName)) + { + string text = $"{ns}.{method.Identifier.Text}"; + messagesNotTested.Add(text); + } + } + } + } + } + } + } + + StringBuilder sb = new StringBuilder(); + + if (notUnitTest.Count > 0) + { + // Error messages that are being used in the Unittest project, but not in a test method. + sb.AppendLine("CodeFix Methods without [TestMethod] attribute:") + .AppendLine(String.Join(Environment.NewLine, notUnitTest)) + .AppendLine(); + } + + if (ignoredUnitTest.Count > 0) + { + // Testmethods with Error messages that are ignored. + sb.AppendLine("Ignored CodeFix Test methods that have a CodeFix:") + .AppendLine(String.Join(Environment.NewLine, ignoredUnitTest)) + .AppendLine(); + } + + if (messagesNotTested.Count > 0) + { + sb.AppendLine("CodeFix error messages that aren't unittested yet:") + .AppendLine(String.Join(Environment.NewLine, messagesNotTested)); + } + + string result = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(result)) + { + Assert.Fail($"{Environment.NewLine}{result}"); + } + } + + /// + /// Checks if the .xml files in the project are used in UnitTests or not. + /// Will fail when an unit test is encountered that doesn't have a file. + /// Will fail when a file is encountered that doesn't have an unit test. + /// + [TestMethod] + public void CheckFiles() + { + List missingFiles = new List(); + List foundFiles = new List(); + + // Search for Protocol directory which is the root folder of all unit tests + if (!Files.TryGetProtocolDirectory(out DirectoryInfo protocolDirectory)) + { + Assert.Fail("Protocol folder not found."); + } + + // Get all XML files + List allFiles = protocolDirectory + .GetFiles("*.xml", SearchOption.AllDirectories) + .Where(x => !x.Name.EndsWith("_Results.xml")) // Maybe add .xml? Need to check + .Select(x => x.FullName.Replace($"{protocolDirectory.Parent.FullName}\\", String.Empty)) // Remove C://... part. Only keep the part starting with Protocol + .ToList(); + + allFiles.Should().NotBeEmpty(); + + foreach (var tree in compilationUnitTest.SyntaxTrees) + { + if (!tree.FilePath.Contains(Path.Combine("ProtocolTests", "Protocol"))) + { + continue; + } + + // Get Root + var rootSyntaxNode = tree.GetRootAsync().Result; + + // Get Namespace + string ns = Roslyn.GetNamespace(rootSyntaxNode); + + // Remove the first part of the namespace + ns = ns.Replace("SLDisValidatorUnitTests.", String.Empty); + string nsFolder = ns.Replace('.', '\\'); + + // Find Validate/Compare/CodeFix Class + foreach (ClassDeclarationSyntax @class in rootSyntaxNode.GetClasses("Validate", "Compare", "CodeFix")) + { + bool isValidate = String.Equals(@class.Identifier.Text, "Validate"); + bool isCompare = String.Equals(@class.Identifier.Text, "Compare"); + bool isCodeFix = String.Equals(@class.Identifier.Text, "CodeFix"); + + // Find all the UnitTest Methods + IEnumerable methodsInClass = @class.DescendantNodes().OfType().ToList(); + methodsInClass.Should().NotBeEmpty(); + foreach (MethodDeclarationSyntax method in methodsInClass) + { + string testCategory = String.Empty; + bool isNewWay = method.ExpressionBody == null; + + // Check Attributes + foreach (AttributeSyntax attr in method.GetAttributes()) + { + switch (attr.Name.ToString()) + { + case "TestCategory": + testCategory = attr.ArgumentList.Arguments[0].ToString().Replace("\"", String.Empty); + break; + } + } + + string fileName = String.Empty; + if (isNewWay) + { + foreach (var item in method.DescendantNodes().OfType()) + { + var left = item.Left.ToString(); + + if (String.Equals(left, "FileName") || String.Equals(left, "FileNameBase")) + { + fileName = item.Right.ToString().Replace("\"", String.Empty); + break; + } + else if (String.Equals(left, "TestType")) + { + testCategory = item.Right.ToString().Replace("Generic.TestType.", String.Empty); + } + } + } + else + { + // FileName is based on name + fileName = method.Identifier.Text.Split('_').Last(); + } + + // Check extension + if (isValidate) + { + fileName = fileName.EndsWith(".xml") ? fileName : $"{fileName}.xml"; + + // Create full path + string fullFilePath = Path.Combine(nsFolder, "Samples", @class.Identifier.Text, testCategory, fileName); + + if (allFiles.Contains(fullFilePath)) + { + foundFiles.Add(fullFilePath); + } + else + { + // File doesn't exists + missingFiles.Add(fullFilePath); + } + } + else if (isCompare) + { + string oldFile = $"{fileName}_Old.xml"; + string newFile = $"{fileName}_New.xml"; + + // Create full path + string fullFilePathOld = Path.Combine(nsFolder, "Samples", @class.Identifier.Text, testCategory, oldFile); + string fullFilePathNew = Path.Combine(nsFolder, "Samples", @class.Identifier.Text, testCategory, newFile); + + if (allFiles.Contains(fullFilePathOld)) + { + foundFiles.Add(fullFilePathOld); + } + else + { + // File doesn't exists + missingFiles.Add(fullFilePathOld); + } + + if (allFiles.Contains(fullFilePathNew)) + { + foundFiles.Add(fullFilePathNew); + } + else + { + // File doesn't exists + missingFiles.Add(fullFilePathNew); + } + } + else if (isCodeFix) + { + fileName = fileName.EndsWith(".xml") ? fileName : $"{fileName}.xml"; + + // Create full path + string fullFilePath = Path.Combine(nsFolder, "Samples", @class.Identifier.Text, fileName); + + if (String.Equals(@class.Identifier.Text, "CodeFix")) + { + fullFilePath = fullFilePath.Replace("CodeFix", "Codefix"); + } + + if (allFiles.Contains(fullFilePath)) + { + foundFiles.Add(fullFilePath); + } + else + { + // File doesn't exists + missingFiles.Add(fullFilePath); + } + } + } + } + } + + StringBuilder sb = new StringBuilder(); + + if (missingFiles.Count > 0) + { + sb.AppendLine($"{missingFiles.Count} Files that are used in unit tests but don't exist:") + .AppendLine(String.Join(Environment.NewLine, missingFiles)) + .AppendLine(); + } + + List excessiveFiles = allFiles.Except(foundFiles).ToList(); + + if (excessiveFiles.Count > 0) + { + sb.AppendLine($"{excessiveFiles.Count} Files that aren't used in any unit test:") + .AppendLine(String.Join(Environment.NewLine, excessiveFiles)); + } + + string result = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(result)) + { + Assert.Fail($"{Environment.NewLine}{result}"); + } + } + + /// + /// Checks if the .xml files in the project are using the correct XSD. + /// Will fail when a file doesn't have a XSD linked to it. + /// Will fail when a file doesn't have the correct XSD linked to it. + /// Will fail when a file has unknown tags or attributes + /// + [TestMethod] + public void CheckFiles_Xsd() + { + /* + * Different unit tests on which we don't want to validate via xsd: + * - Some use the 'Protocol/Connections' tag which we don't want to add to xsd because it should remain unknown to most developer but still needs to be used in some rare cases. + * - Some where we deliberately add xsd mistakes cause those also need to be covered by the Validator. + */ + string[] filesToSkip = + { + @"Protocol\CheckConnections\Samples\Compare\Valid\Valid_Syntax1To2_New.xml", + @"Protocol\CheckConnections\Samples\Compare\Valid\Valid_Syntax1To3_New.xml", + @"Protocol\CheckConnections\Samples\Compare\Valid\Valid_Syntax2To1_Old.xml", + @"Protocol\CheckConnections\Samples\Compare\Valid\Valid_Syntax3To1_Old.xml", + @"Protocol\CheckConnections\Samples\Validate\Invalid\InvalidCombinationOfSyntax1And2.xml", + @"Protocol\CheckConnections\Samples\Validate\Invalid\UnrecommendedSyntax2.xml", + @"Protocol\Groups\Group\Content\CheckContentTag\Samples\Validate\Invalid\MixedTypes.xml", + @"Protocol\Triggers\Trigger\Content\Id\CheckIdTag\Samples\Validate\Invalid\MissingTag.xml", + @"Protocol\Type\CheckTypeTag\Samples\Validate\Valid\Valid_OtherSyntax.xml" + }; + + const string NAMESPACE = "http://www.skyline.be/validatorProtocolUnitTest"; + + List filesWithMissingXsd = new List(); + List filesWithInvalidXsd = new List(); + List filesWithXsdErrors = new List(); + + // Search for Protocol directory which is the root folder of all unit tests + if (!Files.TryGetProtocolDirectory(out DirectoryInfo protocolDirectory)) + { + Assert.Fail("Protocol folder not found."); + } + + // Get all XML files + List allFiles = protocolDirectory + .GetFiles("*.xml", SearchOption.AllDirectories) + .Select(x => x.FullName) + .ToList(); + + allFiles.Should().NotBeEmpty(); + + var xsds = protocolDirectory.Parent.GetFiles("*.xsd").ToList(); + + if (xsds.Count != 1) + { + Assert.Fail("Multiple XSD files found."); + } + + var settings = new XmlReaderSettings(); + settings.Schemas.Add("http://www.skyline.be/validatorProtocolUnitTest", xsds.First().FullName); + settings.ValidationType = ValidationType.Schema; + settings.ValidationEventHandler += Settings_ValidationEventHandler; + + foreach (var filePath in allFiles) + { + string readablePath = filePath.Replace($"{protocolDirectory.Parent.FullName}\\", String.Empty); + if (readablePath == @"Protocol\CheckProtocolTag\Samples\Validate\Invalid\MissingTag.xml") + { + // Hasn't a Protocol tag, so no point in checking. + continue; + } + + if (filesToSkip.Contains(readablePath)) + { + continue; + } + + (bool success, Stream stream) = Files.ReadTextFromFile(filePath); + if (!success) + { + Assert.Fail("Failed to retrieve the file: " + filePath); + } + + try + { + using (var reader = XmlReader.Create(stream, settings)) + { + while (reader.Read()) + { + if (reader.Name != "Protocol" || reader.NodeType == XmlNodeType.EndElement) + { + // Let it continue the reading => Checking the XSD. + continue; + } + + string ns = reader.NamespaceURI; + + if (String.IsNullOrWhiteSpace(ns)) + { + filesWithMissingXsd.Add(readablePath); + continue; + } + + if (!String.Equals(ns, NAMESPACE)) + { + filesWithInvalidXsd.Add(readablePath); + } + } + } + } + catch (InvalidDataException) + { + filesWithXsdErrors.Add(readablePath); + } + catch (Exception e) + { + filesWithMissingXsd.Add("BROKEN|" + e.Message + "|" + readablePath); + } + } + + StringBuilder sb = new StringBuilder(); + + if (filesWithMissingXsd.Count > 0) + { + sb.AppendLine($"{filesWithMissingXsd.Count} Files that don't have an XSD:") + .AppendLine(" - " + String.Join(Environment.NewLine + " - ", filesWithMissingXsd)) + .AppendLine(); + } + + if (filesWithInvalidXsd.Count > 0) + { + sb.AppendLine($"{filesWithInvalidXsd.Count} Files that have a wrong XSD:") + .AppendLine(" - " + String.Join(Environment.NewLine + " - ", filesWithInvalidXsd)) + .AppendLine(); + } + + if (filesWithXsdErrors.Count > 0) + { + sb.AppendLine($"{filesWithXsdErrors.Count} Files that have XSD errors (unknown tags/attributes):") + .AppendLine(" - " + String.Join(Environment.NewLine + " - ", filesWithXsdErrors)); + } + + string result = sb.ToString().Trim(); + if (!String.IsNullOrWhiteSpace(result)) + { + Assert.Fail($"{Environment.NewLine}{result}"); + } + } + + private void Settings_ValidationEventHandler(object sender, ValidationEventArgs e) + { + string[] errorsToCatch = new[] + { + "has invalid child element", // Unknown tag + "attribute is not declared", // Unknown attribute + }; + + if (!errorsToCatch.Any(x => e.Message.Contains(x))) + { + return; + } + + throw new InvalidDataException(); + } + } + + internal static class CodeFixRoslyn + { + internal static bool HasCodeFix(MethodDeclarationSyntax method) + { + foreach (var item in method.DescendantNodes().OfType()) + { + var left = item.Left.ToString(); + + if (String.Equals(left, "HasCodeFix")) + { + Boolean.TryParse(item.Right.ToString(), out bool hasCodeFix); + return hasCodeFix; + } + } + + return false; + } + } + + internal static class Roslyn + { + internal static IEnumerable GetClasses(this SyntaxNode node) + { + return node.DescendantNodes().OfType(); + } + + internal static IEnumerable GetClasses(this SyntaxNode node, params string[] classNames) + { + return node.DescendantNodes().OfType().Where(x => classNames.Contains(x.Identifier.Text)); + } + + internal static IEnumerable GetMethods(this ClassDeclarationSyntax @class) + { + return @class.DescendantNodes().OfType(); + } + + internal static IEnumerable GetAttributes(this MethodDeclarationSyntax method) + { + return method.DescendantNodes().OfType(); + } + + internal static IEnumerable GetAttributes(this ClassDeclarationSyntax method) + { + return method.DescendantNodes().OfType(); + } + + internal static Solution GetSolution() + { + try + { + string solutionPath = GetSolutionPath(); + + // Creating a build workspace. + var workspace = MSBuildWorkspace.Create(); + + // Opening the solution. + Solution solution = workspace.OpenSolutionAsync(solutionPath).Result; + + return solution; + } + catch (ReflectionTypeLoadException tle) + { + string text = String.Join(";", tle.LoaderExceptions.Select(x => x.Message)); + throw new Exception($"ReflectionTypeLoadException with these LoaderExceptions:{Environment.NewLine}{text}"); + } + } + + private static string GetSolutionPath() + { + string solutionPath = String.Empty; + DirectoryInfo a = Directory.GetParent(Assembly.GetExecutingAssembly().Location); + while (solutionPath == String.Empty) + { + var temp = a.GetDirectories("Skyline.DataMiner.CICD.Validators", SearchOption.TopDirectoryOnly); + if (temp.Length == 1) + { + var files = temp[0].GetFiles("*.sln"); + if (files.Length > 0) + { + solutionPath = files[0].FullName; + } + else + { + a = a.Parent; + } + } + else + { + a = a.Parent; + } + } + + return solutionPath; + } + + internal static string GetNamespace(SyntaxNode rootSyntaxNode) + { + var temp = rootSyntaxNode.DescendantNodes().OfType().ToList(); + + if (temp == null || !temp.Any()) + { + return String.Empty; + } + + return temp[0].Name?.ToString() ?? String.Empty; + } + + internal static ISymbol GetSymbol(SemanticModel semantic, MethodDeclarationSyntax method) + { + return semantic.GetSymbolInfo(method).Symbol ?? semantic.GetDeclaredSymbol(method); + } + + internal static ClassDeclarationSyntax FindClass(Compilation compilationVal2, string ns, string expectedClassName) + { + foreach (var tree in compilationVal2.SyntaxTrees) + { + var rootSyntaxNode = tree.GetRootAsync().Result; + + if (!GetNamespace(rootSyntaxNode).Contains(ns)) + { + continue; + } + + var classes = rootSyntaxNode.GetClasses(expectedClassName).ToList(); + + if (classes.Count == 1) + { + return classes[0]; + } + } + + return null; + } + } + + internal static class Files + { + public static bool TryGetProtocolDirectory(out DirectoryInfo protocolDirectory) + { + bool found = false; + + var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + protocolDirectory = Directory.GetParent(currentDirectory); + while (!found) + { + var temp = protocolDirectory.GetDirectories("Protocol", SearchOption.TopDirectoryOnly); + if (temp.Length == 1) + { + // Found protocol folder + protocolDirectory = temp[0]; + found = true; + } + else + { + protocolDirectory = protocolDirectory.Parent; + } + } + + return found; + } + + public static (bool success, Stream stream) ReadTextFromFile(string pathToFile) + { + try + { + pathToFile = @"\\?\" + pathToFile; + + var fileStream = new FileStream(pathToFile, FileMode.Open, FileAccess.Read, FileShare.Read); + return (true, fileStream); + } + catch (FileNotFoundException) + { + throw; + } + } + } + + internal static class ProjectExtensions + { + private static Project AddDocuments(this Project project, IEnumerable files) + { + foreach (string file in files) + { + project = project.AddDocument(file, File.ReadAllText(file)).Project; + } + return project; + } + + private static IEnumerable GetAllSourceFiles(string directoryPath) + { + var res = Directory.GetFiles(directoryPath, "*.cs", SearchOption.AllDirectories); + + return res; + } + + public static Project WithAllSourceFiles(this Project project) + { + string projectDirectory = Directory.GetParent(project.FilePath).FullName; + var files = GetAllSourceFiles(projectDirectory); + var newProject = project.AddDocuments(files); + return newProject; + } + } +} \ No newline at end of file diff --git a/ProtocolTests/CommonTests/TestAttributeTests.cs b/ProtocolTests/CommonTests/TestAttributeTests.cs new file mode 100644 index 00000000..25d43b45 --- /dev/null +++ b/ProtocolTests/CommonTests/TestAttributeTests.cs @@ -0,0 +1,74 @@ +namespace SLDisValidatorUnitTests.CommonTests +{ + using System; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common.Attributes; + using SLDisValidator2.Common.Enums; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckProtocolTag; + + using Skyline.DataMiner.CICD.Validators.Common.Model; + using CheckId = SLDisValidator2.Tests.Protocol.CheckProtocolTag.CheckId; + + + [TestClass] + public class TestAttributeTests + { + #region GetAttribute + + [TestMethod] + public void GetAttribute_CheckProtocolTag_Valid() + { + IValidate test = new CheckProtocolTag(); + + TestAttribute attr = TestAttribute.GetAttribute(test); + + attr.Should().BeAssignableTo(typeof(TestAttribute)); + attr.Category.Should().BeEquivalentTo(Category.Protocol); + attr.CheckId.Should().Be(CheckId.CheckProtocolTag); + } + + [TestMethod] + public void GetAttribute_CheckProtocolTag_ThrowsArgumentNullException() + { + Type type = null; + Assert.ThrowsException(() => TestAttribute.GetAttribute(type)); + } + + [TestMethod] + public void GetAttribute_RandomClass_Null() + { + TestAttribute attr = TestAttribute.GetAttribute(typeof(TestAttributeTests)); + + attr.Should().BeNull(); + } + + #endregion + + #region Constructor + + [TestMethod] + public void Constructor_Valid() + { + TestAttribute attr = new TestAttribute(5, Category.Protocol); + + Assert.AreEqual((uint)5, attr.CheckId); + Assert.AreEqual(Category.Protocol, attr.Category); + Assert.AreEqual(TestOrder.Mid, attr.TestOrder); + } + + [TestMethod] + public void Constructor_Valid2() + { + TestAttribute attr = new TestAttribute(5, Category.Param, TestOrder.Post1); + + Assert.AreEqual((uint)5, attr.CheckId); + Assert.AreEqual(Category.Param, attr.Category); + Assert.AreEqual(TestOrder.Post1, attr.TestOrder); + } + + #endregion + } +} \ No newline at end of file diff --git a/ProtocolTests/CommonTests/TestCollectorTests.cs b/ProtocolTests/CommonTests/TestCollectorTests.cs new file mode 100644 index 00000000..31d3af20 --- /dev/null +++ b/ProtocolTests/CommonTests/TestCollectorTests.cs @@ -0,0 +1,62 @@ +namespace SLDisValidatorUnitTests.CommonTests +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Attributes; + using SLDisValidator2.Interfaces; + + [TestClass] + public class TestCollectorTests + { + [TestMethod] + public void GetAllValidateTests_Valid() + { + // Act + TestCollection tests = TestCollector.GetAllValidateTests(); + + // Assert + tests.Should().NotBeNull(); + tests.Tests.Should().NotBeNullOrEmpty(); + } + + [TestMethod] + public void GetAllCompareTests_Valid() + { + // Act + TestCollection tests = TestCollector.GetAllCompareTests(); + + // Assert + tests.Should().NotBeNull(); + tests.Tests.Should().NotBeNullOrEmpty(); + } + + [TestMethod] + public void GetAllTests_NoDuplicates() + { + IReadOnlyList<(IValidate Test, TestAttribute Attribute)> tests = TestCollector.GetAllValidateTests().Tests; + + HashSet<(Category, uint)> testKeys = new HashSet<(Category, uint)>(); + + foreach ((IValidate test, TestAttribute attribute) in tests) + { + string testName = test.GetType().FullName; + + if (testKeys.Add((attribute.Category, attribute.CheckId))) + { + continue; + } + + string testId = String.Join(".", (int)attribute.Category, attribute.CheckId); + Assert.Fail($"Duplicate validator test: {attribute.Category}/{testName} (ID {testId})"); + } + } + } +} \ No newline at end of file diff --git a/ProtocolTests/CommonTests/ValidationResultTests.cs b/ProtocolTests/CommonTests/ValidationResultTests.cs new file mode 100644 index 00000000..c5a325df --- /dev/null +++ b/ProtocolTests/CommonTests/ValidationResultTests.cs @@ -0,0 +1,92 @@ +namespace SLDisValidatorUnitTests.CommonTests +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + + [TestClass] + public class ValidationResultTests + { + [TestMethod] + public void ValidationResult_BubbleUp() + { + // Arrange + var subResultCritical = new ValidationResult { Severity = Severity.Critical }; + var subResultCritical2 = new ValidationResult { Severity = Severity.Critical }; + var subResultMajor = new ValidationResult { Severity = Severity.Major }; + + var result = new ValidationResult + { + Severity = Severity.BubbleUp, + SubResults = new List + { + subResultMajor, + subResultCritical, + subResultCritical2 + } + }; + + // Act + var bubbleUpResult = (ISeverityBubbleUpResult)result; + bubbleUpResult.DoSeverityBubbleUp(); + + // Assert + Assert.AreEqual(Severity.Critical, result.Severity); + } + + [TestMethod] + public void ValidationResult_BubbleUp_NoHigherSub() + { + // Arrange + var subResultWarning = new ValidationResult { Severity = Severity.Warning }; + var subResultMinor = new ValidationResult { Severity = Severity.Minor }; + + var result = new ValidationResult + { + Severity = Severity.Major, + SubResults = new List + { + subResultWarning, + subResultMinor + } + }; + + // Act + var bubbleUpResult = (ISeverityBubbleUpResult)result; + bubbleUpResult.DoSeverityBubbleUp(); + + // Assert + Assert.AreEqual(Severity.Major, result.Severity); + } + + [TestMethod] + public void ValidationResult_BubbleUp_HigherSub() + { + // Arrange + var subResultCritical = new ValidationResult { Severity = Severity.Critical }; + var subResultMinor = new ValidationResult { Severity = Severity.Minor }; + + var result = new ValidationResult + { + Severity = Severity.Major, + SubResults = new List + { + subResultCritical, + subResultMinor + } + }; + + // Act + var bubbleUpResult = (ISeverityBubbleUpResult)result; + bubbleUpResult.DoSeverityBubbleUp(); + + // Assert + Assert.AreEqual(Severity.Critical, result.Severity); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoProtocol.xml b/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoProtocol.xml new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoProtocol.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoSubChildren.xml b/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoSubChildren.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Generic Tests/Samples/Validate/Valid/NoSubChildren.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Generic.cs b/ProtocolTests/Generic.cs new file mode 100644 index 00000000..4840c1b9 --- /dev/null +++ b/ProtocolTests/Generic.cs @@ -0,0 +1,646 @@ +namespace SLDisValidatorUnitTests +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Runtime.CompilerServices; + using System.Text; + using System.Threading; + + using FluentAssertions; + using FluentAssertions.Equivalency; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Skyline.DataMiner.CICD.Common; + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Models.Protocol.Read.Interfaces; + using Skyline.DataMiner.CICD.Parsers.Common.Xml; + using Skyline.DataMiner.CICD.Validators.Common.Data; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisUnitTestsShared; + using SLDisValidator2; + using SLDisValidator2.Common; + using SLDisValidator2.Common.Attributes; + using SLDisValidator2.Interfaces; + + internal static class Generic + { + #region Actual Check Methods + + public static void CheckCategory(IRoot test, Category category) + { + // Get Category from test + TestAttribute testAttribute = (TestAttribute)Attribute.GetCustomAttribute(test.GetType(), typeof(TestAttribute)); + + if (testAttribute == null) + { + Assert.Fail("No TestAttribute defined on " + test.GetType().Name); + } + else + { + Assert.AreEqual(category, testAttribute.Category); + } + } + + public static void CheckId(IRoot test, uint checkId) + { + // Get CheckId from test + TestAttribute testAttribute = (TestAttribute)Attribute.GetCustomAttribute(test.GetType(), typeof(TestAttribute)); + + if (testAttribute == null) + { + Assert.Fail("No TestAttribute defined on " + test.GetType().Name); + } + else + { + Assert.AreEqual(checkId, testAttribute.CheckId); + } + } + + /// + /// Will run all the checks and filter out all the error messages that aren't part of the specified test. + /// + /// Test that will be used to filter out all the other results. + /// Unit test data. + /// Path to where this class is located. Don't fill in manually unless you know what you are doing. + internal static void FullValidate(IValidate test, ValidateData validate, [CallerFilePath] string pathToClassFile = "") + { + // Arrange + Validator validator = new Validator(); + string code = GetValidate(validate, pathToClassFile); + var qactionCompilationModel = ProtocolTestsHelper.GetQActionCompilationModel(code); + TestAttribute testAttribute = TestAttribute.GetAttribute(test); + string idFilter = $"{(int)testAttribute.Category}.{testAttribute.CheckId}."; + + IProtocolInputData input = new ProtocolInputData(code, qactionCompilationModel); + + // Act + ValidatorSettings settings = GetValidatorSettingsFromEnvironmentData(validate.IsSkylineUser); + IList results = validator.RunValidate(input, settings, CancellationToken.None); + + // Modify results + results = results.Where(result => result.FullId.StartsWith(idFilter)).ToList(); + + foreach (var result in results) + { + if (result.Severity == Severity.BubbleUp && result.SubResults.Count == 0) + { + Assert.Fail($"Result ({result.FullId}) as BubbleUp as severity but has no sub results."); + } + } + + string testName = test.GetType().Name; + if (testName.StartsWith("CSharp")) + { + foreach (var result in results) + { + if (result.PositionNode is IQActionsQAction && !(result is ICSharpValidationResult)) + { + // TODO: Check if there is a way with the ReferenceNode & PositionNode & probably a list with errormessages that need to be excluded? + // Cause PositionNode can also be the attribute instead of the QAction itself? => Something to review. + //Assert.Fail($"Result in test '{testName}' doesn't contain CSharp information"); + } + else if (!(result.PositionNode is IQActionsQAction) && result is ICSharpValidationResult) + { + Assert.Fail($"CSharp information found in result of test '{testName}' but the position node is not a QAction"); + } + } + } + + AssertResults(results, validate.ExpectedResults); + } + + internal static void Validate(IValidate test, ValidateData validate, [CallerFilePath] string pathToClassFile = "") + { + // Arrange. + ValidatorContext context = GetValidatorContext(validate, pathToClassFile); + + // Act. + List results = test.Validate(context); + foreach (var result in results) + { + if (result is ISeverityBubbleUpResult bubbleUpResult) + { + bubbleUpResult.DoSeverityBubbleUp(); + } + + if (result.Severity == Severity.BubbleUp && result.SubResults.Count == 0) + { + Assert.Fail($"Result ({result.FullId}) as BubbleUp as severity but has no sub results."); + } + } + + foreach (var result in validate.ExpectedResults) + { + if (result is ISeverityBubbleUpResult bubbleUpResult) + { + bubbleUpResult.DoSeverityBubbleUp(); + } + + if (result.Severity == Severity.BubbleUp && result.SubResults.Count == 0) + { + Assert.Fail($"Expected result ({result.FullId}) as BubbleUp as severity but has no sub results."); + } + } + + // Assert. + string testName = test.GetType().Name; + + if (testName.StartsWith("CSharp")) + { + foreach (var result in results) + { + if (result.PositionNode is IQActionsQAction && !(result is ICSharpValidationResult)) + { + // TODO: Check if there is a way with the ReferenceNode & PositionNode & probably a list with errormessages that need to be excluded? + // Cause PositionNode can also be the attribute instead of the QAction itself? => Something to review. + // Assert.Fail($"Result in test '{testName}' doesn't contain CSharp information"); + } + else if (!(result.PositionNode is IQActionsQAction) && result is ICSharpValidationResult) + { + Assert.Fail($"CSharp information found in result of test '{testName}' but the position node is not a QAction"); + } + } + } + + AssertResults(results, validate.ExpectedResults); + } + + internal static void Compare(ICompare test, CompareData compare, [CallerFilePath] string pathToClassFile = "") + { + // Arrange. + MajorChangeCheckContext context = GetMajorChangeCheckContext(compare, pathToClassFile); + + // Act. + List results = test.Compare(context); + foreach (var result in results.OfType()) + { + result.DoSeverityBubbleUp(); + } + + foreach (var result in compare.ExpectedResults.OfType()) + { + result.DoSeverityBubbleUp(); + } + + // Assert. + AssertResults(results, compare.ExpectedResults); + } + + internal static void Fix(IRoot test, FixData data, [CallerFilePath] string pathToClassFile = "") + { + // Execute Validate first to receive the results. + + var (model, document, code) = GetValidatorContextData(data, pathToClassFile); + + var qactionCompilationModel = ProtocolTestsHelper.GetQActionCompilationModel(model, code); + + ProtocolInputData input = new ProtocolInputData(model, document, qactionCompilationModel); + ValidatorSettings settings = GetValidatorSettingsFromEnvironmentData(data.IsSkylineUser); + ValidatorContext validatorContext = new ValidatorContext(input, settings); + + if (test is IValidate valTest && test is ICodeFix fixTest) + { + var validateResults = valTest.Validate(validatorContext); + + StringBuilder sb = new StringBuilder(); + + if (validateResults.Count == 0) + { + sb.AppendLine("No results from the test!"); + } + + // Recreate each time the CodeFixContent, but with the same editProtocol (so all the changes are done on the same protocol) + + var (editDocument, editProtocol) = GetCodeFixContextData(document, model); + + bool hasCodeFix = false; + FixRecursive(settings, fixTest, validateResults, sb, editDocument, editProtocol, ref hasCodeFix); + + if (!hasCodeFix) + { + Assert.Fail($"No CodeFix for this result"); + } + + string message = sb.ToString(); + + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail(message); + } + + // Compare the fixed protocol + string fixedCode = GetFix(data, pathToClassFile); + + var fixedData = new ProtocolInputData(fixedCode); + var wrongData = new ProtocolInputData(editProtocol.EditNode.GetXml()); + + // WARNING! Currently there is an issue in FluentAssertions regarding the scenario for ArrayOptions, HTTP, ... + // When you have a class that inherits from IEnumerable (down the line) and has properties itself, then those properties won't be checked by FluentAssertions. + // https://github.com/fluentassertions/fluentassertions/issues/860 + wrongData.Model.Protocol.Should().BeEquivalentTo(fixedData.Model.Protocol, ExcludePropertiesForFix); + + // Backup check for the situation where a tag inherits IReadableList and has properties. + ////editProtocol.EditNode.GetXml().Should().BeEquivalentTo(fixedCode); + // TODO: Can't use the above as that formats the xml differently. (Also doesn't add the xml declaration) + } + else + { + Assert.Fail("Check isn't IValidate or ICodeFix!"); + } + + Assert.IsTrue(true); + } + + private static void FixRecursive(ValidatorSettings settings, ICodeFix fixTest, List validateResults, StringBuilder sb, Skyline.DataMiner.CICD.Parsers.Common.XmlEdit.XmlDocument editDocument, Skyline.DataMiner.CICD.Models.Protocol.Edit.Protocol editProtocol, ref bool hasCodeFix) + { + foreach (var validateResult in validateResults) + { + if (validateResult.SubResults != null && validateResult.SubResults.Count > 0) + { + FixRecursive(settings, fixTest, validateResult.SubResults, sb, editDocument, editProtocol, ref hasCodeFix); + } + + if (!validateResult.HasCodeFix) + { + continue; + } + + hasCodeFix = true; + + // Get CodeFixContext + CodeFixContext codeFixContext = new CodeFixContext(editDocument, editProtocol, (ValidationResult)validateResult, settings); + + var fixResult = fixTest.Fix(codeFixContext); + + if (!fixResult.Success) + { + sb.AppendLine($"CodeFix on '{validateResult.Description}' failed with message: {fixResult.Message}"); + } + } + } + + private static void AssertResults(IList results, IList expectedResults) + { + List errors = new List(); + + AssertResults(errors, results, expectedResults); + + if (errors.Count > 0) + { + string s = Environment.NewLine + String.Join(Environment.NewLine, errors); + Assert.Fail(s); + } + } + + private static void AssertResults(ICollection errors, IList results, IList expectedResults, string parent = null) + { + // Sort so it's easier to compare later on + results = results.OrderBy(result => result.FullId).ThenBy(result => result.Description).ToList(); + expectedResults = expectedResults.OrderBy(result => result.FullId).ThenBy(result => result.Description).ToList(); + + if (results.Count != expectedResults.Count) + { + errors.Add($"[{parent}] {MismatchAmountResults(results, expectedResults)}"); + return; + } + + // Go over every single result and check if they match + for (int i = 0; i < results.Count; i++) + { + IValidationResult result = results[i]; + IValidationResult expectedResult = expectedResults[i]; + + string first = String.Empty; + if (parent != null) + { + first = $"{parent} - "; + } + + string key = $"{first}{result.FullId}"; + + try + { + result.Should().BeEquivalentTo(expectedResult, ExcludePropertiesForGeneric); + } + catch (Exception e) + { + string filteredMessage = e.Message; + int index = e.Message.IndexOf("With configuration:", StringComparison.OrdinalIgnoreCase); + if (index != -1) + { + filteredMessage = e.Message.Remove(index); + } + + errors.Add($"[{key}] {filteredMessage}"); + } + + // Rerun for the subresults + AssertResults(errors, result.SubResults, expectedResult.SubResults, key); + } + } + + #endregion Actual Check Methods + + #region Misc + + public static EquivalencyAssertionOptions ExcludePropertiesForGeneric(EquivalencyAssertionOptions options) + { + options.ComparingByMembers(); + options.ComparingEnumsByName(); + options.IgnoringCyclicReferences(); + options.AllowingInfiniteRecursion(); + options.Excluding(x => x.Position) + .Excluding(x => x.SubResults) + .Excluding(x => x.Line) + .Excluding(x => x.PositionNode) + .Excluding(x => x.ReferenceNode) + .Excluding(x => x.SelectedMemberInfo.MemberType == typeof(IValidate)) // Test + .Excluding(x => x.SelectedMemberPath.EndsWith("ExtraData")); + + return options; + } + + public static EquivalencyAssertionOptions ExcludePropertiesForErrorMessages(EquivalencyAssertionOptions options) + { + options.ComparingByMembers(); + options.ComparingEnumsByName(); + options.IgnoringCyclicReferences(); + options.AllowingInfiniteRecursion(); + options.Excluding(x => x.Position) + .Excluding(x => x.Line) + .Excluding(x => x.PositionNode) + .Excluding(x => x.ReferenceNode) + .Excluding(x => x.CheckId) + .Excluding(x => x.Category) + .Excluding(x => x.ErrorId) + .Excluding(x => x.FullId) + .Excluding(x => x.Source) + .Excluding(x => x.HowToFix) + .Excluding(x => x.ExampleCode) + .Excluding(x => x.SelectedMemberInfo.MemberType == typeof(IValidate)) // Test + .Excluding(x => x.SelectedMemberPath.EndsWith("ExtraData")); + + return options; + } + + private static EquivalencyAssertionOptions ExcludePropertiesForFix(EquivalencyAssertionOptions options) + { + options.Excluding(x => x.SelectedMemberInfo.MemberType == typeof(IProtocolModel)) // Model + .Excluding(x => x.SelectedMemberInfo.MemberType == typeof(XmlElement)) // ReadNode + .Excluding(x => x.SelectedMemberInfo.MemberType == typeof(XmlAttribute)) // ReadAttribute + .Excluding(x => x.SelectedMemberInfo.MemberType == typeof(XmlCDATA)) // CodeCDATA (QActions) + .Excluding(x => x.SelectedMemberPath.Contains("Parent")); + + options.IgnoringCyclicReferences(); + options.ComparingEnumsByName(); + options.AllowingInfiniteRecursion(); + return options; + } + + internal static (string code, bool success) ReadTextFromFile(string pathToFile) + { + try + { + pathToFile = @"\\?\" + pathToFile; + + string code; + var fileStream = new FileStream(pathToFile, FileMode.Open, FileAccess.Read, FileShare.Read); + using (var textReader = new StreamReader(fileStream)) + { + code = textReader.ReadToEnd(); + } + + return (code, true); + } + catch (FileNotFoundException) + { + return (String.Format("Missing file:{0}{1}", Environment.NewLine, pathToFile), false); + } + } + + #endregion Misc + + #region Dynamic Classes + + public class ValidateData + { + public TestType TestType { get; set; } + + /// + /// Gets or sets the file name base. Make sure to add it without the extension! + /// + public string FileName { get; set; } + + public List ExpectedResults { get; set; } + + public bool IsSkylineUser { get; set; } = true; + } + + public class CompareData + { + public TestType TestType { get; set; } + + /// + /// Gets or sets the file name base. Make sure to add it without the extension! + /// + public string FileNameBase { get; set; } + + public List ExpectedResults { get; set; } + + public bool IsSkylineUser { get; set; } = true; + } + + public class FixData + { + /// + /// Gets or sets the file name base. Make sure to add it without the extension! + /// + public string FileNameBase { get; set; } + + public bool IsSkylineUser { get; set; } = true; + } + + #endregion + + #region Get From Samples + + private static string GetValidate(ValidateData data, string pathToClassFile) + { + string validatePath = Path.Combine(Path.GetDirectoryName(pathToClassFile), "Samples", "Validate"); + + string type = data.TestType == TestType.Valid ? "Valid" : "Invalid"; + + string fileName = data.FileName.EndsWith(".xml") ? data.FileName : $"{data.FileName}.xml"; + string filePath = Path.Combine(validatePath, type, fileName); + (string code, bool success) = ReadTextFromFile(filePath); + + return success ? code : throw new FileNotFoundException(code); + } + + private static string GetFix(FixData data, string pathToClassFile) + { + string path = Path.Combine(Path.GetDirectoryName(pathToClassFile), "Samples", "Codefix"); + + string fileName = data.FileNameBase.EndsWith(".xml") ? data.FileNameBase : $"{data.FileNameBase}.xml"; + string filePath = Path.Combine(path, fileName); + (string code, bool success) = ReadTextFromFile(filePath); + + return success ? code : throw new FileNotFoundException(code); + } + + private static (string oldP, string newP) GetCompare(CompareData data, string pathToClassFile) + { + string path = Path.Combine(Path.GetDirectoryName(pathToClassFile), "Samples", "Compare"); + + string type = data.TestType == TestType.Valid ? "Valid" : "Invalid"; + + string oldProtocol = Path.Combine(path, type, $"{data.FileNameBase}_Old.xml"); + string newProtocol = Path.Combine(path, type, $"{data.FileNameBase}_New.xml"); + (string oldP, bool successOld) = ReadTextFromFile(oldProtocol); + (string newP, bool successNew) = ReadTextFromFile(newProtocol); + + if (!successOld) + { + throw new FileNotFoundException(oldP); + } + + if (!successNew) + { + throw new FileNotFoundException(newP); + } + + return (oldP, newP); + } + + #endregion + + #region Get Context + + private static ValidatorContext GetValidatorContext(ValidateData data, string pathToClassFile) + { + ValidatorContext context; + + string code = GetValidate(data, pathToClassFile); + + try + { + var qactionCompilationModel = ProtocolTestsHelper.GetQActionCompilationModel(code); + var input = new ProtocolInputData(code, qactionCompilationModel); + + context = new ValidatorContext(input, GetValidatorSettingsFromEnvironmentData(data.IsSkylineUser)); + } + catch (Exception e) + { + throw new FormatException($"Sample Code could not be parsed by the {nameof(context)} object. FileName: {data.FileName}{Environment.NewLine}{e}"); + } + + return context; + } + + private static MajorChangeCheckContext GetMajorChangeCheckContext(CompareData data, string pathToClassFile = "") + { + MajorChangeCheckContext context; + + (string oldP, string newP) = GetCompare(data, pathToClassFile); + + try + { + var inputOld = new ProtocolInputData(oldP); + var inputNew = new ProtocolInputData(newP); + + context = new MajorChangeCheckContext(inputNew, inputOld, GetValidatorSettingsFromEnvironmentData(data.IsSkylineUser)); + } + catch (Exception e) + { + throw new FormatException($"Sample Code could not be parsed by the {nameof(context)} object. FileName: {data.FileNameBase}{Environment.NewLine}{e}"); + } + + return context; + } + + private static (Skyline.DataMiner.CICD.Parsers.Common.XmlEdit.XmlDocument editDocument, Skyline.DataMiner.CICD.Models.Protocol.Edit.Protocol editProtocol) GetCodeFixContextData(XmlDocument document, IProtocolModel model) + { + var editDocument = new Skyline.DataMiner.CICD.Parsers.Common.XmlEdit.XmlDocument(document); + var xmlElement = editDocument.Element["protocol"]; + var editProtocol = ProtocolTestsHelper.GetEditProtocol(model, xmlElement); + + return (editDocument, editProtocol); + } + + private static (IProtocolModel model, XmlDocument document, string code) GetValidatorContextData(FixData data, string pathToClassFile) + { + ValidateData validateData = new ValidateData + { + TestType = TestType.Invalid, + FileName = data.FileNameBase, + }; + + string code = GetValidate(validateData, pathToClassFile); + + try + { + var a = new ProtocolInputData(code); + + return (a.Model, a.Document, code); + } + catch (Exception e) + { + throw new FormatException($"Sample Code could not be parsed. FileName: {data.FileNameBase}{Environment.NewLine}{e}"); + } + } + + private static ValidatorSettings GetValidatorSettingsFromEnvironmentData(bool isSkylineUser) + { + ValidatorSettings validatorSettings = new ValidatorSettings(); + + if (isSkylineUser) + { + validatorSettings.ExpectedProvider = "Skyline Communications"; + } + + return validatorSettings; + } + + #endregion + + #region Enums + + public enum TestType + { + Valid, + Invalid, + } + + #endregion + + #region Custom Error Logging + + private static string MismatchAmountResults(ICollection results, ICollection expectedResults) + { + var a = expectedResults.Count > results.Count ? "only " : " "; + StringBuilder sb = new StringBuilder() + .AppendLine($"Expected {expectedResults.Count} results, but found {a}{results.Count}.") + .AppendLine("Expected results:"); + + foreach (var item in expectedResults) + { + sb.AppendLine($"\t- [{item.FullId}] {item.Description}"); + } + + sb.AppendLine() + .AppendLine("Actual results:"); + + foreach (var item in results) + { + sb.AppendLine($"\t- [{item.FullId}] {item.Description}"); + } + + return sb.ToString(); + } + + #endregion + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/ConditionalTests.cs b/ProtocolTests/Helpers/ConditionalTests.cs new file mode 100644 index 00000000..bf69b102 --- /dev/null +++ b/ProtocolTests/Helpers/ConditionalTests.cs @@ -0,0 +1,179 @@ +namespace SLDisValidatorUnitTests.Helpers +{ + using System; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Moq; + + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Models.Protocol.Read.Interfaces; + using Skyline.DataMiner.CICD.Models.Protocol.Read.Linking; + + using SLDisValidator2.Helpers.Conditions; + using SLDisValidator2.Tests.Protocol.Groups.Group.Condition.CheckConditionTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + + [TestClass] + public class ConditionalTests + { + [TestMethod] + [DoNotParallelize] + [DataRow("id:10 > 1", "")] + [DataRow("id:65008 > 1", "")] + [DataRow("(id:10 + 10) > 20", "")] + [DataRow("((id:10 * 10) * id:11) > 20", "")] + [DataRow("(id:12 + \"efg\") == \"defefgabc\"", "")] + [DataRow("((id:12 + \"efg\") + \"abc\") == \"defefgabc\"", "")] + [DataRow("((id:10 * 20) > 100) AND (\"defefgabc\" > id:12)", "")] + [DataRow("(\"defefgabc\" > id:12) AND ((id:10 * 20) > 100)", "")] + [DataRow("(-10 > id:12) AND (id:10 + 20 + 20 > 100)", "")] + [DataRow("(+10.5 > id:10) AND (id:10 + 20 + 20 > 100)", "")] + [DataRow("(id:12 == \"\")", "")] + [DataRow("(id:12 + \"A\") == \"Inhibit\"", "")] + public void ValidConditionsSucceed(string inputValue, string expectedOutput) + { + // Arrange + var parameter10InterPreteType = new Mock(); + parameter10InterPreteType.Setup(p => p.Value).Returns(Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamInterpretType.Double); + var parameter10Interprete = new Mock(); + parameter10Interprete.Setup(p => p.Type).Returns(parameter10InterPreteType.Object); + var parameter10 = new Mock(); + parameter10.Setup(p => p.Interprete).Returns(parameter10Interprete.Object); + + var parameter11InterPreteType = new Mock(); + parameter11InterPreteType.Setup(p => p.Value).Returns(Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamInterpretType.Double); + var parameter11Interprete = new Mock(); + parameter11Interprete.Setup(p => p.Type).Returns(parameter11InterPreteType.Object); + var parameter11 = new Mock(); + parameter11.Setup(p => p.Interprete).Returns(parameter11Interprete.Object); + + var parameter12InterPreteType = new Mock(); + parameter12InterPreteType.Setup(p => p.Value).Returns(Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamInterpretType.String); + var parameter12Interprete = new Mock(); + parameter12Interprete.Setup(p => p.Type).Returns(parameter12InterPreteType.Object); + var parameter12 = new Mock(); + parameter12.Setup(p => p.Interprete).Returns(parameter12Interprete.Object); + + var parameter10Object = parameter10.Object; + var parameter11Object = parameter11.Object; + var parameter12Object = parameter12.Object; + + var protocolModel = new Mock(); + protocolModel.Setup(p => p.TryGetObjectByKey(Mappings.ParamsById, "10", out parameter10Object)).Returns(true); + protocolModel.Setup(p => p.TryGetObjectByKey(Mappings.ParamsById, "11", out parameter11Object)).Returns(true); + protocolModel.Setup(p => p.TryGetObjectByKey(Mappings.ParamsById, "12", out parameter12Object)).Returns(true); + + string result = ""; + var addInvalidConditionError = new Action(message => result = Error.InvalidCondition(null, null, null, inputValue, message, "1").Description); + var addInvalidParamIdError = new Action(message => result = Error.NonExistingId(null, null, null, message, "1").Description); + var addConditionCanBeSimpliefiedWarning = new Action(() => result = Error.ConditionCanBeSimplified(null, null, null, inputValue, "1").Description); + + Conditional conditional = new Conditional(addInvalidConditionError, addInvalidParamIdError, addConditionCanBeSimpliefiedWarning); + + // Act + conditional.ParseConditional(inputValue); + conditional.CheckConditional(protocolModel.Object); + + // Assert + result.Should().Be(expectedOutput); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("(id:10 + 10) > 20" , "Tag 'Group/Condition' references a non-existing 'Param' with PID '10'. Group ID '1'.")] + [DataRow("((id:10 * 10) * id:11) > 20" , "Tag 'Group/Condition' references a non-existing 'Param' with PID '10'. Group ID '1'.")] + [DataRow("(id:12 + \"efg\") == \"defefgabc\"", "Tag 'Group/Condition' references a non-existing 'Param' with PID '12'. Group ID '1'.")] + public void ConditionsReferencingNonexistingParametersFail(string inputValue, string expectedOutput) + { + // Arrange + var protocolModel = new Mock(); + + string result = ""; + var addInvalidConditionError = new Action(message => result = Error.InvalidCondition(null, null, null, inputValue, message, "1").Description); + var addInvalidParamIdError = new Action(message => result = Error.NonExistingId(null, null, null, message, "1").Description); + var addConditionCanBeSimpliefiedWarning = new Action(() => result = Error.ConditionCanBeSimplified(null, null, null, inputValue, "1").Description); + + Conditional conditional = new Conditional(addInvalidConditionError, addInvalidParamIdError, addConditionCanBeSimpliefiedWarning); + + // Act + conditional.ParseConditional(inputValue); + conditional.CheckConditional(protocolModel.Object); + + // Assert + result.Should().Be(expectedOutput); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("id: 10 > 1", "Invalid condition 'id: 10 > 1'. Reason 'Invalid id: operand: 'id:'.'. Group ID '1'.")] // Invalid id: placeholder use: no space allowed after 'id:'. + [DataRow("id:10 == \"test", "Invalid condition 'id:10 == \"test'. Reason 'Unexpected condition member block: '\"test'.'. Group ID '1'.")] // Missing quote for string literal. + [DataRow("(id:10 + 10 > 20", "Invalid condition '(id:10 + 10 > 20'. Reason 'Number of opening parentheses '(' does not match number of closing parentheses ')'.'. Group ID '1'.")] // Missing closing parenthesis. + [DataRow("id:10 + 10) > 20", "Invalid condition 'id:10 + 10) > 20'. Reason 'Unexpected condition member block: '10)'.'. Group ID '1'.")] // Missing opening parenthesis. + [DataRow("((id:12 + \"efg\") + 10) == \"defefgabc\"", "Invalid condition '((id:12 + \"efg\") + 10) == \"defefgabc\"'. Reason 'The addition operator ('+') must be used with operands of the same type.'. Group ID '1'.")] // Invalid operands for + operator: cannot mix double and string operand + [DataRow("((id:12 + \"efg\") + id:10) == \"defefgabc\"", "Invalid condition '((id:12 + \"efg\") + id:10) == \"defefgabc\"'. Reason 'The addition operator ('+') must be used with operands of the same type.'. Group ID '1'.")] + [DataRow("((id:10 + 20) + id:12) == \"defefgabc\"", "Invalid condition '((id:10 + 20) + id:12) == \"defefgabc\"'. Reason 'The addition operator ('+') must be used with operands of the same type.'. Group ID '1'.")] + [DataRow("id:10 * 20", "Invalid condition 'id:10 * 20'. Reason 'Condition 'id:10 * 20' is not a boolean expression.'. Group ID '1'.")] // Not a boolean expression. + [DataRow("id:10 AND (\"defefgabc\" > id:12)", "Invalid condition 'id:10 AND (\"defefgabc\" > id:12)'. Reason 'Not all operands of a conditional AND or OR expression are boolean expressions.'. Group ID '1'.")] + [DataRow("(id:10 * 20) AND (\"defefgabc\" > id:12)", "Invalid condition '(id:10 * 20) AND (\"defefgabc\" > id:12)'. Reason 'Not all operands of a conditional AND or OR expression are boolean expressions.'. Group ID '1'.")] + [DataRow("(\"defefgabc\" > id:12) AND (id:10 * 20)", "Invalid condition '(\"defefgabc\" > id:12) AND (id:10 * 20)'. Reason 'Not all operands of a conditional AND or OR expression are boolean expressions.'. Group ID '1'.")] + [DataRow("(\"defefgabc\" > id:12) AND (id:10 * 20 > 20 < 10)", "Invalid condition '(\"defefgabc\" > id:12) AND (id:10 * 20 > 20 < 10)'. Reason 'Multiple relational or equality operators were detected in a single condition member.'. Group ID '1'.")] // Multiple relational or equation operators in a single condition member. + [DataRow("(\"defefgabc\" > \"acb\") AND (id:10 * 20 > 20)", "Condition '(\"defefgabc\" > \"acb\") AND (id:10 * 20 > 20)' can be simplified. Group ID '1'.")] // Constant condition member. + [DataRow("(\"defefgabc\" > id:12) AND (20 > 40)", "Condition '(\"defefgabc\" > id:12) AND (20 > 40)' can be simplified. Group ID '1'.")] + [DataRow("(\"defefgabc\" > id:12) AND (id:10 * 20 > 20 < id:10)", "Invalid condition '(\"defefgabc\" > id:12) AND (id:10 * 20 > 20 < id:10)'. Reason 'Multiple relational or equality operators were detected in a single condition member.'. Group ID '1'.")] // Condition member has multiple equality or relational operators. + [DataRow("(\"defefgabc\" > id:12) AND (id:10 + * 20 + 20 > 100)", "Invalid condition '(\"defefgabc\" > id:12) AND (id:10 + * 20 + 20 > 100)'. Reason 'Missing operator or operand detected.'. Group ID '1'.")] // Condition member has operators without operands (or stated differently, multiple operators are used in sequence). + [DataRow("(\"defefgabc\" id:12) AND (id:10 * 10 > 100)", "Invalid condition '(\"defefgabc\" id:12) AND (id:10 * 10 > 100)'. Reason 'Missing operator or operand detected.'. Group ID '1'.")] // Condition member has operands missing operator. + [DataRow("(> id:12) AND (id:10 * 10 > 100)", "Invalid condition '(> id:12) AND (id:10 * 10 > 100)'. Reason 'Missing operator or operand detected.'. Group ID '1'.")] + [DataRow("(\"defefgabc\" > ) AND (id:10 * 10 > 100)", "Invalid condition '(\"defefgabc\" > ) AND (id:10 * 10 > 100)'. Reason 'Missing operator or operand detected.'. Group ID '1'.")] + [DataRow("(\"defefgabc\" >) AND (id:10 * 10 > 100)", "Invalid condition '(\"defefgabc\" >) AND (id:10 * 10 > 100)'. Reason 'Missing operator or operand detected.'. Group ID '1'.")] // Same as previous but without space in first condition member. + [DataRow("(id:12 != \"[]\" OR id:12 != empty)AND id:10 == 0", "Invalid condition '(id:12 != \"[]\" OR id:12 != empty)AND id:10 == 0'. Reason 'Invalid formatted condition detected.'. Group ID '1'.")] // No space between AND and preceeding closing parenthesis. + [DataRow("(id:10 == \"\")", "Invalid condition '(id:10 == \"\")'. Reason 'Unexpected empty string used in combination with other operand that is a double.'. Group ID '1'.")] + [DataRow("(id:12 + \"A\") == (\"Inhibit\")", "Condition '(id:12 + \"A\") == (\"Inhibit\")' can be simplified. Group ID '1'.")] + [DataRow("(\"defefgabc\" > \"acb\") AND (id:123 * 20 > 20)", "Condition '(\"defefgabc\" > \"acb\") AND (id:123 * 20 > 20)' can be simplified. Group ID '1'.")] + public void InvalidConditionReturnsErrorIndicatingError(string inputValue, string expectedOutput) + { + // Arrange + var parameter10InterPreteType = new Mock(); + parameter10InterPreteType.Setup(p => p.Value).Returns(Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamInterpretType.Double); + var parameter10Interprete = new Mock(); + parameter10Interprete.Setup(p => p.Type).Returns(parameter10InterPreteType.Object); + var parameter10 = new Mock(); + parameter10.Setup(p => p.Interprete).Returns(parameter10Interprete.Object); + + var parameter12InterPreteType = new Mock(); + parameter12InterPreteType.Setup(p => p.Value).Returns(Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamInterpretType.String); + var parameter12Interprete = new Mock(); + parameter12Interprete.Setup(p => p.Type).Returns(parameter12InterPreteType.Object); + var parameter12 = new Mock(); + parameter12.Setup(p => p.Interprete).Returns(parameter12Interprete.Object); + + var parameter10Object = parameter10.Object; + var parameter12Object = parameter12.Object; + + var protocolModel = new Mock(); + protocolModel.Setup(p => p.TryGetObjectByKey(Mappings.ParamsById, "10", out parameter10Object)).Returns(true); + protocolModel.Setup(p => p.TryGetObjectByKey(Mappings.ParamsById, "12", out parameter12Object)).Returns(true); + + string result = ""; + var addInvalidConditionError = new Action(message => result = Error.InvalidCondition(null, null, null, inputValue, message, "1").Description); + var addInvalidParamIdError = new Action(message => result = Error.NonExistingId(null, null, null, message, "1").Description); + var addConditionCanBeSimpliefiedWarning = new Action(() => result = Error.ConditionCanBeSimplified(null, null, null, inputValue, "1").Description); + + Conditional conditional = new Conditional(addInvalidConditionError, addInvalidParamIdError, addConditionCanBeSimpliefiedWarning); + + // Act + conditional.ParseConditional(inputValue); + + if(result == String.Empty) + { + conditional.CheckConditional(protocolModel.Object); + } + + // Assert + result.Should().Be(expectedOutput); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/HelperTests.cs b/ProtocolTests/Helpers/HelperTests.cs new file mode 100644 index 00000000..c17c6a26 --- /dev/null +++ b/ProtocolTests/Helpers/HelperTests.cs @@ -0,0 +1,57 @@ +namespace SLDisValidatorUnitTests.Helpers +{ + using System.Collections.Generic; + using System.Linq; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Tests; + + [TestClass] + public class HelperTests + { + [TestMethod] + [DoNotParallelize] + [DataRow("ABC:ABC")] + [DataRow("ABC-ABC")] + [DataRow("ABCABC")] + public void CheckParamNameInvalidChars(string text) + { + // ToArray() is required to make the fluentAssertions thread safe when having multiple DataRows + char[] invalidCharacters = Helper.CheckInvalidChars(text, ParamHelper.RestrictedParamNameChars).ToArray(); + + invalidCharacters.Should().BeEmpty(); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("ABCABC", '>')] + [DataRow("ABC:ABC", ':')] + [DataRow("ABC\"ABC", '"')] + [DataRow("ABC/ABC", '/')] + [DataRow("ABC\\ABC", '\\')] + [DataRow("ABC|ABC", '|')] + [DataRow("ABC?ABC", '?')] + [DataRow("ABC*ABC", '*')] + [DataRow("ABC;ABC", ';')] + [DataRow("ABC°ABC", '°')] + [DataRow("ABCABC", null)] + public void CheckInvalidChars_ProtocolName(string text, char? invalidChar) + { + // ToArray() is required to make the fluentAssertions thread safe when having multiple DataRows + char[] invalidCharacters = Helper.CheckInvalidChars(text, ProtocolHelper.RestrictedProtocolNameChars).ToArray(); + + if (invalidChar == null) + { + invalidCharacters.Should().BeEmpty(); + } + else + { + invalidCharacters.Should().ContainSingle().Which.Should().BeEquivalentTo(invalidChar); + } + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/ParamHelperTests.cs b/ProtocolTests/Helpers/ParamHelperTests.cs new file mode 100644 index 00000000..ccff4476 --- /dev/null +++ b/ProtocolTests/Helpers/ParamHelperTests.cs @@ -0,0 +1,72 @@ +namespace SLDisValidatorUnitTests.Helpers +{ + using System.Collections.Generic; + using System.Linq; + + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Tests; + + [TestClass] + public class ParamHelperTests + { + [TestMethod] + [DoNotParallelize] + [DataRow("ABCABC", new[] { '>'})] + [DataRow("ABC:ABC", new[] { ':'})] + [DataRow("ABC-ABC", new[] { '-' })] + [DataRow("ABC\"ABC", new[] { '"' })] + [DataRow("ABC/ABC", new[] { '/' })] + [DataRow("ABC\\ABC", new[] { '\\' })] + [DataRow("ABC|ABC", new[] { '|'})] + [DataRow("ABC?ABC", new[] { '?'})] + [DataRow("ABC*ABC", new[] { '*'})] + [DataRow("ABC;ABC", new[] { ';'})] + [DataRow("ABC°ABC", new[] { '°' })] + [DataRow("AC*ABC", new[] { '<', '>', '*' })] + [DataRow("ABCABC", null)] + [DataRow("ABC_ABC", null)] + public void CheckParamNameUnrecommendedChars(string text, IReadOnlyList invalidChars) + { + // ToArray() is required to make the fluentAssertions thread safe when having multiple DataRows + object[] unrecommendedCharacters = ParamHelper.GetParamNameUnrecommendedChars(text).ToArray(); + + if (invalidChars == null) + { + unrecommendedCharacters.Should().BeEmpty(); + } + else + { + unrecommendedCharacters.Should().BeEquivalentTo(invalidChars); + } + } + + [TestMethod] + [DoNotParallelize] + [DataRow("ABC ABC", "[Whitespace]")] + public void CheckParamNameUnrecommendedChars_SpecialCases(string text, string invalidText) + { + // ToArray() is required to make the fluentAssertions thread safe when having multiple DataRows + object[] unrecommendedCharacters = ParamHelper.GetParamNameUnrecommendedChars(text).ToArray(); + + unrecommendedCharacters.Should().ContainSingle().Which.Should().BeEquivalentTo(invalidText); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("ABCABC", "ABC_ABC")] + [DataRow("ABC:ABC", "ABC_ABC")] + [DataRow("ABC-ABC", "ABC_ABC")] + [DataRow("ABCABC", "ABCABC")] + [DataRow("ABC ABC", "ABC ABC")] + [DataRow("ABC_ABC", "ABC_ABC")] + public void CheckReplaceParamNameInvalidChars(string text, string newText) + { + string paramName = ParamHelper.ReplaceParamNameInvalidChars(text); + + paramName.Should().BeEquivalentTo(newText); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/ProtocolHelperTests.cs b/ProtocolTests/Helpers/ProtocolHelperTests.cs new file mode 100644 index 00000000..315c59e1 --- /dev/null +++ b/ProtocolTests/Helpers/ProtocolHelperTests.cs @@ -0,0 +1,54 @@ +namespace SLDisValidatorUnitTests.Helpers +{ + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Tests; + + [TestClass] + public class ProtocolHelperTests + { + [TestMethod] + [DoNotParallelize] + [DataRow("ABCABC", "ABC_ABC")] + [DataRow("ABC:ABC", "ABC_ABC")] + [DataRow("ABC\"ABC", "ABC_ABC")] + [DataRow("ABC/ABC", "ABC_ABC")] + [DataRow("ABC\\ABC", "ABC_ABC")] + [DataRow("ABC|ABC", "ABC_ABC")] + [DataRow("ABC?ABC", "ABC_ABC")] + [DataRow("ABC*ABC", "ABC_ABC")] + [DataRow("ABC;ABC", "ABC_ABC")] + [DataRow("ABC°ABC", "ABC_ABC")] + [DataRow("ABCABC", "ABCABC")] + public void CheckReplaceProtocolNameInvalidChars_DefaultChar(string text, string newText) + { + string protocolName = ProtocolHelper.ReplaceProtocolNameInvalidChars(text); + + protocolName.Should().BeEquivalentTo(newText); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("ABCABC", "ABC-ABC")] + [DataRow("ABC:ABC", "ABC-ABC")] + [DataRow("ABC\"ABC", "ABC-ABC")] + [DataRow("ABC/ABC", "ABC-ABC")] + [DataRow("ABC\\ABC", "ABC-ABC")] + [DataRow("ABC|ABC", "ABC-ABC")] + [DataRow("ABC?ABC", "ABC-ABC")] + [DataRow("ABC*ABC", "ABC-ABC")] + [DataRow("ABC;ABC", "ABC-ABC")] + [DataRow("ABC°ABC", "ABC-ABC")] + [DataRow("ABCABC", "ABCABC")] + public void CheckReplaceProtocolNameInvalidChars_CustomChar(string text, string newText) + { + string protocolName = ProtocolHelper.ReplaceProtocolNameInvalidChars(text, "-"); + + protocolName.Should().BeEquivalentTo(newText); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/Software Parameters/DataMiner Element Control Protocol/Protocol.xml b/ProtocolTests/Helpers/Software Parameters/DataMiner Element Control Protocol/Protocol.xml new file mode 100644 index 00000000..7597f4aa --- /dev/null +++ b/ProtocolTests/Helpers/Software Parameters/DataMiner Element Control Protocol/Protocol.xml @@ -0,0 +1,6972 @@ + + + DataMiner Element Control Protocol + 1.0.0.1 + Skyline Communications + + + + + internal + auto + + + + + + + + + TIMEOUT + Communication state + read + + unsigned number + double + + + true + + + true + 1 + 0 + + + discreet + + + 0 + Responding + + + 1 + Not Responding + + + + + + STATE + Element State + read + + other + string + + + true + + + Element Control + 0 + 0 + + + + + true + + + + New client registered + New client registered + read + + other + string + + + true + + + + true + + + + New Element connection + New Element connection + read + + other + string + + + true + + + Element Control + 1 + 1 + + + + + true + + + + Client disconnected + Client disconnected + read + + other + string + + + true + + + Element Control + 2 + 1 + + + + + true + + + + Element disconnection + Element disconnection + read + + other + string + + + true + + + + true + + + + Parameter descriptions + Parameter descriptions + read + + other + string + + + true + + + Element Control + 2 + 0 + + + + + true + + + + Link file + Link file + read + + other + string + + + true + + + + true + + + + Edited + Edited + read + + other + string + + + true + + + Element Control + 3 + 0 + + + + + true + + + + Element created + Element created + read + + other + string + + + true + + + Element Control + 3 + 1 + + + + + true + + + + Deleted + Deleted + read + + other + string + + + true + + + Element Control + 4 + 1 + + + + + true + + + + + Alarm Template Assigned + Alarm Template Assigned + read + + other + string + + + true + + + Element Control + 6 + 0 + + + + + true + + + + Database optimization + Database optimization + read + + other + string + + + true + + + Element Control + 7 + 0 + + + + + true + + + + Database stack + Database stack + read + + other + string + + + true + + + Element Control + 7 + 1 + + + + + true + + + + Mobile gateway + Mobile gateway + read + + other + string + + + true + + + + Element Control + 8 + 0 + + + + + true + + + + Service path changed + Service path changed + read + + other + string + + + true + + + + true + + + + Startup DataMiner Agent + Startup DataMiner Agent + read + + other + string + + + true + + + + true + + + + Protocol Added + Protocol Added + read + + other + string + + + true + + + + true + + + + Protocol Deleted + Protocol Deleted + read + + other + string + + + true + + + + true + + + + Protocol Replaced + Protocol Replaced + read + + other + string + + + true + + + + true + + + + Alarm Template Added + Alarm Template Added + read + + other + string + + + true + + + + true + + + + Alarm Template Deleted + Alarm Template Deleted + read + + other + string + + + true + + + + true + + + + Alarm Template Edited + Alarm Template Edited + read + + other + string + + + true + + + + true + + + + Script Added + Script Added + read + + other + string + + + true + + + + true + + + + Script Deleted + Script Deleted + read + + other + string + + + true + + + + true + + + + Script Edited + Script Edited + read + + other + string + + + true + + + + true + + + + Information Added + Information Added + read + + other + string + + + true + + + + true + + + + Information Deleted + Information Deleted + read + + other + string + + + true + + + + true + + + + Information Edited + Information Edited + read + + other + string + + + true + + + + true + + + + SMS Received + SMS Received + read + + other + string + + + true + + + + true + + + + SMS Sent + SMS Sent + read + + other + string + + + true + + + Element Control + 8 + 1 + + + + + true + + + + GSM Signal Strength + GSM Signal Strength + read + + other + double + + + true + + + Element Control + 9 + 0 + + + + + true + + + + GSM General Information + GSM General Information + read + + other + string + + + true + + + Element Control + 9 + 1 + + + + + true + + + + Trending Template Edited + Trending Template Edited + read + + other + string + + + true + + + Element Control + 10 + 0 + + + + + true + + + + Trending Template Added + Trending Template Added + read + + other + string + + + true + + + Element Control + 10 + 1 + + + + + true + + + + Trending Template Deleted + Trending Template Deleted + read + + other + string + + + true + + + Element Control + 11 + 1 + + + + + true + + + + VDX Deleted + VDX Deleted + read + + other + string + + + true + + + Element Control + 12 + 0 + + + + + true + + + + VDX Added + VDX Added + read + + other + string + + + true + + + Element Control + 12 + 1 + + + + + true + + + + VDX Edited + VDX Edited + read + + other + string + + + true + + + Element Control + 13 + 0 + + + + + true + + + + Trending Template Assigned + Trending Template Assigned + read + + other + string + + + true + + + Element Control + 13 + 1 + + + + + true + + + + Element Connections Edited + Element Connections Edited + read + + other + string + + + true + + + Element Control + 14 + 0 + + + + + true + + + + Security Edited + Security Edited + read + + other + string + + + true + + + Element Control + 14 + 1 + + + + + true + + + + Views Edited + Views Edited + read + + other + string + + + true + + + Element Control + 15 + 0 + + + + + true + + + + Database settings edited + Database settings edited + read + + other + string + + + true + + + Element Control + 15 + 1 + + + + + true + + + + SNMP-Managers edited + SNMP-Managers edited + read + + other + string + + + true + + + Element Control + 16 + 0 + + + + + true + + + + Start Element Failed + Start Element Failed + read + + other + string + + + true + + + Element Control + 16 + 1 + + + + + true + + + + Load Element Failed + Load Element Failed + read + + other + string + + + true + + + + true + + + + Table Repair + Table Repair + read + + other + string + + + true + + + Element Control + 17 + 0 + + + + + true + + + + Set Parameter + Set Parameter + read + + other + string + + + true + + + Element Control + 17 + 1 + + + + + true + + + + Import elements + Import elements + read + + other + string + + + true + + + Element Control + 18 + 0 + + + + + true + + + + Information.xml assigned + Information.xml assigned + read + + other + string + + + true + + + Element Control + 18 + 1 + + + + + true + + + + Start synchronization + Start synchronization + read + + other + string + + + true + + + Element Control + 19 + 0 + + + + + true + + + + Synchronization finished + Synchronization finished + read + + other + string + + + true + + + Element Control + 19 + 1 + + + + + true + + + + DataMiner Agent found + DataMiner Agent found + read + + other + string + + + true + + + Element Control + 20 + 0 + + + + + true + + + + DataMiner Agent lost + DataMiner Agent lost + read + + other + string + + + true + + + Element Control + 20 + 1 + + + + + true + + + + Error during synchronization + Error during synchronization + read + + other + string + + + true + + + Element Control + 21 + 0 + + + + + true + + + + No connection with DMA + Connection lost with DMA + read + + other + string + + + true + + + Element Control + 21 + 1 + + + + + true + + + + Connection established with DMA + Connection re-established with DMA + read + + other + string + + + true + + + Element Control + 22 + 0 + + + + + true + + + + Automation info + Automation info + read + + other + string + + + true + + + Element Control + 22 + 1 + + + + + true + + + + Scheduler info + Scheduler info + read + + other + string + + + true + + + Element Control + 23 + 0 + + + + + true + + + + Script execution failure + Script execution failure + read + + other + string + + + true + + + Element Control + 23 + 1 + + + + + true + + + + Load Protocol Failed + Load Protocol Failed + read + + other + string + + + true + + + Element Control + 24 + 0 + + + + + true + + + + Startup error + Startup error + read + + other + string + + + true + + + Element Control + 24 + 1 + + + + + true + + + + Scheduled Task Created + Scheduled Task Created + read + + other + string + + + true + + + Element Control + 25 + 1 + + + + + true + + + + Scheduled Task Updated + Scheduled Task Updated + read + + other + string + + + true + + + + true + + + + Scheduled Task Deleted + Scheduled Task Deleted + read + + other + string + + + true + + + + true + + + + Notification + Notification + read + + other + string + + + true + + + Element Control + 26 + 0 + + + + + true + + + + Stop DataMiner + Stop DataMiner + read + + other + string + + + true + + + Element Control + 26 + 1 + + + + + true + + + + DataMiner run-time + DataMiner run-time + read + + other + string + + + true + + + Element Control + 27 + 0 + + + + + true + + + + Task started + Task started + read + + other + string + + + true + + + Element Control + 27 + 1 + + + + + true + + + + Client notification + Client notification + read + + other + string + + + true + + + Element Control + 28 + 0 + + + + + true + + + + Set as production protocol + Set as production protocol + read + + other + string + + + true + + + Element Control + 28 + 1 + + + + + true + + + + Element masked + Element masked + read + + other + string + + + true + + + Element Control + 29 + 0 + + + + + true + + + + Element unmasked + Element unmasked + read + + other + string + + + true + + + Element Control + 29 + 1 + + + + + true + + + + DMS Revisioned + DMS Revisioned + read + + other + string + + + true + + + Element Control + 30 + 0 + + + + + true + + + + Backup status + Backup status + read + + other + string + + + true + + + Element Control + 30 + 1 + + + + + true + + + + SNMPAgent + SNMPAgent + read + + other + string + + + true + + + Element Control + 31 + 0 + + + + + true + + + + File changed + File changed + read + + other + string + + + true + + + Element Control + 31 + 1 + + + + + true + + + + Filter added + Filter added + read + + other + string + + + true + + + Element Control + 32 + 0 + + + + + true + + + + Filter edited + Filter edited + read + + other + string + + + true + + + Element Control + 32 + 1 + + + + + true + + + + Filter deleted + Filter deleted + read + + other + string + + + true + + + Element Control + 33 + 0 + + + + + true + + + + User settings + User settings + read + + other + string + + + true + + + Element Control + 33 + 1 + + + + + true + + + + Document added + Document added + read + + other + string + + + true + + + Element Control + 34 + 0 + + + + + true + + + + Document edited + Document edited + read + + other + string + + + true + + + + true + + + + Document removed + Document removed + read + + other + string + + + true + + + Element Control + 34 + 1 + + + + + true + + + + Script started + Script started + read + + other + string + + + true + + + Element Control + 35 + 0 + + + + + true + + + + Linked to + Linked to + read + + other + string + + + true + + + Element Control + 35 + 1 + + + + + true + + + + State change + State change + read + + other + string + + + true + + + Element Control + 36 + 0 + + + + + true + + + + Service added + Service added + read + + other + string + + + true + + + Element Control + 36 + 1 + + + + + true + + + + Redundancy Group added + Redundancy Group added + read + + other + string + + + true + + + Element Control + 37 + 0 + + + + + true + + + + Preset Created + Preset Created + read + + other + string + + + true + + + Element Control + 38 + 0 + + + + + true + + + + Preset Edited + Preset Edited + read + + other + string + + + true + + + Element Control + 39 + 0 + + + + + true + + + + Preset Renamed + Preset Renamed + read + + other + string + + + true + + + Element Control + 40 + 0 + + + + + true + + + + Preset Deleted + Preset Deleted + read + + other + string + + + true + + + Element Control + 41 + 0 + + + + + true + + + + Real-time TCP Socket + Real-time TCP Socket + read + + other + string + + + true + + + Element Control + 41 + 1 + + + + + true + + + + Database + Database + read + + other + string + + + true + + + Element Control + 42 + 0 + + + + + true + + + + Correlation engine + Correlation engine + read + + other + string + + + true + + + Element Control + 42 + 1 + + + + + true + + + + Alarm colors edited + Alarm colors edited + read + + other + string + + + true + + + Element Control + 43 + 0 + + + + + true + + + + IP Settings + IP Settings + read + + other + string + + + true + + + Element Control + 43 + 1 + + + + + true + + + + Spectrum Script Edited + Spectrum Script Edited + read + + other + string + + + true + + + Element Control + 44 + 0 + + + + + true + + + + Spectrum Script Deleted + Spectrum Script Deleted + read + + other + string + + + true + + + Element Control + 44 + 1 + + + + + true + + + + Spectrum Monitor Edited + Spectrum Monitor Edited + read + + other + string + + + true + + + Element Control + 45 + 0 + + + + + true + + + + Spectrum Monitor Deleted + Spectrum Monitor Deleted + read + + other + string + + + true + + + Element Control + 45 + 1 + + + + + true + + + + Entered Prioritized Mode + Entered Prioritized Mode + read + + other + string + + + true + + + Element Control + 46 + 0 + + + + + true + + + + Left Prioritized Mode + Left Prioritized Mode + read + + other + string + + + true + + + Element Control + 46 + 1 + + + + + true + + + + Spectrum Script Added + Spectrum Script Added + read + + other + string + + + true + + + Element Control + 47 + 0 + + + + + true + + + + Spectrum Monitor Created + Spectrum Monitor Created + read + + other + string + + + true + + + Element Control + 47 + 1 + + + + + true + + + + Mobile Gateway lost contact with DataMiner + Mobile Gateway lost contact with DataMiner + read + + other + string + + + true + + + Element Control + 48 + 0 + + + + + true + + + + Spectrum Monitor Failure + Spectrum Monitor Failure + read + + other + string + + + true + + + Element Control + 48 + 1 + + + + + true + + + + Collaboration Message + Collaboration Message + read + + other + string + + + true + + + Element Control + 49 + 1 + + + + + true + + + + DataMiner Failover Status + DataMiner Failover Status + read + + other + string + + + true + + + Element Control + 50 + 0 + + + + + true + + + + Service Templates + Service Templates + read + + other + string + + + true + + + Element Control + 51 + 0 + + + + + true + + + + Client Eventing + Client Eventing + read + + other + string + + + true + + + Element Control + 51 + 1 + + + + + true + + + + Latch reset info + Latch reset info + read + + other + string + + + true + + + Element Control + 52 + 1 + + + + + true + + + + Annotations Edited + Annotations Edited + read + + other + string + + + true + + + Element Control + 53 + 0 + + + + + true + + + + Asset Manager Configuration + Asset Manager Configuration + read + + other + string + + + true + + + Element Control + 53 + 1 + + + + + true + + + + Map Configuration + Map Configuration + read + + other + string + + + true + + + Element Control + 54 + 0 + + + + + true + + + + SNMP Manager + SNMP Manager + read + + other + string + + + true + + + Element Control + 55 + 0 + + + + + true + + + + Redundancy Group State + Redundancy Group State + read + + other + string + + + true + + + Element Control + 56 + 0 + + + + + true + + + + VDX Assigned + VDX Assigned + read + + other + string + + + true + + + Element Control + 57 + 0 + + + + + true + + + + Export Progress + Export Progress + read + + other + string + + + true + + + Element Control + 58 + 0 + + + + + true + + + + Import Progress + Import Progress + read + + other + string + + + true + + + Element Control + 59 + 0 + + + + + true + + + + Connectivity Engine + Connectivity Engine + read + + other + string + + + true + + + + true + + + + Resource Manager info + Resource Manager info + read + + other + string + + + true + + + Element Control + 60 + 0 + + + + + true + + + + Tickets + Tickets + read + + other + string + + + true + + + Element Control + 61 + 0 + + + + + true + + + + Notes + Notes + read + + other + string + + + true + + + Element Control + 62 + 0 + + + + + true + + + + Profile Manager info + Profile Manager info + read + + other + string + + + true + + + Element Control + 60 + 0 + + + + + true + + + + Spectrum trace recording started + Spectrum trace recording started + read + + other + string + + + true + + + Element Control + 63 + 0 + + + + + true + + + + Spectrum trace recording stopped + Spectrum trace recording stopped + read + + other + string + + + true + + + Element Control + 64 + 0 + + + + + true + + + + Alarm Group + Alarm Group + read + + other + string + + + true + + + Element Control + 65 + 0 + + + + + true + + + + KQI Engine + KQI Engine + read + + other + string + + + true + + + Element Control + 66 + 1 + + + + + true + + + + DataMiner Connectivity Framework + DataMiner Connectivity Framework + read + + other + string + + + true + + + Element Control + 67 + 1 + + + + + true + + + + Authentication Failure + Authentication Failure + read + + other + string + + + true + + + Element Control + 68 + 0 + + + + + true + + + + Sounds + Sounds + read + + other + string + + + true + + + Element Control + 68 + 1 + + + + + true + + + + Disk Watcher + Disk Watcher + read + + other + string + + + true + + + + true + + + + Licensing + Licensing + read + + other + string + + + true + + + true + + + + Protocol Function Manager info + Protocol Function Manager info + read + + other + string + + + true + + + Element Control + 60 + 0 + + + + + true + + + + lock_status + [Lock status] + read + + unsigned number + fixed + 1 + double + + + true + + + General parameters + 0 + 0 + + + + + true + + + discreet + + + Locked + 1 + + + Unlocked + 0 + + + Unlocked with force + 2 + + + + + + lock_status + [Lock status] + write + + unsigned number + fixed + 1 + double + + + true + + + General parameters + 0 + 0 + + + + + true + + + discreet + + + Lock + 1 + + + Unlock + 0 + + + Force unlock + 2 + + + + + + lock_owner + [Lock owner] + read + + other + next param + string + + + true + + + General parameters + 1 + 0 + + + + + true + + + string + + + + TotalNbrOfActiveAlarms + [Number of active alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 2 + 0 + + + + + true + + + number + + + + TotalNbrOfActiveCriticalAlarms + [Number of active Critical alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 3 + 0 + + + + + true + + + number + + + + TotalNbrOfActiveMajorAlarms + [Number of active Major alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 4 + 0 + + + + + true + + + number + + + + TotalNbrOfActiveMinorAlarms + [Number of active Minor alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 5 + 0 + + + + + true + + + number + + + + TotalNbrOfActiveWarningAlarms + [Number of active Warning alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 6 + 0 + + + + + true + + + number + + + + Element alarm state + [Element alarm state] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 7 + 0 + + + + + true + + + discreet + + + Not monitored + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + Masked + 9 + + + Error + 10 + + + + + + TotalNbrOfActiveMaskedAlarms + [Number of masked alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + General parameters + 8 + 0 + + + + + true + + + number + + + + Nbr of alarms + [Nbr of alarms] + array + + + + + + + + + + + + + + other + next param + double + + + true + + + General parameters + 9 + 0 + + + + + table + + + + __PID + [PID] + read + + other + next param + string + + + true + + + string + + + + __Nbr_of_alarms + [Number of alarms] + read + + unsigned number + fixed + 4 + double + + + true + + + number + + + + __Start_time_first_alarm + [Start time first alarm] + read + + other + next param + string + + + true + + + string + + + + __Start_time_last_alarm + [Start time last alarm] + read + + other + next param + string + + + true + + + string + + + + __Reset_alarms + [Reset alarms for PID] + write + + other + next param + string + + + true + + 0 + 64499 + + + + number + + + + __Increment_PID + [Increment PID] + write + + unsigned number + fixed + 4 + double + + + false + + 0 + 64499 + + + + number + + + + __Timer_base + [Timer base] + read + + double + fixed + 8 + double + + + true + 2 + + + General parameters + 12 + 0 + + + + + number + + + + __Timer_base + [Timer base] + write + + double + fixed + 8 + double + + + true + 2 + + + General parameters + 12 + 0 + + + + 0 + 10 + + + + number + + + + __Properties + [Properties] + array + + + + + + + + + + other + next param + double + + + true + + + General parameters + 13 + 0 + + + + + table + + + + __Property name + [Property name] + read + + other + next param + string + + + true + + + string + + + + __Property type + [Property type] + read + + other + next param + string + + + true + + + string + + + + __Property value + [Property value] + read + + other + next param + string + + + true + + + true + + + string + + + + __Read out properties + [Read properties] + read + + unsigned number + fixed + 1 + double + + + number + + + + __Property value + [Property value] + write + + other + next param + string + + + true + + + string + + + + __Element id + [Element id] + elementid + + other + next param + string + + + true + + + string + + + + __Element RCA Level + [RCA Level] + read + + signed number + fixed + 4 + double + + + N/A + -1 + + + + + true + + + General parameters + 10 + 0 + + + + + number + + + + __Last_reset_time_pi_alarm + [Reset time alarms] + read + + other + next param + string + + + true + + + string + + + + __Clients_connected + [Clients connected] + read + + signed number + fixed + 4 + double + + + true + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + + + + __Element_Priority + [Priority Level] + read + + signed number + fixed + 4 + double + + + Not used + 0 + + + + + true + + + General parameters + 11 + 0 + + + + + true + + + number + + + + __Element_Priority + [Priority Level] + write + + signed number + fixed + 4 + double + + + true + + + General parameters + 11 + 0 + + + + 1 + 1000 + + + + true + + + number + + + Not used + 0 + + + + + + __Element Latch state + [Latch state] + read + + signed number + fixed + 4 + double + + + N/A + -1 + + + + + true + + + General parameters + 9 + 0 + + + + + discreet + + + Not monitored + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + Masked + 9 + + + Error + 10 + + + Reset + 1000 + + + + + + __Element Latch state + [Reset element latch] + write + + other + next param + string + + + true + + + General parameters + 9 + 0 + + + + + button + + + Reset + 1000 + + + + + + __Communication info + [Communication Info] + array + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + General parameters + 15 + 0 + + + + + table + + + + __Connection_ID + [Connection ID] + read + + other + next param + string + + + true + + + string + + + + __Communication_Device_RTT + [Device RTT] + read + + signed number + fixed + 4 + double + + + true + ms + + + number + + + + __Communication_Device_Iteration + [Device Iterations] + read + + signed number + fixed + 4 + double + + + true + + + number + + + + __Communication_DataMiner_TX + [DataMiner TX] + read + + double + fixed + 8 + double + + + true + kbps + 4 + + + number + + + + __Communication_DataMiner_RX + [DataMiner RX] + read + + double + fixed + 8 + double + + + true + kbps + 4 + + + number + + + + __Communication_Session_DataMiner_TX + [Session DataMiner TX] + read + + double + fixed + 8 + double + + + 2 + true + MB + + + number + + + + __Communication_Device_DataMiner_RX + [Session DataMiner RX] + read + + double + fixed + 8 + double + + + 2 + true + MB + + + number + + + + __Communication_Message_Drops + [Device Message drops] + read + + signed number + fixed + 4 + double + + + true + + + number + + + + __Communication_info_state + [Communication info state] + read + + other + next param + double + + + true + + + General parameters + 14 + 0 + + + + + discreet + + + Follow overall setting + 0 + + + Enabled + 1 + + + Disabled + 2 + + + + + + __Communication_info_state + [Communication info state] + write + + other + next param + double + + + true + + + General parameters + 14 + 0 + + + + + discreet + + + Follow overall setting + 0 + + + Enabled + 1 + + + Disabled + 2 + + + + + + __Communication_Connection_State + [Connection State] + read + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Responding + 0 + + + Not Responding + 1 + + + Undefined + 2 + + + Connected + 3 + + + Disconnected + 4 + + + + + + Execution Verification + Execution Verification + read + + other + string + + + true + + + 56 + 0 + + + + + true + + + + __Connection_Name + [Connection Name] + read + + numeric text + next param + string + + + true + + + string + + + + __Communication_Connection_Type + [Connection Type] + read + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + SNMP + 1 + + + Serial + 2 + + + Smart-Serial + 3 + + + Virtual + 4 + + + GPIB + 5 + + + OPC + 6 + + + SLA + 7 + + + SNMPv2 + 8 + + + SNMPv3 + 9 + + + HTTP + 10 + + + + + + __Interfaces + [Interfaces] + array + + + + + + + + + + + + + + + + other + next param + double + + + true + + + DataMiner Connectivity Framework + 0 + 0 + + + + + table + + + + __Interface_ID + [Interface ID] + read + + other + next param + string + + + true + + + string + + + + __Interface_Name + [Interface Name] + read + + other + next param + string + + + true + + + string + + + + __Interface_Type + [Interface Type] + read + + other + next param + string + + + true + + + discreet + + + in + 0 + + + out + 1 + + + inout + 2 + + + generic + 3 + + + + + + __Interface_Alarm_State + [Interface Alarm State] + read + + other + next param + string + + + true + + + true + + + discreet + + + Not monitored + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + Masked + 9 + + + Error + 10 + + + + + + __Interface_Properties + [Interface Properties] + array + + + + + + + + + + + + + + other + next param + double + + + true + + + DataMiner Connectivity Framework + 2 + 0 + + + + + table + + + + __Interface_Property_name + [Interface Property name] + read + + other + next param + string + + + true + + + string + + + + __Interface_Property_type + [Interface Property type] + read + + other + next param + string + + + true + + + string + + + + __Interface_Property_value + [Interface Property value] + read + + other + next param + string + + + true + + + string + + + + __Interface_Property_value + [Interface Property value] + write + + other + next param + string + + + true + + + string + + + + __Interface_Property_link + [Interface Property link] + read + + other + next param + string + + + true + + + string + + + + __Connections + [Connections] + array + + + + + + + + + + other + next param + double + + + true + + + DataMiner Connectivity Framework + 6 + 0 + + + + + table + + + + __Connections_ID + [Connections ID] + read + + other + next param + string + + + true + + + string + + + + __Source_Interface + [Source Interface] + read + + other + next param + string + + + true + + + string + + + + __Destination_Interface + [Destination Interface] + read + + other + next param + string + + + true + + + string + + + + __Source_Interface + [Source Interface] + write + + other + next param + string + + + true + + + string + + + + __Destination_Interface + [Destination Interface] + write + + other + next param + string + + + true + + + string + + + + __Connection_Properties + [Connection Properties] + array + + + + + + + + + + + + + + other + next param + double + + + true + + + DataMiner Connectivity Framework + 10 + 0 + + + + + table + + + + __Connection_Property_name + [Connection Property name] + read + + other + next param + string + + + true + + + string + + + + __Connection_Property_type + [Connection Property type] + read + + other + next param + string + + + true + + + string + + + + __Connection_Property_value + [Connection Property value] + read + + other + next param + string + + + true + + + string + + + + __Connection_Property_value + [Connection Property value] + write + + other + next param + string + + + true + + + string + + + + __Connection_Property_link + [Connection Property link] + read + + other + next param + string + + + true + + + string + + + + __Add_Connection + [Add Connection] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 8 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + + + + __Add_Interface_Property + [Add Interface Property] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 4 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + + + + __Add_Connection_Property + [Add Connection Property] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 12 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + + + + __Interface_Property_to_delete + [Interface Property to delete] + read + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 3 + 0 + + + + + number + + + + __Connection_to_delete + [Connection to delete] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 7 + 0 + + + + 0 + 4294967295 + + + + number + + + + __Connection_to_delete + [Connection to delete] + read + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 7 + 0 + + + + + number + + + + __Connection_Property_to_delete + [Connection Property to delete] + read + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 11 + 0 + + + + 0 + 4294967295 + + + + number + + + + __Connection_Property_to_delete + [Connection Property to delete] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 11 + 0 + + + + 0 + 4294967295 + + + + number + + + + __Interface_Property_ID + [Interface Property ID] + read + + other + next param + string + + + true + + + string + + + + __Connection_Property_ID + [Connection Property ID] + read + + other + next param + string + + + true + + + string + + + + __Interface_Property_to_delete + [Interface Property to delete] + write + + unsigned number + fixed + 4 + double + + + true + + + DataMiner Connectivity Framework + 3 + 0 + + + + + number + + + + __Interface_Property_name + [Interface Property name] + write + + other + next param + string + + + true + + + string + + + + __Interface_Property_type + [Interface Property type] + write + + other + next param + string + + + true + + + string + + + + __Connection_Property_name + [Connection Property name] + write + + other + next param + string + + + true + + + string + + + + __Connection_Property_type + [Connection Property type] + write + + other + next param + string + + + true + + + string + + + + __Destination_DataMiner/Element + [Destination DataMiner/Element] + read + + other + next param + string + + + true + + + string + + + + __Destination_DataMiner/Element + [Destination DataMiner/Element] + write + + other + next param + string + + + true + + + string + + + + __Interface_Property_link + [Interface Property link] + write + + other + next param + string + + + true + + + string + + + + __Connection_Property_link + [Connection Property link] + write + + other + next param + string + + + true + + + string + + + + __Custom_Name + [Custom Name] + read + + other + next param + string + + + true + + + string + + + + __Custom_Name + [Custom Name] + write + + other + next param + string + + + true + + + string + + + + __Interface_Dynamic_Link + [Interface Dynamic Link] + read + + other + next param + string + + + true + + + string + + + + __Connections_Name + [Connections Name] + read + + other + next param + string + + + true + + + string + + + + __Interface_Properties_Input + [Interface Properties Input] + write + + other + next param + string + + + true + + + + string + + + + __Connections_Input + [Connections Input] + write + + other + next param + string + + + true + + + + string + + + + __Connections_Properties_Input + [Connections Properties Input] + write + + other + next param + string + + + true + + + + string + + + + __Connections_Filter + [Connections Filter] + read + + other + next param + string + + + true + + + string + + + + __Connections_Filter + [Connections Filter] + write + + other + next param + string + + + true + + + string + + + + DataMiner Connectivity Framework + DataMiner Connectivity Framework + write + + numeric text + next param + double + + + true + + + General parameters + 17 + 0 + + + + + pagebutton + + + Configure... + DataMiner Connectivity Framework + + + + + + ReplicationInfo + Replication Info + write + + numeric text + next param + double + + + true + + + General parameters + 18 + 0 + + + + + pagebutton + + + View... + Replication Info + + + + + + ReplicatedElement + [Replicated Element] + read + + unsigned number + fixed + 4 + double + + + true + + + Replication Info + 0 + 0 + + + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + + + + RemoteDMAIP + [Remote DMA IP] + read + + other + next param + string + + + string + + + true + + + Replication Info + 1 + 0 + + + + + + RemoteElementName + [Remote Element Name] + read + + other + next param + string + + + string + + + true + + + Replication Info + 2 + 0 + + + + + + ConnectedReplicationDmasCount + [Connected Replication DMAs Count] + read + + unsigned number + fixed + 4 + double + + + true + + + Replication Info + 3 + 0 + + + + + true + + + number + + + + ConnectedReplicationDmas + [Connected Replication DMAs] + array + + + + + + + + + true + + + Replication Info + 4 + 0 + + + + + table + + + + ConnectedReplicationDmasId + [ID] + read + + other + next param + string + + + true + + + string + + + + ConnectedReplicationDmasReplicationDmaIp + [DMA IP] + read + + other + next param + string + + + true + + + string + + + + ConnectedReplicationDmasReplicationState + [Replication State] + read + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + Not Active + 0 + + + Active + 1 + + + + + + ConnectedReplicationDmasReplicationLastChange + [Last Change] + read + + other + next param + string + + + true + + + string + + + + ConnectedReplicationDmasReplicationRemoteElementName + [Replicated Element Name] + read + + other + next param + string + + + true + + + string + + + + ReplicationDmaRowCountTrigger + ReplicationDmaRowCountTrigger + dummy + + other + next param + string + + + false + + + + ClearTableAfterStartupTrigger + ClearTableAfterStartupTrigger + dummy + + other + next param + string + + + false + + + + lock_owner_internal + [Internal Lock owner] + read + + other + next param + string + + + true + + + + true + + + string + + + + Resource Info + Resource Info + write + + numeric text + next param + double + + + true + + + General parameters + 19 + 0 + + + + + pagebutton + + + Configure... + Resource Info + + + + + + generic_DVE_table + [Generic DVE Table] + array + + ,65134 + + [Index] + + [Name] + + [Element] + + [State] + + [Function GUID] + + [Link Resource Manager] + + + other + next param + double + + + true + + + Resource Info + 1 + 0 + + + + + table + + + + DVE_index + [DVE IDX] + read + + other + next param + string + + + true + + + string + + + + DVE_name + DVE Name + read + + text + next param + string + + + true + + + string + + + + DVE_element + DVE Element + read + + other + next param + string + + + true + + + false + + + string + + + + DVE_state + DVE State + read + + numeric text + next param + double + + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + dve_function_guid + [DVE function GUID] + read + + text + next param + string + + + true + + + string + + + + DVE_link_resource_manager + DVE Link to Resource Manager + read + + other + next param + string + + + true + + + string + + + + generic_interface_table + [Generic Interfaces] + array + + ,65141 + + + + + + + + + other + next param + double + + + true + + + Resource Info + 2 + 0 + + + + + table + + + + interface_index + [Interface IDX] + read + + other + next param + string + + + true + + + string + + + + interface_name + Interface Name + read + + other + next param + string + + + true + + + string + + + + interface_type + Interface Type + read + + numeric text + next param + double + + + true + + + discreet + + + in + 0 + + + out + 1 + + + inout + 2 + + + + + + interface_FK + Interface FK + read + + other + next param + string + + + true + + + string + + + + interface_link_resource_manager + Interface Link to Resource Manager + read + + other + next param + string + + + true + + + string + + + + interface_id + Interface ID + read + + other + next param + string + + + true + + + string + + + + generic DVE Linker Table + [Generic DVE Linker Table] + array + + + + + + + + + + + other + next param + double + + + true + + + Resource Info + 3 + 0 + + + + + table + + + + Linker Index + [Linker Index] + + [Linker Index] + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + Linker Generic DVE FK + [Linker Generic DVE FK] + + [Linker Generic DVE FK] + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + FK Data + [FK Data] + + [FK Data] + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + FK Table + [FK Table] + + [FK Table] + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + DVE_state + DVE State + write + + numeric text + next param + double + + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + dve_function_guid + [DVE function GUID] + write + + text + next param + string + + + true + + + string + + + + DVE_link_resource_manager + DVE Link to Resource Manager + write + + other + next param + string + + + true + + + string + + + + interface_name + Interface Name + write + + other + next param + string + + + true + + + string + + + + interface_type + Interface Type + write + + numeric text + next param + double + + + true + + + discreet + + + in + 0 + + + out + 1 + + + inout + 2 + + + + + + interface_FK + Interface FK + write + + other + next param + string + + + true + + + string + + + + interface_link_resource_manager + Interface Link to Resource Manager + write + + other + next param + string + + + true + + + string + + + + DVE_to_delete + [DVE index to delete] + read + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 4 + 0 + + + + + number + + + + dve_delete_add + [DVE delete/add] + write + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 5 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + Delete All + 3 + + + + + + interface_to_delete + [Interface Index to Delete] + read + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 6 + 0 + + + + + number + + + + interface_delete_add + [Interface delete/add] + write + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 7 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + + + + DVE_to_delete + [DVE index to delete] + write + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 4 + 0 + + + + + number + + + + interface_to_delete + [Interface Index to Delete] + write + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 6 + 0 + + + + + number + + + + DVE_name + DVE Name + write + + other + next param + string + + + true + + + string + + + + FK Table + [FK Table] + write + + numeric text + next param + double + + + true + + + string + + + + FK Data + [FK Data] + write + + numeric text + next param + double + + + true + + + string + + + + New Generic DVE Link + [New Generic DVE Link] + + [New Generic DVE Link] + + time + range + steps + units + + + read + + true + + + other + next param + string + + + true + + + Resource Info + 8 + 0 + + + + + string + + + + New Generic DVE Link + [New Generic DVE Link] + write + + other + next param + string + + + true + + + Resource Info + 8 + 0 + + + + + string + + + + generic dve link to add delete + [Generic DVE Link delete/add] + write + + unsigned number + fixed + 4 + double + + + true + + + Resource Info + 9 + 0 + + + + + button + + + Add + 1 + + + Delete + 2 + + + + + + Linker Generic DVE FK + [Linker Generic DVE FK] + + [Linker Generic DVE FK] + + time + range + steps + units + + + write + + other + next param + string + + + true + + + string + + + + + + + + + + + + + + + + = 3) + { + row[1] = data[0]; + row[2] = data[1]; + row[3] = data[2]; + row[4] = data[3]; + } + + protocol.NotifyProtocol(149/*NT_ADD_ROW*/, 65060, row); + } + else if (action == DELETE_ROW) + { + protocol.NotifyProtocol(156 /*NT_DELETE_ROW*/, 65060, Convert.ToString(protocol.GetParameter(65079))); + } + } + } + +]]> + + + = 3) + { + row[1] = data[0]; + row[2] = data[1]; + row[3] = data[2]; + row[4] = data[3]; + } + + protocol.NotifyProtocol(149/*NT_ADD_ROW*/, 65054, row); + } + else if (action == DELETE_ROW) + { + protocol.NotifyProtocol(156 /*NT_DELETE_ROW*/, 65054, Convert.ToString(protocol.GetParameter(65077))); + } + } + } + +]]> + + + = 3) + { + row[1] = data[0]; + row[2] = data[1]; + row[3] = data[2]; + row[4] = data[3]; + } + + protocol.NotifyProtocol(149/*NT_ADD_ROW*/, 65068, row); + } + else if (action == DELETE_ROW) + { + protocol.NotifyProtocol(156 /*NT_DELETE_ROW*/, 65068, Convert.ToString(protocol.GetParameter(65081))); + } + } + } + +]]> + + + + + + 0) + { + if (null != result.GetValue(0)) + { + Object[] primaryIndexes = (Object[])result.GetValue(0); + indices = Array.ConvertAll(primaryIndexes, new Converter(Convert.ToString)); + + List indicesToDelete = new List(); + for(int i = 0; i < indices.Length; i++) + { + string key = indices[i]; + object[] row = protocol.NotifyProtocol(215, new object[] { iTableID, key }, null) as object[]; + if (row.GetUpperBound(0) >= 1) + { + if (row[1] == null) + { + indicesToDelete.Add(key); + } + } + } + + indices = indicesToDelete.ToArray(); + } + else + { + indices = new string[0]; + } + } + else + { + indices = new string[0]; + } + protocol.NotifyProtocol(156, iTableID, indices); + } +} + +]]> + + + + + + + + + + + + + + parameter + + action + + 900006 + + + + protocol + + action + + 900007 + + + + + + parameter + run actions + + + parameter + run actions + + + \ No newline at end of file diff --git a/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/2.0.0.x/protocol.xml b/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/2.0.0.x/protocol.xml new file mode 100644 index 00000000..c89280f8 --- /dev/null +++ b/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/2.0.0.x/protocol.xml @@ -0,0 +1,9741 @@ + + + Skyline SLA Definition Basic + Skyline SLA Definition Basic + 2.0.0.33 + Generic + 1.3.6.1.4.1.8813.2.48 + 6 + auto + sla + + Service Level Agreement + Skyline Communications + + + + read_service_name + Service Name + read + + The service name + The name of the service managed by this SLA. + + time + + + + other + next param + string + + + true + + + Main View + 15 + 1 + + + + + string + + + + bus_service_id + Service id + bus + + other + next param + string + + + + not_used + not_used + fixed + + other + fixed + 8 + string + Not used + + + + raw_alarm_input + raw_alarm_input + read + + other + next param + string + + + + value 0 + + fixed + + unsigned number + fixed + 1 + 0x00 + double + + + + value 1 + + fixed + + unsigned number + fixed + 1 + 0x01 + double + + + + value from creation + + fixed + + other + fixed + 19 + 1970/01/01 00:00:00 + string + + + + value forever + + fixed + + other + fixed + 19 + 2100/01/01 00:00:00 + string + + + + read_sla_compliance_Status + Compliance + read + + Compliance status + + + + + time + + + + unsigned number + fixed + 4 + double + + + true + + + Main View + 1 + 0 + + + + + true + + + discreet + + + Compliant + 0 + + + Breached + 1 + + + Compliant (Degraded) + 2 + + + Compliant (Degrading) + 3 + + + + + + read_service_alarm_status + Service Alarm State + read + + The service alarm state + This is the alarm state of the service managed by this SLA. + + range + time + + + + unsigned number + fixed + 4 + double + + + true + + + Main View + 16 + 1 + + + + + true + + + + + 1 + 2 + 3 + 4 + 5 + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + + + + read_sla_predicted_compliance_Status + Predicted Compliance + read + + Predicted compliance status + + + + + time + + + + unsigned number + fixed + 4 + double + + + true + + + Main View + 2 + 0 + + + + + true + + + discreet + + + Compliant + 0 + + + Jeopardy + 1 + + + Breached + 2 + + + + + + history property update + history property update + read + + other + next param + string + + + + read_total_time_left_before_breach + Total Violation Time Left + read + + Total violation time left + + + + + time + + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + Not used + -1 + + + + + true + + + true + + + Main View + 5 + 0 + + + + + number + + + + read_total_time_violated + Total Violation Time + read + + Total Violation Time + This indicates how long the SLA has currently been violated. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 3 + 1 + + + + + number + + + + read_max_violation_time + Longest Violation Time + read + + Longest Violation Time + This indicates the duration of the longest violation. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 4 + 1 + + + + + number + + + + read_number_of_violation + Number of Violations + read + + Number of Violations + This represents the number of violations that occurred in the current window. + + + unsigned number + fixed + 4 + double + + + true + + + true + + + Main View + 5 + 1 + + + + + number + + + + read_reset_counters + Last Manual Reset + read + + Last Manual Reset + Indicates when the last manual reset of the SLA was done. + + + other + next param + string + + + true + + + SLA Configuration + 3 + 1 + + + + + string + + + + write_reset_counters + + write + + other + next param + string + + + true + + + SLA Configuration + 4 + 1 + + + + + button + + + Reset + 0 + + + + + + base_timestamp + Base Timestamp + read + + Time base when using a fixed window. + + + + + + other + next param + string + + + true + + + SLA Configuration + 6 + 1 + + + + + string + + + + base_timestamp + Base Timestamp + write + + other + next param + string + + + true + + + SLA Configuration + 6 + 1 + + + + + string + + + + read_current_timestamp_base + Start Time + read + + Start Time + This is the start time of the current monitor window. + + + other + next param + string + 1970/01/01 00:00:00 + + + Since creation + 1970/01/01 00:00:00 + + + + + true + + + Main View + 21 + 1 + + + + + string + + + + read_next_timestamp_base + End Time + read + + End Time + This is the end time of the current monitor window. + + + other + next param + string + 2100/01/01 00:00:00 + + + Forever + 2100/01/01 00:00:00 + + + + + true + + + Main View + 22 + 1 + + + + + string + + + + read_percent_time_violated + Violation percentage + read + + The percent of time the SLA is violated. + This indicates the percentage of time the SLA is violated. This is a percentage of the total monitor period. + + time + + + + double + fixed + 8 + double + + + false + + + % + 3 + false + + + 0 + 100 + + + + analog + + + + sla_state + Admin State + read + + Admin state + + + + + time + + + + double + fixed + 4 + double + + + true + + + true + + + Main View + 18 + 1 + + + SLA Configuration + 1 + 1 + + + + + discreet + + + Tracking + 1 + + + No tracking + 0 + + + + + + sla_state + Admin State + write + + double + fixed + 4 + double + + + true + + + SLA Configuration + 1 + 1 + + + + + togglebutton + + + Tracking + 1 + + + No Tracking + 0 + + + + + + + array_alarm_store + Outage List + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Outage List + 0 + 0 + + + + + table + + + + column_severity + Alarm Severity + read + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + Manual + 12 + + + + + + column_timestamp + Begin Timestamp + read + + other + next param + string + + + true + + + string + + + + column_admin_state + Adm. State + read + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + Tracking + 1 + + + No tracking + 0 + + + + + + read_max_time_left_before_breach + Single Violation Time Left + read + + The maximum consecutive time left before the SLA is breached. + + + + + time + + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + Not used + -1 + + + + + true + + + true + + + Main View + 8 + 0 + + + + + number + + + + read_breach_time_availability + Total Violation Time Availability + read + + Total violation time availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 6 + 0 + + + + 0 + 100 + + + + number + + + + read_consecutive_breach_time_availability + Single Violation Time Availability + read + + Single violation time availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 9 + 0 + + + + 0 + 100 + + + + number + + + + read_number_of_violations_left + Number of Violations Left + read + + Number of violations left + This indicates how many violations can still occur before the SLA is breached. + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + true + + + Main View + 11 + 0 + + + + 0 + 100 + + + + number + + + + read_violation_count_availability + Number of Violations Availability + read + + Number of violations availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 12 + 0 + + + + 0 + 100 + + + + number + + + + column_end_timestamp + End Timestamp + read + + other + next param + string + + + now + -1 + + + + + true + + + string + + + + column_index + column_index + read + + other + next param + string + + + true + + + string + + + + read_non_percent_time_violated + Availability + read + + Availability of the service. + This indicates the service availability percentage during the current window, and at the current moment. + + time + + + + double + fixed + 8 + double + + + true + + + % + 3 + true + + + Main View + 1 + 1 + + + + 0 + 100 + + + + number + + + + read_predicted_non_percent_time_violated + Predicted Availability + read + + Predicted availability of your service. + + + + + time + + + + double + fixed + 4 + double + + + true + + + % + 3 + true + + + Main View + 2 + 1 + + + + 0 + 100 + + + + number + + + + column_motivation + Motivation + read + + other + next param + string + + + true + + + string + + + + column_motivation + Motivation + write + + other + next param + string + + + true + + + string + + + + column_correction + Correction + read + + double + fixed + 8 + double + 8 + + + none + -1 + + + none + 0 + + + + + true + 8 + + + number + + + + column_correction + Correction + write + + double + fixed + 8 + double + + + true + min + 8 + + -1 + 10080 + + + + number + + + All + -2 + + + + + + column_outage + Outage + read + + double + fixed + 8 + double + + + now + -1 + + + + + true + 20 + + + number + + + + convert + convert + read + + unsigned number + fixed + 1 + double + + + + column_outage_pct + Outage pct + read + + double + fixed + 8 + double + + + now + -1 + + + + + true + % + 4 + + + number + + + + column_correction__pct + Correction pct + read + + double + fixed + 8 + double + 8 + + + none + -1 + + + none + 0 + + + + + true + % + 4 + + + number + + + + last_outage_index + last_outage_index + read + + other + next param + string + + + string + + + + monitorspan in sec + monitor span + read + + unsigned number + fixed + 4 + double + + + + column_outage_corrected + Outage Corrected + read + + double + fixed + 8 + double + 3 + + + now + -1 + + + none + 0 + + + + + true + 2 + + + number + + + + column_violation_pct + Violation pct + read + + double + fixed + 8 + double + 8 + + + now + -1 + + + none + 0 + + + + + true + % + 4 + + + number + + + + column_window_status + Current window + read + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + Yes (Partially) + 2 + + + + + + months_to_keep_outages + Time to Keep Outages + read + + Time to Keep Outages + Specifies how long to keep outages when they are no longer in the current window. + + + unsigned number + next param + double + + + true + Month + + + SLA Configuration + 8 + 1 + + + + + number + + + + months_to_keep_outages + Time to Keep Outages + write + + unsigned number + next param + double + + + true + Month + + + SLA Configuration + 8 + 1 + + + + 1 + 24 + + + + number + + + + read_non_percent_time_violated_without_correction + Availability Without Correction + read + + Availability of the service, without correction. + + + time + + + + double + fixed + 8 + double + + + true + + + % + 3 + true + + + Main View + 8 + 1 + + + + 0 + 100 + + + + number + + + + TicketNr + Ticket + read + + other + next param + string + + + true + + + string + + + + sla_validity_start_time + SLA Validity Start Time + read + + SLA Validity Start Time + This is the start time of when the service is active. + + + other + next param + string + + + Since creation + 1970/01/01 00:00:00 + + + + + true + + + SLA Configuration + 10 + 1 + + + + + string + + + + sla_validity_end_time + SLA Validity End Time + read + + SLA Validity End Time + This is the end time of when the service is active. + + + other + next param + string + + + Forever + 2100/01/01 00:00:00 + + + + + true + + + SLA Configuration + 11 + 1 + + + + + string + + + + sla_validity_start_time + SLA Validity Start Time + write + + This is the start time of when the SLA is active. Format (YYYY/MM/DD HH:MM:SS) + + + other + next param + string + + + true + + + SLA Configuration + 10 + 1 + + + + + string + + + Since creation + 1970/01/01 00:00:00 + + + + + + sla_validity_end_time + SLA Validity End Time + write + + This is the end time of when the SLA is active. Format (YYYY/MM/DD HH:MM:SS) + + + other + next param + string + + + true + + + SLA Configuration + 11 + 1 + + + + + string + + + Forever + 2100/01/01 00:00:00 + + + + + + sla_health_status + SLA health status + read + + The service alarm state + This is the alarm state of the service managed by this SLA. + + range + time + + + + unsigned number + fixed + 4 + double + + + true + + + true + + + discreet + + + Undefined + 0 + + + Healthy + 1 + + + Degraded + 2 + + + + + + service_live_service_state + Service Live State + read + + Service live state + Indicates whether the service is currently on air or not. + + time + + + + other + next param + string + + + true + + + true + + + Main View + 19 + 1 + + + + + string + + + + service_current_violation_impact + Current Outage Impact + read + + Current outage impact + Shows the impact of the current alarms on the SLA. + + time + + + + double + fixed + 8 + double + + + true + + + true + 3 + % + + + Main View + 17 + 1 + + + + + number + + + + column_impact + Outage impact + read + + Outage violation impact + Shows how much the outage is impacted with the current alarms. + + time + + + + double + fixed + 8 + double + + + true + + + true + 3 + % + + + number + + + + read_unweight_total_time_violated + Total Outage Time + read + + Total Outage Time + This indicates how long the SLA is currently affected. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 9 + 1 + + + + + number + + + + read_unweight_max_violation_time + Longest Outage Time + read + + Longest Outage Time + This indicates the longest outage time. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 10 + 1 + + + + + number + + + + column_violation + Violation + read + + double + fixed + 8 + double + 3 + + + now + -1 + + + none + 0 + + + + + true + 2 + + + number + + + + array_alarm_store_ContextMenu + Outage List_ContextMenu + write + + other + next param + string + + + true + + + discreet + + + Delete Selected Manual Outage(s) + deleteoutages + + + + + + array_alarm_store_QActionFeedback + Outage List_QActionFeedback + read + + other + next param + string + + + true + + + string + + + + sla_monitor_time + Time + read + + Time + Specifies the windowsize of the SLA. + + + unsigned number + next param + double + + + false + + + true + + + SLA Configuration + 4 + 0 + + + + + number + + + + sla_monitor_time + Time + write + + The SLA Time. + The time of the SLA. + + time + + + + unsigned number + next param + double + + + + 1 + 100 + + true + + + SLA Configuration + 4 + 0 + + + + + 103 + + + number + + + + sla_monitor_unit + Unit + read + + Unit + Specifies the windowsize of the SLA. + + + unsigned number + next param + double + + + true + + + SLA Configuration + 5 + 0 + + + + + discreet + + + Undefined + 0 + + + Days + 1 + + + Weeks + 2 + + + Months + 3 + + + Hours + 4 + + + Minutes + 5 + + + + + + sla_monitor_unit + Unit + write + + The SLA Unit. + The unit of the SLA. + + time + range + + + + unsigned number + next param + double + + + true + + + SLA Configuration + 5 + 0 + + + + + discreet + + + Days + 1 + + + Weeks + 2 + + + Months + 3 + + + Hours + 4 + + + Minutes + 5 + + + + + + sla_monitor_type + Type + read + + The windowtype of the SLA. + + + + + + unsigned number + next param + double + + + true + + + SLA Configuration + 2 + 0 + + + + + discreet + + + Sliding window + 1 + + + Fixed window + 2 + + + + + + sla_monitor_type + Type + write + + unsigned number + next param + double + + + true + + + SLA Configuration + 2 + 0 + + + + + togglebutton + + + Sliding Window + 1 + + + Fixed Window + 2 + + + + + + sla_delay_time + Delay Time + read + + Delay Time + This specifies how long an outage may occur, before it becomes a violation. + + + unsigned number + next param + double + + + Not used + 0 + + + + + true + + + SLA Configuration + 10 + 0 + + + + + number + + + + sla_delay_time + Delay Time + write + + unsigned number + next param + double + + + s + true + + + SLA Configuration + 10 + 0 + + + + 1 + 1800 + + + + number + + + Not used + 0 + + + + + + sla_recalculate + recalculate + write + + unsigned number + fixed + 4 + double + + + true + + + number + + + + sla_minimum_outage_threshold + Minimum Outage Threshold + read + + Minimum Outage Threshold + Period of the outage, if the delay time has passed, that doesn't count as violation time. + + + unsigned number + next param + double + + + Full outage + 0 + + + + + true + + + SLA Configuration + 11 + 0 + + + + + number + + + + sla_minimum_outage_threshold + Minimum Outage Threshold + write + + unsigned number + next param + double + + + s + true + + + SLA Configuration + 11 + 0 + + + + 1 + 1800 + + + + number + + + Full outage + 0 + + + + + + sla_breach_value + Maximum Total Violations Value + read + + Maximum Total Violations Value + Compliance: Maximum total allowed violation time value. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 0 + + + + + number + + + + sla_breach_value + Maximum Total Violations Value + write + + unsigned number + next param + double + + + + 1 + 90 + + true + + + Compliance Configuration + 6 + 0 + + + + + 123 + + + number + + + + sla_breach_unit + Maximum Total Violations Unit + read + + Maximum Total Violations Unit + Compliance: Maximum total allowed violation time unit. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 7 + 0 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_breach_unit + Maximum Total Violations Unit + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 7 + 0 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_consecutive_breach_value + Maximum Single Violation Value + read + + Maximum Single Violation Value + Compliance: Maximum single allowed violation time value. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 5 + 1 + + + + + number + + + + sla_consecutive_breach_value + Maximum Single Violation Value + write + + unsigned number + next param + double + + + + 1 + 90 + + true + + + Compliance Configuration + 5 + 1 + + + + + 127 + + + number + + + + sla_consecutive_breach_unit + Maximum Single Violation Unit + read + + Maximum Single Violation Unit + Compliance: Maximum single allowed violation time unit. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 1 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_consecutive_breach_unit + Maximum Single Violation Unit + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 1 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_max_violations + Total Violations Before Breach + read + + Total Violations Before Breach + Compliance: The maximum allowed number of violations. + + + signed number + next param + double + + + Not used + -1 + + + + + true + + + Compliance Configuration + 12 + 0 + + + + + number + + + + sla_max_violations + Total Violations Before Breach + write + + signed number + next param + double + + + + 0 + 100 + + true + + + Compliance Configuration + 12 + 0 + + + + + number + + + Not used + -1 + + + + + + sla_violation_level + Violation Level + read + + Violation Level + This indicates from which alarm level onwards the SLA is violated. + + + unsigned number + next param + double + + + true + + + SLA Configuration + 9 + 0 + + + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + + + + sla_violation_level + Violation Level + write + + unsigned number + next param + double + + + true + + + SLA Configuration + 9 + 0 + + + + + discreet + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + + + + manual_outage_start_time + Manual outage start time + read + + The start time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_start_time + Manual outage start time + write + + The start time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_end_time + Manual outage end time + read + + The end time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_end_time + Manual outage end time + write + + The end time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_motivation + Manual outage motivation + read + + The motivation of the manual outage to be added. + + + other + next param + string + + + true + + + string + + + + manual_outage_motivation + Manual outage motivation + write + + The motivation of the manual outage to be added. + + + other + next param + string + + + true + + + string + + + + manual_outage_overrule_motivation + Overrule existing motivations + read + + This indicates if motivations on overruled outages should be overwritten with a reference to the current outage. + + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + + + + manual_outage_overrule_motivation + Overrule existing motivations + write + + This indicates if motivations on overruled outages should be overwritten with a reference to the current outage. + + + unsigned number + fixed + 4 + double + + + true + + + togglebutton + + + No + 0 + + + Yes + 1 + + + + + + manual_outage_add + + write + + + + + + + unsigned number + fixed + 4 + double + + + true + + + Outage List + 2 + 0 + + + + + + 147 + + 149 + 137 + + + + + button + + + Add Outage... + 1 + + + + + + manual_outage_delete + + write + + Deletes a manual outage. + + + unsigned number + fixed + 4 + double + + + true + + + + 143 + + + button + + + Delete outage... + 1 + + + + + + manual_outage_delete_pk + Manual outage key + read + + The primary key(s) of the outage to be deleted. Semicolon-separated values. + + time + range + steps + units + + + + other + next param + string + + + true + + + string + + + + manual_outage_delete_pk + Manual outage key + write + + other + next param + string + + + true + + + string + + + + + + manual_outage_start_time_client_input + New Outage Start Time + read + + The start time of the manual outage to be added. + + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_start_time_client_input + New Outage Start Time + write + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_end_time_client_input + New Outage End Time + read + + The end time of the manual outage to be added. + + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_end_time_client_input + New Outage End Time + write + + double + fixed + 8 + double + + + true + + + number + + + + + TicketNr + Ticket + write + + other + next param + string + + + true + + + string + + + + sla_total_breach + Maximum Total Violation Time + read + + Maximum Total Violation Time + Compliance: Maximum total violation time + + + other + next param + string + + + Invalid + Invalid + + + Not used + Not Used + + + + + true + + + Compliance Configuration + 2 + 0 + + + + + string + + + + sla_max_consecutive_breach + Maximum Single Violation Time + read + + Maximum Single Violation Time + Compliance: Maximum single violation time + + + other + next param + string + + + Invalid + Invalid + + + Not Used + Not Used + + + + + true + + + Compliance Configuration + 1 + 1 + + + + + string + + + + sla_total_slot_type + Maximum Total Violations Type + read + + Compliance: Maximum total violation type + + + + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 4 + 0 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_total_slot_type + Maximum Total Violations Type + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 4 + 0 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_max_consecutive_slot_type + Maximum Single Violation Type + read + + Compliance: Maximum single violation type + + + + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 3 + 1 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_max_consecutive_slot_type + Maximum Single Violation Type + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 3 + 1 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + total_relative_percentage + Maximum Total Violations Percentage + read + + Maximum Total Violations Percentage + Compliance: Maximum total violation percentage + + + double + fixed + 4 + double + + + Not applicable + -1 + + + + + % + 3 + true + + + Compliance Configuration + 9 + 0 + + + + + number + + + + total_relative_percentage + Maximum Total Violations Percentage + write + + double + fixed + 4 + double + + + + 0 + 100 + + % + 3 + true + + + Compliance Configuration + 9 + 0 + + + + + number + + + + max_consecutive_relative_percentage + Maximum Single Violation Percentage + read + + Maximum Single Violation Percentage + Compliance: Maximum single violation percentage + + + double + fixed + 4 + double + + + Not applicable + -1 + + + + + % + 3 + true + + + Compliance Configuration + 8 + 1 + + + + + number + + + + max_consecutive_relative_percentage + Maximum Single Violation Percentage + write + + double + fixed + 4 + double + + + + 0 + 100 + + % + 3 + true + + + Compliance Configuration + 8 + 1 + + + + + number + + + + + Current_array_active_service_alarms + Current Active Service Alarms + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Active Service Alarms + 0 + 0 + + + + + table + + + + Current_array_active_service_alarms_id + Current Active Service Alarm Id + read + + Alarm id of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_severity + Current Active Service Alarm Severity + read + + Severity of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Critical + 1 + + + Major + 2 + + + Minor + 3 + + + Warning + 4 + + + Normal + 5 + + + Information + 13 + + + Timeout + 17 + + + Error + 24 + + + Notice + 28 + + + + + + Current_array_active_service_alarms_time + Current Active Service Alarm Time + read + + Starttime of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_element + Current Active Service Alarm Element + read + + Element of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_parameter + Current Active Service Alarm Parameter + read + + Parameter of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_value + Current Active Service Alarm Value + read + + Value of the alarm active service the SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_state + Current Active Service Alarm State + read + + State of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Cleared + 11 + + + Open + 12 + + + Masked + 25 + + + Clearable + 54 + + + + + + Current_array_active_service_alarms_type + Current Active Service Alarm Type + read + + Type of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Escalated + 8 + + + Dropped + 9 + + + New alarm + 10 + + + Cleared + 11 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + Comment Added + 22 + + + Unmask + 27 + + + Dropped from Critical + 31 + + + Dropped from Major + 32 + + + Dropped from Minor + 33 + + + Dropped from Warning + 34 + + + Escalated from Warning + 35 + + + Escalated from Minor + 36 + + + Escalated from Major + 37 + + + Flipped + 38 + + + Service impact changed + 40 + + + Value changed + 41 + + + Name changed + 42 + + + RCA-Level changed + 43 + + + Properties changed + 50 + + + Threshold changed + 53 + + + Interface changed + 55 + + + + + + Current_array_active_service_alarms_user_state + Current Active Service Alarm User State + read + + User state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Not assigned + 18 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + + + + Current_array_active_service_alarms_source + Current Active Service Alarm Source + read + + Source of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Mobile Gateway + 14 + + + DataMiner + 16 + + + Correlation + 23 + + + Watchdog + 29 + + + External + 30 + + + Aggregation + 56 + + + + + + Current_array_active_service_alarms_category + Current Active Service Alarm Category + read + + Category of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_offline impact + Current Active Service Alarm Offline Impact + read + + Offline impact of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Yes + 1 + + + No + 0 + + + + + + Current_array_active_service_alarms_service_point + Current Active Service Alarm Service Point + read + + Service point of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_component_info + Current Active Service Alarm Component Info + read + + Component info of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_inclusion_state + Current Active Service Alarm Overruled Inclusion State + read + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + Current_array_active_service_alarms_inclusion_state + Current Active Service Alarm Overruled Inclusion State + write + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + Current_array_active_service_alarms_calculated_inclusion_state + Current Active Service Alarm Calculated Inclusion State + read + + Calculated inclusion state of the active service SLA + + + double + fixed + 8 + double + + + true + % + 0 + + + number + + + + title_begin_sla_status + Compliance Info + fixed + + true + + + Main View + 0 + 0 + + + + + title + + + + title_end_sla_status + + fixed + + true + + + Main View + 13 + 0 + + + + + title + + + + title_begin_service_status + General Info + fixed + + true + + + Main View + 14 + 1 + + + + + title + + + + title_end_service_status + + fixed + + true + + + Main View + 23 + 1 + + + + + title + + + + title_begin_violation_status + Performance Indicators + fixed + + true + + + Main View + 0 + 1 + + + + + title + + + + title_end_violation_status + + fixed + + true + + + Main View + 11 + 1 + + + + + title + + + + title_begin_sla_window + Window settings + fixed + + true + + + SLA Configuration + 1 + 0 + + + + + title + + + + title_end_sla_window + + fixed + + true + + + SLA Configuration + 6 + 0 + + + + + title + + + + title_begin_sla_config + Extra settings + fixed + + true + + + SLA Configuration + 0 + 1 + + + + + title + + + + title_end_sla_config + + fixed + + true + + + SLA Configuration + 15 + 1 + + + + + title + + + + title_begin_total_breach_config + Total violation + fixed + + true + + + Compliance Configuration + 1 + 0 + + + + + title + + + + title_end_total_breach_config + + fixed + + true + + + Compliance Configuration + 10 + 0 + + + + + title + + + + title_begin_cons_breach_config + Single violation + fixed + + true + + + Compliance Configuration + 0 + 1 + + + + + title + + + + title_end_cons_breach_config + + fixed + + true + + + Compliance Configuration + 9 + 1 + + + + + title + + + + title_begin_number_breach_config + Violation count + fixed + + true + + + Compliance Configuration + 11 + 0 + + + + + title + + + + title_end_number_breach_config + + fixed + + true + + + Compliance Configuration + 13 + 0 + + + + + title + + + + title_begin_sla_alarm_config + Alarm settings + fixed + + true + + + SLA Configuration + 8 + 0 + + + + + title + + + + title_end_sla_alarm_config + + fixed + + true + + + SLA Configuration + 15 + 0 + + + + + title + + + + trigger_dummy_row_added + trigger_dummy_row_added + read + + other + next param + string + + + + trigger_dummy_row_changed + trigger_dummy_row_changed + read + + other + next param + string + + + + trigger_dummy_row_deleted + trigger_dummy_row_deleted + read + + other + next param + string + + + + + array_offline_window + Offline Window + array + + + + + + + + + + + + + + other + next param + double + + + true + + + Offline Window + 0 + 0 + + + + + table + + + + array_offline_window_id + Offline Window Id + read + + Id of the offline window + + + other + next param + string + + + true + + + string + + + + array_offline_window_start_day + Offline Window Start Day + read + + Start day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_start_time + Offline Window Start Time + read + + Start time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + + number + + + + array_offline_window_end_time + Offline Window End Time + read + + End time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + + number + + + + array_offline_window_state + Offline Window State + read + + State of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + + + + array_offline_window_start_day + Offline Window Start Day + write + + Start day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_start_time + Offline Window Start Time + write + + Start time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + 0 + 1439 + + + + number + + + + array_offline_window_end_day + Offline Window End Day + write + + End day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_end_time + Offline Window End Time + write + + End time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + 0 + 1439 + + + + number + + + + array_offline_window_state + Offline Window State + write + + State of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + Delete + 3 + + + + + + array_offline_window_change + Offline Window Change + write + + Change the offline window settings + + + unsigned number + fixed + 1 + double + + + true + + + Offline Window + 1 + 0 + + + + + button + + + Add Entry + 1 + + + + + + + array_violation_settings + Violation Settings + array + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Violation Configuration + 1 + 0 + + + + + table + + + + array_violation_settings_id + Violation Filter Id + read + + Id of the violation setting + + + other + next param + string + + + true + + + string + + + + array_violation_settings_type + Violation Filter Type + read + + Field on which you want to filter + + + signed number + fixed + 2 + double + + + true + + + discreet + + + Custom service property + -4 + + + Custom view property + -3 + + + Custom element property + -2 + + + Custom alarm property + -1 + + + Undefined + 0 + + + Severity + 9 + + + Element name + 19 + + + Parameter name + 21 + + + Alarm state + 8 + + + Category + 27 + + + Key point + 31 + + + Component info + 33 + + + + + + array_violation_settings_value + Violation Filter Value + read + + Value filter of the violation type + + + other + next param + string + + + true + + + string + + + + array_violation_settings_impact + Violation Filter Impact + read + + Violation impact + + + unsigned number + fixed + 2 + double + + + true + % + + 0 + 100 + + + + number + + + + array_violation_sequence + Violation Filter Sequence + read + + Sequence of the vionlation filter + + + unsigned number + fixed + 2 + double + + + true + + 0 + 100 + + + + number + + + + array_violation_state + Violation Filter State + read + + State of the violation filter. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + + + + array_violation_exclusive + Violation Filter Exclusive + read + + If set to filter and the setting does not match, the alarm is skipped in the SLA processing, if set to continue, the other settings are checked. If at the end no match is found, the alarm is included for SLA Calculations. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Filter + 1 + + + Continue + 2 + + + + + + array_violation_property_name + Violation Filter Property Name + read + + Property name of the violation filter + + + other + next param + string + + + true + + + string + + + + array_violation_settings_type + Violation Filter Type + write + + Field on which you want to filter + + + other + next param + string + + + true + + + discreet + + + Custom service property + -4 + + + Custom view property + -3 + + + Custom element property + -2 + + + Custom alarm property + -1 + + + Severity + 9 + + + Element name + 19 + + + Parameter name + 21 + + + Alarm state + 8 + + + Category + 27 + + + Key point + 31 + + + Component info + 33 + + + + + + array_violation_settings_value + Violation Filter Value + write + + Value filter of the violation type + + + other + next param + string + + + true + + + string + + + + array_violation_settings_impact + Violation Filter Impact + write + + Violation impact + + + unsigned number + fixed + 2 + double + + + true + % + + 0 + 100 + + + + number + + + + array_violation_sequence + Violation Filter Sequence + write + + Sequence of the vionlation filter + + + unsigned number + fixed + 2 + double + + + true + + 0 + 100 + + + + number + + + + array_violation_state + Violation Filter State + write + + State of the violation filter. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + Delete + 3 + + + + + + array_violation_exclusive + Violation Filter Exclusive + write + + If set to true and the filter does not match, the alarm is skipped in the SLA processing, if set to false, the other filters are checked. If at the end no match is found, the alarm is included for SLA Calculations. + + + unsigned number + fixed + 1 + double + + + true + + + togglebutton + + + Filter + 1 + + + Continue + 2 + + + + + + array_violation_property_name + Violation Filter Property Name + write + + Property name of the violation filter + + + other + next param + string + + + true + + + string + + + + array_violation_setting_add_entry + Violation Settings + write + + Change the offline window settings + + + unsigned number + fixed + 1 + double + + + true + + + Violation Configuration + 2 + 0 + + + + + button + + + Add Entry + 1 + + + + + + OutageDetails + OutageDetails + read + + other + next param + string + + + true + + + + + array_root_to_outage + table holding root to outage + array + + + + + + + + + + other + next param + double + + + true + + + table + + + + array_root_to_outage_id + array_root_to_outage_id + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_root + array_root_to_outage_root + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_outage + array_root_to_outage_outage + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_weight + array_root_to_outage_weight + read + + double + fixed + 8 + double + + + true + 2 + % + + + number + + + + array_root_to_outage_inclusion_state + array_root_to_outage_inclustion_state + read + + unsigned number + fixed + 1 + double + + + true + + + number + + + + array_root_to_outage_alarm + array_root_to_outage_alarm + read + + other + next param + string + + + true + + + string + + + + GenerateTicket + Generate Ticket + read + + Generate Ticket + + + + unsigned number + fixed + 4 + double + + + true + + + Ticket Creation + 0 + 0 + + + + + discreet + + + Clear + 0 + + + Create Ticket + 1 + + + Create Ticket, second attempt + 2 + + + Create Ticket, third attempt + 3 + + + Unable to create ticket + 4 + + + + + true + + + + GenerateTicket + Generate Ticket + write + + unsigned number + fixed + 4 + double + + + true + + + Ticket Creation + 0 + 0 + + + + + discreet + + + Clear + 0 + + + Create Ticket + 1 + + + Create Ticket, second attempt + 2 + + + Create Ticket, third attempt + 3 + + + Unable to create ticket + 4 + + + + + + + array_active_service_alarms + Active Service Alarms + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + table + + + + array_active_service_alarms_rootid + Active Service Alarm RootId + read + + Alarm Rootid of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_severity + Active Service Alarm Severity + read + + Severity of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Critical + 1 + + + Major + 2 + + + Minor + 3 + + + Warning + 4 + + + Normal + 5 + + + Information + 13 + + + Timeout + 17 + + + Error + 24 + + + Notice + 28 + + + + + + array_active_service_alarms_time + Active Service Alarm Time + read + + Starttime of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_element + Active Service Alarm Element + read + + Element of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_parameter + Active Service Alarm Parameter + read + + Parameter of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_value + Active Service Alarm Value + read + + Value of the alarm active service the SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_state + Active Service Alarm State + read + + State of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Cleared + 11 + + + Open + 12 + + + Masked + 25 + + + Clearable + 54 + + + + + + array_active_service_alarms_type + Active Service Alarm Type + read + + Type of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Escalated + 8 + + + Dropped + 9 + + + New alarm + 10 + + + Cleared + 11 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + Comment Added + 22 + + + Unmask + 27 + + + Dropped from Critical + 31 + + + Dropped from Major + 32 + + + Dropped from Minor + 33 + + + Dropped from Warning + 34 + + + Escalated from Warning + 35 + + + Escalated from Minor + 36 + + + Escalated from Major + 37 + + + Flipped + 38 + + + Service impact changed + 40 + + + Value changed + 41 + + + Name changed + 42 + + + RCA-Level changed + 43 + + + Properties changed + 50 + + + Threshold changed + 53 + + + Interface changed + 55 + + + + + + array_active_service_alarms_user_state + Active Service Alarm User State + read + + User state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Not assigned + 18 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + + + + array_active_service_alarms_source + Active Service Alarm Source + read + + Source of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Mobile Gateway + 14 + + + DataMiner + 16 + + + Correlation + 23 + + + Watchdog + 29 + + + External + 30 + + + Aggregation + 56 + + + + + + array_active_service_alarms_category + Active Service Alarm Category + read + + Category of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_offline impact + Active Service Alarm Offline Impact + read + + Offline impact of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Yes + 1 + + + No + 0 + + + + + + array_active_service_alarms_service_point + Active Service Alarm Service Point + read + + Service point of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_component_info + Active Service Alarm Component Info + read + + Component info of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_inclusion_state + Active Service Alarm Overruled Inclusion State + read + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + array_active_service_alarms_inclusion_state + Active Service Alarm Overruled Inclusion State + write + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + array_active_service_alarms_calculated_inclusion_state + Active Service Alarm Calculated Inclusion State + read + + Calculated inclusion state of the active service SLA + + + double + fixed + 8 + double + + + true + % + 0 + + + number + + + + array_active_service_alarms_id + Active Service Alarm Id + read + + Alarm id of the active service SLA + + + other + next param + string + + + true + + + string + + + + + History Statistics Table + History Statistics Table + array + + + + + + + + + + + + + + + + + + + + + + + + Table containing key parameter SLA statistics of previous tracking periods. + + + other + next param + double + + + true + + + History + 0 + 0 + + + + + table + + + + Tracking Period + Tracking Period [IDX] + + Tracking Period + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + Start Time (History) + Start Time (History) + + History Start Time + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + End Time (History) + End Time (History) + + History End Time + + time + range + steps + units + + + read + + other + next param + string + + + now + -1 + + + + + true + + + string + + + + Stored End Time (History) + Stored End Time (History) + read + + other + next param + string + + + true + + + string + + + + Compliance (History) + Compliance (History) + + Compliance + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + + + discreet + + + Compliant + 0 + + + Breached + 1 + + + Compliant (Degraded) + 2 + + + Compliant (Degrading) + 3 + + + + + + Availability (History) + Availability (History) + + Availability + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + % + 2 + + 0 + 100 + + + + number + + + + Availability Without Corrections (History) + Availability Without Corrections (History) + + Availability Without Corrections + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + % + 2 + + 0 + 100 + + + + number + + + + Total Violation Time (History) + Total Violation Time (History) + read + + This indicates how long the SLA is currently violated. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + number + + + + Longest Violation Time (History) + Longest Violation Time (History) + read + + This indicates the duration of the longest violation. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + number + + + + Number Of Violations (History) + Number of Violations (History) + read + + This represents the number of violations that occured in the current window. + + + unsigned number + fixed + 4 + double + + + true + + + true + + + number + + + + Clear History Statistics Table + + + Clear History Statistics Table + + time + range + steps + units + + + write + + numeric text + next param + double + + + true + + + History + 1 + 0 + + + + + button + + + Clear History + 1 + + + + + + Current History IDX + Current History IDX + read + + other + next param + string + + + + Max Number Of History Rows + Max Number of History Rows + + Max Number of History Rows + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + History + 2 + 0 + + + + + number + + + + Max Number Of History Rows + Max Number of History Rows + write + + numeric text + next param + double + + + true + + + History + 2 + 0 + + + + + number + + + + ConfigurationName + Configuration Name + + Configuration Name + The Configuration Name used to Save or Load a specific Configuration + + time + range + steps + units + + + read + + other + next param + string + + + true + + + Save/Load Configuration + 0 + 0 + + + + + false + + + string + + + + ConfigurationName + Configuration Name + write + + other + next param + string + + + true + + + Save/Load Configuration + 0 + 0 + + + + + string + + + + + AvailableConfigurations + AvailableConfigurations + + AvailableConfigurations + All Detected and Available Configurations + + time + range + steps + units + + + read + + other + next param + string + + + false + + + true + + + string + + + + SaveLoadConfig + + write + + numeric text + next param + double + + + true + + + Save/Load Configuration + 2 + 0 + + + + + button + + + Save + 0 + + + Load + 1 + + + Delete + 2 + + + + + + Save/Load Status + Save/Load Status + + Save/Load Status + Indicates the status for the save or load action + + time + range + steps + units + + + read + + other + next param + string + + + false + + + true + + + Save/Load Configuration + 3 + 0 + + + + + string + + + + + PB_SaveLoadConfig + + write + + other + next param + string + + + true + + + SLA Configuration + 0 + 0 + + + Compliance Configuration + 0 + 0 + + + Violation Configuration + 0 + 0 + + + + + pagebutton + + + Save/Load Config... + Save/Load Configuration + + + + + + BUT_LoadConfigurations + + write + + numeric text + next param + double + + + true + + + Save/Load Configuration + 1 + 0 + + + + + button + + + Load Configurations + 1 + + + + + + pagebutton Edit Outage + + write + + other + next param + string + + + true + + + Outage List + 1 + 0 + + + + + pagebutton + + + Edit Outage... + Edit Outage + + + + + + Outage_to_Stop_Delete + Outage to Stop or Delete + + Outage to Stop or Delete + Outage to Stop or Delete + + time + range + steps + units + + + read + + other + next param + string + + + true + + + Edit Outage + 1 + 0 + + + + + string + + + + Outage_to_Stop_Delete + Outage to Stop or Delete + write + + other + next param + string + + + true + + + Edit Outage + 1 + 0 + + + + + string + + + + Delete Selected Outage + + write + + numeric text + next param + double + + + true + + + Edit Outage + 2 + 0 + + + + + button + + + Delete Outage + 1 + + + Stop Outage... + 2 + + + + + + hide_filtered_alarms + Hide filtered alarms + read + + Hide violation filtered alarms + + + + + range + steps + units + time + + + + double + fixed + 4 + double + + + Show + 0 + + + + + true + + + SLA Configuration + 13 + 1 + + + + + discreet + + + Show + -1 + + + Hide + 1 + + + + + + hide_filtered_alarms + Hide filtered alarms + write + + double + fixed + 4 + double + + + true + + + SLA Configuration + 13 + 1 + + + + + togglebutton + + + Show + 0 + + + Hide + 1 + + + + + + + + + dblViolation) dblInput = dblViolation; + dblViolation -= dblInput; + + protocol.SetParameterIndexByKey(protocol.array_alarm_store.TableId, protocol.RowKey(), Parameter.Array_alarm_store.Idx.column_correction + 1, dblInput); + protocol.SetParameterIndexByKey(protocol.array_alarm_store.TableId, protocol.RowKey(), Parameter.Array_alarm_store.Idx.column_violation + 1, dblViolation); + } +} + ]]> + + + + /// Manual Outage Delete + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol) + { + var allOutagesToDelete = new List(); + + var sKeysToDelete = Convert.ToString(protocol.Manual_outage_delete_pk_143).Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + + if (sKeysToDelete.Length > 20) + { + var oOutageTable = (object[])protocol.NotifyProtocol( + 321, + Parameter.Array_alarm_store.tablePid /*37*/, + new UInt32[] + { + Parameter.Array_alarm_store.Idx.column_index_47, + Parameter.Array_alarm_store.Idx.column_severity_38 + }); + var oOutagePks = (object[])oOutageTable[0]; + var oOutageType = (object[])oOutageTable[1]; + var keyToType = new Dictionary(); + + for (var i = 0; i < oOutagePks.Length; i++) + { + keyToType[Convert.ToString(oOutagePks[i])] = oOutageType[i]; + } + + foreach (var sKeyToDelete in sKeysToDelete) + { + if (!keyToType.ContainsKey(sKeyToDelete)) + { + continue; + } + // Check type, only delete manual outages + var iOutageType = Convert.ToInt32(keyToType[sKeyToDelete]); + if (iOutageType == 12) + { + allOutagesToDelete.Add(sKeyToDelete); + } + + // Make sure we don't delete the same key twice by failing the next exist lookup + keyToType.Remove(sKeyToDelete); + } + } + else + { + foreach (var sKeyToDelete in sKeysToDelete) + { + if (!protocol.array_alarm_store.Exists(sKeyToDelete)) + { + continue; + } + + var iOutageType = Convert.ToInt32(protocol.array_alarm_store[sKeyToDelete, Parameter.Array_alarm_store.Idx.column_severity_38]); + if (iOutageType == 12) + { + // Only delete manual outages + allOutagesToDelete.Add(sKeyToDelete); + } + } + } + + if (allOutagesToDelete.Count != 0) + { + protocol.array_alarm_store.DeleteRow(allOutagesToDelete); + } + } +} +]]> + + + + + + (); + var ignoredOutages = new List(); + + if (keys.Length - startIndex > 20) + { + var oOutageTable = (object[])protocol.NotifyProtocol( + 321, + Parameter.Array_alarm_store.tablePid /*37*/, + new UInt32[] + { + Parameter.Array_alarm_store.Idx.column_index_47, + Parameter.Array_alarm_store.Idx.column_severity_38 + }); + var oOutagePks = (object[])oOutageTable[0]; + var oOutageType = (object[])oOutageTable[1]; + var keyToType = new Dictionary(); + + for (var i = 0; i < oOutagePks.Length; i++) + { + keyToType[Convert.ToString(oOutagePks[i])] = oOutageType[i]; + } + + for (var i = startIndex; i < keys.Length; i++) + { + if (!keyToType.ContainsKey(keys[i])) + { + continue; + } + + // Check type, only delete manual outages + var iOutageType = Convert.ToInt32(keyToType[keys[i]]); + if (iOutageType == 12) + { + allOutagesToDelete.Add(keys[i]); + } + else + { + ignoredOutages.Add(keys[i]); + } + + // Make sure we don't delete the same key twice by failing the next exist lookup + keyToType.Remove(keys[i]); + + } + } + else + { + for (var i = startIndex; i < keys.Length; i++) + { + if (!protocol.array_alarm_store.Exists(keys[i])) + { + continue; + } + + var iOutageType = Convert.ToInt32(protocol.array_alarm_store[keys[i], Parameter.Array_alarm_store.Idx.column_severity_38]); + if (iOutageType == 12) + { + // Only delete manual outages + allOutagesToDelete.Add(keys[i]); + } + else + { + ignoredOutages.Add(keys[i]); + } + } + } + + if (allOutagesToDelete.Count != 0) + { + protocol.array_alarm_store.DeleteRow(allOutagesToDelete); + } + + if (ignoredOutages.Count > 0) + { + protocol.SetParameter( + Parameter.array_alarm_store_qactionfeedback_79, + keys[0] + + "|INFO|The following selected outages were not deleted because they were not created manually:\r\n" + + string.Join(", ", ignoredOutages)); + } + } +} +]]> + + + + /// Validate User Input + /// + /// Link with Skyline DataMiner + public static void Run(SLProtocolExt protocol) + { + var trigger = protocol.GetTriggerParameter(); + if (trigger == Parameter.Write.manual_outage_start_time_client_input_148) + { + var startDt = ParamToDt(protocol.Manual_outage_start_time_client_input_148); + var endDt = ParamToDt(protocol.Manual_outage_end_time_client_input_149); + + protocol.Manual_outage_start_time_client_input_147 = startDt.ToOADate(); + protocol.Manual_outage_start_time_134 = startDt.ToString(DtFormat); + + if (startDt > endDt) + { + // End date-time is incorrect, so we set them to the start date-time + protocol.Manual_outage_end_time_client_input_149 = startDt.ToOADate(); + protocol.Manual_outage_end_time_136 = startDt.ToString(DtFormat); + } + } + else + { + var startDt = ParamToDt(protocol.Manual_outage_start_time_client_input_147); + var endDt = ParamToDt(protocol.Manual_outage_end_time_client_input_150); + + if (startDt > endDt) + { + // End date-time is incorrect, so we set them to the start date-time + protocol.Manual_outage_end_time_client_input_149 = startDt.ToOADate(); + protocol.Manual_outage_end_time_136 = startDt.ToString(DtFormat); + } + else + { + protocol.Manual_outage_end_time_client_input_149 = endDt.ToOADate(); + protocol.Manual_outage_end_time_136 = endDt.ToString(DtFormat); + } + } + } + + private static DateTime ParamToDt(object paramValue) + { + if (!(paramValue is double)) + { + return new DateTime(); + } + return DateTime.FromOADate((double)paramValue); + } +} +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + /// Update History Statistics + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol) + { + int iTrigger = protocol.GetTriggerParameter(); + + String startWindow = Convert.ToString(protocol.GetParameter(31)); + String endWindow = Convert.ToString(protocol.GetParameter(32)); + + if(startWindow =="" || endWindow =="") return; + DateTime window_start, window_end; + if (!DateTime.TryParse(startWindow, out window_start)) return; + if(!DateTime.TryParse(endWindow, out window_end))return; + + int window_unit = Convert.ToInt32(protocol.GetParameter(103)); + + string currentidx = Convert.ToString(protocol.GetParameter(1051)); + string newidx = GetIdx(window_unit, window_start); + + if (currentidx != newidx) + { + //update copy the stored end time + object storedendtime = protocol.GetParameterIndexByKey(1000, currentidx, 4); + protocol.SetParameterIndexByKey(1000, currentidx, 3, storedendtime); + + //new idx + protocol.SetParameter(1051, newidx); + currentidx = newidx; + + } + + if (String.IsNullOrWhiteSpace(currentidx)) return; + + if (iTrigger == 31) // window start time changed + { + if (!protocol.Exists(1000, currentidx)) + { + HistoryStatisticsTableQActionRow newrow = new HistoryStatisticsTableQActionRow() + { + TrackingPeriod = currentidx, + StartTimeHistory = window_start.ToString("yyyy-MM-dd HH:mm:ss"), + EndTimeHistory = "-1", + StoredEndTimeHistory = window_end.ToString("yyyy-MM-dd HH:mm:ss"), + ComplianceHistory = 0, + AvailabilityHistory = 100, + AvailabilityWithoutCorrectionsHistory = 100, + TotalViolationTimeHistory = 0, + LongestViolationTimeHistory = 0, + NumberOfViolationsHistory = 0 + }; + + protocol.historyStatisticsTable.AddRow(newrow); + + //limit number of rows + LimitRows(protocol); + } + } + else // value changed + { + if (!protocol.Exists(1000, currentidx)) + return; + + object value = protocol.GetParameter(iTrigger); + + switch (iTrigger) + { + case 10: // compliance + protocol.SetParameterIndexByKey(1000, currentidx, 5, value); + break; + case 48: // availability + protocol.SetParameterIndexByKey(1000, currentidx, 6, value); + break; + case 65: // availability without corrections + protocol.SetParameterIndexByKey(1000, currentidx, 7, value); + break; + case 21: // total violation time + protocol.SetParameterIndexByKey(1000, currentidx, 8, value); + break; + case 22: // longest violation time + protocol.SetParameterIndexByKey(1000, currentidx, 9, value); + break; + case 24: // number of violations + protocol.SetParameterIndexByKey(1000, currentidx, 10, value); + break; + } + } + + } + + private static void LimitRows(SLProtocolExt protocol) + { + int table = 1000; + + if (protocol.IsEmpty(1052)) + protocol.SetParameter(1052, 1000); + + int maxrows = Convert.ToInt32(protocol.GetParameter(1052)); + + int rowcount = protocol.RowCount(table); + if (rowcount > maxrows) + { + try + { + string[] delkeys = protocol.GetKeys(table).OrderBy(k => Convert.ToDateTime(protocol.GetParameterIndexByKey(table, k, 2))).Take(rowcount - maxrows).ToArray(); + protocol.DeleteRow(table, delkeys); + } + catch + { + // A DateTime Conversion has failed + // Find and Delete entries with unConvertable DateTimeStrings + // While going over all entries and converting them, set all Converted strings back with the correct format + List liDelKeys = new List(); + foreach (string key in protocol.GetKeys(table)) + { + DateTime dtTime; + bool bSucces = false; + string strToConvert = protocol.GetParameterIndexByKey(table, key, 2).ToString(); + try + { + bSucces = DateTime.TryParse(strToConvert, out dtTime); + string strCorrectFormat = dtTime.ToString("yyyy-MM-dd HH:mm:ss"); + if (bSucces) + { + if (string.Compare(strToConvert, strCorrectFormat) != 0) + { + //When Conversion succeeds and changes (in format) has occurred, put the datetime with correct format in place + protocol.SetParameterIndexByKey(table, key, 2, strCorrectFormat); + protocol.Log(8, -1, string.Format("Converted {0} to {1}", strToConvert, strCorrectFormat)); + } + } + else + { + //When Conversion fails, remove entry + liDelKeys.Add(key); + protocol.Log(8, -1, string.Format("Delete key: {0}; Could not convert {1} to {2}", key, strToConvert, strCorrectFormat)); + } + } + catch(Exception e) + { + //When conversion fails bad, catch exception and delete bad entry + liDelKeys.Add(key); + protocol.Log(8, -1, string.Format("Delete key: {0}; Could not convert {1} because of Exception: {2}", key, strToConvert, e.Message)); + } + } + //Delete rows with troublesome DateTimes + protocol.DeleteRow(table, liDelKeys.ToArray()); + } + } + } + + private static string GetIdx(int window_unit, DateTime window_start) + { + string idx = ""; + + switch (window_unit) + { + case 0: // Undefined + + break; + case 1: // Days + idx = window_start.ToString("yyyy-MM-dd"); + break; + case 2: // Weeks + idx = window_start.ToString("yyyy") + " week " + GetWeekNumber(window_start); + break; + case 3: // Months + idx = window_start.ToString("yyyy-MM"); + break; + case 4: // Hours + idx = window_start.ToString("yyyy-MM-dd HH"); + break; + case 5: // Minutes + idx = window_start.ToString("yyyy-MM-dd HH:mm"); + break; + } + + return idx; + } + + private static int GetWeekNumber(DateTime dtPassed) + { + CultureInfo ciCurr = CultureInfo.CurrentCulture; + int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); + return weekNum; + } +} + + +]]> + + + + /// Clear History Statistics Table + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + protocol.ClearAllKeys(1000); + } + } + ]]> + + + + /// Clear History Statistics Table + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + + int iTrigger = protocol.GetTriggerParameter(); + String sKey= protocol.RowKey(); + + UInt32 newValue=Convert.ToUInt32(protocol.GetParameter(iTrigger)); + + protocol.Log(8,5,String.Format("{0}/{1}/{2}",iTrigger,sKey,newValue)); + + UInt32 window_start = Convert.ToUInt32(protocol.GetParameterIndexByKey(400,sKey,3)); + UInt32 window_end = Convert.ToUInt32(protocol.GetParameterIndexByKey(400,sKey,4)); + + if(iTrigger == 413) + { + //StartTime + if(newValue < window_end && newValue >= 0 && newValue < 1439) + protocol.SetParameterIndexByKey(400,sKey,3,newValue); + else + protocol.Log(8,5,String.Format("Window Start value not correct. (Window Start Value must be: Lesser than Window End Value, Greater than or equal to 0, lesser than 23:59)")); + } + else + { + //EndTime + if(newValue > window_start && newValue > 0 && newValue <= 1439) + protocol.SetParameterIndexByKey(400,sKey,4,newValue); + else + protocol.Log(8,5,String.Format("Window End value not correct. (Window End Value must be: Greater than Window Start Value, Greater than 0, lesser than or equal to 23:59)")); + } + } + } + ]]> + + + + /// Save/LoadConfig + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + /*--------------------------------- + * To Add or Remove Parameters from the configuration save, simply adjust the static Mapper Class + * --------------------------------- + * SLA-ConfigurationFiles are in readable XML format and are processed using XmlSerializer that maps Object Model to XML, for ease of use: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
+ *
+ *
+ * + * + * ----------------------------------------------------- + * */ + + var error = new Error(); + var handler = new Handler(protocol, error); + + try + { + handler.Handle(); + } + catch (Exception e) + { + handler.error.ErrorOccured = true; + handler.error.SetMessage(Error.AppendPolicy.None, "Failed (Exception on Top-Level Run): ", e); + } + finally + { + protocol.SetParameter(1064, handler.error.GetMessage()); + } + } +} + +namespace Skyline.Protocol +{ + using Model; + + public class Handler + { + private readonly SLProtocol protocol; + public Error error; + + public Handler(SLProtocol protocol, Error error) + { + this.protocol = protocol; + this.error = error; + } + + public void Handle() + { + const string saveLocation = @"C:\Skyline DataMiner\Documents\SLA Configurations\"; + + //Check if Dir Exists + if (!Directory.Exists(saveLocation)) + { + protocol.CreateFolder("SLA Configurations"); + } + + var load = Convert.ToInt32(protocol.GetParameter(protocol.GetTriggerParameter())); // 0 or 1 returned + var name = Convert.ToString(protocol.GetParameter(1060)); + if (string.IsNullOrEmpty(name)) + { + error.ErrorOccured = true; + error.SetMessage("Failed: Name was Null or Empty"); + return; + } + + if (name[0] == '\\' || name[0] == '/') + { + name = name.Substring(1); + } + + var fullPath = saveLocation + name; + if (!fullPath.EndsWith(".xml")) + { + fullPath += ".xml"; + } + + switch (load) + { + case 0: + protocol.SetParameter(1064, "Saving..."); + var saver = new Saver(protocol, fullPath, error); + saver.Save(); + protocol.SetParameter(1065, 1); //Reload Configurations + break; + case 1: + protocol.SetParameter(1064, "Loading..."); + var loader = new Loader(protocol, fullPath, error); + loader.Load(); + break; + case 2: + protocol.SetParameter(1064, "Deleting..."); + try + { + if (File.Exists(fullPath)) + { + File.Delete(fullPath); + + protocol.FileChanged(fullPath, ProtocolExtensions.FileChangeType.Removed); + + error.SetMessage(Error.AppendPolicy.None, "Successfully deleted configuration: ", fullPath); + protocol.SetParameter(1065, 1); //Reload Configurations + } + else + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed to Delete Configuration file: ", fullPath); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed to Delete Configuration file: ", fullPath); + protocol.Log(8, 5, "ERR: Failed to Delete Configuration file: " + fullPath); + protocol.Log(8, 5, "Exception:" + e); + + //CONTINUE HERE + } + break; + } + } + } + + public class Saver + { + SLProtocol protocol; + string fullPath; + private Error error; + + public Saver(SLProtocol protocol, string fullPath, Error error) + { + this.protocol = protocol; + this.fullPath = fullPath; + this.error = error; + } + + public void Save() + { + //Creating the XML + var config = new Configuration(); + CreatePageXML("SLA", config.SLA.Parameters, config.SLA.Tables, Mapper.SLAParamMapping, null); + CreatePageXML("Compliance", config.Compliance.Parameters, config.Compliance.Tables, Mapper.ComplianceParamMapping, null); + CreatePageXML("Violation", config.Violation.Parameters, config.Violation.Tables, null, Mapper.ViolationTableMapping); + + var changeType = File.Exists(fullPath) + ? ProtocolExtensions.FileChangeType.Changed + : ProtocolExtensions.FileChangeType.Added; + + try + { + var xmlSerializer = new XmlSerializer(typeof(Configuration)); + try + { + using (TextWriter xmlWriter = new StreamWriter(fullPath)) + { + xmlSerializer.Serialize(xmlWriter, config); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed (Exception at Serializing -saving- to File): ", e); + return; + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed (Exception at Creating XML using Serializer): ", e); + return; + } + + //Tell the dataminer system that a file has been added or updated. + protocol.FileChanged(fullPath, changeType); + + if (error.ErrorOccured) + { + error.PrefixMessage(true, "Save Partially Successful ! Errors occurred, see Below:"); + } + else + { + error.SetMessage("Save Successful!"); + } + } + + public void CreatePageXML( + string page, + List parameters, + List tables, + Dictionary paramMapping, + Dictionary tableMapping) + { + #region parameters + + try + { + MapParameters(page, parameters, paramMapping); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " (Exception While Creating SLA):"); + error.AddMessage(e); + } + + #endregion + + #region tables + + try + { + MapTables(page, tables, tableMapping); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page", page, " processing ViolationMapping (Exception While Processing ViolationMapping):"); + error.AddMessage(e); + } + + #endregion + } + + private void MapParameters(string page, List parameters, Dictionary paramMapping) + { + if (paramMapping == null || paramMapping.Count <= 0) + { + return; + } + + var pids = paramMapping.Keys.ToArray(); + var results = (object[])protocol.GetParameters(pids); + + if (results != null) + { + for (var i = 0; i < results.Length; i++) + { + var pid = pids[i]; + try + { + if (results[i] != null) + { + object result = Mapper.NULLSTRING; + if (!protocol.IsEmpty(Convert.ToInt32(pid))) + { + result = results[i]; + } + parameters.Add(new Param(pid, paramMapping[pid], result)); + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " PID:", pid, " Name: ", paramMapping[pid]); + } + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " PID:", pid, " Name: ", paramMapping[pid]); + } + } + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.None, "Failed Creating ", page, " (GetParameters Returned Empty)"); + } + } + + private void MapTables(string page, List
tables, Dictionary tableMapping) + { + if (tableMapping == null || tableMapping.Count <= 0) + { + return; + } + + var tableIDs = new Dictionary>(); + var tableMaxIdxs = new Dictionary(); + + //Collecting all Data from TableMapping and converting into usable format. + foreach (var v in tableMapping) + { + var key = v.Key; + var keyA = key.Split('/'); + if (keyA.Length > 1) + { + var dictionaryKey = Convert.ToInt32(keyA[0]); + var dictionaryValue = Convert.ToUInt32(keyA[1]); + + if (!tableIDs.ContainsKey(dictionaryKey)) + { + tableIDs[dictionaryKey] = new List(); + } + if (!tableMaxIdxs.ContainsKey(dictionaryKey)) + { + tableMaxIdxs[dictionaryKey] = dictionaryValue; + } + tableIDs[dictionaryKey].Add(dictionaryValue); + if (tableMaxIdxs[dictionaryKey] < dictionaryValue) + tableMaxIdxs[dictionaryKey] = dictionaryValue; //Finding highest IDX (necessary for setrows in the Loader) + } + else + { + tableIDs[Convert.ToInt32(key)] = new List(); + } + } + + //Iterating over all requested Tables + foreach (var table in tableIDs) + { + var tableID = table.Key; + try + { + var columnsToRetrieve = table.Value.ToArray(); + var columns = (object[])protocol.NotifyProtocol(321 /*NT_GT_TABLE_COLUMNS*/, tableID, columnsToRetrieve); + var keys = (object[])columns[0]; + var rowsDic = new Dictionary(); + + if (keys != null) + { + for (var c = 0; c < columns.Length; c++) + { + var idx = columnsToRetrieve[c]; + var mapKey = tableID + "/" + idx; + var name = tableMapping[mapKey]; + + var column = (object[])columns[c]; + if (column != null) + { + for (var r = 0; r < column.Length; r++) + { + var rowKey = Convert.ToString(keys[r]); + if (!rowsDic.ContainsKey(rowKey)) + { + var highestIDX = tableMaxIdxs[tableID]; + rowsDic.Add(rowKey, new Row(rowKey, highestIDX)); + } + var value = column[r]; + var innerColValue = new Column(idx, name, value); + rowsDic[rowKey].Columns.Add(innerColValue); + } + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page ", page, " to retrieve Column:", idx, "-", name, " From table:", tableID); + } + } + + tables.Add(new Table(tableID, tableMapping[Convert.ToString(tableID)], rowsDic.Values.ToList())); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page ", page, " Creating Table", tableID, " (Exception While Creating ViolationTable):"); + error.AddMessage(e); + } + } + } + } + + public class Loader + { + SLProtocol protocol; + string fullPath; + private Error error; + + public Loader(SLProtocol protocol, string fullPath, Error error) + { + this.protocol = protocol; + this.fullPath = fullPath; + this.error = error; + } + + public void Load() + { + if (File.Exists(fullPath)) + { + var xmlSerializer = new XmlSerializer(typeof(Configuration)); + try + { + using (TextReader tr = new StreamReader(fullPath)) + { + var config = (Configuration)xmlSerializer.Deserialize(tr); + LoadPage("SLA", config.SLA.Parameters, config.SLA.Tables); + LoadPage("Compliance", config.Compliance.Parameters, config.Compliance.Tables); + LoadPage("Violations", config.Violation.Parameters, config.Violation.Tables); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.AfterLastPart, "Failed (Exception at Serializing -Loading- from File): "); + error.AddMessage(e); + return; + } + } + else + { + error.SetMessage("Failed Loading: File Does Not Exist!"); + return; + } + + if (error.ErrorOccured) + { + error.PrefixMessage(true, "Load Partially Successful ! Errors occurred, see Below:"); + } + else + { + error.SetMessage("Load Successful!"); + } + } + + private void LoadPage(string page, List parameters, List
tables) + { + try + { + LoadParameters(parameters); + LoadTables(tables); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed (Exception Occurred Loading ", page, "):"); + error.AddMessage(e); + } + } + + private void LoadParameters(List parameters) + { + if (parameters == null) + { + return; + } + + foreach (var p in parameters) + { + try + { + if (Convert.ToString(p.Value) != Mapper.NULLSTRING) + { + protocol.SetParameter(Convert.ToInt32(p.PID), p.Value); + } + else + { + //Clear this Parameter + var clearTrigger = Convert.ToInt32(p.PID) + 1000; + protocol.CheckTrigger(clearTrigger); + } + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed to Load parameter with PID:", p.PID); + } + } + } + + private void LoadTables(List
tables) + { + if (tables == null) + { + return; + } + + foreach (var t in tables) + { + //Clear Table + protocol.ClearAllKeys(t.PID); + foreach (var r in t.Rows) + { + try + { + var row = new object[(r.MaxIDX + 1)]; //creating array with 'null values' till MaxIDX+1 (idx is 0 based) + foreach (Column col in r.Columns) + { + row[col.IDX] = col.Value; + } + + //setrow to avoid issues with AutoIncrement and missing columns (null) if any. + protocol.AddRow(t.PID, row); + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed to Load Row with Key ", r.Key); + } + } + } + } + } + + /// + /// Error class can be accessed from all other classes to set the state + /// + public class Error + { + public bool ErrorOccured = false; + private readonly StringBuilder state = new StringBuilder(); + + public enum AppendPolicy + { + /// + /// Add no newlines. + /// + None, + /// + /// Add a newline at the end of the whole message + /// + AfterLastPart, + /// + /// Add a newline after every part provided + /// + AfterEveryPart + } + + public void SetMessage(object message) + { + SetMessage(AppendPolicy.None, message); + } + + public void SetMessage(AppendPolicy appendPolicy, params object[] messageParts) + { + state.Length = 0; + AddMessage(appendPolicy, messageParts); + } + + public void AddMessage(object message) + { + AddMessage(AppendPolicy.None, message); + } + public void AddMessage(AppendPolicy appendPolicy, params object[] messageParts) + { + foreach (var messagePart in messageParts) + { + state.Append(messagePart); + if (appendPolicy == AppendPolicy.AfterEveryPart) + { + state.AppendLine(); + } + } + + if (appendPolicy == AppendPolicy.AfterLastPart) + { + state.AppendLine(); + } + } + + public void PrefixMessage(bool appendLine, object message) + { + state.Insert(0, Environment.NewLine); + state.Insert(0, message); + } + + public string GetMessage() + { + return state.ToString(); + } + } + + public static class ProtocolExtensions + { + public enum FileChangeType + { + Changed = 32, + Removed = 33, + Added = 34 + } + + public static void FileChanged(this SLProtocol protocol, string fullPath, FileChangeType type) + { + protocol.NotifyDataMiner(41 /*NT_SEND_DMS_FILE_CHANGE*/, fullPath, (int)type); + } + + public static void CreateFolder(this SLProtocol protocol, string path) + { + protocol.NotifyDataMiner(181 /*NT_CREATE_FOLDER*/, path, null); + } + } + + namespace Model + { + /// + /// The Mapper class contains the PID-Names of the parameters/tables that need to be Saved. Adjust this if more parameters are to be saved or if parameters have to be removed from the save. + /// + public static class Mapper + { + public static string NULLSTRING = "***NULL***"; + + //All parameters from the SLA page that need to be saved + public static Dictionary SLAParamMapping = new Dictionary() + { + {105, "Type"}, + {103, "Unit"}, + {101, "Time"}, + {131, "Violation Level"}, + {108, "Delay Time"}, + {111, "Minimum Outage Threshold"}, + {35, "Admin State"}, + {29, "Base State"}, + {63, "Time to Keep Outages"}, + {67, "SLA Validity Start Time"}, + {68, "SLA Validity Stop Time"}, + {2050, "Hide Filtered Alarms" } + }; + + //All Parameters from the Compliance Page that need to be saved + public static Dictionary ComplianceParamMapping = new Dictionary() + { + {208, "Maximum Total Violations Type"}, + {123, "Maximum Total Violations Unit"}, + {121, "Maximum Total Violations Value"}, + {212, "Maximum Total Violations Percentage"}, + {129, "Total Violations Before Breach"}, + {210, "Maximum Single Violation Type"}, + {127, "Maximum Single Violation Unit"}, + {125, "Maximum Single Violation Value"}, + {216, "Maximum Single Violations Percentage"} + }; + + //All Columns and tables from the Violation Page that need to be saved + public static Dictionary ViolationTableMapping = new Dictionary() + { + {"450", "Violation Settings"}, + {"450/0", "Violation Filter Id"}, + {"450/1", "Violation Filter Type"}, + {"450/2", "Violation Filter Value"}, + {"450/3", "Violation Filter Impact"}, + {"450/4", "Violation Filter Sequence"}, + {"450/5", "Violation Filter State"}, + {"450/6", "Violation Filter Exclusive"}, + {"450/7", "Violation Filter Property Name"} + }; + } + + [Serializable()] + public class Configuration + { + public Configuration() { }//XMLSerializer always requires a parameterless constructor + private SLA sla = new SLA(); + + public SLA SLA + { + get { return sla; } + set { sla = value; } + } + private Compliance compliance = new Compliance(); + + public Compliance Compliance + { + get { return compliance; } + set { compliance = value; } + } + private Violation violation = new Violation(); + + public Violation Violation + { + get { return violation; } + set { violation = value; } + } + } + [Serializable()] + public class SLA + { + public SLA() { }//XMLSerializer always requires a parameterless constructor + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + [Serializable()] + public class Compliance + { + public Compliance() { }//XMLSerializer always requires a parameterless constructor + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + [Serializable()] + public class Violation + { + public Violation() { }//XMLSerializer always requires a parameterless constructor + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + [Serializable()] + public class Param + { + public Param() { }//XMLSerializer always requires a parameterless constructor + private uint pid; + public uint PID + { + get { return pid; } + set { pid = value; } + } + private string name; + public string Name + { + get { return name; } + set { name = value; } + } + private object value; + public object Value + { + get { return this.value; } + set { this.value = value; } + } + public Param(uint pid, string name, object value) + { + PID = pid; + Name = name; + Value = value; + } + } + [Serializable()] + public class Table + { + public Table() { }//XMLSerializer always requires a parameterless constructor + + private int pid; + + public int PID + { + get { return pid; } + set { pid = value; } + } + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + private List rows = new List(); + + public List Rows + { + get { return rows; } + set { rows = value; } + } + + public Table(int tableID, string name, List rows) + { + PID = tableID; + Name = name; + Rows = rows; + } + + } + [Serializable()] + public class Row + { + public Row() { }//XMLSerializer always requires a parameterless constructor + private string key; + public string Key + { + get { return key; } + set { key = value; } + } + + private uint maxIDX; + public uint MaxIDX + { + get { return maxIDX; } + set { maxIDX = value; } + } + + private List columns = new List(); + public List Columns + { + get { return columns; } + set { columns = value; } + } + + public Row(string key, List cols, uint maxIDX) + { + Key = key; + Columns = cols; + MaxIDX = maxIDX; + } + public Row(string key, uint maxIDX) + { + Key = key; + MaxIDX = maxIDX; + } + } + [Serializable()] + public class Column + { + public Column() { }//XMLSerializer always requires a parameterless constructor + private uint idx; + + public uint IDX + { + get { return idx; } + set { idx = value; } + } + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + private object value; + + public object Value + { + get { return this.value; } + set { this.value = value; } + } + + public Column(uint idx, string name, object value) + { + IDX = idx; + Name = name; + Value = value; + } + } + } +} +]]> + + + + /// LoadConfigurations + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + const string saveLocation = @"C:\Skyline DataMiner\Documents\SLA Configurations\"; + if (Directory.Exists(saveLocation)) + { + string[] allFiles = Directory.GetFiles(saveLocation); + string allFilesDiscreet = ""; + if (allFiles != null && allFiles.Length > 0) + { + allFilesDiscreet = string.Join(";", allFiles.Select(p=>Path.GetFileNameWithoutExtension(p))); + } + protocol.SetParameter(1062, allFilesDiscreet); + } + } +} +]]> + + + + /// Stop Outage + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol, Object input) + { + if (protocol.IsEmpty(2001)) + return; + + var strKey = Convert.ToString(protocol.GetParameter(2001)); + if (protocol.array_alarm_store.Exists(strKey)) + { + switch (Convert.ToUInt32(input)) + { + case 1: + //Delete + protocol.DeleteRow(37, strKey); + break; + case 2: + //Stop + var currentRow = (Object[])protocol.array_alarm_store.GetRow(strKey); + var setRow = new Object[currentRow.Length]; + + var strEnd = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); + var dtEnd = DateTime.Parse(strEnd); + + setRow[Parameter.Array_alarm_store.Idx.column_end_timestamp] = strEnd; + + DateTime dtStart; + if (ConvertToDateTime(Convert.ToString(currentRow[Parameter.Array_alarm_store.Idx.column_timestamp]), out dtStart)) + { + var dblOutageWeight = Convert.ToDouble(currentRow[Parameter.Array_alarm_store.Idx.column_impact]); + var dblOutage = (dtEnd - dtStart).TotalSeconds; + setRow[Parameter.Array_alarm_store.Idx.column_outage] = dblOutage / 60; + + var dbldelay = (Double)protocol.GetParameter(108); + var dblThreshold = (Double)protocol.GetParameter(111); + var dblOutageCorrected = dblOutage; + var dblViolation = 0.0; + + //Only let outage times bigger than delaytime through + if (dbldelay > 0.0 && dblOutage < dbldelay) + dblOutageCorrected = 0.0; + + //subtract minimum outage threshold of the outage time + if (dblThreshold > 0 && dblOutage > dblThreshold) + dblOutageCorrected = dblOutage - dblThreshold; + else if (dblThreshold != 0) + dblOutageCorrected = 0; + + //Calculate Violation + dblViolation = dblOutageCorrected * dblOutageWeight / 100; + + setRow[Parameter.Array_alarm_store.Idx.column_outage_corrected] = dblOutageCorrected / 60; + setRow[Parameter.Array_alarm_store.Idx.column_violation] = dblViolation / 60; + + protocol.SetRow(protocol.array_alarm_store.TableId, strKey, setRow); + } + else + { + protocol.Log(String.Format("QA{0} STOP OUTAGE - Unable to convert the StartDateTime {1}", protocol.QActionID, Convert.ToString(currentRow[Parameter.Array_alarm_store.Idx.column_timestamp])), LogType.Error, LogLevel.NoLogging); + } + break; + default: + break; + } + } + } + /// + /// convert to datetime that is expected to succeed + /// + /// + /// + public static Boolean ConvertToDateTime(String sDateTime, out DateTime dateTime) + { + dateTime = DateTime.Now; + try + { + dateTime = DateTime.Parse(sDateTime); + return true; + } + catch + { return false; } + } +}]]> + + + + + + Dummy group + Dummy group + + + + + + + + protocol + + action + + 1 + 2 + 3 + + + + Clear105 + action + + 1105 + 2105 + + + + Clear101 + action + + 1101 + 2101 + + + + Clear103 + action + + 1103 + 2103 + + + + Clear131 + action + + 1131 + 2131 + + + + Clear108 + action + + 1108 + 2108 + + + + Clear111 + action + + 1111 + 2111 + + + + Clear35 + action + + 1035 + 2035 + + + + Clear29 + action + + 1029 + 2029 + + + + Clear63 + action + + 1063 + 2063 + + + + Clear67 + action + + 1067 + 2067 + + + + Clear68 + action + + 1068 + 2068 + + + + Clear208 + action + + 1208 + 2208 + + + + Clear121 + action + + 1121 + 2121 + + + + Clear123 + action + + 1123 + 2123 + + + + Clear212 + action + + 1212 + 2212 + + + + Clear129 + action + + 1129 + 2129 + + + + Clear210 + action + + 1210 + 2210 + + + + Clear125 + action + + 1125 + 2125 + + + + Clear127 + action + + 1127 + 2127 + + + + Clear216 + action + + 1216 + 2216 + + + + + + + parameter + copy + + + id:67 == emptystring + parameter + copy + + + id:68 == emptystring + parameter + copy + + + Clear105 + parameter + clear + + + ClearOD105 + parameter + clear on display + + + Clear101 + parameter + clear + + + ClearOD101 + parameter + clear on display + + + Clear103 + parameter + clear + + + ClearOD103 + parameter + clear on display + + + Clear131 + parameter + clear + + + ClearOD131 + parameter + clear on display + + + Clear108 + parameter + clear + + + ClearOD108 + parameter + clear on display + + + Clear111 + parameter + clear + + + ClearOD111 + parameter + clear on display + + + Clear35 + parameter + clear + + + ClearOD35 + parameter + clear on display + + + Clear29 + parameter + clear + + + ClearOD29 + parameter + clear on display + + + Clear63 + parameter + clear + + + ClearOD63 + parameter + clear on display + + + Clear67 + parameter + clear + + + ClearOD67 + parameter + clear on display + + + Clear68 + parameter + clear + + + ClearOD68 + parameter + clear on display + + + Clear208 + parameter + clear + + + ClearOD208 + parameter + clear on display + + + Clear121 + parameter + clear + + + ClearOD121 + parameter + clear on display + + + Clear123 + parameter + clear + + + ClearOD123 + parameter + clear on display + + + Clear212 + parameter + clear + + + ClearOD212 + parameter + clear on display + + + Clear129 + parameter + clear + + + ClearOD129 + parameter + clear on display + + + Clear210 + parameter + clear + + + ClearOD210 + parameter + clear on display + + + Clear125 + parameter + clear + + + ClearOD125 + parameter + clear on display + + + Clear127 + parameter + clear + + + ClearOD127 + parameter + clear on display + + + Clear216 + parameter + clear + + + ClearOD216 + parameter + clear on display + + + diff --git a/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/3.0.0.x/Protocol.xml b/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/3.0.0.x/Protocol.xml new file mode 100644 index 00000000..a5e7c594 --- /dev/null +++ b/ProtocolTests/Helpers/Software Parameters/Skyline SLA Definition Basic/3.0.0.x/Protocol.xml @@ -0,0 +1,10517 @@ + + + Skyline SLA Definition Basic + Skyline SLA Definition Basic + 3.0.0.10 + Generic + 1.3.6.1.4.1.8813.2.48 + 6 + auto + sla + + Service Level Agreement + Skyline Communications + + + read_service_name + Service Name + read + + The service name + The name of the service managed by this SLA. + + time + + + + other + next param + string + + + true + + + Main View + 13 + 1 + + + + + string + + + + bus_service_id + Service id + bus + + other + next param + string + + + + not_used + not_used + fixed + + other + fixed + 8 + string + Not used + + + + raw_alarm_input + raw_alarm_input + read + + other + next param + string + + + + value 0 + + fixed + + unsigned number + fixed + 1 + 0x00 + double + + + + value 1 + + fixed + + unsigned number + fixed + 1 + 0x01 + double + + + + value from creation + + fixed + + other + fixed + 19 + 1970/01/01 00:00:00 + string + + + + value forever + + fixed + + other + fixed + 19 + 2100/01/01 00:00:00 + string + + + + read_sla_compliance_Status + Compliance + read + + Compliance status + + + + + time + + + + unsigned number + fixed + 4 + double + + + true + + + Main View + 1 + 0 + + + + + true + + + discreet + + + Compliant + 0 + + + Breached + 1 + + + Compliant (Degraded) + 2 + + + Compliant (Degrading) + 3 + + + + + + read_service_alarm_status + Service Alarm State + read + + The service alarm state + This is the alarm state of the service managed by this SLA. + + range + time + + + + unsigned number + fixed + 4 + double + + + true + + + Main View + 14 + 1 + + + + + true + + + + + 1 + 2 + 3 + 4 + 5 + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + + + + read_sla_predicted_compliance_Status + Predicted Compliance + read + + Predicted compliance status + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + Predictions + 0 + 0 + + + + + true + + + discreet + + + Compliant + 0 + + + Jeopardy + 1 + + + Breached + 2 + + + + + + history property update + history property update + read + + other + next param + string + + + + read_total_time_left_before_breach + Total Violation Time Left + read + + Total violation time left + + + + + time + + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + Not used + -1 + + + + + Not used + -1 + + + + + true + + + true + + + Main View + 3 + 0 + + + + + number + + + + read_total_time_violated + Total Violation Time + read + + Total Violation Time + This indicates how long the SLA has currently been violated. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 2 + 1 + + + + + number + + + + read_max_violation_time + Longest Violation Time + read + + Longest Violation Time + This indicates the duration of the longest violation. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 3 + 1 + + + + + number + + + + read_number_of_violation + Number of Violations + read + + Number of Violations + This represents the number of violations that occurred in the current window. + + + unsigned number + fixed + 4 + double + + + true + + + true + + + Main View + 4 + 1 + + + + + number + + + + read_number_of_affecting_alarms + Number of Affecting Alarms + read + + Number of Affecting Alarms + This represents the number of alarms that currently have an impact on the SLA. + + + unsigned number + fixed + 4 + double + + + true + + + true + + + Main View + 5 + 1 + + + + + number + + + + read_reset_counters + Last Manual Reset + read + + Last Manual Reset + Indicates when the last manual reset of the SLA was done. + + + other + next param + string + + + true + + + SLA Configuration + 3 + 1 + + + + + string + + + + write_reset_counters + + write + + other + next param + string + + + true + + + SLA Configuration + 4 + 1 + + + + + button + + + Reset + 0 + + + + + + base_timestamp + Base Timestamp + read + + Time base when using a fixed window. + + + + + + other + next param + string + + + true + + + SLA Configuration + 6 + 1 + + + + + string + + + + base_timestamp + Base Timestamp + write + + other + next param + string + + + true + + + SLA Configuration + 6 + 1 + + + + + string + + + + read_current_timestamp_base + Start Time + read + + Start Time + This is the start time of the current monitor window. + + + other + next param + string + 1970/01/01 00:00:00 + + + Since creation + 1970/01/01 00:00:00 + + + + + true + + + Main View + 19 + 1 + + + + + string + + + + read_next_timestamp_base + End Time + read + + End Time + This is the end time of the current monitor window. + + + other + next param + string + 2100/01/01 00:00:00 + + + Forever + 2100/01/01 00:00:00 + + + + + true + + + Main View + 20 + 1 + + + + + string + + + + read_percent_time_violated + Violation percentage + read + + The percent of time the SLA is violated. + This indicates the percentage of time the SLA is violated. This is a percentage of the total monitor period. + + time + + + + double + fixed + 8 + double + + + false + + + % + 3 + false + + 0 + 100 + + + + analog + + + + sla_state + Admin State + read + + Admin state + + + + + time + + + + double + fixed + 4 + double + + + true + + + true + + + Main View + 16 + 1 + + + SLA Configuration + 1 + 1 + + + + + discreet + + + Tracking + 1 + + + No tracking + 0 + + + + + + sla_state + Admin State + write + + double + fixed + 4 + double + + + true + + + SLA Configuration + 1 + 1 + + + + + togglebutton + + + Tracking + 1 + + + No Tracking + 0 + + + + + + array_alarm_store + Outage List + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Outage List + 0 + 0 + + + + + table + + + + column_severity + Alarm Severity + read + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + Manual + 12 + + + + + + column_timestamp + Begin Timestamp + read + + other + next param + string + + + true + + + string + + + + column_admin_state + Adm. State + read + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + Tracking + 1 + + + No tracking + 0 + + + + + + read_max_time_left_before_breach + Single Violation Time Left + read + + The maximum consecutive time left before the SLA is breached. + + + + + time + + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + Not used + -1 + + + + + Not used + -1 + + + + + true + + + true + + + Main View + 6 + 0 + + + + + number + + + + read_breach_time_availability + Total Violation Time Availability + read + + Total violation time availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 4 + 0 + + + + 0 + 100 + + + + number + + + + read_consecutive_breach_time_availability + Single Violation Time Availability + read + + Single violation time availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 7 + 0 + + + + 0 + 100 + + + + number + + + + read_number_of_violations_left + Number of Violations Left + read + + Number of violations left + This indicates how many violations can still occur before the SLA is breached. + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + true + + + Main View + 9 + 0 + + + + 0 + 100 + + + + number + + + + read_violation_count_availability + Number of Violations Availability + read + + Number of violations availability + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Main View + 10 + 0 + + + + 0 + 100 + + + + number + + + + column_end_timestamp + End Timestamp + read + + other + next param + string + + + now + -1 + + + + + true + + + string + + + + column_index + column_index + read + + other + next param + string + + + true + + + string + + + + read_non_percent_time_violated + Availability + read + + Availability of the service. + This indicates the service availability percentage during the current window, and at the current moment. + + time + + + + double + fixed + 8 + double + + + true + + + % + 3 + true + + + Main View + 1 + 1 + + + + 0 + 100 + + + + number + + + + read_predicted_non_percent_time_violated + Predicted Availability + read + + Predicted availability of your service. + + + + + time + + + + double + fixed + 4 + double + + + Not used + -1 + + + + + true + + + % + 3 + true + + + Predictions + 1 + 0 + + + + 0 + 100 + + + + number + + + + column_motivation + Motivation + read + + other + next param + string + + + true + + + string + + + + column_motivation + Motivation + write + + other + next param + string + + + true + + + string + + + + column_correction + Correction + read + + double + fixed + 8 + double + + + none + -1 + + + none + 0 + + + + + true + + + number + 8 + + + + column_correction + Correction + write + + double + fixed + 8 + double + + + true + min + 8 + + -1 + 10080 + + + + number + + + All + -2 + + + + + + column_outage + Outage + read + + double + fixed + 8 + double + + + now + -1 + + + + + true + 20 + + + number + + + + convert + convert + read + + unsigned number + fixed + 1 + double + + + + column_outage_pct + Outage pct + read + + double + fixed + 8 + double + + + now + -1 + + + + + true + % + 4 + + + number + + + + column_correction__pct + Correction pct + read + + double + fixed + 8 + double + 8 + + + none + -1 + + + none + 0 + + + + + true + % + 4 + + + number + + + + last_outage_index + last_outage_index + read + + other + next param + string + + + string + + + + monitorspan in sec + monitor span + read + + unsigned number + fixed + 4 + double + + + + column_outage_corrected + Outage Corrected + read + + double + fixed + 8 + double + + + now + -1 + + + none + 0 + + + + + true + 8 + + + number + + + + column_violation_pct + Violation pct + read + + double + fixed + 8 + double + 8 + + + now + -1 + + + none + 0 + + + + + true + % + 4 + + + number + + + + column_window_status + Current window + read + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + Yes (Partially) + 2 + + + + + + months_to_keep_outages + Time to Keep Outages + read + + Time to Keep Outages + Specifies how long to keep outages when they are no longer in the current window. + + + unsigned number + next param + double + + + true + Month + + + SLA Configuration + 8 + 1 + + + + + number + + + + months_to_keep_outages + Time to Keep Outages + write + + unsigned number + next param + double + + + true + Month + + + SLA Configuration + 8 + 1 + + + + 1 + 24 + + + + number + + + + read_non_percent_time_violated_without_correction + Availability Without Correction + read + + Availability of the service, without correction. + This indicates the service availability percentage during the current window, and at the current moment. Corrections on outages are ignored. + + time + + + + double + fixed + 8 + double + + + true + + + % + 3 + true + + + Main View + 7 + 1 + + + + 0 + 100 + + + + number + + + + TicketNr + Ticket + read + + other + next param + string + + + true + + + string + + + + sla_validity_start_time + SLA Validity Start Time + read + + SLA Validity Start Time + This is the start time of when the service is active. + + + other + next param + string + 1970/01/01 00:00:00 + + + Since creation + 1970/01/01 00:00:00 + + + + + true + + + SLA Configuration + 10 + 1 + + + + + string + + + + sla_validity_end_time + SLA Validity End Time + read + + SLA Validity End Time + This is the end time of when the service is active. + + + other + next param + string + 2100/01/01 00:00:00 + + + Forever + 2100/01/01 00:00:00 + + + + + true + + + SLA Configuration + 11 + 1 + + + + + string + + + + sla_validity_start_time + SLA Validity Start Time + write + + This is the start time of when the SLA is active. Format (YYYY/MM/DD HH:MM:SS) + + + other + next param + string + + + true + + + SLA Configuration + 10 + 1 + + + + + string + + + Since creation + 1970/01/01 00:00:00 + + + + + + sla_validity_end_time + SLA Validity End Time + write + + This is the end time of when the SLA is active. Format (YYYY/MM/DD HH:MM:SS) + + + other + next param + string + + + true + + + SLA Configuration + 11 + 1 + + + + + string + + + Forever + 2100/01/01 00:00:00 + + + + + + sla_health_status + SLA health status + read + + The service alarm state + This is the alarm state of the service managed by this SLA. + + range + time + + + + unsigned number + fixed + 4 + double + + + true + + + true + + + discreet + + + Undefined + 0 + + + Healthy + 1 + + + Degraded + 2 + + + + + + service_live_service_state + Service Live State + read + + Service live state + Indicates whether the service is currently on air or not. + + time + + + + other + next param + string + + + true + + + true + + + Main View + 17 + 1 + + + + + string + + + + service_current_violation_impact + Current Outage Impact + read + + Current outage impact + Shows the impact of the current alarms on the SLA. + + time + + + + double + fixed + 8 + double + + + true + + + true + 3 + % + + + Main View + 15 + 1 + + + + + number + + + + column_impact + Outage impact + read + + Outage violation impact + Shows how much the outage is impacted with the current alarms. + + time + + + + double + fixed + 8 + double + + + true + + + true + 3 + % + + + number + + + + read_unweight_total_time_violated + Total Outage Time + read + + Total Outage Time + This indicates how long the SLA is currently affected. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 8 + 1 + + + + + number + + + + read_unweight_max_violation_time + Longest Outage Time + read + + Longest Outage Time + This indicates the longest outage time. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + Main View + 9 + 1 + + + + + number + + + + column_violation + Violation + read + + double + fixed + 8 + double + + + now + -1 + + + none + 0 + + + + + true + 8 + + + number + + + + array_alarm_store_ContextMenu + Outage List_ContextMenu + write + + other + next param + string + + + true + + + discreet + + + Delete Selected Manual Outage(s) + deleteoutages + + + + + + array_alarm_store_QActionFeedback + Outage List_QActionFeedback + read + + other + next param + string + + + true + + + string + + + + sla_monitor_time + Time + read + + Time + Specifies the window size of the SLA. + + + unsigned number + next param + double + + + false + + + true + + + SLA Configuration + 4 + 0 + + + + + number + + + + sla_monitor_time + Time + write + + The SLA Time. + The time of the SLA. + + time + + + + unsigned number + next param + double + + + + 1 + 100 + + true + + + SLA Configuration + 4 + 0 + + + + + 103 + + + number + + + + sla_monitor_unit + Unit + read + + Unit + Specifies the window size of the SLA. + + + unsigned number + next param + double + + + true + + + SLA Configuration + 5 + 0 + + + + + discreet + + + Undefined + 0 + + + Days + 1 + + + Weeks + 2 + + + Months + 3 + + + Hours + 4 + + + Minutes + 5 + + + + + + sla_monitor_unit + Unit + write + + The SLA Unit. + The unit of the SLA. + + time + range + + + + unsigned number + next param + double + + + true + + + SLA Configuration + 5 + 0 + + + + + discreet + + + Days + 1 + + + Weeks + 2 + + + Months + 3 + + + Hours + 4 + + + Minutes + 5 + + + + + + sla_monitor_type + Type + read + + The windowtype of the SLA. + + + + + + unsigned number + next param + double + + + true + + + SLA Configuration + 2 + 0 + + + + + discreet + + + Sliding window + 1 + + + Fixed window + 2 + + + + + + sla_monitor_type + Type + write + + unsigned number + next param + double + + + true + + + SLA Configuration + 2 + 0 + + + + + togglebutton + + + Sliding Window + 1 + + + Fixed Window + 2 + + + + + + sla_delay_time + Delay Time + read + + Delay Time + This specifies how long an outage may occur, before it becomes a violation. + + + unsigned number + next param + double + + + Not used + 0 + + + + + true + + + SLA Configuration + 10 + 0 + + + + + number + + + + sla_delay_time + Delay Time + write + + unsigned number + next param + double + + + s + true + + + SLA Configuration + 10 + 0 + + + + 1 + 1800 + + + + number + + + Not used + 0 + + + + + + sla_recalculate + recalculate + write + + unsigned number + fixed + 4 + double + + + true + + + number + + + + sla_minimum_outage_threshold + Minimum Outage Threshold + read + + Minimum Outage Threshold + Period of the outage, if the delay time has passed, that doesn't count as violation time. + + + unsigned number + next param + double + + + Full outage + 0 + + + + + true + + + SLA Configuration + 11 + 0 + + + + + number + + + + sla_minimum_outage_threshold + Minimum Outage Threshold + write + + unsigned number + next param + double + + + s + true + + + SLA Configuration + 11 + 0 + + + + 1 + 1800 + + + + number + + + Full outage + 0 + + + + + + sla_breach_value + Maximum Total Violations Value + read + + Maximum Total Violations Value + Compliance: Maximum total allowed violation time value. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 0 + + + + + number + + + + sla_breach_value + Maximum Total Violations Value + write + + unsigned number + next param + double + + + + 1 + 90 + + true + + + Compliance Configuration + 6 + 0 + + + + + 123 + + + number + + + + sla_breach_unit + Maximum Total Violations Unit + read + + Maximum Total Violations Unit + Compliance: Maximum total allowed violation time unit. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 7 + 0 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_breach_unit + Maximum Total Violations Unit + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 7 + 0 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_consecutive_breach_value + Maximum Single Violation Value + read + + Maximum Single Violation Value + Compliance: Maximum single allowed violation time value. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 5 + 1 + + + + + number + + + + sla_consecutive_breach_value + Maximum Single Violation Value + write + + unsigned number + next param + double + + + + 1 + 90 + + true + + + Compliance Configuration + 5 + 1 + + + + + 127 + + + number + + + + sla_consecutive_breach_unit + Maximum Single Violation Unit + read + + Maximum Single Violation Unit + Compliance: Maximum single allowed violation time unit. + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 1 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_consecutive_breach_unit + Maximum Single Violation Unit + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 6 + 1 + + + + + discreet + + + Seconds + 1 + + + Minutes + 2 + + + Hours + 3 + + + Days + 4 + + + + + + sla_max_violations + Total Violations Before Breach + read + + Total Violations Before Breach + Compliance: The maximum allowed number of violations. + + + signed number + next param + double + + + Not used + -1 + + + + + true + + + Compliance Configuration + 12 + 0 + + + + + number + + + + sla_max_violations + Total Violations Before Breach + write + + signed number + next param + double + + + + 0 + 100 + + true + + + Compliance Configuration + 12 + 0 + + + + + number + + + Not used + -1 + + + + + + sla_violation_level + Violation Level + read + + Violation Level + This indicates from which alarm level onwards the SLA is violated. + + + unsigned number + next param + double + + + true + + + SLA Configuration + 9 + 0 + + + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + + + + sla_violation_level + Violation Level + write + + unsigned number + next param + double + + + true + + + SLA Configuration + 9 + 0 + + + + + discreet + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + + + + manual_outage_start_time + Manual outage start time + read + + The start time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_start_time + Manual outage start time + write + + The start time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_end_time + Manual outage end time + read + + The end time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_end_time + Manual outage end time + write + + The end time of the manual outage to be added. + This time should be formatted as YYYY/MM/DD hh:mm:ss + + + other + next param + string + + + true + + + string + + + + manual_outage_motivation + Manual outage motivation + read + + The motivation of the manual outage to be added. + + + other + next param + string + + + true + + + string + + + + manual_outage_motivation + Manual outage motivation + write + + The motivation of the manual outage to be added. + + + other + next param + string + + + true + + + string + + + + manual_outage_overrule_motivation + Overrule existing motivations + read + + This indicates if motivations on overruled outages should be overwritten with a reference to the current outage. + + + unsigned number + fixed + 4 + double + + + true + + + discreet + + + No + 0 + + + Yes + 1 + + + + + + manual_outage_overrule_motivation + Overrule existing motivations + write + + This indicates if motivations on overruled outages should be overwritten with a reference to the current outage. + + + unsigned number + fixed + 4 + double + + + true + + + togglebutton + + + No + 0 + + + Yes + 1 + + + + + + manual_outage_add + + write + + + + + + + unsigned number + fixed + 4 + double + + + true + + + Outage List + 2 + 0 + + + + + + 147 + + 149 + 137 + + + + + button + + + Add Outage... + 1 + + + + + + manual_outage_delete + + write + + Deletes a manual outage. + + + unsigned number + fixed + 4 + double + + + true + + + 143 + + + button + + + Delete outage... + 1 + + + + + + manual_outage_delete_pk + Manual outage key + read + + The primary key(s) of the outage to be deleted. Semicolon-separated values. + + time + range + steps + units + + + + other + next param + string + + + true + + + string + + + + manual_outage_delete_pk + Manual outage key + write + + other + next param + string + + + true + + + string + + + + + + manual_outage_start_time_client_input + New Outage Start Time + read + + The start time of the manual outage to be added. + + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_start_time_client_input + New Outage Start Time + write + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_end_time_client_input + New Outage End Time + read + + The end time of the manual outage to be added. + + + double + fixed + 8 + double + + + true + + + number + + + + manual_outage_end_time_client_input + New Outage End Time + write + + double + fixed + 8 + double + + + true + + + number + + + + + TicketNr + Ticket + write + + other + next param + string + + + true + + + string + + + + sla_total_breach + Maximum Total Violation Time + read + + Maximum Total Violation Time + Compliance: Maximum total violation time + + + other + next param + string + + + Invalid + Invalid + + + Not used + Not Used + + + + + true + + + Compliance Configuration + 2 + 0 + + + + + string + + + + sla_max_consecutive_breach + Maximum Single Violation Time + read + + Maximum Single Violation Time + Compliance: Maximum single violation time + + + other + next param + string + + + Invalid + Invalid + + + Not Used + Not Used + + + + + true + + + Compliance Configuration + 1 + 1 + + + + + string + + + + sla_total_slot_type + Maximum Total Violations Type + read + + Compliance: Maximum total violation type + + + + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 4 + 0 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_total_slot_type + Maximum Total Violations Type + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 4 + 0 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_max_consecutive_slot_type + Maximum Single Violation Type + read + + Compliance: Maximum single violation type + + + + + + unsigned number + next param + double + + + true + + + Compliance Configuration + 3 + 1 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + sla_max_consecutive_slot_type + Maximum Single Violation Type + write + + unsigned number + next param + double + + + true + + + Compliance Configuration + 3 + 1 + + + + + discreet + + + Not used + 0 + + + Absolute + 1 + + + Relative + 2 + + + + + + total_relative_percentage + Maximum Total Violations Percentage + read + + Maximum Total Violations Percentage + Compliance: Maximum total violation percentage + + + double + fixed + 4 + double + + + Not applicable + -1 + + + + + % + 3 + true + + + Compliance Configuration + 9 + 0 + + + + + number + + + + total_relative_percentage + Maximum Total Violations Percentage + write + + double + fixed + 4 + double + + + + 0 + 100 + + % + 3 + true + + + Compliance Configuration + 9 + 0 + + + + + number + + + + max_consecutive_relative_percentage + Maximum Single Violation Percentage + read + + Maximum Single Violation Percentage + Compliance: Maximum single violation percentage + + + double + fixed + 4 + double + + + Not applicable + -1 + + + + + % + 3 + true + + + Compliance Configuration + 8 + 1 + + + + + number + + + + max_consecutive_relative_percentage + Maximum Single Violation Percentage + write + + double + fixed + 4 + double + + + + 0 + 100 + + % + 3 + true + + + Compliance Configuration + 8 + 1 + + + + + number + + + + Current_array_active_service_alarms + Current Active Service Alarms + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Active Service Alarms + 0 + 0 + + + + + table + + + + Current_array_active_service_alarms_id + Current Active Service Alarm Id + read + + Alarm id of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_severity + Current Active Service Alarm Severity + read + + Severity of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Critical + 1 + + + Major + 2 + + + Minor + 3 + + + Warning + 4 + + + Normal + 5 + + + Information + 13 + + + Timeout + 17 + + + Error + 24 + + + Notice + 28 + + + + + + Current_array_active_service_alarms_time + Current Active Service Alarm Time + read + + Starttime of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_element + Current Active Service Alarm Element + read + + Element of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_parameter + Current Active Service Alarm Parameter + read + + Parameter of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_value + Current Active Service Alarm Value + read + + Value of the alarm active service the SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_state + Current Active Service Alarm State + read + + State of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Cleared + 11 + + + Open + 12 + + + Masked + 25 + + + Clearable + 54 + + + + + + Current_array_active_service_alarms_type + Current Active Service Alarm Type + read + + Type of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Escalated + 8 + + + Dropped + 9 + + + New alarm + 10 + + + Cleared + 11 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + Comment Added + 22 + + + Unmask + 27 + + + Dropped from Critical + 31 + + + Dropped from Major + 32 + + + Dropped from Minor + 33 + + + Dropped from Warning + 34 + + + Escalated from Warning + 35 + + + Escalated from Minor + 36 + + + Escalated from Major + 37 + + + Flipped + 38 + + + Service impact changed + 40 + + + Value changed + 41 + + + Name changed + 42 + + + RCA-Level changed + 43 + + + Properties changed + 50 + + + Threshold changed + 53 + + + Interface changed + 55 + + + + + + Current_array_active_service_alarms_user_state + Current Active Service Alarm User State + read + + User state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Not assigned + 18 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + + + + Current_array_active_service_alarms_source + Current Active Service Alarm Source + read + + Source of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Mobile Gateway + 14 + + + DataMiner + 16 + + + Correlation + 23 + + + Watchdog + 29 + + + External + 30 + + + Aggregation + 56 + + + + + + Current_array_active_service_alarms_category + Current Active Service Alarm Category + read + + Category of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_offline impact + Current Active Service Alarm Offline Impact + read + + Offline impact of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Yes + 1 + + + No + 0 + + + + + + Current_array_active_service_alarms_service_point + Current Active Service Alarm Service Point + read + + Service point of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_component_info + Current Active Service Alarm Component Info + read + + Component info of the active service SLA + + + other + next param + string + + + true + + + string + + + + Current_array_active_service_alarms_inclusion_state + Current Active Service Alarm Overruled Inclusion State + read + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + Current_array_active_service_alarms_inclusion_state + Current Active Service Alarm Overruled Inclusion State + write + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + Current_array_active_service_alarms_calculated_inclusion_state + Current Active Service Alarm Calculated Inclusion State + read + + Calculated inclusion state of the active service SLA + + + double + fixed + 8 + double + + + true + % + 0 + + + number + + + + title_begin_sla_status + Compliance Info + fixed + + true + + + Main View + 0 + 0 + + + + + title + + + + title_end_sla_status + + fixed + + true + + + Main View + 11 + 0 + + + + + title + + + + title_begin_service_status + General Info + fixed + + true + + + Main View + 12 + 1 + + + + + title + + + + title_end_service_status + + fixed + + true + + + Main View + 21 + 1 + + + + + title + + + + title_begin_violation_status + Performance Indicators + fixed + + true + + + Main View + 0 + 1 + + + + + title + + + + title_end_violation_status + + fixed + + true + + + Main View + 10 + 1 + + + + + title + + + + title_begin_sla_window + Window settings + fixed + + true + + + SLA Configuration + 1 + 0 + + + + + title + + + + title_end_sla_window + + fixed + + true + + + SLA Configuration + 6 + 0 + + + + + title + + + + title_begin_sla_config + Extra settings + fixed + + true + + + SLA Configuration + 0 + 1 + + + + + title + + + + title_end_sla_config + + fixed + + true + + + SLA Configuration + 14 + 1 + + + + + title + + + + title_begin_total_breach_config + Total violation + fixed + + true + + + Compliance Configuration + 1 + 0 + + + + + title + + + + title_end_total_breach_config + + fixed + + true + + + Compliance Configuration + 10 + 0 + + + + + title + + + + title_begin_cons_breach_config + Single violation + fixed + + true + + + Compliance Configuration + 0 + 1 + + + + + title + + + + title_end_cons_breach_config + + fixed + + true + + + Compliance Configuration + 9 + 1 + + + + + title + + + + title_begin_number_breach_config + Violation count + fixed + + true + + + Compliance Configuration + 11 + 0 + + + + + title + + + + title_end_number_breach_config + + fixed + + true + + + Compliance Configuration + 13 + 0 + + + + + title + + + + title_begin_sla_alarm_config + Alarm settings + fixed + + true + + + SLA Configuration + 8 + 0 + + + + + title + + + + title_end_sla_alarm_config + + fixed + + true + + + SLA Configuration + 15 + 0 + + + + + title + + + + title_begin_advanced_config + Advanced Config + fixed + + true + + + Advanced Configuration + 0 + 0 + + + + + title + + + + title_end_advanced_config + + fixed + + true + + + Advanced Configuration + 9 + 0 + + + + + title + + + + trigger_dummy_row_added + trigger_dummy_row_added + read + + other + next param + string + + + + trigger_dummy_row_changed + trigger_dummy_row_changed + read + + other + next param + string + + + + trigger_dummy_row_deleted + trigger_dummy_row_deleted + read + + other + next param + string + + + + array_offline_window + Offline Window + array + + + + + + + + + + + + + + other + next param + double + + + true + + + Offline Window + 0 + 0 + + + + + table + + + + array_offline_window_id + Offline Window Id + read + + Id of the offline window + + + other + next param + string + + + true + + + string + + + + array_offline_window_start_day + Offline Window Start Day + read + + Start day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_start_time + Offline Window Start Time + read + + Start time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + + number + + + + array_offline_window_end_time + Offline Window End Time + read + + End time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + + number + + + + array_offline_window_state + Offline Window State + read + + State of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + + + + array_offline_window_start_day + Offline Window Start Day + write + + Start day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_start_time + Offline Window Start Time + write + + Start time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + 0 + 1439 + + + + number + + + + array_offline_window_end_day + Offline Window End Day + write + + End day of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Undefined + 0 + + + Monday + 2 + + + Tuesday + 3 + + + Wednesday + 4 + + + Thursday + 5 + + + Friday + 6 + + + Saturday + 7 + + + Sunday + 1 + + + + + + array_offline_window_end_time + Offline Window End Time + write + + End time of the offline window + + + unsigned number + fixed + 4 + double + + + true + + 0 + 1439 + + + + number + + + + array_offline_window_state + Offline Window State + write + + State of the offline window + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + Delete + 3 + + + + + + array_offline_window_change + Offline Window Change + write + + Change the offline window settings + + + unsigned number + fixed + 1 + double + + + true + + + Offline Window + 1 + 0 + + + + + button + + + Add Entry + 1 + + + + + + array_violation_settings + Violation Settings + array + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Violation Configuration + 1 + 0 + + + + + table + + + + array_violation_settings_id + Violation Filter Id + read + + Id of the violation setting + + + other + next param + string + + + true + + + string + + + + array_violation_settings_type + Violation Filter Type + read + + Field on which you want to filter + + + signed number + fixed + 2 + double + + + true + + + discreet + + + Custom service property + -4 + + + Custom view property + -3 + + + Custom element property + -2 + + + Custom alarm property + -1 + + + Undefined + 0 + + + Severity + 9 + + + Element name + 19 + + + Parameter name + 21 + + + Alarm state + 8 + + + Category + 27 + + + Key point + 31 + + + Component info + 33 + + + + + + array_violation_settings_value + Violation Filter Value + read + + Value filter of the violation type + + + other + next param + string + + + true + + + string + + + + array_violation_settings_impact + Violation Filter Impact + read + + Violation impact + + + unsigned number + fixed + 2 + double + + + true + % + + 0 + 100 + + + + number + + + + array_violation_sequence + Violation Filter Sequence + read + + Sequence of the vionlation filter + + + unsigned number + fixed + 2 + double + + + true + + 0 + 100 + + + + number + + + + array_violation_state + Violation Filter State + read + + State of the violation filter. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + + + + array_violation_exclusive + Violation Filter Exclusive + read + + If set to filter and the setting does not match, the alarm is skipped in the SLA processing, if set to continue, the other settings are checked. If at the end no match is found, the alarm is included for SLA Calculations. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Filter + 1 + + + Continue + 2 + + + + + + array_violation_property_name + Violation Filter Property Name + read + + Property name of the violation filter + + + other + next param + string + + + true + + + string + + + + array_violation_settings_type + Violation Filter Type + write + + Field on which you want to filter + + + other + next param + string + + + true + + + discreet + + + Custom service property + -4 + + + Custom view property + -3 + + + Custom element property + -2 + + + Custom alarm property + -1 + + + Severity + 9 + + + Element name + 19 + + + Parameter name + 21 + + + Alarm state + 8 + + + Category + 27 + + + Key point + 31 + + + Component info + 33 + + + + + + array_violation_settings_value + Violation Filter Value + write + + Value filter of the violation type + + + other + next param + string + + + true + + + string + + + + array_violation_settings_impact + Violation Filter Impact + write + + Violation impact + + + unsigned number + fixed + 2 + double + + + true + % + + 0 + 100 + + + + number + + + + array_violation_sequence + Violation Filter Sequence + write + + Sequence of the vionlation filter + + + unsigned number + fixed + 2 + double + + + true + + 0 + 100 + + + + number + + + + array_violation_state + Violation Filter State + write + + State of the violation filter. + + + unsigned number + fixed + 1 + double + + + true + + + discreet + + + Enabled + 1 + + + Disabled + 2 + + + Delete + 3 + + + + + + array_violation_exclusive + Violation Filter Exclusive + write + + If set to true and the filter does not match, the alarm is skipped in the SLA processing, if set to false, the other filters are checked. If at the end no match is found, the alarm is included for SLA Calculations. + + + unsigned number + fixed + 1 + double + + + true + + + togglebutton + + + Filter + 1 + + + Continue + 2 + + + + + + array_violation_property_name + Violation Filter Property Name + write + + Property name of the violation filter + + + other + next param + string + + + true + + + string + + + + array_violation_setting_add_entry + Violation Settings + write + + Change the offline window settings + + + unsigned number + fixed + 1 + double + + + true + + + Violation Configuration + 2 + 0 + + + + + button + + + Add Entry + 1 + + + + + + OutageDetails + OutageDetails + read + + other + next param + string + + + true + + + + array_root_to_outage + table holding root to outage + array + + + + + + + + + + other + next param + double + + + true + + + table + + + + array_root_to_outage_id + array_root_to_outage_id + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_root + array_root_to_outage_root + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_outage + array_root_to_outage_outage + read + + other + next param + string + + + true + + + string + + + + array_root_to_outage_weight + array_root_to_outage_weight + read + + double + fixed + 8 + double + + + true + 2 + % + + + number + + + + array_root_to_outage_inclusion_state + array_root_to_outage_inclustion_state + read + + unsigned number + fixed + 1 + double + + + true + + + number + + + + array_root_to_outage_alarm + array_root_to_outage_alarm + read + + other + next param + string + + + true + + + string + + + + GenerateTicket + Generate Ticket + read + + Generate Ticket + + + + unsigned number + fixed + 4 + double + + + true + + + Ticket Creation + 0 + 0 + + + + + discreet + + + Clear + 0 + + + Create Ticket + 1 + + + Create Ticket, second attempt + 2 + + + Create Ticket, third attempt + 3 + + + Unable to create ticket + 4 + + + + + true + + + + GenerateTicket + Generate Ticket + write + + unsigned number + fixed + 4 + double + + + true + + + Ticket Creation + 0 + 0 + + + + + discreet + + + Clear + 0 + + + Create Ticket + 1 + + + Create Ticket, second attempt + 2 + + + Create Ticket, third attempt + 3 + + + Unable to create ticket + 4 + + + + + + array_active_service_alarms + Active Service Alarms + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + other + next param + double + + + false + + + table + + + + array_active_service_alarms_rootid + Active Service Alarm RootId + read + + Alarm Rootid of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_severity + Active Service Alarm Severity + read + + Severity of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Critical + 1 + + + Major + 2 + + + Minor + 3 + + + Warning + 4 + + + Normal + 5 + + + Information + 13 + + + Timeout + 17 + + + Error + 24 + + + Notice + 28 + + + + + + array_active_service_alarms_time + Active Service Alarm Time + read + + Starttime of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_element + Active Service Alarm Element + read + + Element of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_parameter + Active Service Alarm Parameter + read + + Parameter of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_value + Active Service Alarm Value + read + + Value of the alarm active service the SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_state + Active Service Alarm State + read + + State of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Cleared + 11 + + + Open + 12 + + + Masked + 25 + + + Clearable + 54 + + + + + + array_active_service_alarms_type + Active Service Alarm Type + read + + Type of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Escalated + 8 + + + Dropped + 9 + + + New alarm + 10 + + + Cleared + 11 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + Comment Added + 22 + + + Unmask + 27 + + + Dropped from Critical + 31 + + + Dropped from Major + 32 + + + Dropped from Minor + 33 + + + Dropped from Warning + 34 + + + Escalated from Warning + 35 + + + Escalated from Minor + 36 + + + Escalated from Major + 37 + + + Flipped + 38 + + + Service impact changed + 40 + + + Value changed + 41 + + + Name changed + 42 + + + RCA-Level changed + 43 + + + Properties changed + 50 + + + Threshold changed + 53 + + + Interface changed + 55 + + + + + + array_active_service_alarms_user_state + Active Service Alarm User State + read + + User state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Not assigned + 18 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + + + + array_active_service_alarms_source + Active Service Alarm Source + read + + Source of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Mobile Gateway + 14 + + + DataMiner + 16 + + + Correlation + 23 + + + Watchdog + 29 + + + External + 30 + + + Aggregation + 56 + + + + + + array_active_service_alarms_category + Active Service Alarm Category + read + + Category of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_offline impact + Active Service Alarm Offline Impact + read + + Offline impact of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Yes + 1 + + + No + 0 + + + + + + array_active_service_alarms_service_point + Active Service Alarm Service Point + read + + Service point of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_component_info + Active Service Alarm Component Info + read + + Component info of the active service SLA + + + other + next param + string + + + true + + + string + + + + array_active_service_alarms_inclusion_state + Active Service Alarm Overruled Inclusion State + read + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + array_active_service_alarms_inclusion_state + Active Service Alarm Overruled Inclusion State + write + + Inclusion state of the active service SLA + + + other + next param + string + + + true + + + discreet + + + Included + Yes + + + Not included + No + + + + + + array_active_service_alarms_calculated_inclusion_state + Active Service Alarm Calculated Inclusion State + read + + Calculated inclusion state of the active service SLA + + + double + fixed + 8 + double + + + true + % + 0 + + + number + + + + array_active_service_alarms_id + Active Service Alarm Id + read + + Alarm id of the active service SLA + + + other + next param + string + + + true + + + string + + + + History Statistics Table + History Statistics Table + array + + + + + + + + + + + + + + + + + + + + + + + + Table containing key parameter SLA statistics of previous tracking periods. + + + other + next param + double + + + true + + + History + 0 + 0 + + + + + table + + + + Tracking Period + Tracking Period [IDX] + + Tracking Period + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + Start Time (History) + Start Time (History) + + History Start Time + + time + range + steps + units + + + read + + other + next param + string + + + true + + + string + + + + End Time (History) + End Time (History) + + History End Time + + time + range + steps + units + + + read + + other + next param + string + + + now + -1 + + + + + true + + + string + + + + Stored End Time (History) + Stored End Time (History) + read + + other + next param + string + + + true + + + string + + + + Compliance (History) + Compliance (History) + + Compliance + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + + + discreet + + + Compliant + 0 + + + Breached + 1 + + + Compliant (Degraded) + 2 + + + Compliant (Degrading) + 3 + + + + + + Availability (History) + Availability (History) + + Availability + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + % + 2 + + 0 + 100 + + + + number + + + + Availability Without Corrections (History) + Availability Without Corrections (History) + + Availability Without Corrections + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + true + % + 2 + + 0 + 100 + + + + number + + + + Total Violation Time (History) + Total Violation Time (History) + read + + This indicates how long the SLA is currently violated. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + number + + + + Longest Violation Time (History) + Longest Violation Time (History) + read + + This indicates the duration of the longest violation. + + + unsigned number + fixed + 4 + double + HalfToInfinity + + + true + + + true + + + number + + + + Number Of Violations (History) + Number of Violations (History) + read + + This represents the number of violations that occured in the current window. + + + unsigned number + fixed + 4 + double + + + true + + + true + + + number + + + + Clear History Statistics Table + + + Clear History Statistics Table + + time + range + steps + units + + + write + + numeric text + next param + double + + + true + + + History + 1 + 0 + + + + + button + + + Clear History + 1 + + + + + + Current History IDX + Current History IDX + read + + other + next param + string + + + + Max Number Of History Rows + Max Number of History Rows + + Max Number of History Rows + + time + range + steps + units + + + read + + numeric text + next param + double + + + true + + + History + 2 + 0 + + + + + number + + + + Max Number Of History Rows + Max Number of History Rows + write + + numeric text + next param + double + + + true + + + History + 2 + 0 + + + + + number + + + + ConfigurationName + Configuration Name + + Configuration Name + The Configuration Name used to Save or Load a specific Configuration + + time + range + steps + units + + + read + + other + next param + string + + + true + + + Save/Load Configuration + 0 + 0 + + + + + false + + + string + + + + ConfigurationName + Configuration Name + write + + other + next param + string + + + true + + + Save/Load Configuration + 0 + 0 + + + + + string + + + + + AvailableConfigurations + AvailableConfigurations + + AvailableConfigurations + All Detected and Available Configurations + + time + range + steps + units + + + read + + other + next param + string + + + false + + + true + + + string + + + + SaveLoadConfig + + write + + numeric text + next param + double + + + true + + + Save/Load Configuration + 2 + 0 + + + + + button + + + Save + 0 + + + Load + 1 + + + Delete + 2 + + + + + + Save/Load Status + Save/Load Status + + Save/Load Status + Indicates the status for the save or load action + + time + range + steps + units + + + read + + other + next param + string + + + false + + + true + + + Save/Load Configuration + 3 + 0 + + + + + string + + + + + PB_SaveLoadConfig + + write + + other + next param + string + + + true + + + SLA Configuration + 0 + 0 + + + Compliance Configuration + 0 + 0 + + + Violation Configuration + 0 + 0 + + + + + pagebutton + + + Save/Load Config... + Save/Load Configuration + + + + + + BUT_LoadConfigurations + + write + + numeric text + next param + double + + + true + + + Save/Load Configuration + 1 + 0 + + + + + button + + + Load Configurations + 1 + + + + + + pagebutton Edit Outage + + write + + other + next param + string + + + true + + + Outage List + 1 + 0 + + + + + pagebutton + + + Edit Outage... + Edit Outage + + + + + + Outage_to_Stop_Delete + Outage to Stop or Delete + + Outage to Stop or Delete + Outage to Stop or Delete + + time + range + steps + units + + + read + + other + next param + string + + + true + + + Edit Outage + 1 + 0 + + + + + string + + + + Outage_to_Stop_Delete + Outage to Stop or Delete + write + + other + next param + string + + + true + + + Edit Outage + 1 + 0 + + + + + string + + + + Delete Selected Outage + + write + + numeric text + next param + double + + + true + + + Edit Outage + 2 + 0 + + + + + button + + + Delete Outage + 1 + + + Stop Outage... + 2 + + + + + + hide_violation_filtered_alarms + Violation Filtered Alarms + read + + Hide violation filtered alarms + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 3 + 0 + + + + + discreet + + + Show + 0 + + + Hide + 1 + + + + + + hide_violation_filtered_alarms + Violation Filtered Alarms + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 3 + 0 + + + + + togglebutton + + + Show + 0 + + + Hide + 1 + + + + + + hide_offline_window_outages + Offline Window Outages + read + + Offline Window Outages + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 4 + 0 + + + + + discreet + + + Show + 0 + + + Hide + 1 + + + + + + hide_offline_window_outages + Offline Window Outages + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 4 + 0 + + + + + togglebutton + + + Show + 0 + + + Hide + 1 + + + + + + enable_predictions + Predictions + read + + Enable Predictions + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 5 + 0 + + + + + discreet + + + Enabled + 0 + + + Disabled + 1 + + + + + + enable_predictions + Predictions + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 5 + 0 + + + + + togglebutton + + + Enabled + 0 + + + Disabled + 1 + + + + + + enable_outages + Outages + read + + Enable Outages + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 2 + 0 + + + + + discreet + + + Enabled + 0 + + + Disabled + 1 + + + + + + enable_outages + Outages + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 2 + 0 + + + + + togglebutton + + + Enabled + 0 + + + Disabled + 1 + + + + + + show_active_alarms + Active Alarms + read + + Show Active Alarms + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 1 + 0 + + + + + discreet + + + Show + 0 + + + Hide + 1 + + + + + + show_active_alarms + Active Alarms + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 1 + 0 + + + + + togglebutton + + + Show + 0 + + + Hide + 1 + + + + + + enable_enhanced_service_mode + Enhanced Service Mode + read + + Enhanced Service Mode + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + show_excluded_service_element_alarms + Excluded Service Element Alarms Visibility + read + + Show Active Alarms + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 6 + 0 + + + + + discreet + + + Show + 0 + + + Hide + 1 + + + + + + show_excluded_service_element_alarms + Excluded Service Element Alarms Visibility + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 6 + 0 + + + + + togglebutton + + + Show + 0 + + + Hide + 1 + + + + + + use_service_capping + Service Capping + read + + Use Alarm capping defined on the service + + + + + range + steps + units + time + + + + double + fixed + 4 + double + 0 + + + true + + + Advanced Configuration + 7 + 0 + + + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + use_service_capping + Service Capping + write + + double + fixed + 4 + double + + + true + + + Advanced Configuration + 7 + 0 + + + + + togglebutton + + + Disabled + 0 + + + Enabled + 1 + + + + + + Affecting_Alarms_Level + Affecting Alarms Level + read + + Affecting Alarms Level + + range + steps + units + time + + + + double + fixed + 4 + double + + + Not applicable + -1 + + + + + % + true + + + Advanced Configuration + 8 + 0 + + + + + number + + + + Affecting_Alarms_Level + Affecting Alarms Level + write + + double + fixed + 4 + double + + + + 0 + 100 + + % + true + + + Advanced Configuration + 8 + 0 + + + + + number + + + + + + dblViolation) dblInput = dblViolation; + dblViolation -= dblInput; + + protocol.SetParameterIndexByKey(protocol.array_alarm_store.TableId, protocol.RowKey(), Parameter.Array_alarm_store.Idx.column_correction + 1, dblInput); + protocol.SetParameterIndexByKey(protocol.array_alarm_store.TableId, protocol.RowKey(), Parameter.Array_alarm_store.Idx.column_violation + 1, dblViolation); + } +} +]]> + + + + /// Manual Outage Delete + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol) + { + var allOutagesToDelete = new List(); + + var sKeysToDelete = Convert.ToString(protocol.Manual_outage_delete_pk_143).Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + + if (sKeysToDelete.Length > 20) + { + var oOutageTable = (object[])protocol.NotifyProtocol( + 321, + Parameter.Array_alarm_store.tablePid /*37*/, + new UInt32[] + { + Parameter.Array_alarm_store.Idx.column_index_47, + Parameter.Array_alarm_store.Idx.column_severity_38 + }); + var oOutagePks = (object[])oOutageTable[0]; + var oOutageType = (object[])oOutageTable[1]; + var keyToType = new Dictionary(); + + for (var i = 0; i < oOutagePks.Length; i++) + { + keyToType[Convert.ToString(oOutagePks[i])] = oOutageType[i]; + } + + foreach (var sKeyToDelete in sKeysToDelete) + { + if (!keyToType.ContainsKey(sKeyToDelete)) + { + continue; + } + // Check type, only delete manual outages + var iOutageType = Convert.ToInt32(keyToType[sKeyToDelete]); + if (iOutageType == 12) + { + allOutagesToDelete.Add(sKeyToDelete); + } + + // Make sure we don't delete the same key twice by failing the next exist lookup + keyToType.Remove(sKeyToDelete); + } + } + else + { + foreach (var sKeyToDelete in sKeysToDelete) + { + if (!protocol.array_alarm_store.Exists(sKeyToDelete)) + { + continue; + } + + var iOutageType = Convert.ToInt32(protocol.array_alarm_store[sKeyToDelete, Parameter.Array_alarm_store.Idx.column_severity_38]); + if (iOutageType == 12) + { + // Only delete manual outages + allOutagesToDelete.Add(sKeyToDelete); + } + } + } + + if (allOutagesToDelete.Count != 0) + { + protocol.array_alarm_store.DeleteRow(allOutagesToDelete); + } + } +} +]]> + + + + + + (); + var ignoredOutages = new List(); + + if (keys.Length - startIndex > 20) + { + var oOutageTable = (object[])protocol.NotifyProtocol( + 321, + Parameter.Array_alarm_store.tablePid /*37*/, + new UInt32[] + { + Parameter.Array_alarm_store.Idx.column_index_47, + Parameter.Array_alarm_store.Idx.column_severity_38 + }); + var oOutagePks = (object[])oOutageTable[0]; + var oOutageType = (object[])oOutageTable[1]; + var keyToType = new Dictionary(); + + for (var i = 0; i < oOutagePks.Length; i++) + { + keyToType[Convert.ToString(oOutagePks[i])] = oOutageType[i]; + } + + for (var i = startIndex; i < keys.Length; i++) + { + if (!keyToType.ContainsKey(keys[i])) + { + continue; + } + + // Check type, only delete manual outages + var iOutageType = Convert.ToInt32(keyToType[keys[i]]); + if (iOutageType == 12) + { + allOutagesToDelete.Add(keys[i]); + } + else + { + ignoredOutages.Add(keys[i]); + } + + // Make sure we don't delete the same key twice by failing the next exist lookup + keyToType.Remove(keys[i]); + + } + } + else + { + for (var i = startIndex; i < keys.Length; i++) + { + if (!protocol.array_alarm_store.Exists(keys[i])) + { + continue; + } + + var iOutageType = Convert.ToInt32(protocol.array_alarm_store[keys[i], Parameter.Array_alarm_store.Idx.column_severity_38]); + if (iOutageType == 12) + { + // Only delete manual outages + allOutagesToDelete.Add(keys[i]); + } + else + { + ignoredOutages.Add(keys[i]); + } + } + } + + if (allOutagesToDelete.Count != 0) + { + protocol.array_alarm_store.DeleteRow(allOutagesToDelete); + } + + if (ignoredOutages.Count > 0) + { + protocol.SetParameter( + Parameter.array_alarm_store_qactionfeedback_79, + keys[0] + + "|INFO|The following selected outages were not deleted because they were not created manually:\r\n" + + string.Join(", ", ignoredOutages)); + } + } +} +]]> + + + + /// Validate User Input + /// + /// Link with Skyline DataMiner + public static void Run(SLProtocolExt protocol) + { + var trigger = protocol.GetTriggerParameter(); + if (trigger == Parameter.Write.manual_outage_start_time_client_input_148) + { + var startDt = ParamToDt(protocol.Manual_outage_start_time_client_input_148); + var endDt = ParamToDt(protocol.Manual_outage_end_time_client_input_149); + + protocol.Manual_outage_start_time_client_input_147 = startDt.ToOADate(); + protocol.Manual_outage_start_time_134 = startDt.ToString(DtFormat); + + if (startDt > endDt) + { + // End date-time is incorrect, so we set them to the start date-time + protocol.Manual_outage_end_time_client_input_149 = startDt.ToOADate(); + protocol.Manual_outage_end_time_136 = startDt.ToString(DtFormat); + } + } + else + { + var startDt = ParamToDt(protocol.Manual_outage_start_time_client_input_147); + var endDt = ParamToDt(protocol.Manual_outage_end_time_client_input_150); + + if (startDt > endDt) + { + // End date-time is incorrect, so we set them to the start date-time + protocol.Manual_outage_end_time_client_input_149 = startDt.ToOADate(); + protocol.Manual_outage_end_time_136 = startDt.ToString(DtFormat); + } + else + { + protocol.Manual_outage_end_time_client_input_149 = endDt.ToOADate(); + protocol.Manual_outage_end_time_136 = endDt.ToString(DtFormat); + } + } + } + + private static DateTime ParamToDt(object paramValue) + { + if (!(paramValue is double)) + { + return new DateTime(); + } + return DateTime.FromOADate((double)paramValue); + } +} +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + /// Update History Statistics + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol) + { + int iTrigger = protocol.GetTriggerParameter(); + + String startWindow = Convert.ToString(protocol.GetParameter(31)); + String endWindow = Convert.ToString(protocol.GetParameter(32)); + + if (startWindow == "" || endWindow == "") return; + DateTime window_start, window_end; + if (!DateTime.TryParse(startWindow, out window_start)) return; + if (!DateTime.TryParse(endWindow, out window_end)) return; + + int window_unit = Convert.ToInt32(protocol.GetParameter(103)); + + string currentidx = Convert.ToString(protocol.GetParameter(1051)); + string newidx = GetIdx(window_unit, window_start); + + if (currentidx != newidx) + { + //update copy the stored end time + object storedendtime = protocol.GetParameterIndexByKey(1000, currentidx, 4); + protocol.SetParameterIndexByKey(1000, currentidx, 3, storedendtime); + + //new idx + protocol.SetParameter(1051, newidx); + currentidx = newidx; + + } + + if (String.IsNullOrWhiteSpace(currentidx)) return; + + if (iTrigger == 31) // window start time changed + { + if (!protocol.Exists(1000, currentidx)) + { + HistoryStatisticsTableQActionRow newrow = new HistoryStatisticsTableQActionRow() + { + TrackingPeriod = currentidx, + StartTimeHistory = window_start.ToString("yyyy-MM-dd HH:mm:ss"), + EndTimeHistory = "-1", + StoredEndTimeHistory = window_end.ToString("yyyy-MM-dd HH:mm:ss"), + ComplianceHistory = 0, + AvailabilityHistory = 100, + AvailabilityWithoutCorrectionsHistory = 100, + TotalViolationTimeHistory = 0, + LongestViolationTimeHistory = 0, + NumberOfViolationsHistory = 0 + }; + + protocol.historyStatisticsTable.AddRow(newrow); + + //limit number of rows + LimitRows(protocol); + } + } + else // value changed + { + if (!protocol.Exists(1000, currentidx)) + return; + + object value = protocol.GetParameter(iTrigger); + + switch (iTrigger) + { + case 10: // compliance + protocol.SetParameterIndexByKey(1000, currentidx, 5, value); + break; + case 48: // availability + protocol.SetParameterIndexByKey(1000, currentidx, 6, value); + break; + case 65: // availability without corrections + protocol.SetParameterIndexByKey(1000, currentidx, 7, value); + break; + case 21: // total violation time + protocol.SetParameterIndexByKey(1000, currentidx, 8, value); + break; + case 22: // longest violation time + protocol.SetParameterIndexByKey(1000, currentidx, 9, value); + break; + case 24: // number of violations + protocol.SetParameterIndexByKey(1000, currentidx, 10, value); + break; + } + } + + } + + private static void LimitRows(SLProtocolExt protocol) + { + int table = 1000; + + if (protocol.IsEmpty(1052)) + protocol.SetParameter(1052, 1000); + + int maxrows = Convert.ToInt32(protocol.GetParameter(1052)); + + int rowcount = protocol.RowCount(table); + if (rowcount > maxrows) + { + try + { + string[] delkeys = protocol.GetKeys(table).OrderBy(k => Convert.ToDateTime(protocol.GetParameterIndexByKey(table, k, 2))).Take(rowcount - maxrows).ToArray(); + protocol.DeleteRow(table, delkeys); + } + catch + { + // A DateTime Conversion has failed + // Find and Delete entries with unConvertable DateTimeStrings + // While going over all entries and converting them, set all Converted strings back with the correct format + List liDelKeys = new List(); + foreach (string key in protocol.GetKeys(table)) + { + DateTime dtTime; + bool bSucces = false; + string strToConvert = protocol.GetParameterIndexByKey(table, key, 2).ToString(); + try + { + bSucces = DateTime.TryParse(strToConvert, out dtTime); + string strCorrectFormat = dtTime.ToString("yyyy-MM-dd HH:mm:ss"); + if (bSucces) + { + if (string.Compare(strToConvert, strCorrectFormat) != 0) + { + //When Conversion succeeds and changes (in format) has occurred, put the datetime with correct format in place + protocol.SetParameterIndexByKey(table, key, 2, strCorrectFormat); + protocol.Log(8, -1, string.Format("Converted {0} to {1}", strToConvert, strCorrectFormat)); + } + } + else + { + //When Conversion fails, remove entry + liDelKeys.Add(key); + protocol.Log(8, -1, string.Format("Delete key: {0}; Could not convert {1} to {2}", key, strToConvert, strCorrectFormat)); + } + } + catch (Exception e) + { + //When conversion fails bad, catch exception and delete bad entry + liDelKeys.Add(key); + protocol.Log(8, -1, string.Format("Delete key: {0}; Could not convert {1} because of Exception: {2}", key, strToConvert, e.Message)); + } + } + //Delete rows with troublesome DateTimes + protocol.DeleteRow(table, liDelKeys.ToArray()); + } + } + } + + private static string GetIdx(int window_unit, DateTime window_start) + { + string idx = ""; + + switch (window_unit) + { + case 0: // Undefined + + break; + case 1: // Days + idx = window_start.ToString("yyyy-MM-dd"); + break; + case 2: // Weeks + idx = window_start.ToString("yyyy") + " week " + GetWeekNumber(window_start); + break; + case 3: // Months + idx = window_start.ToString("yyyy-MM"); + break; + case 4: // Hours + idx = window_start.ToString("yyyy-MM-dd HH"); + break; + case 5: // Minutes + idx = window_start.ToString("yyyy-MM-dd HH:mm"); + break; + } + + return idx; + } + + private static int GetWeekNumber(DateTime dtPassed) + { + CultureInfo ciCurr = CultureInfo.CurrentCulture; + int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); + return weekNum; + } +} +]]> + + + + /// Clear History Statistics Table + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + protocol.ClearAllKeys(1000); + } + } +]]> + + + + /// Clear History Statistics Table + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + + int iTrigger = protocol.GetTriggerParameter(); + String sKey = protocol.RowKey(); + + UInt32 newValue = Convert.ToUInt32(protocol.GetParameter(iTrigger)); + + protocol.Log(8, 5, String.Format("{0}/{1}/{2}", iTrigger, sKey, newValue)); + + UInt32 window_start = Convert.ToUInt32(protocol.GetParameterIndexByKey(400, sKey, 3)); + UInt32 window_end = Convert.ToUInt32(protocol.GetParameterIndexByKey(400, sKey, 4)); + + if (iTrigger == 413) + { + //StartTime + if (newValue < window_end && newValue >= 0 && newValue < 1439) + protocol.SetParameterIndexByKey(400, sKey, 3, newValue); + else + protocol.Log(8, 5, String.Format("Window Start value not correct. (Window Start Value must be: Lesser than Window End Value, Greater than or equal to 0, lesser than 23:59)")); + } + else + { + //EndTime + if (newValue > window_start && newValue > 0 && newValue <= 1439) + protocol.SetParameterIndexByKey(400, sKey, 4, newValue); + else + protocol.Log(8, 5, String.Format("Window End value not correct. (Window End Value must be: Greater than Window Start Value, Greater than 0, lesser than or equal to 23:59)")); + } + } +} +]]> + + + + /// Save/LoadConfig + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + /*--------------------------------- + * To Add or Remove Parameters from the configuration save, simply adjust the static Mapper Class + * --------------------------------- + * SLA-ConfigurationFiles are in readable XML format and are processed using XmlSerializer that maps Object Model to XML, for ease of use: + * + * + * + * + * + * + * + * + * + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
+ * + * + * + * + * ----------------------------------------------------- + * */ + + var error = new Error(); + var handler = new Handler(protocol, error); + + try + { + handler.Handle(); + } + catch (Exception e) + { + handler.error.ErrorOccured = true; + handler.error.SetMessage(Error.AppendPolicy.None, "Failed (Exception on Top-Level Run): ", e); + } + finally + { + protocol.SetParameter(1064, handler.error.GetMessage()); + } + } +} + +namespace Skyline.Protocol +{ + using Model; + + public class Handler + { + private readonly SLProtocol protocol; + public Error error; + + public Handler(SLProtocol protocol, Error error) + { + this.protocol = protocol; + this.error = error; + } + + public void Handle() + { + const string saveLocation = @"C:\Skyline DataMiner\Documents\SLA Configurations\"; + + //Check if Dir Exists + if (!Directory.Exists(saveLocation)) + { + protocol.CreateFolder("SLA Configurations"); + } + + var load = Convert.ToInt32(protocol.GetParameter(protocol.GetTriggerParameter())); // 0 or 1 returned + var name = Convert.ToString(protocol.GetParameter(1060)); + if (string.IsNullOrEmpty(name)) + { + error.ErrorOccured = true; + error.SetMessage("Failed: Name was Null or Empty"); + return; + } + + if (name[0] == '\\' || name[0] == '/') + { + name = name.Substring(1); + } + + var fullPath = saveLocation + name; + if (!fullPath.EndsWith(".xml")) + { + fullPath += ".xml"; + } + + switch (load) + { + case 0: + protocol.SetParameter(1064, "Saving..."); + var saver = new Saver(protocol, fullPath, error); + saver.Save(); + protocol.SetParameter(1065, 1); //Reload Configurations + break; + case 1: + protocol.SetParameter(1064, "Loading..."); + var loader = new Loader(protocol, fullPath, error); + loader.Load(); + break; + case 2: + protocol.SetParameter(1064, "Deleting..."); + try + { + if (File.Exists(fullPath)) + { + File.Delete(fullPath); + + protocol.FileChanged(fullPath, ProtocolExtensions.FileChangeType.Removed); + + error.SetMessage(Error.AppendPolicy.None, "Successfully deleted configuration: ", fullPath); + protocol.SetParameter(1065, 1); //Reload Configurations + } + else + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed to Delete Configuration file: ", fullPath); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed to Delete Configuration file: ", fullPath); + protocol.Log(8, 5, "ERR: Failed to Delete Configuration file: " + fullPath); + protocol.Log(8, 5, "Exception:" + e); + + //CONTINUE HERE + } + break; + } + } + } + + public class Saver + { + SLProtocol protocol; + string fullPath; + private Error error; + + public Saver(SLProtocol protocol, string fullPath, Error error) + { + this.protocol = protocol; + this.fullPath = fullPath; + this.error = error; + } + + public void Save() + { + //Creating the XML + var config = new Configuration(); + CreatePageXML("SLA", config.SLA.Parameters, config.SLA.Tables, Mapper.SLAParamMapping, null); + CreatePageXML("Compliance", config.Compliance.Parameters, config.Compliance.Tables, Mapper.ComplianceParamMapping, null); + CreatePageXML("Violation", config.Violation.Parameters, config.Violation.Tables, null, Mapper.ViolationTableMapping); + CreatePageXML("Advanced Parameters", config.Advanced.Parameters, config.Advanced.Tables, Mapper.SLAAdvancedParamMapping, null); + + var changeType = File.Exists(fullPath) + ? ProtocolExtensions.FileChangeType.Changed + : ProtocolExtensions.FileChangeType.Added; + + try + { + var xmlSerializer = new XmlSerializer(typeof(Configuration)); + try + { + using (TextWriter xmlWriter = new StreamWriter(fullPath)) + { + xmlSerializer.Serialize(xmlWriter, config); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed (Exception at Serializing -saving- to File): ", e); + return; + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.None, "Failed (Exception at Creating XML using Serializer): ", e); + return; + } + + //Tell the dataminer system that a file has been added or updated. + protocol.FileChanged(fullPath, changeType); + + if (error.ErrorOccured) + { + error.PrefixMessage(true, "Save Partially Successful ! Errors occurred, see Below:"); + } + else + { + error.SetMessage("Save Successful!"); + } + } + + public void CreatePageXML( + string page, + List parameters, + List tables, + Dictionary paramMapping, + Dictionary tableMapping) + { + #region parameters + + try + { + MapParameters(page, parameters, paramMapping); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " (Exception While Creating SLA):"); + error.AddMessage(e); + } + + #endregion + + #region tables + + try + { + MapTables(page, tables, tableMapping); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page", page, " processing ViolationMapping (Exception While Processing ViolationMapping):"); + error.AddMessage(e); + } + + #endregion + } + + private void MapParameters(string page, List parameters, Dictionary paramMapping) + { + if (paramMapping == null || paramMapping.Count <= 0) + { + return; + } + + var pids = paramMapping.Keys.ToArray(); + var results = (object[])protocol.GetParameters(pids); + + if (results != null) + { + for (var i = 0; i < results.Length; i++) + { + var pid = pids[i]; + try + { + if (results[i] != null) + { + object result = Mapper.NULLSTRING; + if (!protocol.IsEmpty(Convert.ToInt32(pid))) + { + result = results[i]; + } + parameters.Add(new Param(pid, paramMapping[pid], result)); + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " PID:", pid, " Name: ", paramMapping[pid]); + } + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed Creating ", page, " PID:", pid, " Name: ", paramMapping[pid]); + } + } + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.None, "Failed Creating ", page, " (GetParameters Returned Empty)"); + } + } + + private void MapTables(string page, List
tables, Dictionary tableMapping) + { + if (tableMapping == null || tableMapping.Count <= 0) + { + return; + } + + var tableIDs = new Dictionary>(); + var tableMaxIdxs = new Dictionary(); + + //Collecting all Data from TableMapping and converting into usable format. + foreach (var v in tableMapping) + { + var key = v.Key; + var keyA = key.Split('/'); + if (keyA.Length > 1) + { + var dictionaryKey = Convert.ToInt32(keyA[0]); + var dictionaryValue = Convert.ToUInt32(keyA[1]); + + if (!tableIDs.ContainsKey(dictionaryKey)) + { + tableIDs[dictionaryKey] = new List(); + } + if (!tableMaxIdxs.ContainsKey(dictionaryKey)) + { + tableMaxIdxs[dictionaryKey] = dictionaryValue; + } + tableIDs[dictionaryKey].Add(dictionaryValue); + if (tableMaxIdxs[dictionaryKey] < dictionaryValue) + tableMaxIdxs[dictionaryKey] = dictionaryValue; //Finding highest IDX (necessary for setrows in the Loader) + } + else + { + tableIDs[Convert.ToInt32(key)] = new List(); + } + } + + //Iterating over all requested Tables + foreach (var table in tableIDs) + { + var tableID = table.Key; + try + { + var columnsToRetrieve = table.Value.ToArray(); + var columns = (object[])protocol.NotifyProtocol(321 /*NT_GT_TABLE_COLUMNS*/, tableID, columnsToRetrieve); + var keys = (object[])columns[0]; + var rowsDic = new Dictionary(); + + if (keys != null) + { + for (var c = 0; c < columns.Length; c++) + { + var idx = columnsToRetrieve[c]; + var mapKey = tableID + "/" + idx; + var name = tableMapping[mapKey]; + + var column = (object[])columns[c]; + if (column != null) + { + for (var r = 0; r < column.Length; r++) + { + var rowKey = Convert.ToString(keys[r]); + if (!rowsDic.ContainsKey(rowKey)) + { + var highestIDX = tableMaxIdxs[tableID]; + rowsDic.Add(rowKey, new Row(rowKey, highestIDX)); + } + var value = column[r]; + var innerColValue = new Column(idx, name, value); + rowsDic[rowKey].Columns.Add(innerColValue); + } + } + else + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page ", page, " to retrieve Column:", idx, "-", name, " From table:", tableID); + } + } + + tables.Add(new Table(tableID, tableMapping[Convert.ToString(tableID)], rowsDic.Values.ToList())); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed on Page ", page, " Creating Table", tableID, " (Exception While Creating ViolationTable):"); + error.AddMessage(e); + } + } + } + } + + public class Loader + { + SLProtocol protocol; + string fullPath; + private Error error; + + public Loader(SLProtocol protocol, string fullPath, Error error) + { + this.protocol = protocol; + this.fullPath = fullPath; + this.error = error; + } + + public void Load() + { + if (File.Exists(fullPath)) + { + var xmlSerializer = new XmlSerializer(typeof(Configuration)); + try + { + using (TextReader tr = new StreamReader(fullPath)) + { + var config = (Configuration)xmlSerializer.Deserialize(tr); + LoadPage("SLA", config.SLA.Parameters, config.SLA.Tables); + LoadPage("Compliance", config.Compliance.Parameters, config.Compliance.Tables); + LoadPage("Violations", config.Violation.Parameters, config.Violation.Tables); + LoadPage("Advanced Parameters", config.Advanced.Parameters, config.Advanced.Tables); + } + } + catch (Exception e) + { + error.ErrorOccured = true; + error.SetMessage(Error.AppendPolicy.AfterLastPart, "Failed (Exception at Serializing -Loading- from File): "); + error.AddMessage(e); + return; + } + } + else + { + error.SetMessage("Failed Loading: File Does Not Exist!"); + return; + } + + if (error.ErrorOccured) + { + error.PrefixMessage(true, "Load Partially Successful ! Errors occurred, see Below:"); + } + else + { + error.SetMessage("Load Successful!"); + } + } + + private void LoadPage(string page, List parameters, List
tables) + { + try + { + LoadParameters(parameters); + LoadTables(tables); + } + catch (Exception e) + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed (Exception Occurred Loading ", page, "):"); + error.AddMessage(e); + } + } + + private void LoadParameters(List parameters) + { + if (parameters == null) + { + return; + } + + foreach (var p in parameters) + { + try + { + if (Convert.ToString(p.Value) != Mapper.NULLSTRING) + { + protocol.SetParameter(Convert.ToInt32(p.PID), p.Value); + } + else + { + //Clear this Parameter + var clearTrigger = Convert.ToInt32(p.PID) + 1000; + protocol.CheckTrigger(clearTrigger); + } + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed to Load parameter with PID:", p.PID); + } + } + } + + private void LoadTables(List
tables) + { + if (tables == null) + { + return; + } + + foreach (var t in tables) + { + //Clear Table + protocol.ClearAllKeys(t.PID); + foreach (var r in t.Rows) + { + try + { + var row = new object[(r.MaxIDX + 1)]; //creating array with 'null values' till MaxIDX+1 (idx is 0 based) + foreach (Column col in r.Columns) + { + row[col.IDX] = col.Value; + } + + //setrow to avoid issues with AutoIncrement and missing columns (null) if any. + protocol.AddRow(t.PID, row); + } + catch + { + error.ErrorOccured = true; + error.AddMessage(Error.AppendPolicy.AfterLastPart, "Failed to Load Row with Key ", r.Key); + } + } + } + } + } + + /// + /// Error class can be accessed from all other classes to set the state + /// + public class Error + { + public bool ErrorOccured = false; + private readonly StringBuilder state = new StringBuilder(); + + public enum AppendPolicy + { + /// + /// Add no newlines. + /// + None, + /// + /// Add a newline at the end of the whole message + /// + AfterLastPart, + /// + /// Add a newline after every part provided + /// + AfterEveryPart + } + + public void SetMessage(object message) + { + SetMessage(AppendPolicy.None, message); + } + + public void SetMessage(AppendPolicy appendPolicy, params object[] messageParts) + { + state.Length = 0; + AddMessage(appendPolicy, messageParts); + } + + public void AddMessage(object message) + { + AddMessage(AppendPolicy.None, message); + } + public void AddMessage(AppendPolicy appendPolicy, params object[] messageParts) + { + foreach (var messagePart in messageParts) + { + state.Append(messagePart); + if (appendPolicy == AppendPolicy.AfterEveryPart) + { + state.AppendLine(); + } + } + + if (appendPolicy == AppendPolicy.AfterLastPart) + { + state.AppendLine(); + } + } + + public void PrefixMessage(bool appendLine, object message) + { + state.Insert(0, Environment.NewLine); + state.Insert(0, message); + } + + public string GetMessage() + { + return state.ToString(); + } + } + + public static class ProtocolExtensions + { + public enum FileChangeType + { + Changed = 32, + Removed = 33, + Added = 34 + } + + public static void FileChanged(this SLProtocol protocol, string fullPath, FileChangeType type) + { + protocol.NotifyDataMiner(41 /*NT_SEND_DMS_FILE_CHANGE*/, fullPath, (int)type); + } + + public static void CreateFolder(this SLProtocol protocol, string path) + { + protocol.NotifyDataMiner(181 /*NT_CREATE_FOLDER*/, path, null); + } + } + + namespace Model + { + /// + /// The Mapper class contains the PID-Names of the parameters/tables that need to be Saved. Adjust this if more parameters are to be saved or if parameters have to be removed from the save. + /// + public static class Mapper + { + public static readonly string NULLSTRING = "***NULL***"; + + //All parameters from the SLA page that need to be saved + public static readonly Dictionary SLAParamMapping = new Dictionary() + { + {105, "Type"}, + {103, "Unit"}, + {101, "Time"}, + {131, "Violation Level"}, + {108, "Delay Time"}, + {111, "Minimum Outage Threshold"}, + {35, "Admin State"}, + {29, "Base State"}, + {63, "Time to Keep Outages"}, + {67, "SLA Validity Start Time"}, + {68, "SLA Validity Stop Time"} + }; + + //All Parameters from the Compliance Page that need to be saved + public static readonly Dictionary ComplianceParamMapping = new Dictionary() + { + {208, "Maximum Total Violations Type"}, + {123, "Maximum Total Violations Unit"}, + {121, "Maximum Total Violations Value"}, + {212, "Maximum Total Violations Percentage"}, + {129, "Total Violations Before Breach"}, + {210, "Maximum Single Violation Type"}, + {127, "Maximum Single Violation Unit"}, + {125, "Maximum Single Violation Value"}, + {216, "Maximum Single Violations Percentage"} + }; + + //All Columns and tables from the Violation Page that need to be saved + public static readonly Dictionary ViolationTableMapping = new Dictionary() + { + {"450", "Violation Settings"}, + {"450/0", "Violation Filter Id"}, + {"450/1", "Violation Filter Type"}, + {"450/2", "Violation Filter Value"}, + {"450/3", "Violation Filter Impact"}, + {"450/4", "Violation Filter Sequence"}, + {"450/5", "Violation Filter State"}, + {"450/6", "Violation Filter Exclusive"}, + {"450/7", "Violation Filter Property Name"} + }; + + //All parameters from the SLA page that need to be saved + public static readonly Dictionary SLAAdvancedParamMapping = new Dictionary() + { + {2050, "Hide Violation Filtered Alarms"}, + {2052, "Hide Offline Window Outages"}, + {2054, "Enable Predictions"}, + {2056, "Enable Outages"}, + {2058, "Show Active Alarms"}, + {2060, "Enhanced Service Mode"}, + {2062, "Show Excluded Service Element Alarms"}, + {2064, "Use Service Capping"}, + {2066, "Affecting Alarms Level"} + }; + } + + [Serializable()] + public class Configuration + { + //XMLSerializer always requires a parameterless constructor + public Configuration() + { + } + + private SLA sla = new SLA(); + + public SLA SLA + { + get { return sla; } + set { sla = value; } + } + + private Compliance compliance = new Compliance(); + + public Compliance Compliance + { + get { return compliance; } + set { compliance = value; } + } + + private Violation violation = new Violation(); + + public Violation Violation + { + get { return violation; } + set { violation = value; } + } + + private Advanced advanced = new Advanced(); + + public Advanced Advanced + { + get { return advanced; } + set { advanced = value; } + } + } + + [Serializable()] + public class SLA + { + //XMLSerializer always requires a parameterless constructor + public SLA() + { + } + + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + + [Serializable()] + public class Compliance + { + //XMLSerializer always requires a parameterless constructor + public Compliance() + { + } + + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + + [Serializable()] + public class Violation + { + //XMLSerializer always requires a parameterless constructor + public Violation() + { + } + + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + + [Serializable()] + public class Advanced + { + //XMLSerializer always requires a parameterless constructor + public Advanced() + { + } + + private List parameters = new List(); + + public List Parameters + { + get { return parameters; } + set { parameters = value; } + } + + private List
tables = new List
(); + + public List
Tables + { + get { return tables; } + set { tables = value; } + } + } + + [Serializable()] + public class Param + { + //XMLSerializer always requires a parameterless constructor + public Param() + { + } + + public Param(uint pid, string name, object value) + { + PID = pid; + Name = name; + Value = value; + } + + private uint pid; + + public uint PID + { + get { return pid; } + set { pid = value; } + } + + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + + private object value; + + public object Value + { + get { return value; } + set { this.value = value; } + } + } + + [Serializable()] + public class Table + { + //XMLSerializer always requires a parameterless constructor + public Table() + { + } + + public Table(int tableID, string name, List rows) + { + PID = tableID; + Name = name; + Rows = rows; + } + + private int pid; + + public int PID + { + get { return pid; } + set { pid = value; } + } + + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + + private List rows = new List(); + + public List Rows + { + get { return rows; } + set { rows = value; } + } + } + + [Serializable()] + public class Row + { + //XMLSerializer always requires a parameterless constructor + public Row() + { + } + + public Row(string key, uint maxIDX) + { + Key = key; + MaxIDX = maxIDX; + } + + public Row(string key, List cols, uint maxIDX) + { + Key = key; + Columns = cols; + MaxIDX = maxIDX; + } + + private string key; + + public string Key + { + get { return key; } + set { key = value; } + } + + private uint maxIDX; + + public uint MaxIDX + { + get { return maxIDX; } + set { maxIDX = value; } + } + + private List columns = new List(); + + public List Columns + { + get { return columns; } + set { columns = value; } + } + } + + [Serializable()] + public class Column + { + //XMLSerializer always requires a parameterless constructor + public Column() + { + } + + public Column(uint idx, string name, object value) + { + IDX = idx; + Name = name; + Value = value; + } + + private uint idx; + + public uint IDX + { + get { return idx; } + set { idx = value; } + } + + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + + private object value; + + public object Value + { + get { return value; } + set { this.value = value; } + } + } + } +} +]]> + + + + /// LoadConfigurations + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocol protocol) + { + const string saveLocation = @"C:\Skyline DataMiner\Documents\SLA Configurations\"; + if (Directory.Exists(saveLocation)) + { + string[] allFiles = Directory.GetFiles(saveLocation); + string allFilesDiscreet = ""; + if (allFiles != null && allFiles.Length > 0) + { + allFilesDiscreet = string.Join(";", allFiles.Select(p => Path.GetFileNameWithoutExtension(p))); + } + protocol.SetParameter(1062, allFilesDiscreet); + } + } +} +]]> + + + + /// Stop Outage + /// + /// Link with Skyline Dataminer + public static void Run(SLProtocolExt protocol, Object input) + { + if (protocol.IsEmpty(2001)) + return; + + string strKey = Convert.ToString(protocol.GetParameter(2001)); + if (protocol.array_alarm_store.Exists(strKey)) + { + switch (Convert.ToUInt32(input)) + { + case 1: + //Delete + protocol.DeleteRow(37, strKey); + break; + case 2: + //Stop + object[] currentRow = (object[])protocol.array_alarm_store.GetRow(strKey); + object[] setRow = new object[currentRow.Length]; + + String strEnd = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); + DateTime dtEnd = DateTime.Parse(strEnd); + + setRow[Parameter.Array_alarm_store.Idx.column_end_timestamp] = strEnd; + + DateTime dtStart; + if (ConvertToDateTime(Convert.ToString(currentRow[Parameter.Array_alarm_store.Idx.column_timestamp]), out dtStart)) + { + double dblOutageWeight = Convert.ToDouble(currentRow[Parameter.Array_alarm_store.Idx.column_impact]); + double dblOutage = (dtEnd - dtStart).TotalSeconds; + setRow[Parameter.Array_alarm_store.Idx.column_outage] = dblOutage / 60; + + double dbldelay = (double)protocol.GetParameter(108); + double dblThreshold = (double)protocol.GetParameter(111); + double dblOutageCorrected = dblOutage; + double dblViolation = 0.0; + + //Only let outage times bigger than delay time through + if (dbldelay > 0.0 && dblOutage < dbldelay) + dblOutageCorrected = 0.0; + + //subtract minimum outage threshold of the outage time + if (dblThreshold > 0 && dblOutage > dblThreshold) + dblOutageCorrected = dblOutage - dblThreshold; + else if (dblThreshold != 0) + dblOutageCorrected = 0; + + //Calculate Violation + dblViolation = dblOutageCorrected * dblOutageWeight / 100; + + setRow[Parameter.Array_alarm_store.Idx.column_outage_corrected] = dblOutageCorrected / 60; + setRow[Parameter.Array_alarm_store.Idx.column_violation] = dblViolation / 60; + + protocol.SetRow(protocol.array_alarm_store.TableId, strKey, setRow); + } + else + { + protocol.Log(string.Format("QA{0} STOP OUTAGE - Unable to convert the StartDateTime {1}", protocol.QActionID, Convert.ToString(currentRow[Parameter.Array_alarm_store.Idx.column_timestamp])), LogType.Error, LogLevel.NoLogging); + } + break; + default: + break; + } + } + } + /// + /// convert to date time that is expected to succeed + /// + /// + /// + public static bool ConvertToDateTime(string sDateTime, out DateTime dateTime) + { + dateTime = DateTime.Now; + try + { + dateTime = DateTime.Parse(sDateTime); + return true; + } + catch + { return false; } + } +} +]]> + + + + + + + After Startup + protocol + + action + + 1 + 2 + 3 + + + + Clear105 + action + + 1105 + 2105 + + + + Clear101 + action + + 1101 + 2101 + + + + Clear103 + action + + 1103 + 2103 + + + + Clear131 + action + + 1131 + 2131 + + + + Clear108 + action + + 1108 + 2108 + + + + Clear111 + action + + 1111 + 2111 + + + + Clear35 + action + + 1035 + 2035 + + + + Clear29 + action + + 1029 + 2029 + + + + Clear63 + action + + 1063 + 2063 + + + + Clear67 + action + + 1067 + 2067 + + + + Clear68 + action + + 1068 + 2068 + + + + Clear208 + action + + 1208 + 2208 + + + + Clear121 + action + + 1121 + 2121 + + + + Clear123 + action + + 1123 + 2123 + + + + Clear212 + action + + 1212 + 2212 + + + + Clear129 + action + + 1129 + 2129 + + + + Clear210 + action + + 1210 + 2210 + + + + Clear125 + action + + 1125 + 2125 + + + + Clear127 + action + + 1127 + 2127 + + + + Clear216 + action + + 1216 + 2216 + + + + + + Copy '0' to Generate Ticket + parameter + copy + + + copy creation value to validity start time if the latter is empty + id:67 == emptystring + parameter + copy + + + copy forever value to validity end time if the latter is empty + id:68 == emptystring + parameter + copy + + + Clear105 + parameter + clear + + + ClearOD105 + parameter + clear on display + + + Clear101 + parameter + clear + + + ClearOD101 + parameter + clear on display + + + Clear103 + parameter + clear + + + ClearOD103 + parameter + clear on display + + + Clear131 + parameter + clear + + + ClearOD131 + parameter + clear on display + + + Clear108 + parameter + clear + + + ClearOD108 + parameter + clear on display + + + Clear111 + parameter + clear + + + ClearOD111 + parameter + clear on display + + + Clear35 + parameter + clear + + + ClearOD35 + parameter + clear on display + + + Clear29 + parameter + clear + + + ClearOD29 + parameter + clear on display + + + Clear63 + parameter + clear + + + ClearOD63 + parameter + clear on display + + + Clear67 + parameter + clear + + + ClearOD67 + parameter + clear on display + + + Clear68 + parameter + clear + + + ClearOD68 + parameter + clear on display + + + Clear208 + parameter + clear + + + ClearOD208 + parameter + clear on display + + + Clear121 + parameter + clear + + + ClearOD121 + parameter + clear on display + + + Clear123 + parameter + clear + + + ClearOD123 + parameter + clear on display + + + Clear212 + parameter + clear + + + ClearOD212 + parameter + clear on display + + + Clear129 + parameter + clear + + + ClearOD129 + parameter + clear on display + + + Clear210 + parameter + clear + + + ClearOD210 + parameter + clear on display + + + Clear125 + parameter + clear + + + ClearOD125 + parameter + clear on display + + + Clear127 + parameter + clear + + + ClearOD127 + parameter + clear on display + + + Clear216 + parameter + clear + + + ClearOD216 + parameter + clear on display + + + diff --git a/ProtocolTests/Helpers/Software Parameters/Skyline Service Definition Basic/Protocol.xml b/ProtocolTests/Helpers/Software Parameters/Skyline Service Definition Basic/Protocol.xml new file mode 100644 index 00000000..32edb9d7 --- /dev/null +++ b/ProtocolTests/Helpers/Software Parameters/Skyline Service Definition Basic/Protocol.xml @@ -0,0 +1,1810 @@ + + + + + Skyline Service Definition Basic + Skyline Service Definition Basic + 1.0.0.10 + service + Skyline Communications + 1.3.6.1.4.1.8813.2.48 + 10 + Service Element + + Skyline Communications + auto + + + + + Service Severity + + Service Severity + + Displays the Service Severity. + + read + + numeric text + next param + double + + + Undefined + -1 + + + + + true + + + General + 0 + 0 + + + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + + + + + Severity Update + + Severity Update + read + + other + next param + string + + + string + + + + raw_alarm_input + raw_alarm_input + read + + other + next param + string + + + string + + + + subservice_element_update + Severity Update (Element in Sub Service) + read + + other + next param + string + + + string + + + + + + + Service Element Status + + Service Element Status + array + + + + + + + + + + + + + + + + + + + Shows elements included in service and their alarm levels. + + + other + next param + double + + + true + + + Elements + 0 + 0 + + + + + table + + + + + Service_Element_Status_Alias + Alias [IDX] (Service Element Status) + read + + The key of this table, value is element name or the name provided as alias in the service setup. + + + other + next param + string + + + true + + + string + + + + Service_Element_Status_Element_Name + Element Name (Service Element Status) + read + + The element name if the row represents an element. + + + other + next param + string + + + true + + + string + + + + Service_Element_Status_Element_ID + Element ID (Service Element Status) + read + + The [DMA ID]/[Element ID] for the element or service. + + + other + next param + string + + + true + + + string + + + + Service_Element_Status_Severity + Severity (Service Element Status) + read + + The highest severity of the included alarms. + + + numeric text + next param + double + + + true + + + true + 1 + 2 + 3 + 4 + 5 + + + discreet + + + Undefined + 0 + + + Normal + 1 + + + Warning + 2 + + + Minor + 3 + + + Major + 4 + + + Critical + 5 + + + Timeout + 7 + + + + + + Service_Element_Status_State + State (Service Element Status) + read + + Whether the element is Included, Excluded or Not Used. + + + numeric text + next param + double + + + true + + + true + 1 + 0;2;3 + + + discreet + + + Undefined + 0 + + + Included + 1 + + + Excluded + 2 + + + Not Used + 3 + + + + + + Service_Element_Status_Calculated + Calculated (Service Element Status) + read + + Indicates the calculate alarm level and if the element is included or not. + + + numeric text + next param + double + + + Unknown + 0 + + + + + true + + + true + 11;21;31 + 12;22;32 + 13;23;33 + 14;24;34 + 15;25;35 + + + discreet + + + Included - Undefined + 10 + + + Included - Normal + 11 + + + Included - Warning + 12 + + + Included - Minor + 13 + + + Included - Major + 14 + + + Included - Critical + 15 + + + Included - Timeout + 17 + + + Excluded - Undefined + 20 + + + Excluded - Normal + 21 + + + Excluded - Warning + 22 + + + Excluded - Minor + 23 + + + Excluded - Major + 24 + + + Excluded - Critical + 25 + + + Excluded - Timeout + 27 + + + Not Used - Undefined + 30 + + + Not Used - Normal + 31 + + + Not Used - Warning + 32 + + + Not Used - Minor + 33 + + + Not Used - Major + 34 + + + Not Used - Critical + 35 + + + Not Used - Timeout + 37 + + + + + + Service_Element_Status_Parent_Service_Name + Parent Service Name (Service Element Status) + read + + The name of the parent service if the element or service is not directly included in this service. + + + other + next param + string + + + true + + + string + + + + Service_Element_Status_Parent_Service_ID + Parent Service ID (Service Element Status) + read + + The ID of the parent service if the element or service is not directly included in this service. + + + other + next param + string + + + true + + + string + + + + Service_Element_Status_Service_Index + Service Index (Service Element Status) + read + + An index of the included element or service in its parent service. + + + other + next param + string + + + + true + + + string + + + + Service_Element_Status_Alarm_Count_Critical + Critical (Service Element Status) + read + + Amount of critical alarms of the element that are active in this service. + + + double + fixed + 8 + double + + + N/A + -1 + + + + + + true + + 0 + 2147483647 + + + + + true + 0 + 1 + + + number + + + + Service_Element_Status_Alarm_Count_Major + Major (Service Element Status) + read + + Amount of major alarms of the element that are active in this service. + + + double + fixed + 8 + double + + + N/A + -1 + + + + + + true + + 0 + 2147483647 + + + + + true + 0 + 1 + + + number + + + + Service_Element_Status_Alarm_Count_Minor + Minor (Service Element Status) + read + + Amount of minor alarms of the element that are active in this service. + + + double + fixed + 8 + double + + + N/A + -1 + + + + + + true + + 0 + 2147483647 + + + + + true + 0 + 1 + + + number + + + + Service_Element_Status_Alarm_Count_Warning + Warning (Service Element Status) + read + + Amount of warning alarms of the element that are active in this service. + + + double + fixed + 8 + double + + + N/A + -1 + + + + + + true + + 0 + 2147483647 + + + + + true + 0 + 1 + + + number + + + + Service_Element_Status_Alarm_Count_Timeout + Timeout (Service Element Status) + read + + Amount of timeout alarms of the element that are active in this service. + + + double + fixed + 8 + double + + + N/A + -1 + + + + + + true + + 0 + 2147483647 + + + + + true + 0 + 1 + + + number + + + + Service_Element_Type + Type (Service Element Status) + read + + + + + + + double + fixed + 8 + double + + + true + + + discreet + + + Element + 1 + + + Service + 2 + + + + + + monitor_active_alarms + Monitor Active Alarms + read + + Enables the monitoring of the active alarms on service + + + double + fixed + 4 + double + 0 + + + true + + + Alarms + 0 + 0 + + + + + true + 1 + 0 + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + monitor_active_alarms + Monitor Active Alarms + write + + double + fixed + 4 + double + + + true + + + Alarms + 0 + 0 + + + + + togglebutton + + + Disabled + 0 + + + Enabled + 1 + + + + + + + active_service_alarms + Active Service Alarms + array + + Shows all active alarms in the service. + + + + + + + + + + + + + + + + + + + + other + next param + double + + + true + + + Alarms + 1 + 0 + + + + + table + + + + active_service_alarms_root_alarm_ID + Root Alarm ID [IDX] (Active Service Alarms) + read + + Alarm Root ID of the active service alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_alarm_ID + Alarm ID (Active Service Alarms) + read + + Alarm ID of the active service alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_severity + Severity (Active Service Alarms) + read + + Severity of the active service alarm + + + other + next param + string + + + true + + + discreet + + + Critical + Critical + + + Major + Major + + + Minor + Minor + + + Warning + Warning + + + Normal + Normal + + + Information + Information + + + Timeout + Timeout + + + Error + Error + + + Notice + Notice + + + + + + active_service_alarms_time + Time (Active Service Alarms) + read + + time of the active service alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_element + Element Name (Active Service Alarms) + read + + Element of the active service alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_parameter_description + Parameter Description (Active Service Alarms) + read + + Parameter Description of the active service alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_param_index + Parameter Key (Active Service Alarms) + read + + Parameter Key + + + other + next param + string + + + true + + + string + + + + active_service_alarms_value + Value (Active Service Alarms) + read + + Value of the alarm active service the Alarm + + + other + next param + string + + + true + + + string + + + + active_service_alarms_status + Status (Active Service Alarms) + read + + Status of the active service alarm + + + numeric text + next param + double + + + true + + + discreet + + + Cleared + 11 + + + Open + 12 + + + Masked + 25 + + + Clearable + 54 + + + + + + active_service_alarms_alarm_type + Alarm Type (Active Service Alarms) + read + + Alarm Type of the active service alarm + + + numeric text + next param + double + + + true + + + discreet + + + Escalated + 8 + + + Dropped + 9 + + + New alarm + 10 + + + Cleared + 11 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + Comment Added + 22 + + + Unmask + 27 + + + Dropped from Critical + 31 + + + Dropped from Major + 32 + + + Dropped from Minor + 33 + + + Dropped from Warning + 34 + + + Escalated from Warning + 35 + + + Escalated from Minor + 36 + + + Escalated from Major + 37 + + + Flipped + 38 + + + Service impact changed + 40 + + + Value changed + 41 + + + Name changed + 42 + + + RCA-Level changed + 43 + + + Properties changed + 50 + + + Threshold changed + 53 + + + Interface changed + 55 + + + + + + active_service_alarms_user_state + User Status (Active Service Alarms) + read + + User state of the active service alarm + + + numeric text + next param + double + + + true + + + discreet + + + Not assigned + 18 + + + Acknowledged + 19 + + + Resolved + 20 + + + Unresolved + 21 + + + + + + active_service_alarms_source + Source (Active Service Alarms) + read + + Source of the active service alarm + + + numeric text + next param + double + + + true + + + discreet + + + Mobile Gateway + 14 + + + DataMiner System + 16 + + + Correlation Engine + 23 + + + Watchdog + 29 + + + External + 30 + + + Aggregation + 56 + + + + + + active_service_alarms_category + Category (Active Service Alarms) + read + + Category of the active service alarm + + + other + next param + string + + + true + + + string + + + + + + + + + + + 8 ? split[8] : "-1", + Service_element_type_115 = split.Length > 9 && split[9] != "0" ? 2d : 1d, + }; + } + else + { + bool isAlarmsEnabled = Convert.ToInt32(protocol.GetParameter(Parameter.monitor_active_alarms_198)) == 1; + + bool isNotAnElement = split.Length < 9 || String.IsNullOrWhiteSpace(split[8]); // || split[8] == "-1" + double defaultValue = !isNotAnElement && isAlarmsEnabled ? 0.0 : -1.0; + + row = new ServiceElementStatusQActionRow + { + Service_element_status_alias = alias, + Service_element_status_element_name = split[1], + Service_element_status_element_id = split[2], + Service_element_status_severity = split[3], + Service_element_status_state = split[4], + Service_element_status_parent_service_name = string.Empty, + Service_element_status_parent_service_id = string.Empty, + Service_element_status_service_index_109 = split.Length >= 9 ? split[8] : "-1", + Service_element_status_alarm_count_critical_110 = defaultValue, + Service_element_status_alarm_count_major_111 = defaultValue, + Service_element_status_alarm_count_minor_112 = defaultValue, + Service_element_status_alarm_count_warning_113 = defaultValue, + Service_element_status_alarm_count_timeout_114 = defaultValue, + Service_element_type_115 = split.Length > 9 && split[9] != "0" ? 2d : 1d, + }; + } + + row.Service_element_status_calculated = GetServiceElementStatusCalculated( + protocol, + row.Service_element_status_state, + row.Service_element_status_severity, + strSeverityInput); + + protocol.serviceElementStatus.SetRow(row, bNewRow); + } + catch (Exception ex) + { + protocol.Log(string.Format("QA{0}|ChildElement|{1}", protocol.QActionID, ex), LogType.Error, LogLevel.NoLogging); + } + } + + public static void SubServiceElement(SLProtocolExt protocol) + { + try + { + // Format of incoming data (tab-separated) + // + // 00 - child element/service alias + // 01 - child element/service name + // 02 - child element/service dmaid/eid + // 03 - child element/service actual severity (1=normal, ..., 5=critical, 7=timeout) + // 04 - child element/service included status (1=included, 2=excluded, 3=not used) [taking into account parent states] + // 05 - child element/service group path () + // 06 - child element/service included status [direct trigger status] + // 07 - child element/service capped severity + // 08 - Direct parent service name + // 09 - Direct parent service dmaid/eid + // 10 - path to this child element (SUBSERVICE/SUBSUBSERVICE/CHILD) + // 11 - child element/service sub-index + // 12 - is service + + var severityInput = Convert.ToString(protocol.Subservice_element_update_5); + + var severityInputParts = severityInput.Split('\t'); + + if (severityInputParts.Length <= 10) + { + protocol.Log( + string.Format("QA{0}|SubServiceElement|Update value was incorrect: insufficient items:{1}", protocol.QActionID, severityInput), + LogType.Error, + LogLevel.NoLogging); + + return; + } + +#if DEBUG + protocol.Log( + string.Format("QA{0}|SubServiceElement|SUB SERVICE ELEMENT:{1}", protocol.QActionID, severityInput), + LogType.DebugInfo, + LogLevel.NoLogging); +#endif + + var alias = severityInputParts[10]; + + if (String.IsNullOrWhiteSpace(alias)) + { + // We don't do the fancy key search here because the key is supposed to be a compound of the parent service name, so it should always be provided by the notify. + protocol.Log( + string.Format("QA{0}|ChildElement|Alias and name were empty for {1}", protocol.QActionID, severityInputParts[2]), + LogType.Error, + LogLevel.NoLogging); + + return; + } + + ServiceElementStatusQActionRow row; + var bNewRow = !protocol.serviceElementStatus.Exists(alias); + + if (!bNewRow) + { + row = new ServiceElementStatusQActionRow + { + // Set PK to full path + Service_element_status_alias = alias, + Service_element_status_element_name = severityInputParts[1], + Service_element_status_element_id = severityInputParts[2], + Service_element_status_severity = severityInputParts[3], + Service_element_status_state = severityInputParts[4], + Service_element_status_parent_service_id = severityInputParts[9], + Service_element_status_parent_service_name = severityInputParts[8], + Service_element_status_service_index_109 = severityInputParts.Length > 11 ? severityInputParts[11] : "-1", + Service_element_type_115 = severityInputParts.Length > 12 && severityInputParts[12] != "0" ? 2d : 1d, + }; + } + else + { + bool isAlarmsEnabled = Convert.ToInt32(protocol.GetParameter(Parameter.monitor_active_alarms_198)) == 1; + + bool isNotAnElement = severityInputParts.Length < 12 || String.IsNullOrWhiteSpace(severityInputParts[11]); // || split[11] == "-1" + double defaultValue = !isNotAnElement && isAlarmsEnabled ? 0.0 : -1.0; + + row = new ServiceElementStatusQActionRow + { + // Set PK to full path + Service_element_status_alias = alias, + Service_element_status_element_name = severityInputParts[1], + Service_element_status_element_id = severityInputParts[2], + Service_element_status_severity = severityInputParts[3], + Service_element_status_state = severityInputParts[4], + Service_element_status_parent_service_id = severityInputParts[9], + Service_element_status_parent_service_name = severityInputParts[8], + Service_element_status_service_index_109 = severityInputParts.Length > 11 ? severityInputParts[11] : "-1", + Service_element_status_alarm_count_critical_110 = defaultValue, + Service_element_status_alarm_count_major_111 = defaultValue, + Service_element_status_alarm_count_minor_112 = defaultValue, + Service_element_status_alarm_count_warning_113 = defaultValue, + Service_element_status_alarm_count_timeout_114 = defaultValue, + Service_element_type_115 = severityInputParts.Length > 12 && severityInputParts[12] != "0" ? 2d : 1d, + }; + } + + row.Service_element_status_calculated = GetServiceElementStatusCalculated( + protocol, + row.Service_element_status_state, + row.Service_element_status_severity, + severityInput); + + protocol.serviceElementStatus.SetRow(row, bNewRow); + } + catch (Exception ex) + { + protocol.Log(string.Format("QA{0}|SubServiceElement|{1}", protocol.QActionID, ex), LogType.Error, LogLevel.NoLogging); + } + } + + private static double GetServiceElementStatusCalculated(SLProtocolExt protocol, object state, object severity, string source) + { + double dblElementStatus, dblElementSeverity; + if (ToDouble(state, out dblElementStatus) && ToDouble(severity, out dblElementSeverity)) + { + return (dblElementStatus * 10.0) + dblElementSeverity; + } + + protocol.Log( + string.Format("QA{0}|GetServiceElementStatusCalculated|Could not parse Service_element_status_state '{1}' or Service_element_status_severity '{2}'. from:\r\n{3}", + protocol.QActionID, + state, + severity, + source), + LogType.Error, + LogLevel.NoLogging); + + return 0; + } + + private static bool ToDouble(object value, out double result) + { + var sValue = value as string; + if (!string.IsNullOrWhiteSpace(sValue)) + { + return double.TryParse(sValue, NumberStyles.Float, CultureInfo.InvariantCulture, out result); + } + + result = 0d; + return false; + } + + // Do in SLDataMiner before sending string array! + private static string ResolveAlias(SLProtocol protocol, string[] inputData) + { + var alias = inputData[0]; + + // Take alias value from child name or id if not specified + if (String.IsNullOrWhiteSpace(alias)) + { + if (String.IsNullOrWhiteSpace(inputData[1])) + { + if (String.IsNullOrWhiteSpace(inputData[2])) + { + protocol.Log( + string.Format("QA{0}|ResolveAlias|Alias, name, and id were empty for {1}", protocol.QActionID, inputData[2]), + LogType.Error, + LogLevel.NoLogging); + + return null; + } + else + { + var splittedID = inputData[2].Split('/'); + + if (splittedID.Length != 2) + { + protocol.Log( + string.Format("QA{0}|ResolveAlias|Alias and name were empty, {1} could not be parsed as an DMAID/EID", protocol.QActionID, inputData[2]), + LogType.Error, + LogLevel.NoLogging); + + return null; + } + + var oID = new uint[2]; + + oID[0] = Convert.ToUInt32(splittedID[0]); + oID[1] = Convert.ToUInt32(splittedID[1]); + + var oName = protocol.NotifyDataMiner(144 /*NT_GET_ELEMENT_NAME*/, oID, null); + + alias = oName as string; + if (String.IsNullOrWhiteSpace(alias)) + { + protocol.Log( + string.Format("QA{0}|ResolveAlias|Alias and name were empty, could not resolve name from ID {1} and used this ID instead", protocol.QActionID, inputData[2]), + LogType.DebugInfo, + LogLevel.NoLogging); + + alias = inputData[2]; + } + else + { + protocol.Log( + string.Format("QA{0}|ResolveAlias|Alias and name were empty, resolved ID {1} to {2}", protocol.QActionID, inputData[2], alias), + LogType.DebugInfo, + LogLevel.NoLogging); + } + } + } + else + { + protocol.Log( + string.Format("QA{0}|ResolveAlias|Alias was empty, took element name for {1}:{2}", protocol.QActionID, inputData[2], inputData[1]), + LogType.DebugInfo, + LogLevel.NoLogging); + + alias = inputData[1]; + } + } + + return alias; + } +} +]]> + + + + + + 9.0.3.0 + true + + + + + + + + + + + + + + + + + + 2020-07-30 + + JST + Skyline Communications + + + Suppressed or Fixed Validator issues. + + + + 2020-08-05 + + FCO + Skyline Communications + + + Fixed type and discreets of Severity (Active Service Alarms), PID=203. + + + + 2022-03-17 + + SVD + Skyline Communications + + + Fixed some validator issues + Other protocol cleanup + + + + + + + + + + + diff --git a/ProtocolTests/Helpers/Software Parameters/Software Parameters.cs b/ProtocolTests/Helpers/Software Parameters/Software Parameters.cs new file mode 100644 index 00000000..9aa15d64 --- /dev/null +++ b/ProtocolTests/Helpers/Software Parameters/Software Parameters.cs @@ -0,0 +1,172 @@ +namespace SLDisValidatorUnitTests.Helpers.SoftwareParameters +{ + using System; + using System.IO; + using System.Reflection; + using System.Text; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Parsers.Common.Xml; + + using SLDisValidator2.Tests; + + [TestClass] + public class SoftwareParameters + { + [TestMethod] + public void IsCorrectEnhancedServiceParam() + { + // Get Protocol + string path = Path.Combine(Helper.GetProjectPath(), "Helpers\\Software Parameters\\Skyline Service Definition Basic\\Protocol.xml"); + var model = DocumentParsing.GetProtocol(path); + + StringBuilder sb = new StringBuilder(); + foreach (var item in model.Protocol.Params) + { + if (!ParamHelper.IsCorrectEnhancedServiceParam(item)) + { + sb.AppendLine($"[{item.Id.Value.Value}]{Environment.NewLine}\t{item.Name?.Value}{Environment.NewLine}\t{item.Description?.Value}"); + } + } + + string message = sb.ToString(); + + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + [TestMethod] + public void IsRestrictedParamName() + { + // Get Protocol + string path = Path.Combine(Helper.GetProjectPath(), "Helpers\\Software Parameters\\DataMiner Element Control Protocol\\Protocol.xml"); + var model = DocumentParsing.GetProtocol(path); + + StringBuilder sb = new StringBuilder(); + foreach (var item in model.Protocol.Params) + { + if (!ParamHelper.IsRestrictedParamName(item)) + { + sb.AppendLine($"[{item.Id.Value.Value}]{Environment.NewLine}\t{item.Name?.Value}{Environment.NewLine}\t{item.Description?.Value}"); + } + } + + string message = sb.ToString(); + + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + [TestMethod] + [Ignore("Need to be revised (tables aren't listed apparently)")] + public void IsGeneralParam() + { + // Get Protocol + string path = Path.Combine(Helper.GetProjectPath(), "Helpers\\Software Parameters\\DataMiner Element Control Protocol\\Protocol.xml"); + var model = DocumentParsing.GetProtocol(path); + + StringBuilder sb = new StringBuilder(); + foreach (var item in model.Protocol.Params) + { + if (item.Id.Value.Value < 65000 || item.Type.Value == Skyline.DataMiner.CICD.Models.Protocol.Enums.EnumParamType.Write) + { + continue; + } + + if (!ParamHelper.IsGeneralParam(item)) + { + sb.AppendLine($"[{item.Id.Value.Value}]{Environment.NewLine}\t{item.Name?.Value}{Environment.NewLine}\t{item.Description?.Value}"); + } + } + + string message = sb.ToString(); + + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + + [DataTestMethod] + [DataRow("Helpers\\Software Parameters\\Skyline SLA Definition Basic\\2.0.0.x\\protocol.xml")] + [DataRow("Helpers\\Software Parameters\\Skyline SLA Definition Basic\\3.0.0.x\\Protocol.xml")] + public void IsCorrectSlaParamName(string path) + { + // Get Protocol + path = Path.Combine(Helper.GetProjectPath(), path); + var model = DocumentParsing.GetProtocol(path); + + StringBuilder sb = new StringBuilder(); + foreach (var item in model.Protocol.Params) + { + if (!ParamHelper.IsCorrectSlaParam(item)) + { + sb.AppendLine($"[{item.Id.Value.Value}]{Environment.NewLine}\t{item.Name?.Value}{Environment.NewLine}\t{item.Description?.Value}"); + } + } + + string message = sb.ToString(); + + if (!String.IsNullOrWhiteSpace(message)) + { + Assert.Fail($"{Environment.NewLine}{message}"); + } + } + } + + internal static class Helper + { + public static string GetProjectPath() + { + var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + return Path.GetFullPath(Path.Combine(baseDir, @"..\..\..\..\ProtocolTests")); + } + } + + internal static class DocumentParsing + { + internal static Skyline.DataMiner.CICD.Models.Protocol.Read.ProtocolModel GetProtocol(string path) + { + (string code, bool success) = ReadTextFromFile(path); + if (!success) + { + Assert.Fail(code); + } + + (var model, var document) = ParseProtocol(code); + + return model; + } + + private static (string code, bool success) ReadTextFromFile(string pathToFile) + { + try + { + string code; + var fileStream = new FileStream(pathToFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + using (var textReader = new StreamReader(fileStream)) + { + code = textReader.ReadToEnd(); + } + + return (code, true); + } + catch (FileNotFoundException) + { + return (String.Format("Missing file:{0}{1}", Environment.NewLine, pathToFile), false); + } + } + + private static (Skyline.DataMiner.CICD.Models.Protocol.Read.ProtocolModel, Skyline.DataMiner.CICD.Parsers.Common.Xml.XmlDocument) ParseProtocol(string protocolCode) + { + Parser parser = new Parser(new StringBuilder(protocolCode)); + + return (new Skyline.DataMiner.CICD.Models.Protocol.Read.ProtocolModel(parser.Document), parser.Document); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Helpers/TitleCasingTests.cs b/ProtocolTests/Helpers/TitleCasingTests.cs new file mode 100644 index 00000000..deb4b3b6 --- /dev/null +++ b/ProtocolTests/Helpers/TitleCasingTests.cs @@ -0,0 +1,201 @@ +namespace SLDisValidatorUnitTests.Helpers +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Tests; + + [TestClass] + public class TitleCasingTests + { + private static IEnumerable ReusableTestData => new List + { + new []{ "", ""}, + + new []{ "A", "A"}, + new []{ "Oneword", "Oneword"}, + new []{ "oneword", "Oneword"}, + + // For single letters, we allow all casing + new []{ "i", "i"}, // ex: 1080i (Interlaced) + new []{ "I", "I"}, // ex: Item I + new []{ "p", "p"}, // ex: 1080p (Progressive) + new []{ "P", "P"}, // ex: Item P + + // Prepositions with <=3 chars + new []{ "Preposition in Between", "Preposition in Between"}, + new []{ "Preposition In Between", "Preposition in Between"}, + new []{ "In Leading Preposition", "In Leading Preposition"}, + new []{ "in Leading Preposition", "In Leading Preposition"}, + new []{ "Trailing Preposition In", "Trailing Preposition In"}, + new []{ "Trailing Preposition in", "Trailing Preposition In"}, + + // Prepositions with >3 chars + new []{ "Preposition From Between", "Preposition From Between"}, + new []{ "Preposition from Between", "Preposition From Between"}, + new []{ "From Leading Preposition", "From Leading Preposition"}, + new []{ "from Leading Preposition", "From Leading Preposition"}, + new []{ "Trailing Preposition From", "Trailing Preposition From"}, + new []{ "Trailing Preposition from", "Trailing Preposition From"}, + + // Verbs + new []{ "Verb is in the Middle", "Verb Is in the Middle"}, + + // Coordinating Conjunctions + new []{ "Something and Something Else", "Something and Something Else"}, + new []{"Something And Something Else", "Something and Something Else"}, + + // Word Separators + new []{ "Dash-Separator", "Dash-Separator"}, + new []{ "dash-separator", "Dash-Separator"}, + new []{ "Slash-Separator", "Slash-Separator"}, + new []{ "slash-separator", "Slash-Separator"}, + new []{ "Underscore_Separator", "Underscore_Separator"}, + new []{ "underscore_separator", "Underscore_Separator"}, + new []{ "Numerical2Separator", "Numerical2Separator"}, + new []{ "numerical2separator", "Numerical2Separator"}, + new []{ "Between (Parentheses)", "Between (Parentheses)"}, + new []{ "Between (parentheses)", "Between (Parentheses)"}, + + // XML Reserved Chars + new []{ """, """}, + new []{ """, """}, + new []{ "<", "<"}, + new []{ ">", ">"}, + new []{ "&", "&"}, + + new []{ "&Word&", "&Word&"}, + new []{ "&word&", "&Word&"}, + new []{ ""Word"", ""Word""}, + new []{ ""word"", ""Word""}, + new []{ "One < Two", "One < Two"}, + new []{ "one < two", "One < Two"}, + new []{ "Two > One", "Two > One"}, + new []{ "two > one", "Two > One"}, + new []{ "Something & Something Else", "Something & Something Else"}, + new []{ "something & something else", "Something & Something Else"}, + + // Abbreviations + new []{ "HTTP", "HTTP" }, + new []{ "Http", "HTTP" }, + + // Abbreviations in their plural form + new []{ "VLANs", "VLANs" }, + new []{ "Aaa VLANs", "Aaa VLANs" }, + new []{ "VLANs Bbb", "VLANs Bbb" }, + new []{ "Column 1 (VLANs)", "Column 1 (VLANs)" }, + new []{ "PIDs", "PIDs" }, + + // Units with ignoreInDescription=false + new []{ "aA", "aA"}, + new []{ "Aa", "aA"}, + new []{ "am/d", "am/d"}, + new []{ "Am/D", "am/d"}, + new []{ "barG", "barG"}, + new []{ "Barg", "barG"}, + new []{ "ft/s", "ft/s"}, + new []{ "Ft/S", "ft/s"}, + + // For small (< 4 chars) units & words with specific casing, we allow both specific casing and all upper case. + // Otherwise, we end up with too many conflicts between words with specific casing and abbreviations. + new []{ "cH", "cH"}, + new []{ "CH", "CH"}, + + // Words with specific casing + new []{ "CM", "CM" }, + new []{ "Cm", "CM" }, + new []{ "Dataminer", "DataMiner" }, + new []{ "DataMiner", "DataMiner" }, + new []{ "QAction", "QAction" }, + new []{ "QActions", "QActions" }, + new []{ "DiSEqC", "DiSEqC" }, + new []{ "Diseqc", "DiSEqC" }, + new []{ "DISEQC", "DiSEqC" }, + new []{ "My IP", "My IP" }, + new []{ "My Ip", "My IP" }, + new []{ "My IPv4", "My IPv4" }, + new []{ "My Ipv6", "My IPv6" }, + new []{ "My Ipv6 Smth", "My IPv6 Smth" }, + new []{ "1080psf/25", "1080psf/25" }, + new []{ "1080 25psf", "1080 25psf" }, + new []{ "PsF Test", "PsF Test" }, + new []{ "Always On-Air", "Always On-Air" }, + + // Units with 2 possible casing + new []{ "mbar", "mbar"}, // Milli-bar + new []{ "Mbar", "Mbar"}, // Mega-bar + + new []{ "peV", "peV"}, // pico-electronvolt + new []{ "PeV", "PeV"}, // peta-electronvolt + + new []{ "CC Errors", "CC Errors"}, // Continuity Counter Errors + new []{ "cC", "cC"}, // centi-coulomb unit + + // Words with 2 possible casing: min (minutes) vs Min (Minimum) + new []{ "min", "min"}, + new []{ "Min", "Min"}, + new []{ "Aaa min", "Aaa min"}, + new []{ "Aaa Min", "Aaa Min"}, + new []{ "min Aaa", "min Aaa"}, + new []{ "Min Aaa", "Min Aaa"}, + new []{ "Aaa min Bbb", "Aaa min Bbb"}, + new []{ "Aaa Min Bbb", "Aaa Min Bbb"}, + + new []{ "bar", "bar"}, // bar (pressure unit) + new []{ "Bar", "Bar"}, // Bar (Bar Tender, Metal Bar, etc) + + new []{ "Voice over IP", "Voice over IP" }, // over : Known principles such as "Voice over IP", "IP over CDLC", etc + new []{ "Come Over Here", "Come Over Here"}, // Over : preposition of >3 chars + + // Words followed by brackets should be considered same as a last word + new []{ "Turn on Turn On", "Turn on Turn On"}, + new []{ "Turn on Turn On (Turn On)", "Turn on Turn On (Turn On)"}, + new []{ "Turn on (Turn On) Turn On (Turn On) (Turn On)", "Turn On (Turn On) Turn On (Turn On) (Turn On)"}, + + // Words preceded by brackets should be considered same as a first word + new []{ "On Air on Air", "On Air on Air"}, + new []{ "On Air on Air (On Air)", "On Air on Air (On Air)"}, + new []{ "(On Air) On Air on Air (On Air)", "(On Air) On Air on Air (On Air)"}, + + // Words with non-ASCII chars + /* TODO-MOD: This fails in .NET + new []{ "500 µs", "500 µs"}, // Micro Symbol µ (hex C2B5) + new []{ "500µs", "500µs"}, // Micro Symbol µ (hex C2B5) + //new []{ "µ", "µ"}, // Micro Symbol µ (hex C2B5) + //new []{ "\u00B5", "µ"}, // Micro Symbol µ (hex C2B5) + //new []{ "" + (char)0xC2B5, "µ"}, // Micro Symbol µ (hex C2B5) + */ + + new []{ "500 μs", "500 Μs"}, // Greek letter μ (hex CEBC) + new []{ "500μs", "500Μs"}, // Greek letter μ (hex CEBC) + //new []{ "μ", "Μ"}, // Greek letter μ (hex CEBC) + //new []{ "\u03BC", "Μ"}, // Greek letter μ (hex CEBC) + //new []{ "" + (char)0xCEBC, "Μ"}, // Greek letter μ (hex CEBC) + }; + + [TestMethod] + [DoNotParallelize] + [DynamicData(nameof(ReusableTestData))] + public void ToTitleCase_Valid(string inputValue, string expectedOutput) + { + TitleCasing titleCasing = new TitleCasing(new ValidatorSettings()); + string output = titleCasing.ToTitleCase(inputValue); + + Assert.AreEqual(expectedOutput, output); + } + + [TestMethod] + [DoNotParallelize] + [DataRow("On Air on Air", "On Air on Air")] + [DataRow("On Air on Air (On Air)", "On Air on Air (On Air)")] + [DataRow("(On Air) On Air on Air (On Air)", "(On Air) On Air on Air (On Air)")] + public void ToTitleCase_Valid_ForQuickDebugging(string inputValue, string expectedOutput) + { + TitleCasing titleCasing = new TitleCasing(new ValidatorSettings()); + string output = titleCasing.ToTitleCase(inputValue); + + Assert.AreEqual(expectedOutput, output); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Initialize.cs b/ProtocolTests/Initialize.cs new file mode 100644 index 00000000..fdcf5f48 --- /dev/null +++ b/ProtocolTests/Initialize.cs @@ -0,0 +1,35 @@ +namespace SLDisValidatorUnitTests +{ + using System; + using System.Linq; + using System.Reflection; + using Microsoft.Build.Locator; + using Microsoft.CodeAnalysis.Host.Mef; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class Initialize + { + [AssemblyInitialize] + public static void AssemblyInitialize(TestContext context) + { + // Needed for Jenkins + if (!MSBuildLocator.IsRegistered) + { + MSBuildLocator.RegisterDefaults(); + } + + try + { + // warm up some Roslyn classes, to avoid that unit test fail + var defaultServices = MSBuildMefHostServices.DefaultServices; + var defaultHost = MefHostServices.DefaultHost; + } + catch (ReflectionTypeLoadException tle) + { + string text = String.Join(";", tle.LoaderExceptions.Select(x => x.Message)); + throw new Exception($"ReflectionTypeLoadException with these LoaderExceptions:{Environment.NewLine}{text}"); + } + } + } +} diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/CheckActionTypes.cs b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/CheckActionTypes.cs new file mode 100644 index 00000000..ea23247c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/CheckActionTypes.cs @@ -0,0 +1,499 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.CheckActionTypes +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.CheckActionTypes; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckActionTypes(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckActionTypes_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnCommand() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnCommand", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnGroup", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnPair() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnPair", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnParam", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnProtocol() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnProtocol", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnResponse() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnResponse", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_ValidOnTimer() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnTimer", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckActionTypes_ExcessiveTypeIdOrTypeValueAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveTypeIdOrTypeValueAttribute", + ExpectedResults = new List + { + // On Pair + Error.ExcessiveTypeIdOrTypeValueAttribute(null, null, null, "set next", "pair", "3000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_IncompatibleTypeVsOnTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IncompatibleTypeVsOnTag", + ExpectedResults = new List + { + // On Command + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "command", "1000"), + + // On Group + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "group", "2000"), + + // On Pair + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "pair", "3000"), + + // On Param + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "parameter", "4000"), + + // On Protocol + Error.IncompatibleTypeVsOnTag(null, null, null, "add to execute", "protocol", "5000"), + + // On Response + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "response", "6000"), + + // On Timer + Error.IncompatibleTypeVsOnTag(null, null, null, "close", "timer", "7000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_MissingOnIdAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingOnIdAttribute", + ExpectedResults = new List + { + // On Group + Error.MissingOnIdAttribute(null, null, null, "add to execute", "group", "2000"), + Error.MissingOnIdAttribute(null, null, null, "execute", "group", "2010"), + Error.MissingOnIdAttribute(null, null, null, "execute next", "group", "2020"), + Error.MissingOnIdAttribute(null, null, null, "execute one", "group", "2030"), + Error.MissingOnIdAttribute(null, null, null, "execute one top", "group", "2040"), + Error.MissingOnIdAttribute(null, null, null, "execute one now", "group", "2050"), + Error.MissingOnIdAttribute(null, null, null, "force execute", "group", "2060"), + + Error.MissingOnIdAttribute(null, null, null, "set", "group", "2500"), + Error.MissingOnIdAttribute(null, null, null, "set with wait", "group", "2510"), + + // On Pair + Error.MissingOnIdAttribute(null, null, null, "timeout", "pair", "3010"), + + // On Timer + Error.MissingOnIdAttribute(null, null, null, "reschedule", "timer", "7000"), + Error.MissingOnIdAttribute(null, null, null, "restart timer", "timer", "7001"), + Error.MissingOnIdAttribute(null, null, null, "start", "timer", "7002"), + Error.MissingOnIdAttribute(null, null, null, "stop", "timer", "7003"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_MissingOnNrAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingOnNrAttribute", + ExpectedResults = new List + { + // On Pair + Error.MissingOnNrAttribute(null, null, null, "set next", "pair", "3000"), + Error.MissingOnNrAttribute(null, null, null, "set next", "pair", "3001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_MissingTypeIdAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTypeIdAttribute", + ExpectedResults = new List + { + // On Pair + Error.MissingTypeIdAttribute(null, null, null, "timeout", "pair", "3010"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_MissingTypeIdOrTypeValueAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTypeIdOrTypeValueAttribute", + ExpectedResults = new List + { + // On Pair + Error.MissingTypeIdOrTypeValueAttribute(null, null, null, "set next", "pair", "3000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_NonExistingConnectionRefInTypeNrAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingConnectionRefInTypeNrAttribute", + ExpectedResults = new List + { + // On Group + Error.NonExistingConnectionRefInTypeNrAttribute(null, null, null, "typo", "2500"), + Error.NonExistingConnectionRefInTypeNrAttribute(null, null, null, "-1", "2501"), + Error.NonExistingConnectionRefInTypeNrAttribute(null, null, null, "1", "2510"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_NonExistingParamRefInTypeIdAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParamRefInTypeIdAttribute", + ExpectedResults = new List + { + // On Pair + Error.NonExistingParamRefInTypeIdAttribute(null, null, null, "1", "3001"), + Error.NonExistingParamRefInTypeIdAttribute(null, null, null, "1", "3010"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_NonExistingRefToPairOnTimeoutSetNext() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingRefToPairOnTimeoutSetNext", + ExpectedResults = new List + { + // On Pair Hard coded timeout time + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "a", "100", "3000", "101"), + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "5", "100", "3000", "101"), + + // On Pair dynamic timeout time + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "b", "100", "3001", "101"), + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "0", "100", "3001", "101"), + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "-1", "100", "3001", "101"), + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "", "100", "3001", "101"), + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "10", "100", "3001", "101"), + + // On Pair no Trigger + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "1", "NoGroup", "4000", "NoTrigger"), + + // On Pair no Group + Error.NonExistingRefToPairOnTimeoutSetNext(null, null, null, "1", "NoGroup", "5000", "500"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_UnsupportedAttributeOnNr() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedAttributeOnNr", + ExpectedResults = new List + { + // On Command + Error.UnsupportedAttributeOnNr(null, null, null, "crc", "command", "1000"), + + // On Group + Error.UnsupportedAttributeOnNr(null, null, null, "add to execute", "group", "2000"), + + // On Pair + Error.UnsupportedAttributeOnNr(null, null, null, "timeout", "pair", "3010"), + + // On Parameter + Error.UnsupportedAttributeOnNr(null, null, null, "aggregate", "parameter", "4000"), + + // On Protocol + Error.UnsupportedAttributeOnNr(null, null, null, "close", "protocol", "5000"), + + // On Response + Error.UnsupportedAttributeOnNr(null, null, null, "clear", "response", "6000"), + + // On Timer + Error.UnsupportedAttributeOnNr(null, null, null, "reschedule", "timer", "7000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_UnsupportedConnectionTypeDueTo() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedConnectionTypeDueTo", + ExpectedResults = new List + { + // On Group + Error.UnsupportedConnectionTypeDueTo(null, null, null, "set", "group", "0", "virtual", "2500", "Default value for "), + Error.UnsupportedConnectionTypeDueTo(null, null, null, "set", "group", "1", "http", "2501", ""), + + Error.UnsupportedConnectionTypeDueTo(null, null, null, "set with wait", "group", "0", "virtual", "2510", ""), + Error.UnsupportedConnectionTypeDueTo(null, null, null, "set with wait", "group", "2", "serial", "2511", ""), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_UnsupportedGroupContentDueTo() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedGroupContentDueTo", + ExpectedResults = new List + { + // On Group + Error.UnsupportedGroupContentDueTo(null, null, null, "set", "group", "1", "2500"), + + Error.UnsupportedGroupContentDueTo(null, null, null, "set with wait", "group", "2", "2510"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_UnsupportedGroupParamType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedGroupParamType", + ExpectedResults = new List + { + // On Group + Error.UnsupportedGroupParamType(null, null, null, "set", "group", "1", "150", "read", "2500"), + Error.UnsupportedGroupParamType(null, null, null, "set", "group", "1", "151", "write bit", "2500"), + + Error.UnsupportedGroupParamType(null, null, null, "set with wait", "group", "2", "250", "dummy", "2510"), + Error.UnsupportedGroupParamType(null, null, null, "set with wait", "group", "2", "251", "read bit", "2510"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckActionTypes_UnsupportedGroupParamWithoutSnmp() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedGroupParamWithoutSnmp", + ExpectedResults = new List + { + // On Group + Error.UnsupportedGroupParamWithoutSnmp(null, null, null, "set", "group", "1", "150", "false", "2500"), + Error.UnsupportedGroupParamWithoutSnmp(null, null, null, "set", "group", "1", "151", "", "2500"), + + Error.UnsupportedGroupParamWithoutSnmp(null, null, null, "set with wait", "group", "2", "250", "", "2510"), + Error.UnsupportedGroupParamWithoutSnmp(null, null, null, "set with wait", "group", "2", "251", "typo", "2510"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckActionTypes_IncompatibleTypeVsOnTag() + { + // Create ErrorMessage + var message = Error.IncompatibleTypeVsOnTag(null, null, null, "actionType", "actionOn", "actionId"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.7.1", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Incompatible 'Action/Type' value 'actionType' with 'Action/On' value 'actionOn'. Action ID 'actionId'.", + HowToFix = "", + ExampleCode = "", + Details = "Only the following combination of 'Action/On' and 'Action/Type' are supported." + Environment.NewLine + "- command" + Environment.NewLine + " - crc" + Environment.NewLine + " - length" + Environment.NewLine + " - make" + Environment.NewLine + " - replace" + Environment.NewLine + " - replace data" + Environment.NewLine + " - stuffing" + Environment.NewLine + "- group" + Environment.NewLine + " - add to execute" + Environment.NewLine + " - execute" + Environment.NewLine + " - execute next" + Environment.NewLine + " - execute one" + Environment.NewLine + " - execute one top" + Environment.NewLine + " - execute one now" + Environment.NewLine + " - force execute" + Environment.NewLine + " - set" + Environment.NewLine + " - set with wait" + Environment.NewLine + "- pair" + Environment.NewLine + " - set next" + Environment.NewLine + " - timeout" + Environment.NewLine + "- parameter" + Environment.NewLine + " - aggregate" + Environment.NewLine + " - append" + Environment.NewLine + " - append data" + Environment.NewLine + " - change lenght" + Environment.NewLine + " - clear" + Environment.NewLine + " - clear on display" + Environment.NewLine + " - copy" + Environment.NewLine + " - copy reverse" + Environment.NewLine + " - go" + Environment.NewLine + " - increment" + Environment.NewLine + " - multiply" + Environment.NewLine + " - normalize" + Environment.NewLine + " - pow" + Environment.NewLine + " - read" + Environment.NewLine + " - replace data" + Environment.NewLine + " - reverse" + Environment.NewLine + " - run actions" + Environment.NewLine + " - save" + Environment.NewLine + " - set" + Environment.NewLine + " - set and get with wait" + Environment.NewLine + " - set info" + Environment.NewLine + " - set with wait" + Environment.NewLine + "- protocol" + Environment.NewLine + " - close" + Environment.NewLine + " - lock/unlock" + Environment.NewLine + " - merge" + Environment.NewLine + " - open" + Environment.NewLine + " - priority lock/unlock" + Environment.NewLine + " - read file" + Environment.NewLine + " - sleep" + Environment.NewLine + " - stop current group" + Environment.NewLine + " - swap column" + Environment.NewLine + " - wmi" + Environment.NewLine + "- response" + Environment.NewLine + " - clear" + Environment.NewLine + " - clear length info" + Environment.NewLine + " - crc" + Environment.NewLine + " - length" + Environment.NewLine + " - read" + Environment.NewLine + " - read stuffing" + Environment.NewLine + " - replace" + Environment.NewLine + " - replace data" + Environment.NewLine + " - stuffing" + Environment.NewLine + "- timer" + Environment.NewLine + " - restart timer" + Environment.NewLine + " - start" + Environment.NewLine + " - stop" + Environment.NewLine + " - reschedule", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckActionTypes(); + + [TestMethod] + public void Action_CheckActionTypes_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckActionTypes_CheckId() => Generic.CheckId(check, CheckId.CheckActionTypes); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/ExcessiveTypeIdOrTypeValueAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/ExcessiveTypeIdOrTypeValueAttribute.xml new file mode 100644 index 00000000..4af9f9f7 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/ExcessiveTypeIdOrTypeValueAttribute.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3000 + + + + + + + pair_set next + pair + set next + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/IncompatibleTypeVsOnTag.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/IncompatibleTypeVsOnTag.xml new file mode 100644 index 00000000..7218281c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/IncompatibleTypeVsOnTag.xml @@ -0,0 +1,54 @@ + + + + + + command_close + command + close + + + + + group_close + group + close + + + + + pair_close + pair + close + + + + + parameter_close + parameter + close + + + + + protocol_add to execute + protocol + add to execute + + + + + response_close + response + close + + + + + timer_close + timer + close + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnIdAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnIdAttribute.xml new file mode 100644 index 00000000..ef6ffc2e --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnIdAttribute.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + group_add to execute + group + add to execute + + + group_execute + group + execute + + + group_execute next + group + execute next + + + group_execute one + group + execute one + + + group_execute one top + group + execute one top + + + group_execute one now + group + execute one now + + + group_force execute + group + force execute + + + + group_Set + group + set + + + group_SetWithWait + group + set with wait + + + + + Pair_Timeout + pair + timeout + + + + + + + + + + + Timer_Reschedule + timer + reschedule + + + Timer_RestartTimer + timer + restart timer + + + Timer_Start + timer + start + + + Timer_Stop + timer + stop + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnNrAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnNrAttribute.xml new file mode 100644 index 00000000..49ee1559 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingOnNrAttribute.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3000 + + + + + + + pair_set next_HardCoded + pair + set next + + + pair_set next_Dynamic + pair + set next + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdAttribute.xml new file mode 100644 index 00000000..d571203c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdAttribute.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + Pair_Timeout + pair + timeout + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdOrTypeValueAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdOrTypeValueAttribute.xml new file mode 100644 index 00000000..556a3b2f --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/MissingTypeIdOrTypeValueAttribute.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3000 + + + + + + + pair_set next + pair + set next + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingConnectionRefInTypeNrAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingConnectionRefInTypeNrAttribute.xml new file mode 100644 index 00000000..0efffd7c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingConnectionRefInTypeNrAttribute.xml @@ -0,0 +1,40 @@ + + snmp + + + + SNMP Write Param + write + + true + + + + + + + + 1 + + + + + + + group_Set_TypoOnConnectionId + group + set + + + group_Set_NegativeConnectionId + group + set + + + group_SetWithWait_TooHighConnectionId + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingParamRefInTypeIdAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingParamRefInTypeIdAttribute.xml new file mode 100644 index 00000000..cb222579 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingParamRefInTypeIdAttribute.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3001 + + + + + + + pair_set next_Dynamic + pair + set next + + + pair_timeout + pair + timeout + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingRefToPairOnTimeoutSetNext.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingRefToPairOnTimeoutSetNext.xml new file mode 100644 index 00000000..70c0f437 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/NonExistingRefToPairOnTimeoutSetNext.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3000 + 3001 + + + + + action + + 5000 + + + + + + + pair_set next_HardCoded + pair + set next + + + pair_set next_Dynamic + pair + set next + + + pair_set next_NoTrigger + pair + set next + + + pair_set next_NoGroup + pair + set next + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedAttributeOnNr.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedAttributeOnNr.xml new file mode 100644 index 00000000..8551833c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedAttributeOnNr.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + Unsupported_Reverse_Group + command + crc + + + + + group_add to execute + group + add to execute + + + + + pair_timeout + pair + timeout + + + + + parameter_aggregate + parameter + aggregate + + + + + protocol_close + protocol + close + + + + + response_clear + response + clear + + + + + timer_reschedule + timer + reschedule + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedConnectionTypeDueTo.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedConnectionTypeDueTo.xml new file mode 100644 index 00000000..9fde2bd6 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedConnectionTypeDueTo.xml @@ -0,0 +1,46 @@ + + virtual + + + + SNMP Write Param + write + + true + + + + + + + + + 1 + + + + + + + group_Set_OnDefaultConnection_Virtual + group + set + + + group_Set_Http + group + set + + + group_SetWithWait_Virtual + group + set with wait + + + group_SetWithWait_Serial + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupContentDueTo.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupContentDueTo.xml new file mode 100644 index 00000000..945c172a --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupContentDueTo.xml @@ -0,0 +1,33 @@ + + snmp + + + + + + + + Empty Group + + + Pair Group + + 1 + + + + + + + group_Set + group + set + + + group_SetWithWait + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamType.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamType.xml new file mode 100644 index 00000000..4e4c31c2 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamType.xml @@ -0,0 +1,66 @@ + + snmp + + + + Read + read + + true + + + + WriteBit + write bit + + true + + + + + Dummy + dummy + + true + + + + ReadBit + read bit + + true + + + + + + + SNMP Group 1 + + 150 + 151 + + + + SNMP Group 2 + + 250 + 251 + + + + + + + group_Set + group + set + + + group_SetWithWait + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamWithoutSnmp.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamWithoutSnmp.xml new file mode 100644 index 00000000..f65b4c5d --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Invalid/UnsupportedGroupParamWithoutSnmp.xml @@ -0,0 +1,66 @@ + + snmp + + + + SnmpEnabledFalse + write + + false + + + + NoSnmpEnabled + write + + + + + + + NoSnmp + write + + + + SnmpEnabledWithTypo + write + + typo + + + + + + + SNMP Group 1 + + 150 + 151 + + + + SNMP Group 2 + + 250 + 251 + + + + + + + group_Set + group + set + + + group_SetWithWait + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..4262baed --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,11 @@ + + + + + protocol_close + protocol + close + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnCommand.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnCommand.xml new file mode 100644 index 00000000..38f5c2e6 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnCommand.xml @@ -0,0 +1,36 @@ + + + + + command_crc + command + crc + + + command_length + command + length + + + command_make + command + make + + + command_replace + command + replace + + + command_replace data + command + replace data + + + command_stuffing + command + stuffing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnGroup.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnGroup.xml new file mode 100644 index 00000000..e97d1fde --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnGroup.xml @@ -0,0 +1,75 @@ + + snmp + + + + SNMP Write Param + write + + true + + + + + + + Group + + + SNMP Group + + 1 + + + + + + + group_add to execute + group + add to execute + + + group_execute + group + execute + + + group_execute next + group + execute next + + + group_execute one + group + execute one + + + group_execute one top + group + execute one top + + + group_execute one now + group + execute one now + + + group_force execute + group + force execute + + + + group_Set + group + set + + + group_SetWithWait + group + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnPair.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnPair.xml new file mode 100644 index 00000000..e0c55572 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnPair.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + 100 + 200 + + + + + + + group + action + + 3000 + 3001 + + + + + + + pair_set next_HardCoded + pair + set next + + + pair_set next_Dynamic + pair + set next + + + pair_timeout + pair + timeout + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnParam.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnParam.xml new file mode 100644 index 00000000..ccbecbb4 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnParam.xml @@ -0,0 +1,116 @@ + + + + + parameter_aggregate + parameter + aggregate + + + parameter_append + parameter + append + + + parameter_append data + parameter + append data + + + parameter_change length + parameter + change length + + + parameter_clear + parameter + clear + + + parameter_clear on display + parameter + clear on display + + + parameter_copy + parameter + copy + + + parameter_copy reverse + parameter + copy reverse + + + parameter_go + parameter + go + + + parameter_increment + parameter + increment + + + parameter_multiply + parameter + multiply + + + parameter_normalize + parameter + normalize + + + parameter_pow + parameter + pow + + + parameter_read + parameter + read + + + parameter_replace data + parameter + replace data + + + parameter_reverse + parameter + reverse + + + parameter_run actions + parameter + run actions + + + parameter_save + parameter + save + + + parameter_set + parameter + set + + + parameter_set and get with wait + parameter + set and get with wait + + + parameter_set info + parameter + set info + + + parameter_set with wait + parameter + set with wait + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnProtocol.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnProtocol.xml new file mode 100644 index 00000000..31554830 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnProtocol.xml @@ -0,0 +1,66 @@ + + + + + protocol_close + protocol + close + + + protocol_lock + protocol + lock + + + protocol_unlock + protocol + unlock + + + protocol_merge + protocol + merge + + + protocol_open + protocol + open + + + protocol_priority lock + protocol + priority lock + + + protocol_priority unlock + protocol + priority unlock + + + protocol_read file + protocol + read file + + + protocol_sleep + protocol + sleep + + + protocol_stop current group + protocol + stop current group + + + protocol_swap column + protocol + swap column + + + protocol_wmi + protocol + wmi + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnResponse.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnResponse.xml new file mode 100644 index 00000000..04b4ad05 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnResponse.xml @@ -0,0 +1,51 @@ + + + + + response_clear + response + clear + + + response_clear length info + response + clear length info + + + response_crc + response + crc + + + response_length + response + length + + + response_read + response + read + + + response_read stuffing + response + read stuffing + + + response_replace + response + replace + + + response_replace data + response + replace data + + + response_stuffing + response + stuffing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnTimer.xml b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnTimer.xml new file mode 100644 index 00000000..42e86e3e --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckActionTypes/Samples/Validate/Valid/ValidOnTimer.xml @@ -0,0 +1,33 @@ + + + + + timer_reschedule + timer + reschedule + + + + timer_restart timer + timer + restart timer + + + + timer_start + timer + start + + + + timer_stop + timer + stop + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..5b2d16b0 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,334 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.CheckIdAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "6.2.5", + Category = Category.Action, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "More than one Action with same ID '2'. Action Names '3'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The Action@id attribute is used internally as the identifier for each action.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each action should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "6.2.2", + Category = Category.Action, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'Action@id'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The Action@id attribute is used internally as the identifier for each action.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each action should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "MyName"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "6.2.4", + Category = Category.Action, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Invalid value '2' in attribute 'Action@id'. Action name 'MyName'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The Action@id attribute is used internally as the identifier for each action.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each action should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.2.1", + Category = Category.Action, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Missing attribute 'Action@id'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The Action@id attribute is used internally as the identifier for each action.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each action should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "6.2.3", + Category = Category.Action, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed attribute 'Action@id'. Current value '2'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The Action@id attribute is used internally as the identifier for each action.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each action should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Action_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..621ffe8e --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..eeb1d7ad --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..4892c213 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..a65eb94b --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..45ce85ee --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..6cef0d7b --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..eb51b841 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..0cdce1ab --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.Condition.CheckConditionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "currentCondition", "reason", "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.4.1", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition 'currentCondition'. Reason 'reason'. Action ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Action/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "6.4.2", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Action/Condition' references a non-existing 'Param' with PID '2'. Action ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Action/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void Action_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..29044e7a --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..4040ef6b --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,22 @@ + + + + + + + + string + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..b23c13b1 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,11 @@ + + + + + + + 20]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a125c59c --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,24 @@ + + + + + + + + double + + + + + string + + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..915af862 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,105 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.Name.CheckNameTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckNameTag_DuplicatedValue() + { + // Create ErrorMessage + var message = Error.DuplicatedValue(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.1.1", + Category = Category.Action, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Duplicated Action Name '0'. Action IDs '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckNameTag(); + + [TestMethod] + public void Action_CheckNameTag_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckNameTag_CheckId() => Generic.CheckId(check, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..4291655f --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e353aed4 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..28166593 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,328 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.On.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.On.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckIdAttribute_EmptyAttibute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttibute", + ExpectedResults = new List + { + Error.EmptyAttibute(null, null, null, "100"), + Error.EmptyAttibute(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "100"), + + Error.InvalidValue(null, null, null, "-2;1.5;2,6", "200").WithSubResults( + Error.InvalidValue(null, null, null, "-2", "200"), + Error.InvalidValue(null, null, null, "1.5", "200"), + Error.InvalidValue(null, null, null, "2,6", "200")), + + Error.InvalidValue(null, null, null, "03;+4;5x10^1", "203").WithSubResults( + Error.InvalidValue(null, null, null, "03", "203"), + Error.InvalidValue(null, null, null, "+4", "203"), + Error.InvalidValue(null, null, null, "5x10^1", "203")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("TODO")] + public void Action_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "actionType", "actionId"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + // Command + Error.NonExistingId(null, null, null, "Command", "108", "101"), + + Error.NonExistingId(null, null, null, "Command", "108", "102"), + Error.NonExistingId(null, null, null, "Command", "109", "102"), + + // Group + Error.NonExistingId(null, null, null, "Group", "208", "201"), + + Error.NonExistingId(null, null, null, "Group", "208", "202"), + Error.NonExistingId(null, null, null, "Group", "209", "202"), + + // Pair + Error.NonExistingId(null, null, null, "Pair", "308", "301"), + + Error.NonExistingId(null, null, null, "Pair", "308", "302"), + Error.NonExistingId(null, null, null, "Pair", "309", "302"), + + // Param + Error.NonExistingId(null, null, null, "Param", "408", "401"), + + Error.NonExistingId(null, null, null, "Param", "408", "402"), + Error.NonExistingId(null, null, null, "Param", "409", "402"), + + // Response + Error.NonExistingId(null, null, null, "Response", "608", "601"), + + Error.NonExistingId(null, null, null, "Response", "608", "602"), + Error.NonExistingId(null, null, null, "Response", "609", "602"), + + // Timer + Error.NonExistingId(null, null, null, "Timer", "708", "701"), + + Error.NonExistingId(null, null, null, "Timer", "708", "702"), + Error.NonExistingId(null, null, null, "Timer", "709", "702"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedValueInAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedValueInAttribute", + ExpectedResults = new List + { + Error.UntrimmedValueInAttribute(null, null, null, " 101", "1"), + Error.UntrimmedValueInAttribute(null, null, null, "102 ", "2"), + Error.UntrimmedValueInAttribute(null, null, null, " 103 ", "3"), + + Error.UntrimmedValueInAttribute(null, null, null, "101 ; 102", "102").WithSubResults( + Error.UntrimmedValueInAttribute(null, null, null, "101 ", "102"), + Error.UntrimmedValueInAttribute(null, null, null, " 102", "102")), + + Error.UntrimmedValueInAttribute(null, null, null, " 101;102 ; 103", "103").WithSubResults( + Error.UntrimmedValueInAttribute(null, null, null, " 101", "103"), + Error.UntrimmedValueInAttribute(null, null, null, "102 ", "103"), + Error.UntrimmedValueInAttribute(null, null, null, " 103", "103")), + + Error.UntrimmedValueInAttribute(null, null, null, "101 ; 102;103 ; 104 ;105;106;107", "104").WithSubResults( + Error.UntrimmedValueInAttribute(null, null, null, "101 ", "104"), + Error.UntrimmedValueInAttribute(null, null, null, " 102", "104"), + Error.UntrimmedValueInAttribute(null, null, null, "103 ", "104"), + Error.UntrimmedValueInAttribute(null, null, null, " 104 ", "104")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedValueInAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedValueInAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttibute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "6.3.2", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'On@id' in Action '2'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "The 'Action/On@id' attribute can contain a semicolon list of unsigned number which refer to the id of an existing protocol item. The type of item is specified by the inner value of the 'Action/On' tag." + Environment.NewLine + "If the 'Action/On@id' attribute is not present, the action will apply to all item of the type given by the value of the 'Action/On' tag." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "6.3.4", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Invalid value '2' in attribute 'On@id'. Action ID '3'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "The 'Action/On@id' attribute can contain a semicolon list of unsigned number which refer to the id of an existing protocol item. The type of item is specified by the inner value of the 'Action/On' tag." + Environment.NewLine + "If the 'Action/On@id' attribute is not present, the action will apply to all item of the type given by the value of the 'Action/On' tag." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3", "4"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "6.3.5", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Attribute 'On@id' references a non-existing '2' with ID '3'. Action ID '4'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "The 'Action/On@id' attribute can contain a semicolon list of unsigned number which refer to the id of an existing protocol item. The type of item is specified by the inner value of the 'Action/On' tag." + Environment.NewLine + "If the 'Action/On@id' attribute is not present, the action will apply to all item of the type given by the value of the 'Action/On' tag." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckIdAttribute_UntrimmedValueInAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInAttribute(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "6.3.3", + Category = Category.Action, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed value '2' in attribute 'On@id'. Action ID '3'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "The 'Action/On@id' attribute can contain a semicolon list of unsigned number which refer to the id of an existing protocol item. The type of item is specified by the inner value of the 'Action/On' tag." + Environment.NewLine + "If the 'Action/On@id' attribute is not present, the action will apply to all item of the type given by the value of the 'Action/On' tag." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Action_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Codefix/UntrimmedValueInAttribute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Codefix/UntrimmedValueInAttribute.xml new file mode 100644 index 00000000..5d48a1cd --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Codefix/UntrimmedValueInAttribute.xml @@ -0,0 +1,42 @@ + + + + + LeadingSpaces + command + + + TrailingSpaces + command + + + LeadingAndTrailingSpace + command + + + + Untrimmed_2 + command + + + Untrimmed_3 + command + + + Untrimmed_4 + command + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttibute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttibute.xml new file mode 100644 index 00000000..50d98de6 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttibute.xml @@ -0,0 +1,14 @@ + + + + + Empty + command + + + Spaces + command + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..9aaf6422 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,19 @@ + + + + + String + command + + + + Number_NonUint + command + + + Number_Format + command + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..fce93843 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..b77c0e6e --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,101 @@ + + + + + + Command_1_Id + command + + + Command_2_Ids + command + + + + + Group_1_Id + group + + + Group_2_Ids + group + + + + + Pair_1_Id + pair + + + Pair_2_Ids + pair + + + + + Param_1_Id + parameter + + + Param_2_Ids + parameter + + + + + + + + Response_1_Id + response + + + Response_2_Ids + response + + + + + Timer_1_Id + timer + + + Timer_2_Ids + timer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedValueInAttribute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedValueInAttribute.xml new file mode 100644 index 00000000..6347c4fa --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedValueInAttribute.xml @@ -0,0 +1,42 @@ + + + + + LeadingSpaces + command + + + TrailingSpaces + command + + + LeadingAndTrailingSpace + command + + + + Untrimmed_2 + command + + + Untrimmed_3 + command + + + Untrimmed_4 + command + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..595d8bee --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,125 @@ + + + + + + Command_NoId + command + + + Command_1_Id + command + + + Command_2_Ids + command + + + + + Group_NoId + group + + + Group_1_Id + group + + + Group_2_Ids + group + + + + + Pair_NoId + pair + + + Pair_1_Id + pair + + + Pair_2_Ids + pair + + + + + Param_NoId + parameter + + + Param_1_Id + parameter + + + Param_2_Ids + parameter + + + + + Protocol_NoId + protocol + + + + + Response_NoId + response + + + Response_1_Id + response + + + Response_2_Ids + response + + + + + Timer_NoId + timer + + + Timer_1_Id + timer + + + Timer_2_Ids + timer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/CheckNrAttribute.cs b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/CheckNrAttribute.cs new file mode 100644 index 00000000..b6eecca9 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/CheckNrAttribute.cs @@ -0,0 +1,130 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.On.CheckNrAttribute +{ + using System; + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.On.CheckNrAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckNrAttribute(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckNrAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckNrAttribute_EmptyAttibute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttibute", + ExpectedResults = new List + { + Error.EmptyAttibute(null, null, null, "1"), + Error.EmptyAttibute(null, null, null, "2"), + Error.EmptyAttibute(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Currently not expecting any result")] + public void Action_CheckNrAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + // There is currently no such thing as invalid value for this attribute as any string is authorized. + // Note that this should only cover invalid values according to xsd/ProtocolModel. + // Further parsing is done via the CheckActionTypes check + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckNrAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 0;1", "1"), + Error.UntrimmedAttribute(null, null, null, "0;1 ", "2"), + Error.UntrimmedAttribute(null, null, null, " 0;1 ", "3"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckNrAttribute(); + + [TestMethod] + public void Action_CheckOnTag_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckNrAttribute(); + + [TestMethod] + public void Action_CheckNrAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckNrAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckNrAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..5c24e883 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + Leading + parameter + reverse + + + Trailing + parameter + reverse + + + LeadingAndTrailing + parameter + reverse + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/EmptyAttibute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/EmptyAttibute.xml new file mode 100644 index 00000000..e1168929 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/EmptyAttibute.xml @@ -0,0 +1,22 @@ + + + + + Empty + parameter + reverse + + + Spaces + parameter + reverse + + + Enters + parameter + reverse + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..49defabf --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,10 @@ + + + + + parameter + reverse + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..9d477598 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + Leading + parameter + reverse + + + Trailing + parameter + reverse + + + LeadingAndTrailing + parameter + reverse + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..5ca0e61a --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckNrAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,29 @@ + + + + + + + + + + Pair_SetNext + pair + set next + + + + + Parameter_Reverse + parameter + reverse + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/CheckOnTag.cs b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/CheckOnTag.cs new file mode 100644 index 00000000..08ba8d15 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/CheckOnTag.cs @@ -0,0 +1,252 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.On.CheckOnTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.On.CheckOnTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOnTag(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckOnTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckOnTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckOnTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "typo", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckOnTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckOnTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " command"), + Error.UntrimmedTag(null, null, null, "2", "group "), + Error.UntrimmedTag(null, null, null, "3", " pair "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckOnTag(); + + [TestMethod] + public void Action_CheckOnTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckOnTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "6.6.2", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'On' in Action '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/On' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "command, group, pair, parameter, protocol, response, timer.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckOnTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "6.6.4", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'On'. Action ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/On' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "command, group, pair, parameter, protocol, response, timer.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckOnTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.6.1", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'On' in Action '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/On' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "command, group, pair, parameter, protocol, response, timer.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckOnTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "6.6.3", + Category = Category.Action, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'On' in Action '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/On' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "command, group, pair, parameter, protocol, response, timer.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOnTag(); + + [TestMethod] + public void Action_CheckOnTag_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckOnTag_CheckId() => Generic.CheckId(check, CheckId.CheckOnTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..49152e34 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading + command + + + Trailing + group + + + Leading_Trailing + pair + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..9e4dd2ea --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,19 @@ + + + + + Empty + + + + Spaces + + + + Enters + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..89f775ed --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,9 @@ + + + + + typo + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..4db68131 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,9 @@ + + + + + MissingOnTag + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..e72c0ceb --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading + command + + + Trailing + group + + + Leading_Trailing + pair + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d51ed19b --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/On/CheckOnTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,34 @@ + + + + + command + command + + + group + group + + + pair + pair + + + parameter + parameter + + + protocol + protocol + + + response + response + + + timer + timer + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..0c1cfaf0 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,252 @@ +namespace SLDisValidatorUnitTests.Protocol.Actions.Action.Type.CheckTypeTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Actions.Action.Type.CheckTypeTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Action_CheckTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Action_CheckTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckTypeTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "typo", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckTypeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Action_CheckTypeTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " add to execute"), + Error.UntrimmedTag(null, null, null, "2", "aggregate "), + Error.UntrimmedTag(null, null, null, "3", " append "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckTypeTag(); + + [TestMethod] + public void Action_CheckTypeTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckTypeTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "6.5.2", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Type' in Action '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/Type' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "add to execute, aggregate, append, append data, change length, clear, clear length info, clear on display, close, copy, copy reverse, crc, execute, execute next, execute one, execute one top, execute one now, force execute, go, increment, length, lock, unlock, make, merge, multiply, normalize, open, pow, priority lock, priority unlock, read, read file, read stuffing, replace, replace data, reschedule, restart timer, reverse, run actions, save, set, set and get with wait, set info, set next, set with wait, sleep, start, stop, stop current group, stuffing, swap column, timeout, wmi.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckTypeTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "6.5.4", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Type'. Action ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/Type' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "add to execute, aggregate, append, append data, change length, clear, clear length info, clear on display, close, copy, copy reverse, crc, execute, execute next, execute one, execute one top, execute one now, force execute, go, increment, length, lock, unlock, make, merge, multiply, normalize, open, pow, priority lock, priority unlock, read, read file, read stuffing, replace, replace data, reschedule, restart timer, reverse, run actions, save, set, set and get with wait, set info, set next, set with wait, sleep, start, stop, stop current group, stuffing, swap column, timeout, wmi.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckTypeTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "6.5.1", + Category = Category.Action, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Type' in Action '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/Type' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "add to execute, aggregate, append, append data, change length, clear, clear length info, clear on display, close, copy, copy reverse, crc, execute, execute next, execute one, execute one top, execute one now, force execute, go, increment, length, lock, unlock, make, merge, multiply, normalize, open, pow, priority lock, priority unlock, read, read file, read stuffing, replace, replace data, reschedule, restart timer, reverse, run actions, save, set, set and get with wait, set info, set next, set with wait, sleep, start, stop, stop current group, stuffing, swap column, timeout, wmi.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Action_CheckTypeTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "6.5.3", + Category = Category.Action, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Type' in Action '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The 'Action/Type' tag is mandatory and should contain one of the following values:" + Environment.NewLine + "add to execute, aggregate, append, append data, change length, clear, clear length info, clear on display, close, copy, copy reverse, crc, execute, execute next, execute one, execute one top, execute one now, force execute, go, increment, length, lock, unlock, make, merge, multiply, normalize, open, pow, priority lock, priority unlock, read, read file, read stuffing, replace, replace data, reschedule, restart timer, reverse, run actions, save, set, set and get with wait, set info, set next, set with wait, sleep, start, stop, stop current group, stuffing, swap column, timeout, wmi.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTypeTag(); + + [TestMethod] + public void Action_CheckTypeTag_CheckCategory() => Generic.CheckCategory(check, Category.Action); + + [TestMethod] + public void Action_CheckTypeTag_CheckId() => Generic.CheckId(check, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..04b39546 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading + add to execute + + + Trailing + aggregate + + + Leading_Trailing + append + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..888477d5 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,19 @@ + + + + + Empty + + + + Spaces + + + + Enters + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..6d4bda96 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,10 @@ + + + + + typo + typo + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..59fa5049 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,9 @@ + + + + + MissingType + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..3cec6748 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading + add to execute + + + Trailing + aggregate + + + Leading_Trailing + append + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d70be2c4 --- /dev/null +++ b/ProtocolTests/Protocol/Actions/Action/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,226 @@ + + + + + add to execute + add to execute + + + aggregate + aggregate + + + append + append + + + append data + append data + + + change length + change length + + + clear + clear + + + clear length info + clear length info + + + clear on display + clear on display + + + close + close + + + copy + copy + + + copy reverse + copy reverse + + + crc + crc + + + create element + create element + + + execute + execute + + + execute next + execute next + + + execute one + execute one + + + execute one top + execute one top + + + execute one now + execute one now + + + force execute + force execute + + + go + go + + + increment + increment + + + length + length + + + lock + lock + + + make + make + + + merge + merge + + + multiply + multiply + + + normalize + normalize + + + open + open + + + pow + pow + + + priority lock + priority lock + + + priority unlock + priority unlock + + + read + read + + + read file + read file + + + read stuffing + read stuffing + + + replace + replace + + + replace data + replace data + + + reschedule + reschedule + + + restart timer + restart timer + + + reverse + reverse + + + run actions + run actions + + + save + save + + + set + set + + + set and get with wait + set and get with wait + + + set info + set info + + + set next + set next + + + set with wait + set with wait + + + sleep + sleep + + + start + start + + + stop + stop + + + stop current group + stop current group + + + stuffing + stuffing + + + swap column + swap column + + + timeout + timeout + + + unlock + unlock + + + wmi + wmi + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/CheckChildNameAttributes.cs b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/CheckChildNameAttributes.cs new file mode 100644 index 00000000..b50ece9e --- /dev/null +++ b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/CheckChildNameAttributes.cs @@ -0,0 +1,111 @@ +namespace SLDisValidatorUnitTests.Protocol.Chains.CheckChildNameAttributes +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Chains.CheckChildNameAttributes; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckChildNameAttributes(); + + #region Valid Checks + + [TestMethod] + public void Chain_CheckChildNameAttributes_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Chain_CheckChildNameAttributes_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue.xml", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1"), + Error.DuplicatedValue(null, null, null, "Name1")), + Error.DuplicatedValue(null, null, null, "Name2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name2"), + Error.DuplicatedValue(null, null, null, "Name2")), + Error.DuplicatedValue(null, null, null, "Name3").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name3"), + Error.DuplicatedValue(null, null, null, "Name3")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Action_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.DuplicatedValue(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "15.1.1", + Category = Category.Chain, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Duplicated Chain child Name '2'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckChildNameAttributes(); + + [TestMethod] + public void Chain_CheckChildNameAttributes_CheckCategory() => Generic.CheckCategory(root, Category.Chain); + + [TestMethod] + public void Chain_CheckChildNameAttributes_CheckId() => Generic.CheckId(root, CheckId.CheckChildNameAttributes); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..5df5a21d --- /dev/null +++ b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6f25b955 --- /dev/null +++ b/ProtocolTests/Protocol/Chains/CheckChildNameAttributes/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/CheckConnectionPingGroups.cs b/ProtocolTests/Protocol/CheckConnectionPingGroups/CheckConnectionPingGroups.cs new file mode 100644 index 00000000..c5ad3ea1 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/CheckConnectionPingGroups.cs @@ -0,0 +1,371 @@ +namespace SLDisValidatorUnitTests.Protocol.CheckConnectionPingGroups +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckConnectionPingGroups; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConnectionPingGroups(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSerialExplicitPingGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSerialExplicitPingGroup", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSerialExplicitPingPair() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSerialExplicitPingPair", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSerialExplicitPingPairs() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSerialExplicitPingPairs", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSerialImplicitPingPair() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSerialImplicitPingPair", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSmartSerialNoPairWithResponse() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSmartSerialNoPairWithResponse", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSnmpExplicitPingGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSnmpExplicitPingGroup", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSnmpImplicitPingGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSnmpImplicitPingGroup", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_ValidSnmpNoPolling() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSnmpNoPolling", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_InvalidPingGroupType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPingGroupType", + ExpectedResults = new List + { + Error.InvalidPingGroupType(null, null, null, "snmp", "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_MultiplePingPairsForConnection() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MultiplePingPairsForConnection", + ExpectedResults = new List + { + Error.MultiplePingPairsForConnection(null, null, null, "My Serial Main Connection", "serial", "0").WithSubResults( + Error.MultiplePingPairsForConnection_Sub(null, null, null, "0", "1"), + Error.MultiplePingPairsForConnection_Sub(null, null, null, "0", "2"), + Error.MultiplePingPairsForConnection_Sub(null, null, null, "0", "3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_PingSerialPairHasNoResponse() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PingSerialPairHasNoResponse", + ExpectedResults = new List + { + Error.PingSerialPairHasNoResponse(null, null, null, "serial", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_PingSerialPairHasNoResponseExplicitGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PingSerialPairHasNoResponseExplicitGroup", + ExpectedResults = new List + { + Error.PingSerialPairHasNoResponse(null, null, null, "serial", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_PingSerialPairHasNoResponseImplicit() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PingSerialPairHasNoResponseImplicit", + ExpectedResults = new List + { + Error.PingSerialPairHasNoResponse(null, null, null, "serial", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_PingSmartSerialPairHasNoResponse() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PingSmartSerialPairHasNoResponse", + ExpectedResults = new List + { + Error.PingSerialPairHasNoResponse(null, null, null, "smart-serial", "2"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckConnectionPingGroups_InvalidPingGroupType() + { + // Create ErrorMessage + var message = Error.InvalidPingGroupType(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.26.1", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Ping group for '2' connection is not a '2' poll group. Group ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "When to define a poll group:" + Environment.NewLine + "If a protocol has, at least, one group of type \"poll\" (no matter on which connection), then, the main connection should have a ping group defined in the protocol." + Environment.NewLine + "" + Environment.NewLine + "How to define a poll group:" + Environment.NewLine + "No matter the (1st) connection type, if a group with id=\"-1\" is defined, it will be the ping group." + Environment.NewLine + "Otherwise:" + Environment.NewLine + " - SNMP: the first group defined in the XML." + Environment.NewLine + " - (smart-)serial: " + Environment.NewLine + " - The pair with ping attribute set to true." + Environment.NewLine + " - If no such pair, the pair with lowest ID.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_MultiplePingPairsForConnection() + { + // Create ErrorMessage + var message = Error.MultiplePingPairsForConnection(null, null, null, "2", "3", "4"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.26.3", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Multiple ping pairs for connection with name '2' and type '3'. Connection ID '4'.", + HowToFix = "", + ExampleCode = "", + Details = "There should always be one and only one ping pair per (smart-)serial connection.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_MultiplePingPairsForConnection_Sub() + { + // Create ErrorMessage + var message = Error.MultiplePingPairsForConnection_Sub(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.26.4", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Multiple ping pairs for connection '2'. Pair '3'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_PingSerialPairHasNoResponse() + { + // Create ErrorMessage + var message = Error.PingSerialPairHasNoResponse(null, null, null, "serial", "1"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.26.2", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Ping pair for 'serial' connection contains no response. Pair ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The pair used for the ping group should always contain a response.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConnectionPingGroups(); + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckConnectionPingGroups_CheckId() => Generic.CheckId(check, CheckId.CheckConnectionPingGroups); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/InvalidPingGroupType.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/InvalidPingGroupType.xml new file mode 100644 index 00000000..c18beaab --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/InvalidPingGroupType.xml @@ -0,0 +1,37 @@ + + snmp + + + + Http Session 1 - Request URL + + + Http Session 1 - Response Status Code + + + Http Session 1 - Response Content + + + + + + + + + + + + + + + + + + Ping Group (first group in xml) + + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/MultiplePingPairsForConnection.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/MultiplePingPairsForConnection.xml new file mode 100644 index 00000000..7a848c96 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/MultiplePingPairsForConnection.xml @@ -0,0 +1,51 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Ping Pair 1 + + 1 + 1 + + + + Ping Pair 2 + + 1 + 1 + + + + Ping Pair 3 - Via Group id "-1" + + 1 + 1 + + + + + + + Ping Group (id '-1') + + 3 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponse.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponse.xml new file mode 100644 index 00000000..bdb14b7a --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponse.xml @@ -0,0 +1,33 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair (pair with ping attribute true) + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseExplicitGroup.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseExplicitGroup.xml new file mode 100644 index 00000000..38aa9151 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseExplicitGroup.xml @@ -0,0 +1,49 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair (via group with id '-1') + + 1 + + + + + + + + Other Group + + 1 + + + + + Ping Group (group with id '-1') + + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseImplicit.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseImplicit.xml new file mode 100644 index 00000000..8fcb3fd9 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSerialPairHasNoResponseImplicit.xml @@ -0,0 +1,33 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair (pair with lowest id) + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSmartSerialPairHasNoResponse.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSmartSerialPairHasNoResponse.xml new file mode 100644 index 00000000..43a652ea --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Invalid/PingSmartSerialPairHasNoResponse.xml @@ -0,0 +1,33 @@ + + smart-serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair (pair with ping attribute true) + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0ede2200 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,25 @@ + + snmp + + + + SNMP Param 101 + read + + true + 1.3.6.1.2.1.1.1.0 + octetstring + + + + + + + Ping Group (first group in xml) + + 101 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingGroup.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingGroup.xml new file mode 100644 index 00000000..199e0161 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingGroup.xml @@ -0,0 +1,48 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + + + + Ping Pair + + 1 + 1 + + + + + + + Other Group + + 1 + + + + + Ping Group (group with id '-1') + + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPair.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPair.xml new file mode 100644 index 00000000..14efa86e --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPair.xml @@ -0,0 +1,33 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair (pair with ping attribute true) + + 1 + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPairs.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPairs.xml new file mode 100644 index 00000000..45edcc57 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialExplicitPingPairs.xml @@ -0,0 +1,54 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + 1 + + + + Ping Pair - Connection 0 + + 1 + 1 + + + + Ping Pair - Connection 1 + + 1 + 1 + + + + Ping Pair - Connection 1 + + 1 + 1 + + + + Ping Pair - Connection 3 + + 1 + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialImplicitPingPair.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialImplicitPingPair.xml new file mode 100644 index 00000000..10789d8a --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSerialImplicitPingPair.xml @@ -0,0 +1,32 @@ + + serial + + + + Command 1 + + + + + + Response 1 + + + + + + Other Pair + + 1 + + + + Ping Pair (pair with lowest id) + + 1 + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSmartSerialNoPairWithResponse.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSmartSerialNoPairWithResponse.xml new file mode 100644 index 00000000..742f6de0 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSmartSerialNoPairWithResponse.xml @@ -0,0 +1,62 @@ + + smart-serial + + + + + + TrapReceiver + Trap Received + dummy + + true + * + + + + + + + Command 100 + + + + + + Response 100 + + + + + + Pair 100 + + 100 + + + + + + + Other Group + action + + 1 + + + + Pair 100 + poll + + 100 + + + + + + + Other Action + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpExplicitPingGroup.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpExplicitPingGroup.xml new file mode 100644 index 00000000..0ed3964a --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpExplicitPingGroup.xml @@ -0,0 +1,38 @@ + + snmp + + + + SNMP Param 101 + read + + true + 1.3.6.1.2.1.1.1.0 + octetstring + + + + + + + Other Group + action + + 1 + + + + Ping Group (group with id '-1') + + 101 + + + + + + + Other Action + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpImplicitPingGroup.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpImplicitPingGroup.xml new file mode 100644 index 00000000..c5b7cda6 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpImplicitPingGroup.xml @@ -0,0 +1,38 @@ + + snmp + + + + SNMP Param 101 + read + + true + 1.3.6.1.2.1.1.1.0 + octetstring + + + + + + + Ping Group (first group in xml) + + 101 + + + + Other Group + action + + 1 + + + + + + + Other Action + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpNoPolling.xml b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpNoPolling.xml new file mode 100644 index 00000000..7d64e7d6 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnectionPingGroups/Samples/Validate/Valid/ValidSnmpNoPolling.xml @@ -0,0 +1,34 @@ + + snmp + + + + + + TrapReceiver + Trap Received + dummy + + true + * + + + + + + + Other Group + action + + 1 + + + + + + + Other Action + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/CheckConnections.cs b/ProtocolTests/Protocol/CheckConnections/CheckConnections.cs new file mode 100644 index 00000000..9fd34a41 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/CheckConnections.cs @@ -0,0 +1,760 @@ +namespace SLDisValidatorUnitTests.Protocol.CheckConnections +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckConnections; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConnections(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckConnections_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_Valid_BasicNames() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_BasicNames", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_Valid_ExtendedNames() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ExtendedNames", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_Valid_SshNames() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_SshNames", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckConnections_DuplicateConnectionName() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateConnectionName", + ExpectedResults = new List + { + Error.DuplicateConnectionName(null, null, null, "SNMP Connection").WithSubResults( + Error.DuplicateConnectionName_Sub(null, null, null, "SNMP Connection", "0"), + Error.DuplicateConnectionName_Sub(null, null, null, "SNMP Connection", "3")), + + Error.DuplicateConnectionName(null, null, null, "HTTP Connection").WithSubResults( + Error.DuplicateConnectionName_Sub(null, null, null, "HTTP Connection", "1"), + Error.DuplicateConnectionName_Sub(null, null, null, "HTTP Connection", "2")), + + Error.DuplicateConnectionName(null, null, null, "IP Connection - Test").WithSubResults( + Error.DuplicateConnectionName_Sub(null, null, null, "IP Connection - Test", "4"), + Error.DuplicateConnectionName_Sub(null, null, null, "IP Connection - Test", "5"), + Error.DuplicateConnectionName_Sub(null, null, null, "IP Connection - Test", "6")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidCombinationOfSyntax1And2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCombinationOfSyntax1And2", + ExpectedResults = new List + { + Error.InvalidCombinationOfSyntax1And2(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidConnectionCount() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidConnectionCount", + ExpectedResults = new List + { + Error.InvalidConnectionCount(null, null, null, "2", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidConnectionName() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidConnectionName", + ExpectedResults = new List + { + Error.InvalidConnectionName(null, null, null, "Polling", "snmp", "0"), + Error.InvalidConnectionName(null, null, null, "Events", "smart-serial", "1"), + Error.InvalidConnectionName(null, null, null, "BLA", "snmp", "2"), + Error.InvalidConnectionName(null, null, null, "SNMP Connection - XXX", "serial", "3"), + Error.InvalidConnectionName(null, null, null, "IP Connection", "snmp", "4"), + Error.InvalidConnectionName(null, null, null, "- 0", "snmp", "5"), + Error.InvalidConnectionName(null, null, null, "XXX - 0", "snmp", "6"), + Error.InvalidConnectionName(null, null, null, "SNMP Connection - ", "snmp", "7"), + Error.InvalidConnectionName(null, null, null, "IP Connection - SSH", "serial", "9"), + //Error.InvalidConnectionName(null, null, null, "SNMP Connection", "snmp", "8"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_MismatchingNames() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MismatchingNames", + ExpectedResults = new List + { + Error.MismatchingNames(null, null, null, "1", "'IP Connection' vs 'IP Connection - Events'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "1", "'IP Connection - Events'", false), + Error.MismatchingNames(null, null, null, "1", "'IP Connection'", false)), + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - BLA' vs 'SNMP Connection - Testing'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - Testing'", false), + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - BLA'", false)), + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection' vs 'HTTP Connection - Web Stuff'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection - Web Stuff'", false), + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection'", false)) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_MismatchingNamesUndefined1() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MismatchingNamesUndefined1", + ExpectedResults = new List + { + Error.MismatchingNames(null, null, null, "1", "'IP Connection' vs ''", true).WithSubResults( + Error.MismatchingNames(null, null, null, "1", "''", false), + Error.MismatchingNames(null, null, null, "1", "'IP Connection'", false)), + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - BLA' vs ''", true).WithSubResults( + Error.MismatchingNames(null, null, null, "2", "''", false), + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - BLA'", false)), + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection' vs ''", true).WithSubResults( + Error.MismatchingNames(null, null, null, "3", "''", false), + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection'", false)) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_MismatchingNamesUndefined2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MismatchingNamesUndefined2", + ExpectedResults = new List + { + Error.MismatchingNames(null, null, null, "1", "'' vs 'IP Connection - Events'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "1", "'IP Connection - Events'", false), + Error.MismatchingNames(null, null, null, "1", "''", false)), + Error.MismatchingNames(null, null, null, "2", "'' vs 'SNMP Connection - Testing'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "2", "'SNMP Connection - Testing'", false), + Error.MismatchingNames(null, null, null, "2", "''", false)), + Error.MismatchingNames(null, null, null, "3", "'' vs 'HTTP Connection - Web Stuff'", true).WithSubResults( + Error.MismatchingNames(null, null, null, "3", "'HTTP Connection - Web Stuff'", false), + Error.MismatchingNames(null, null, null, "3", "''", false)), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckConnections_UnrecommendedSyntax2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSyntax2", + ExpectedResults = new List + { + Error.UnrecommendedSyntax2(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckConnections(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_Multiple() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_Multiple", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_SnmpV2ToSnmp() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_SnmpV2ToSnmp", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_Syntax1To2() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_Syntax1To2", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_Syntax1To3() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_Syntax1To3", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_Syntax2To1() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_Syntax2To1", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_Syntax3To1() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid_Syntax3To1", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckTypeTag_ConnectionAdded() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ConnectionAdded", + ExpectedResults = new List + { + ErrorCompare.ConnectionAdded(null, null, "smart-serial", "2", ""), + ErrorCompare.ConnectionAdded(null, null, "serial", "3", "Serial Name"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_ConnectionAddedFromNothing() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ConnectionAddedFromNothing", + ExpectedResults = new List + { + ErrorCompare.ConnectionAdded(null, null, "http", "1", "SomeHTTPConnection"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_ConnectionsOrderChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ConnectionsOrderChanged", + ExpectedResults = new List + { + ErrorCompare.ConnectionsOrderChanged(null, null, "0:snmp, 1:http, 2:smart-serial, 3:serial", "0:snmp, 1:smart-serial, 2:http, 3:serial"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_ConnectionTypeChanged_Multiple() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ConnectionTypeChanged_Multiple", + ExpectedResults = new List + { + ErrorCompare.ConnectionTypeChanged(null, null, "serial", "0", "", "snmp"), + ErrorCompare.ConnectionTypeChanged(null, null, "serial", "1", "serialToSnmpV2", "snmpv2"), + ErrorCompare.ConnectionTypeChanged(null, null, "smart-serial", "2", "smartSerialToSnmpV3", "snmpv3"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_ConnectionTypeChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ConnectionTypeChanged", + ExpectedResults = new List + { + ErrorCompare.ConnectionTypeChanged(null, null, "snmp", "0", "", "snmpv2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckConnections(); + + [TestMethod] + public void Protocol_CheckConnections_MismatchingNames() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MismatchingNames", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + #region Validate Errors + + [TestMethod] + public void Protocol_CheckConnections_DuplicateConnectionName() + { + // Create ErrorMessage + var message = Error.DuplicateConnectionName(null, null, null, "myConnection"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.23.3", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Duplicated Connection name 'myConnection'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "- When having only one connection for a specific type, the name needs to be of following format, where the second option can (optionally) be used to add more info about the goal of the connection (ex: XXX = Traps, XXX = Events, XXX = Alarms, etc):" + Environment.NewLine + "     - \"IP Connection\" or \"IP Connection - XXX\": for drivers that support TCP and/or UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)" + Environment.NewLine + "     - \"HTTP Connection\" or \"HTTP Connection - XXX\"" + Environment.NewLine + "     - \"SSH Connection\" or \"SSH Connection - XXX\"" + Environment.NewLine + "     - \"SNMP Connection\" or \"SNMP Connection - XXX\"" + Environment.NewLine + "     - \"Serial Connection\" or \"Serial Connection - XXX\": for drivers that only support the physical serial port. In other words, driver connections of type serial which don't support TCP nor UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)." + Environment.NewLine + "- When having more than one connection for a specific type, the name needs to be of following format where XXX is used to distinguish them (ex: XXX = Redundant, XXX = Redundant 2, XXX = Backup, XXX = Traps, XXX = Events, etc):" + Environment.NewLine + "     - \"IP Connection - XXX\"" + Environment.NewLine + "     - \"HTTP Connection - XXX\"" + Environment.NewLine + "     - etc", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_DuplicateConnectionName_Sub() + { + // Create ErrorMessage + var message = Error.DuplicateConnectionName_Sub(null, null, null, "myConnection", "1"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.23.4", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Duplicated Connection name 'myConnection'. Connection IDs '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "- When having only one connection for a specific type, the name needs to be of following format, where the second option can (optionally) be used to add more info about the goal of the connection (ex: XXX = Traps, XXX = Events, XXX = Alarms, etc):" + Environment.NewLine + "     - \"IP Connection\" or \"IP Connection - XXX\": for drivers that support TCP and/or UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)" + Environment.NewLine + "     - \"HTTP Connection\" or \"HTTP Connection - XXX\"" + Environment.NewLine + "     - \"SSH Connection\" or \"SSH Connection - XXX\"" + Environment.NewLine + "     - \"SNMP Connection\" or \"SNMP Connection - XXX\"" + Environment.NewLine + "     - \"Serial Connection\" or \"Serial Connection - XXX\": for drivers that only support the physical serial port. In other words, driver connections of type serial which don't support TCP nor UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)." + Environment.NewLine + "- When having more than one connection for a specific type, the name needs to be of following format where XXX is used to distinguish them (ex: XXX = Redundant, XXX = Redundant 2, XXX = Backup, XXX = Traps, XXX = Events, etc):" + Environment.NewLine + "     - \"IP Connection - XXX\"" + Environment.NewLine + "     - \"HTTP Connection - XXX\"" + Environment.NewLine + "     - etc", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidCombinationOfSyntax1And2() + { + // Create ErrorMessage + var message = Error.InvalidCombinationOfSyntax1And2(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 6, + FullId = "1.23.6", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Connections can not be defined simultaneously via 'Protocol/Type' and 'Protocol/Connections'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"Connections can be defined either via 'Protocol/Type' or via 'Protocol/Connections' but both syntaxes can not be used in the same protocol.{Environment.NewLine}" + + $"- 'Protocol/Type' is the recommended syntax.{Environment.NewLine}" + + "- 'Protocol/Connections' should only be used in case one of the rare features only available in this syntax is needed.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidConnectionCount() + { + // Create ErrorMessage + var message = Error.InvalidConnectionCount(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "1.23.5", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Connection count in 'Protocol/Type' tag '0' does not match with PortSettings count '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "For each port that is defined, a PortSettings element should be defined. In addition, the order of these PortSettings elements must correspond with the order of the con­nections defined in the Protocol/Type@advanced attribute." + Environment.NewLine + "- Connection count = number of connections defined in 'Protocol/Type@advanced' + 1 for the main connection define in 'Protocol/Type' tag." + Environment.NewLine + "- PortSettings count = number of PortSettings in 'Protocol/Ports' tag + 1 for main PortSettings define in 'Protocol/PortSettings'.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_InvalidConnectionName() + { + // Create ErrorMessage + var message = Error.InvalidConnectionName(null, null, null, "myName", "snmp", "1"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.23.2", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Invalid connection name 'myName' for a 'snmp' connection. Connection ID '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "- When having only one connection for a specific type, the name needs to be of following format, where the second option can (optionally) be used to add more info about the goal of the connection (ex: XXX = Traps, XXX = Events, XXX = Alarms, etc):" + Environment.NewLine + "     - \"IP Connection\" or \"IP Connection - XXX\": for drivers that support TCP and/or UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)" + Environment.NewLine + "     - \"HTTP Connection\" or \"HTTP Connection - XXX\"" + Environment.NewLine + "     - \"SSH Connection\" or \"SSH Connection - XXX\"" + Environment.NewLine + "     - \"SNMP Connection\" or \"SNMP Connection - XXX\"" + Environment.NewLine + "     - \"Serial Connection\" or \"Serial Connection - XXX\": for drivers that only support the physical serial port. In other words, driver connections of type serial which don't support TCP nor UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)." + Environment.NewLine + "- When having more than one connection for a specific type, the name needs to be of following format where XXX is used to distinguish them (ex: XXX = Redundant, XXX = Redundant 2, XXX = Backup, XXX = Traps, XXX = Events, etc):" + Environment.NewLine + "     - \"IP Connection - XXX\"" + Environment.NewLine + "     - \"HTTP Connection - XXX\"" + Environment.NewLine + "     - etc", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_MismatchingNames() + { + // Create ErrorMessage + var message = Error.MismatchingNames(null, null, null, "0", "'myConnectionName' vs 'myConnectionOtherName'", false); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.23.1", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Connection 0 has mismatching names: 'myConnectionName' vs 'myConnectionOtherName'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "- When having only one connection for a specific type, the name needs to be of following format, where the second option can (optionally) be used to add more info about the goal of the connection (ex: XXX = Traps, XXX = Events, XXX = Alarms, etc):" + Environment.NewLine + "     - \"IP Connection\" or \"IP Connection - XXX\": for drivers that support TCP and/or UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)" + Environment.NewLine + "     - \"HTTP Connection\" or \"HTTP Connection - XXX\"" + Environment.NewLine + "     - \"SSH Connection\" or \"SSH Connection - XXX\"" + Environment.NewLine + "     - \"SNMP Connection\" or \"SNMP Connection - XXX\"" + Environment.NewLine + "     - \"Serial Connection\" or \"Serial Connection - XXX\": for drivers that only support the physical serial port. In other words, driver connections of type serial which don't support TCP nor UDP (See PortTypeIP, PortTypeUDP and PortTypeSerial tags under PortSettings tag)." + Environment.NewLine + "- When having more than one connection for a specific type, the name needs to be of following format where XXX is used to distinguish them (ex: XXX = Redundant, XXX = Redundant 2, XXX = Backup, XXX = Traps, XXX = Events, etc):" + Environment.NewLine + "     - \"IP Connection - XXX\"" + Environment.NewLine + "     - \"HTTP Connection - XXX\"" + Environment.NewLine + "     - etc", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_UnrecommendedSyntax2() + { + // Create ErrorMessage + var message = Error.UnrecommendedSyntax2(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 7, + FullId = "1.23.7", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Unrecommended use of the 'Protocol/Connections' syntax.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"Connections can be defined either via 'Protocol/Type' or via 'Protocol/Connections' but both syntaxes can not be used in the same protocol.{Environment.NewLine}" + + $"- 'Protocol/Type' is the recommended syntax.{Environment.NewLine}" + + "- 'Protocol/Connections' should only be used in case one of the rare features only available in this syntax is needed.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + #endregion + + #region Compare Errors + + [TestMethod] + public void Protocol_CheckConnections_ConnectionAdded() + { + // Create ErrorMessage + var message = ErrorCompare.ConnectionAdded(null, null, "snmp", "0", "myNewSnmp"); + + var expected = new ValidationResult + { + ErrorId = 10, + FullId = "1.23.10", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.MajorChangeChecker, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "snmp Connection '0' with name 'myNewSnmp' was added.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_ConnectionsOrderChanged() + { + // Create ErrorMessage + var message = ErrorCompare.ConnectionsOrderChanged(null, null, "0:snmp, 1:serial", "0:serial, 1:snmp"); + + var expected = new ValidationResult + { + ErrorId = 8, + FullId = "1.23.8", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.MajorChangeChecker, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Order of connections changed from '0:snmp, 1:serial' to '0:serial, 1:snmp'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckConnections_ConnectionTypeChanged() + { + // Create ErrorMessage + var message = ErrorCompare.ConnectionTypeChanged(null, null, "snmp", "0", "myConnection", "serial"); + + var expected = new ValidationResult + { + ErrorId = 9, + FullId = "1.23.9", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.MajorChangeChecker, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "snmp Connection '0' with name 'myConnection' was changed into 'serial'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConnections(); + + [TestMethod] + public void Protocol_CheckConnections_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckConnections_CheckId() => Generic.CheckId(check, CheckId.CheckConnections); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Codefix/MismatchingNames.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Codefix/MismatchingNames.xml new file mode 100644 index 00000000..d74c666b --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Codefix/MismatchingNames.xml @@ -0,0 +1,15 @@ + + snmp + + + + + + true + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_New.xml new file mode 100644 index 00000000..a2196405 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_New.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_Old.xml new file mode 100644 index 00000000..b7ba3079 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAddedFromNothing_Old.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_New.xml new file mode 100644 index 00000000..d7a4aa64 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_Old.xml new file mode 100644 index 00000000..fbdfa915 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionAdded_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_New.xml new file mode 100644 index 00000000..ab04e759 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_Old.xml new file mode 100644 index 00000000..dbd1b9f9 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Multiple_Old.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_New.xml new file mode 100644 index 00000000..b7653260 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_New.xml @@ -0,0 +1,4 @@ + + + snmpv2 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Old.xml new file mode 100644 index 00000000..f6bbf47f --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionTypeChanged_Old.xml @@ -0,0 +1,4 @@ + + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_New.xml new file mode 100644 index 00000000..05cb7627 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_Old.xml new file mode 100644 index 00000000..6154b259 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Invalid/ConnectionsOrderChanged_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_New.xml new file mode 100644 index 00000000..e1bb3fc2 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_Old.xml new file mode 100644 index 00000000..7c594e48 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Multiple_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..98c7d38a --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..98c7d38a --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_New.xml new file mode 100644 index 00000000..78a05a69 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_Old.xml new file mode 100644 index 00000000..57f75528 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_SnmpV2ToSnmp_Old.xml @@ -0,0 +1,3 @@ + + snmpv2 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_New.xml new file mode 100644 index 00000000..f9e58cd9 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_New.xml @@ -0,0 +1,12 @@ + + + + + serial + + + snmp + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_Old.xml new file mode 100644 index 00000000..21d5fbda --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To2_Old.xml @@ -0,0 +1,11 @@ + + + serial + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_New.xml new file mode 100644 index 00000000..c35d2b97 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_New.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_Old.xml new file mode 100644 index 00000000..21d5fbda --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax1To3_Old.xml @@ -0,0 +1,11 @@ + + + serial + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_New.xml new file mode 100644 index 00000000..21d5fbda --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_New.xml @@ -0,0 +1,11 @@ + + + serial + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_Old.xml new file mode 100644 index 00000000..f9e58cd9 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax2To1_Old.xml @@ -0,0 +1,12 @@ + + + + + serial + + + snmp + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_New.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_New.xml new file mode 100644 index 00000000..21d5fbda --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_New.xml @@ -0,0 +1,11 @@ + + + serial + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_Old.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_Old.xml new file mode 100644 index 00000000..10899d20 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Compare/Valid/Valid_Syntax3To1_Old.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/DuplicateConnectionName.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/DuplicateConnectionName.xml new file mode 100644 index 00000000..03654168 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/DuplicateConnectionName.xml @@ -0,0 +1,18 @@ + + + snmp + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidCombinationOfSyntax1And2.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidCombinationOfSyntax1And2.xml new file mode 100644 index 00000000..46fd2db5 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidCombinationOfSyntax1And2.xml @@ -0,0 +1,9 @@ + + + + virtual + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionCount.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionCount.xml new file mode 100644 index 00000000..50f20016 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionCount.xml @@ -0,0 +1,4 @@ + + snmp + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionName.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionName.xml new file mode 100644 index 00000000..932f1539 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/InvalidConnectionName.xml @@ -0,0 +1,47 @@ + + snmp + + + + + + + + + true + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNames.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNames.xml new file mode 100644 index 00000000..e77ed140 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNames.xml @@ -0,0 +1,18 @@ + + snmp + + + + + + + + true + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined1.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined1.xml new file mode 100644 index 00000000..f806b665 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined1.xml @@ -0,0 +1,24 @@ + + + + + snmp + + + + + + + + true + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined2.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined2.xml new file mode 100644 index 00000000..4c321398 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/MismatchingNamesUndefined2.xml @@ -0,0 +1,24 @@ + + + + + snmp + + + + + + + + true + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/UnrecommendedSyntax2.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/UnrecommendedSyntax2.xml new file mode 100644 index 00000000..1bb7e130 --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Invalid/UnrecommendedSyntax2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..4ca2c54d --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + virtual + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_BasicNames.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_BasicNames.xml new file mode 100644 index 00000000..b2e0b81e --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_BasicNames.xml @@ -0,0 +1,17 @@ + + snmp + + + + + + + + true + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_ExtendedNames.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_ExtendedNames.xml new file mode 100644 index 00000000..bf21f48c --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_ExtendedNames.xml @@ -0,0 +1,27 @@ + + snmp + + + + + + + + true + + + + + + + true + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_SshNames.xml b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_SshNames.xml new file mode 100644 index 00000000..48717bfc --- /dev/null +++ b/ProtocolTests/Protocol/CheckConnections/Samples/Validate/Valid/Valid_SshNames.xml @@ -0,0 +1,43 @@ + + serial + + + + 22 + true + + + true + + + true + + + true + + + + + + + 2222 + + + true + + + true + + + true + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/CheckEndlessLoop.cs b/ProtocolTests/Protocol/CheckEndlessLoop/CheckEndlessLoop.cs new file mode 100644 index 00000000..2442b4ca --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/CheckEndlessLoop.cs @@ -0,0 +1,390 @@ +namespace SLDisValidatorUnitTests.Protocol.CheckEndlessLoop +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckEndlessLoop; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckEndlessLoop(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckEndlessLoop_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckEndlessLoop_ValidActionAggregate() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidActionAggregate", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckEndlessLoop_ValidActionMerge() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidActionMerge", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckEndlessLoop_EndlessLoop() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EndlessLoop", + ExpectedResults = new List + { + // Case 1: + Error.EndlessLoop(null,null,null, @"Trigger 100->Action 100->Param 100->Trigger 100"), + Error.EndlessLoop(null,null,null, @"Trigger 101->Action 101->Param 101->Trigger 101"), + Error.EndlessLoop(null,null,null, @"Trigger 102->Action 102->Param 102->Trigger 102"), + Error.EndlessLoop(null,null,null, @"Trigger 103->Action 103->Param 103->Trigger 103"), + //Error.EndlessLoop(null,null,null, @"Trigger 104->Action 104->Param 104->Trigger 104"), // Comment out as copy actions don't cause trigger to go off. + Error.EndlessLoop(null,null,null, @"Trigger 105->Action 105->Param 105->Trigger 105"), + + Error.EndlessLoop(null,null,null, @"Trigger 700->Action 700->Param 701->Trigger 701->Action 701->Param 700->Trigger 700"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.EndlessLoop(null,null,null, @"Trigger 701->Action 701->Param 700->Trigger 700->Action 700->Param 701->Trigger 701"), + + Error.EndlessLoop(null,null,null, @"Action 801->Param 801->Trigger 801->Action 801"), + // Below one is considered an unfiltered duplicate of the above one. + //Error.EndlessLoop(null,null,null, @"Trigger 800->Action 801->Param 801->Trigger 801->Action 801"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.EndlessLoop(null,null,null, @"Trigger 801->Action 801->Param 801->Trigger 801"), + + // Case 2: + Error.EndlessLoop(null,null,null, @"Trigger 1000->Trigger 1001->Action 1000->Param 1000->Trigger 1000"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.EndlessLoop(null,null,null, @"Trigger 1001->Action 1000->Param 1000->Trigger 1000->Trigger 1001"), + + // Case 3: + Error.EndlessLoop(null,null,null, @"Trigger 2000->Action 2000->Group 2000->Action 2001->Param 2000->Trigger 2000"), + Error.EndlessLoop(null,null,null, @"Trigger 2002->Action 2002->Group 2002->Action 2003->Param 2002->Trigger 2002"), + + // Case 4: + Error.EndlessLoop(null,null,null, @"Trigger 3000->Action 3000->Group 3000->Param 3000->Trigger 3000"), + Error.EndlessLoop(null,null,null, @"Trigger 3001->Action 3001->Group 3001->Param 3001->Trigger 3001"), + Error.EndlessLoop(null,null,null, @"Trigger 3002->Action 3002->Group 3002->Param 3002->Trigger 3002"), + Error.EndlessLoop(null,null,null, @"Trigger 3003->Action 3003->Group 3003->Param 3003->Trigger 3003"), + + Error.EndlessLoop(null,null,null, @"Trigger 3004->Action 3004->Group 3004->Param 3004->Trigger 3004"), + Error.EndlessLoop(null,null,null, @"Action 3004->Group 3004->Param 3005->Trigger 3005->Action 3004"), + // Below one is considered an unfiltered duplicate of the above one. + //Error.EndlessLoop(null,null,null, @"Trigger 3004->Action 3004->Group 3004->Param 3005->Trigger 3005->Action 3004"), + + // Below ones are considered duplicate of the above ones so we decided not to return it. + //Error.EndlessLoop(null,null,null, @"Trigger 3005->Action 3004->Group 3004->Param 3004->Trigger 3004->Action 3004"), + //Error.EndlessLoop(null,null,null, @"Trigger 3005->Action 3004->Group 3004->Param 3005->Trigger 3005"), + + // Case 5: + Error.EndlessLoop(null,null,null, @"Trigger 4000->Action 4000->Group 4000->Trigger 4000"), + Error.EndlessLoop(null,null,null, @"Trigger 4001->Action 4001->Group 4001->Trigger 4001"), + Error.EndlessLoop(null,null,null, @"Trigger 4002->Action 4002->Group 4002->Trigger 4002"), + Error.EndlessLoop(null,null,null, @"Trigger 4003->Action 4003->Group 4003->Trigger 4003"), + + // Case 6: + Error.EndlessLoop(null,null,null, @"Trigger 5000->Action 5000->Group 5000->Pair 5000->Response 5000->Param 5000->Trigger 5000"), + Error.EndlessLoop(null,null,null, @"Trigger 5001->Action 5001->Group 5001->Pair 5001->Response 5001->Param 5001->Trigger 5001"), + Error.EndlessLoop(null,null,null, @"Trigger 5002->Action 5002->Group 5002->Pair 5002->Response 5002->Param 5002->Trigger 5002"), + Error.EndlessLoop(null,null,null, @"Trigger 5003->Action 5003->Group 5003->Pair 5003->Response 5003->Param 5003->Trigger 5003"), + Error.EndlessLoop(null,null,null, @"Trigger 5004->Action 5004->Group 5004->Pair 5004->Response 5004->Param 5004->Trigger 5004"), + Error.EndlessLoop(null,null,null, @"Trigger 5005->Action 5005->Group 5005->Pair 5005->Response 5005->Param 5005->Trigger 5005"), + Error.EndlessLoop(null,null,null, @"Trigger 5006->Action 5006->Group 5006->Pair 5006->Response 5006->Param 5006->Trigger 5006"), + Error.EndlessLoop(null,null,null, @"Trigger 5007->Action 5007->Group 5007->Pair 5007->Response 5007->Param 5007->Trigger 5007"), + Error.EndlessLoop(null,null,null, @"Trigger 5008->Action 5008->Group 5008->Pair 5008->Response 5008->Param 5008->Trigger 5008"), + Error.EndlessLoop(null,null,null, @"Trigger 5009->Action 5009->Group 5009->Pair 5009->Response 5009->Param 5009->Trigger 5009"), + + // Case 7: + Error.EndlessLoop(null,null,null, @"Trigger 6000->Action 6000->Group 6000->Pair 6000->Response 6000->Trigger 6000"), + Error.EndlessLoop(null,null,null, @"Trigger 6001->Action 6001->Group 6001->Pair 6001->Response 6001->Trigger 6001"), + Error.EndlessLoop(null,null,null, @"Trigger 6002->Action 6002->Group 6002->Pair 6002->Response 6002->Trigger 6002"), + + // Case 8: + Error.EndlessLoop(null,null,null, @"Trigger 7000->Action 7000->Group 7000->Pair 7000->Command 7000->Trigger 7000"), + Error.EndlessLoop(null,null,null, @"Trigger 7000->Action 7000->Group 7000->Pair 7000->Response 7000->Trigger 7000"), + Error.EndlessLoop(null,null,null, @"Trigger 7001->Action 7001->Group 7001->Pair 7001->Trigger 7001"), + Error.EndlessLoop(null,null,null, @"Trigger 7002->Action 7002->Group 7002->Pair 7002->Trigger 7002"), + + // Case 9: + Error.EndlessLoop(null,null,null, @"Trigger 8000->Action 8000->Group 8000->Session 8000->Param 8000->Trigger 8000"), + Error.EndlessLoop(null,null,null, @"Trigger 8001->Action 8001->Group 8001->Session 8001->Param 8001->Trigger 8001"), + + // Case 10: + Error.EndlessLoop(null,null,null, @"Trigger 9000->Action 9000->Group 9000->Session 9000->Trigger 9000"), + + // Case 100: + Error.EndlessLoop(null,null,null, @"Action 1000000->Group 1000000->Action 1000000"), + // Below one is considered an unfiltered duplicate of the above one. + //Error.EndlessLoop(null,null,null, @"Trigger 1000000->Action 1000000->Group 1000000->Action 1000000"), + + // Case 101: + Error.EndlessLoop(null,null,null, @"Action 1010000->Group 1010000->Action 1010000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckEndlessLoop_EndlessLoopActionAggregate() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EndlessLoopActionAggregate", + ExpectedResults = new List + { + Error.EndlessLoop(null,null,null, @"Action 210->Param 250->Trigger 310->Action 210"), + Error.EndlessLoop(null,null,null, @"Trigger 201->Action 201->Param 201->Trigger 201"), + Error.EndlessLoop(null,null,null, @"Trigger 202->Action 202->Param 242->Trigger 202"), + Error.EndlessLoop(null,null,null, @"Trigger 203->Action 203->Param 203->Trigger 203"), + Error.EndlessLoop(null,null,null, @"Trigger 204->Action 204->Param 204->Trigger 204"), + Error.EndlessLoop(null,null,null, @"Trigger 205->Action 205->Param 245->Trigger 205"), + + Error.EndlessLoop(null,null,null, @"Trigger 210->Action 210->Param 210->Trigger 210"), + Error.EndlessLoop(null,null,null, @"Trigger 211->Action 211->Param 251->Trigger 211"), + Error.EndlessLoop(null,null,null, @"Trigger 212->Action 212->Param 252->Trigger 212"), + Error.EndlessLoop(null,null,null, @"Trigger 213->Action 213->Param 253->Trigger 213"), + Error.EndlessLoop(null,null,null, @"Trigger 214->Action 214->Param 254->Trigger 214"), + Error.EndlessLoop(null,null,null, @"Trigger 215->Action 215->Param 255->Trigger 215"), + Error.EndlessLoop(null,null,null, @"Trigger 216->Action 216->Param 276->Trigger 216"), + Error.EndlessLoop(null,null,null, @"Trigger 217->Action 217->Param 257->Trigger 217"), + Error.EndlessLoop(null,null,null, @"Trigger 218->Action 218->Param 258->Trigger 218"), + Error.EndlessLoop(null,null,null, @"Trigger 219->Action 219->Param 309->Trigger 219"), + Error.EndlessLoop(null,null,null, @"Trigger 221->Action 221->Param 301->Trigger 221"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("toBeImplemented")] + public void Protocol_CheckEndlessLoop_EndlessLoopActionMerge() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EndlessLoopActionMerge", + ExpectedResults = new List + { + + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckEndlessLoop_PotentialEndlessLoop() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PotentialEndlessLoop", + ExpectedResults = new List + { + // Case 1: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 100->Action 100->Param 100->Trigger 100"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 101->Action 101->Param 101->Trigger 101"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 102->Action 102->Param 102->Trigger 102"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 103->Action 103->Param 103->Trigger 103"), + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 104->Action 104->Param 104->Trigger 104"), // Comment out as copy actions don't cause trigger to go off. + Error.PotentialEndlessLoop(null,null,null, @"Trigger 105->Action 105->Param 105->Trigger 105"), + + Error.PotentialEndlessLoop(null,null,null, @"Trigger 700->Action 700->Param 701->Trigger 701->Action 701->Param 700->Trigger 700"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 151->Action 151->Param 150->Trigger 150->Action 150->Param 151->Trigger 151"), + + Error.PotentialEndlessLoop(null,null,null, @"Action 801->Param 801->Trigger 801->Action 801"), + // Below one is considered an unfiltered version of the above one. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 200->Action 201->Param 201->Trigger 201->Action 201"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 201->Action 201->Param 201->Trigger 201"), + + // Case 2: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 1000->Trigger 1001->Action 1000->Param 1000->Trigger 1000"), + + // Below one is considered duplicate of the above one so we decided not to return it. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 1001->Action 1000->Param 1000->Trigger 1000->Trigger 1001"), + + // Case 3: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 2000->Action 2000->Group 2000->Action 2001->Param 2000->Trigger 2000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 2002->Action 2002->Group 2002->Action 2003->Param 2002->Trigger 2002"), + + // Case 4: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 3000->Action 3000->Group 3000->Param 3000->Trigger 3000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 3001->Action 3001->Group 3001->Param 3001->Trigger 3001"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 3002->Action 3002->Group 3002->Param 3002->Trigger 3002"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 3003->Action 3003->Group 3003->Param 3003->Trigger 3003"), + + Error.PotentialEndlessLoop(null,null,null, @"Trigger 3004->Action 3004->Group 3004->Param 3004->Trigger 3004"), + Error.PotentialEndlessLoop(null,null,null, @"Action 3004->Group 3004->Param 3005->Trigger 3005->Action 3004"), + // Below one is considered an unfiltered version of the above one. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 3004->Action 3004->Group 3004->Param 3005->Trigger 3005->Action 3004"), + + // Below ones are considered duplicate of the above ones so we decided not to return it. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 3005->Action 3004->Group 3004->Param 3004->Trigger 3004->Action 3004"), + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 3005->Action 3004->Group 3004->Param 3005->Trigger 3005"), + + // Case 5: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 4000->Action 4000->Group 4000->Trigger 4000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 4001->Action 4001->Group 4001->Trigger 4001"), + + // Case 6: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5000->Action 5000->Group 5000->Pair 5000->Response 5000->Param 5000->Trigger 5000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5001->Action 5001->Group 5001->Pair 5001->Response 5001->Param 5001->Trigger 5001"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5002->Action 5002->Group 5002->Pair 5002->Response 5002->Param 5002->Trigger 5002"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5003->Action 5003->Group 5003->Pair 5003->Response 5003->Param 5003->Trigger 5003"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5004->Action 5004->Group 5004->Pair 5004->Response 5004->Param 5004->Trigger 5004"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5005->Action 5005->Group 5005->Pair 5005->Response 5005->Param 5005->Trigger 5005"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 5006->Action 5006->Group 5006->Pair 5006->Response 5006->Param 5006->Trigger 5006"), + + // Case 7: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 6000->Action 6000->Group 6000->Pair 6000->Response 6000->Trigger 6000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 6001->Action 6001->Group 6001->Pair 6001->Response 6001->Trigger 6001"), + + // Case 8: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 7000->Action 7000->Group 7000->Pair 7000->Command 7000->Trigger 7000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 7000->Action 7000->Group 7000->Pair 7000->Response 7000->Trigger 7000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 7001->Action 7001->Group 7001->Pair 7001->Trigger 7001"), + + // Case 9: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 8000->Action 8000->Group 8000->Session 8000->Param 8000->Trigger 8000"), + Error.PotentialEndlessLoop(null,null,null, @"Trigger 8001->Action 8001->Group 8001->Session 8001->Param 8001->Trigger 8001"), + + // Case 10: + Error.PotentialEndlessLoop(null,null,null, @"Trigger 9000->Action 9000->Group 9000->Session 9000->Trigger 9000"), + + // Case 100: + Error.PotentialEndlessLoop(null,null,null, @"Action 1000000->Group 1000000->Action 1000000"), + // Below one is considered an unfiltered version of the above one. + //Error.PotentialEndlessLoop(null,null,null, @"Trigger 1000000->Action 1000000->Group 1000000->Action 1000000"), + + // Case 101: + Error.PotentialEndlessLoop(null,null,null, @"Action 1010000->Group 1010000->Action 1010000"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + + public void Protocol_CheckEndlessLoop_EndlessLoop() + { + // Create ErrorMessage + var message = Error.EndlessLoop(null, null, null, "1"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.24.1", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Endless loop detected. Involved items '1'", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckEndlessLoop_PotentialEndlessLoop() + { + // Create ErrorMessage + var message = Error.PotentialEndlessLoop(null, null, null, "1"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.24.2", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Potential endless loop detected. Involved items '1'", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "Uncertain because not all paths could be completed due to conditions in the flow of the loop.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + + public class Attribute + { + private readonly IRoot check = new CheckEndlessLoop(); + + [TestMethod] + public void Protocol_CheckEndlessLoop_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckEndlessLoop_CheckId() => Generic.CheckId(check, CheckId.CheckEndlessLoop); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoop.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoop.xml new file mode 100644 index 00000000..f1e4a4ad --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoop.xml @@ -0,0 +1,1621 @@ + + + CheckEndlessLoop_EndlessLoop + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + Case1_Basic_IncrementAction + read + + + Case1_Basic_PowAction_TriggerNoiseBefore + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + read + + + + Case1_Basic_AggregateAction + read + + + + Case1_Nested_IncrementAction_1 + read + + + Case1_Nested_IncrementAction_2 + read + + + + Case1_WithPrefix_IncrementAction_Prefix + read + + + Case1_WithPrefix_IncrementAction + read + + + + Case2_Basic_IncrementAction + read + + + + Case3_Basic_GroupAction_NoiseBeforeGroup + read + + + Case3_Basic_GroupAction + read + + + Case3_Basic_GroupPollAction + read + + + Case3_Basic_GroupPollAction_NoiseAfterGroup + read + + + + Case4_Basic_Execute_GroupDefault_NoiseBeforeGroup + read + + + Case4_Basic_Execute_GroupDefault_NoiseAfterGroup + read + + + Case4_Basic_Execute_GroupDefault + read + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + read + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + read + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + read + + + Case4_Basic_Execute_GroupDefaultMultipleParams1 + read + + + Case4_Basic_Execute_GroupDefaultMultipleParams2 + read + + + + Case5_Basic_Set_GroupBefore + read + + + Case5_Basic_Set_GroupAfter + read + + + + Case6_Basic_Execute_NoNoise + read + + + Case6_Basic_Execute_ResponseNoiseBefore + read + + + Case6_Basic_Execute_ResponseNoiseAfter + read + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + read + + + Case6_Basic_Execute_ActionNoiseBefore + read + + + Case6_Basic_Execute_ActionNoiseAfter + read + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + read + + + Case6_Basic_Execute_PairNoiseBefore + read + + + Case6_Basic_Execute_PairNoiseAfter + read + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + read + + + + Case9_Basic_Execute_NoiseBeforeGroup + read + + + Case9_Basic_Execute_NoiseAfterGroup + read + + + Case9_Basic_Execute_NoiseSessionTimeout + read + + + Case9_Basic_Execute_NoiseSessionTimeoutAfterRetries + read + + + Case9_Basic_Execute_Session + read + + + Case9_Basic_Execute_ResponseStatusCodeParam + read + + + + Case10_Basic_Execute_NoiseBeforeGroup + read + + + Case10_Basic_Execute_NoiseAfterGroup + read + + + Case10_Basic_Execute_NoiseSessionRspStatusCode + read + + + Case10_Basic_Execute_NoiseSessionRspHeader + read + + + Case10_Basic_Execute_NoiseSessionRspContent + read + + + + + Case100_Basic_Execute + read + + + + + + + + + + + + + + + + + + + + + + + + + + + Case1_Basic_IncrementAction + parameter + + action + + 100 + + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + + action + + + 1 + 101 + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + + action + + + 102 + 1 + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + + action + + + 1 + 103 + 1 + + + + + Case1_Basic_AggregateAction + parameter + + action + + 105 + + + + + Case1_Nested_IncrementAction_1 + parameter + + action + + 700 + + + + Case1_Nested_IncrementAction_2 + parameter + + action + + 701 + + + + + Case1_WithPrefix_IncrementAction_Prefix + parameter + + action + + 801 + + + + Case1_WithPrefix_IncrementAction + parameter + + action + + 801 + + + + + Case2_Basic_IncrementAction_1 + parameter + + trigger + + 1001 + + + + Case2_Basic_IncrementAction_2 + action + + 1000 + + + + + Case3_Basic_GroupAction_NoiseBeforeGroup + group + + action + + 1999 + + + + Case3_Basic_GroupAction + parameter + + action + + 2000 + + + + Case3_Basic_GroupPollAction + parameter + + action + + 2002 + + + + Case3_Basic_GroupPollAction_NoiseAfterGroup + group + + action + + 2004 + + + + + Case4_Basic_Execute_GroupDefault_NoiseBeforeGroup + group + + action + + 2995 + + + + Case4_Basic_Execute_GroupDefault_NoiseAfterGroup + group + + action + + 2996 + + + + Case4_Basic_Execute_GroupDefault + parameter + + action + + 3000 + + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + parameter + + action + + 3001 + + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + parameter + + action + + 3002 + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + parameter + + action + + 3003 + + + + Case4_Basic_Execute_GroupDefaultMultipleParams1 + parameter + + action + + 3004 + + + + Case4_Basic_Execute_GroupDefaultMultipleParams2 + parameter + + action + + 3004 + + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + + action + + 4000 + + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + + action + + 4001 + + + + Case5_Basic_Set_GroupBefore + group + + action + + 4002 + + + + Case5_Basic_Set_GroupAfter + group + + action + + 4003 + + + + + Case6_Basic_Execute_NoNoise + parameter + + action + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + parameter + + action + + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + parameter + + action + + 5002 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + parameter + + action + + 5003 + + + + Case6_Basic_Execute_ActionNoiseBefore + parameter + + action + + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + parameter + + action + + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + parameter + + action + + 5006 + + + + Case6_Basic_Execute_PairNoiseBefore + parameter + + action + + 5007 + + + + Case6_Basic_Execute_PairNoiseAfter + parameter + + action + + 5008 + + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + parameter + + action + + 5009 + + + + + Case7_Basic_Execute_ResponseWithOneParam + response + + action + + 6000 + + + + Case7_Basic_Execute_ResponseEmptyContent + response + + action + + 6001 + + + + Case7_Basic_Execute_ResponseNoContent + response + + action + + 6002 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + pair + + action + + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmptyContent + pair + + action + + 7001 + + + + Case8_Basic_Execute_PairSucceeded_PairNoContent + pair + + action + + 7002 + + + + + Case9_Basic_Execute_NoiseBeforeGroup + group + + action + + 7995 + + + + Case9_Basic_Execute_NoiseAfterGroup + group + + action + + 7996 + + + + Case9_Basic_Execute_NoiseSessionTimeout + session + + action + + 7997 + + + + Case9_Basic_Execute_NoiseSessionTimeoutAfterRetries + session + + action + + 7998 + + + + Case9_Basic_Execute_ResponseContentParam + parameter + + action + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + parameter + + action + + 8001 + + + + + Case10_Basic_Execute_NoiseBeforeGroup + group + + action + + 8995 + + + + Case10_Basic_Execute_NoiseAfterGroup + group + + action + + 8996 + + + + Case10_Basic_Execute_SessionEmptyResponse + session + + action + + 9000 + + + + + + + + Case100_Basic_Execute + parameter + + action + + 1000000 + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + Case1_Basic_IncrementAction + parameter + increment + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + pow + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + multiply + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + multiply + + + + Case1_Basic_AggregateAction + parameter + aggregate + + + + Case1_Nested_IncrementAction_1 + parameter + increment + + + Case1_Nested_IncrementAction_2 + parameter + increment + + + + Case1_WithPrefix_IncrementAction + parameter + increment + + + + Case2_Basic_IncrementAction + parameter + increment + + + + Case3_Basic_GroupAction_NoiseBeforeGroup + parameter + run actions + + + Case3_Basic_GroupAction_ExecuteGroup + group + execute + + + Case3_Basic_GroupAction_Increment + parameter + increment + + + Case3_Basic_GroupPollAction_ExecuteGroup + group + execute + + + Case3_Basic_GroupPollAction_Increment + parameter + increment + + + Case3_Basic_GroupPollAction_NoiseAfterGroup + parameter + run actions + + + + Case4_Basic_Execute_GroupDefault_NoiseBeforeGroup + parameter + run actions + + + Case4_Basic_Execute_GroupDefault_NoiseAfterGroup + parameter + run actions + + + Case4_Basic_Execute_GroupDefault + group + execute + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + group + execute + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + group + execute next + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + group + add to execute + + + Case4_Basic_Execute_GroupDefaultMultipleParams + group + execute + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + execute + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + execute + + + Case5_Basic_Set_GroupBefore + group + set + + + Case5_Basic_Set_GroupAfter + group + set + + + + Case6_Basic_Execute_NoNoise + group + execute + + + Case6_Basic_Execute_ResponseNoiseBefore + group + execute + + + Case6_Basic_Execute_ResponseNoiseAfter + group + execute + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + group + execute + + + Case6_Basic_Execute_ActionNoiseBefore + group + execute + + + Case6_Basic_Execute_ActionNoiseAfter + group + execute + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + group + execute + + + Case6_Basic_Execute_PairNoiseBefore + group + execute + + + Case6_Basic_Execute_PairNoiseAfter + group + execute + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + group + execute + + + + Case7_Basic_Execute_ResponseWithOneParam + group + execute + + + Case7_Basic_Execute_ResponseEmptyContent + group + execute + + + Case7_Basic_Execute_ResponseNoContent + group + execute + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + group + execute + + + Case8_Basic_Execute_PairSucceeded_PairEmptyContent + group + execute + + + Case8_Basic_Execute_PairSucceeded_PairNoContent + group + execute + + + + Case9_Basic_Execute_NoiseBeforeGroup + parameter + run actions + + + Case9_Basic_Execute_NoiseAfterGroup + parameter + run actions + + + Case9_Basic_Execute_NoiseSessionTimeout + parameter + run actions + + + Case9_Basic_Execute_NoiseSessionTimeoutAfterRetries + parameter + run actions + + + Case9_Basic_Execute_ResponseContentParam + group + execute + + + Case9_Basic_Execute_ResponseStatusCodeParam + group + execute + + + + Case10_Basic_Execute_NoiseBeforeGroup + parameter + run actions + + + Case10_Basic_Execute_NoiseAfterGroup + parameter + run actions + + + Case10_Basic_Execute_SessionEmptyResponse + group + execute + + + + + + + Case100_Basic_Execute + group + execute + + + Case101_Basic_Execute + group + execute + + + + + + Group_Noise_1 + + + + + Group_Noise_2 + + + + + Case3_Basic_GroupAction + action + + 2001 + + + + Case3_Basic_GroupPollAction + action + + 2003 + + + + + Case4_Basic_Execute_GroupDefault + + 3000 + + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + poll + + 1 + 3001 + + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + poll + + 3002 + 1 + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + poll + + 1 + 3003 + 2 + + + + Case4_Basic_Execute_GroupDefaultMultipleLoopParams + poll + + 3004 + 3005 + + + + + + Case5_Basic_Execute_GroupDefaultNoContent + + + Case5_Basic_Execute_GroupDefaultEmptyContent + + + + Case5_Basic_Set_GroupBefore + + 4002 + + + + Case5_Basic_Set_GroupAfter + + 4003 + + + + + Case6_Basic_Execute_NoNoise + poll + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + poll + + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + poll + + 5002 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + poll + + 5003 + + + + Case6_Basic_Execute_ActionNoiseBefore + poll + + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + poll + + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + poll + + 5006 + + + + Case6_Basic_Execute_PairNoiseBefore + poll + + 5007 + + + + Case6_Basic_Execute_PairNoiseAfter + poll + + 5008 + + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + poll + + 5009 + + + + + Case7_Basic_Execute_ResponseWithOneParam + poll + + 6000 + + + + Case7_Basic_Execute_ResponseEmptyContent + poll + + 6001 + + + + Case7_Basic_Execute_ResponseNoContent + poll + + 6002 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + poll + + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmptyContent + poll + + 7001 + + + + Case8_Basic_Execute_PairSucceeded_PairNoContent + poll + + 7002 + + + + + Case9_Basic_Execute_ResponseContentParam + poll + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + poll + + 8001 + + + + + Case10_Basic_Execute_SessionEmptyResponse + poll + + 9000 + + + + + Case100_Basic_Execute + poll action + + 1000000 + + + + Case101_Basic_Execute + poll action + + 1010000 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + Case6_Basic_Execute + + 5000 + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 5000 + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + + 5000 + 5002 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + + 5000 + 5003 + + + + Case6_Basic_Execute_ActionNoiseBefore + + 5000 + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + + 5000 + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + + 5000 + 5006 + + + + Case6_Basic_Execute_PairNoiseBefore + + 5000 + 1 + 5007 + + + + Case6_Basic_Execute_PairNoiseAfter + + 5000 + 5008 + 1 + + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + + 5000 + 1 + 5009 + 1 + + + + + Case7_Basic_Execute_ResponseWithOneParam + + 6000 + 6000 + + + + Case7_Basic_Execute_ResponseEmptyContent + + 6000 + 6001 + + + + Case7_Basic_Execute_ResponseNoContent + + 6000 + 6002 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 7000 + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmptyContent + + + + + Case8_Basic_Execute_PairSucceeded_PairNoContent + + + + + + + Case6_Basic_Execute + + 1 + 2 + + + + + Case7_Basic_Execute_Response + + 1 + 2 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 1 + 2 + + + + + + + Response_Noise + + + + + + Case6_Basic_Execute_NoNoise + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 1 + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + + 5002 + 1 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + + 1 + 5003 + 1 + + + + Case6_Basic_Execute_ActionNoiseBefore + + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + + 5006 + + + + Case6_Basic_Execute_PairNoiseBefore + + 5007 + + + + Case6_Basic_Execute_PairNoiseAfter + + 5008 + + + + Case6_Basic_Execute_PairNoiseBeforeAndAfter + + 5009 + + + + + Case7_Basic_Execute_AfterResponse + + 1 + + + + Case7_Basic_Execute_AfterResponseEmptyContent + + + + + Case7_Basic_Execute_AfterResponseNoContent + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionAggregate.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionAggregate.xml new file mode 100644 index 00000000..607fe5c1 --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionAggregate.xml @@ -0,0 +1,468 @@ + + + CheckEndlessLoop_EndlessLoop + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + Aggregate_OneReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_Default + read + + + Aggregate_OneGroupby + read + + + Aggregate_MultipleGroupBy1 + read + + + Aggregate_MultipleGroupBy2 + read + + + Aggregate_OneReturn_Default + read + + + Aggregate_OneReturn_Default + read + + + Aggregate_MultipleReturn_Default1 + read + + + Aggregate_MultipleReturn_Default2 + read + + + Aggregate_MultipleReturn_Default2 + read + + + Aggregate_OneGroupBy_Default1 + read + + + Aggregate_OneGroupBy_Default2 + read + + + Aggregate_OneReturn_Default1 + read + + + Aggregate_OneReturn_Default2 + read + + + Aggregate_OneReturn_Default3 + read + + + Aggregate_OneGroupBy_OneReturn1 + read + + + Aggregate_OneGroupBy_OneReturn2 + read + + + Aggregate_MultipleGroupBy_OneReturn1 + read + + + Aggregate_MultipleGroupBy_OneReturn2 + read + + + Aggregate_MultipleGroupBy_OneReturn3 + read + + + Aggregate_MultipleGroupBy_MultipleReturn1 + read + + + Aggregate_MultipleGroupBy_MultipleReturn2 + read + + + Aggregate_MultipleGroupBy_MultipleReturn3 + read + + + Aggregate_MultipleGroupBy_MultipleReturn4 + read + + + Aggregate_OneGroupBy_OneReturn_Default1 + read + + + Aggregate_OneGroupBy_OneReturn_Default2 + read + + + Aggregate_OneGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default1 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default2 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default4 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default1 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default2 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default4 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default5 + read + + + Aggregate_Weight + read + + + Aggregate_Weight_OneReturn + read + + + Aggregate_Weight_OneReturn + read + + + Aggregate_TriggerParameter + read + + + Aggregate_OnParameter + read + + + Aggregate_WeightParameter + read + + + + + + + + + + + + Aggregate_OneReturn + parameter + + action + + 201 + + + + Aggregate_MultipleReturn + parameter + + action + + 202 + + + + Aggregate_Default + parameter + + action + + 203 + + + + Aggregate_OneGroupBy + parameter + + action + + 204 + + + + Aggregate_MultipleGroupBy + parameter + + action + + 205 + + + + Aggregate_OneReturn_Default + parameter + + action + + 210 + + + + Aggregate_OneReturn_Default2 + parameter + + action + + 210 + + + + Aggregate_MultipleReturn_Default + parameter + + action + + 211 + + + + Aggregate_OneGroupBy_Default + parameter + + action + + 212 + + + + Aggregate_MultipleGroupBy_Default + parameter + + action + + 213 + + + + Aggregate_OneGroupBy_OneReturn + parameter + + action + + 214 + + + + Aggregate_MultipleGroupBy_OneReturn + parameter + + action + + 215 + + + + Aggregate_MultipleGroupBy_MultipleReturn + parameter + + action + + 216 + + + + Aggregate_OneGroupBy_OneReturn_Default + parameter + + action + + 217 + + + + Aggregate_MultipleGroupBy_OneReturn_Default + parameter + + action + + 218 + + + + Aggregate_MultipleGroupBy_MultipleReturn_Default + parameter + + action + + 219 + + + + Aggregate_Weight_OneReturn + parameter + + action + + 221 + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + Aggregate_EmptyOptions + parameter + aggregate + + + Aggregate_OneReturn + parameter + aggregate + + + Aggregate_MultipleReturn + parameter + aggregate + + + Aggregate_Default + parameter + aggregate + + + Aggregate_OneGroupBy + parameter + aggregate + + + Aggregate_MultipleGroupBy + parameter + aggregate + + + Aggregate_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleReturn_Default + parameter + aggregate + + + Aggregate_OneGroupBy_Default + parameter + aggregate + + + Aggregate_MultipleGroupby_Default + parameter + aggregate + + + Aggregate_OneGroupBy_OneReturn + parameter + aggregate + + + Aggregate_MultipleGroupBy_OneReturn + parameter + aggregate + + + Aggregate_MultipleGroupBy_MultipleReturn + parameter + aggregate + + + Aggregate_OneGroupBy_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleGroupBy_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleGroupBy_MultipleReturn_Default + parameter + aggregate + + + Aggregate_Weight_OneReturn + parameter + aggregate + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionMerge.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionMerge.xml new file mode 100644 index 00000000..2162a232 --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/EndlessLoopActionMerge.xml @@ -0,0 +1,49 @@ + + + CheckEndlessLoop_EndlessLoop + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + + + + + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/PotentialEndlessLoop.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/PotentialEndlessLoop.xml new file mode 100644 index 00000000..f864ff62 --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Invalid/PotentialEndlessLoop.xml @@ -0,0 +1,1210 @@ + + + CheckEndlessLoop_PotentialEndlessLoop + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + Condition_Param_1 + read + + + Condition_Param_2 + read + + + + Case1_Basic_IncrementAction + read + + + Case1_Basic_PowAction_TriggerNoiseBefore + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + read + + + + Case1_Basic_AggregateAction + read + + + + Case1_Nested_IncrementAction_1 + read + + + Case1_Nested_IncrementAction_2 + read + + + + Case1_WithPrefix_IncrementAction_Prefix + read + + + Case1_WithPrefix_IncrementAction + read + + + + Case2_Basic_IncrementAction + read + + + + Case3_Basic_GroupAction + read + + + Case3_Basic_GroupPollAction + read + + + + Case4_Basic_Execute_GroupDefault + read + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + read + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + read + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + read + + + Case4_Basic_Execute_GroupDefaultMultipleParams1 + read + + + Case4_Basic_Execute_GroupDefaultMultipleParams2 + read + + + + + Case6_Basic_Execute_NoNoise + read + + + Case6_Basic_Execute_ResponseNoiseBefore + read + + + Case6_Basic_Execute_ResponseNoiseAfter + read + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + read + + + Case6_Basic_Execute_ActionNoiseBefore + read + + + Case6_Basic_Execute_ActionNoiseAfter + read + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + read + + + + + Case9_Basic_Execute_Session + read + + + Case9_Basic_Execute_ResponseStatusCodeParam + read + + + + Case100_Basic_Execute + read + + + + + + + + + + Noise_Trigger_1 + protocol + + action + + + + + Noise_Trigger_2 + parameter + + action + + + + + Case1_Basic_IncrementAction + parameter + + action + + 100 + + + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + + action + + + 1 + 101 + + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + + action + + + 102 + 1 + + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + + action + + + 1 + 103 + 1 + + + + + Case1_Basic_AggregateAction + parameter + + action + + 105 + + + + + Case1_Nested_IncrementAction_1 + parameter + + action + + 700 + + + + Case1_Nested_IncrementAction_2 + parameter + + action + + 701 + + + + + Case1_WithPrefix_IncrementAction_Prefix + parameter + + action + + 801 + + + + Case1_WithPrefix_IncrementAction + parameter + + action + + 801 + + + + + + Case2_Basic_IncrementAction_1 + parameter + + trigger + + 1001 + 1 + + + + + Case2_Basic_IncrementAction_2 + action + + 1 + 1000 + + + + + Case3_Basic_GroupAction + parameter + + action + + 2000 + + + + Case3_Basic_GroupPollAction + parameter + + action + + 2002 + + + + + Case4_Basic_Execute_GroupDefault + parameter + + action + + 3000 + + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + parameter + + action + + 3001 + + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + parameter + + action + + 3002 + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + parameter + + action + + 3003 + + + + Case4_Basic_Execute_GroupDefaultMultipleParams1 + parameter + + action + + 3004 + + + + Case4_Basic_Execute_GroupDefaultMultipleParams2 + parameter + + action + + 3004 + + + + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + + action + + 4000 + + + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + + action + + 4001 + + + + + Case6_Basic_Execute_NoNoise + parameter + + action + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + parameter + + action + + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + parameter + + action + + 5002 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + parameter + + action + + 5003 + + + + Case6_Basic_Execute_ActionNoiseBefore + parameter + + action + + 5004 + + + + + Case6_Basic_Execute_ActionNoiseAfter + parameter + + action + + 5005 + + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + parameter + + action + + 5006 + + + + + Case7_Basic_Execute_ResponseWithOneParam + response + + action + + 6000 + + + + Case7_Basic_Execute_ResponseEmpty + response + + action + + 6001 + + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + pair + + action + + 7000 + + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + pair + + action + + 7001 + + + + + Case9_Basic_Execute_ResponseContentParam + parameter + + action + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + parameter + + action + + 8001 + + + + + Case10_Basic_Execute_SessionEmpty + session + + action + + 9000 + + + + + + Case100_Basic_Execute + parameter + + action + + 1000000 + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + + Case1_Basic_IncrementAction + parameter + increment + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + pow + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + multiply + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + multiply + + + + + Case1_Basic_AggregateAction + parameter + aggregate + + + + + Case1_Nested_IncrementAction_1 + parameter + increment + + + + Case1_Nested_IncrementAction_2 + parameter + increment + + + + + Case1_WithPrefix_IncrementAction + parameter + increment + + + + Case2_Basic_IncrementAction + parameter + increment + + + + + Case3_Basic_GroupAction_ExecuteGroup + group + execute + + + Case3_Basic_GroupAction_Increment + parameter + increment + + + Case3_Basic_GroupPollAction_ExecuteGroup + group + execute + + + + Case3_Basic_GroupPollAction_Increment + parameter + increment + + + + + Case4_Basic_Execute_GroupDefault + group + execute + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + group + execute + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + group + execute next + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + group + add to execute + + + Case4_Basic_Execute_GroupDefaultMultipleParams + group + execute + + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + execute + + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + execute + + + + + Case6_Basic_Execute_NoNoise + group + execute + + + + Case6_Basic_Execute_ResponseNoiseBefore + group + execute + + + Case6_Basic_Execute_ResponseNoiseAfter + group + execute + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + group + execute + + + + Case6_Basic_Execute_ActionNoiseBefore + group + execute + + + Case6_Basic_Execute_ActionNoiseAfter + group + execute + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + group + execute + + + + + Case7_Basic_Execute_ResponseWithOneParam + group + execute + + + + Case7_Basic_Execute_ResponseEmpty + group + execute + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + group + execute + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + group + execute + + + + + Case9_Basic_Execute_ResponseContentParam + group + execute + + + + Case9_Basic_Execute_ResponseStatusCodeParam + group + execute + + + + + Case10_Basic_Execute_SessionEmpty + group + execute + + + + Case100_Basic_Execute + group + execute + + + Case101_Basic_Execute + group + execute + + + + + + Group_Noise_1 + + + + + Group_Noise_2 + + + + + Case3_Basic_GroupAction + action + + 2001 + + + + Case3_Basic_GroupPollAction + action + + + 2003 + + + + + Case4_Basic_Execute_GroupDefault + + 3000 + + + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + poll + + 1 + 3001 + + + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + poll + + 3002 + 1 + + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + poll + + 1 + 3003 + 2 + + + + + Case4_Basic_Execute_GroupDefaultMultipleLoopParams + poll + + 3004 + 3005 + + + + + Case5_Basic_Execute_GroupDefaultNoContent + + + Case5_Basic_Execute_GroupDefaultEmptyContent + + + + + Case6_Basic_Execute_NoNoise + poll + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + poll + + 5001 + + + + + Case6_Basic_Execute_ResponseNoiseAfter + poll + + 5002 + + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + poll + + 5003 + + + + Case6_Basic_Execute_ActionNoiseBefore + poll + + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + poll + + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + poll + + 5006 + + + + + Case7_Basic_Execute_ResponseWithOneParam + poll + + 6000 + + + + Case7_Basic_Execute_ResponseEmpty + poll + + 6001 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + poll + + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + poll + + 7001 + + + + + Case9_Basic_Execute_ResponseContentParam + poll + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + poll + + 8001 + + + + + Case10_Basic_Execute_SessionEmpty + poll + + 9000 + + + + + + Case100_Basic_Execute + poll action + + 1000000 + + + + + Case101_Basic_Execute + poll action + + 1010000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Case6_Basic_Execute + + 5000 + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 5000 + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + + 5000 + 1 + 5002 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + + 5000 + 1 + 5003 + 1 + + + + Case6_Basic_Execute_ActionNoiseBefore + + 5000 + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + + 5000 + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + + 5000 + 5006 + + + + + Case7_Basic_Execute_ResponseWithOneParam + + 6000 + 6000 + + + + Case7_Basic_Execute_ResponseEmpty + + 6000 + 6001 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 7000 + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + + + + + + + + + Case6_Basic_Execute_NoNoise + + + + + + Case7_Basic_Execute_Response + + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + + + + + + + Response_Noise + + + + + + Case6_Basic_Execute_NoNoise + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 1 + 5001 + + + + Case6_Basic_Execute_ResponseNoiseAfter + + 5002 + 1 + + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + + 1 + 5003 + 1 + + + + Case6_Basic_Execute_ActionNoiseBefore + + 5004 + + + + Case6_Basic_Execute_ActionNoiseAfter + + 5005 + + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + + 5006 + + + + + Case7_Basic_Execute_AfterResponse + + 1 + + + + Case7_Basic_Execute_AfterResponseEmpty + + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d42a8fdf --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,1572 @@ + + + CheckEndlessLoop_ValidMultipleSequences + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + Case1_Basic_IncrementAction + read + + + Case1_Basic_PowAction_TriggerNoiseBefore + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + read + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + read + + + + Case1_Basic_CopyAction + read + + + Case1_Basic_AggregateAction + read + + + Case1_Basic_RunActionsAction + read + + + Case1_Basic_MultiplyAction_InvalidNoise + read + + + + Case1_Nested_IncrementAction_1 + read + + + Case1_Nested_IncrementAction_2 + read + + + + Case1_WithPrefix_IncrementAction_Prefix + read + + + Case1_WithPrefix_IncrementAction + read + + + + Case2_Basic_IncrementAction + read + + + + Case3_Basic_GroupAction + read + + + Case3_Basic_GroupPollAction + read + + + Case3_InvalidNoise + read + + + + Case4_Basic_Execute_GroupDefault + read + + + Case4_Basic_Execute_GroupPoll_GroupNoiseBefore + read + + + Case4_Basic_ExecuteNext_GroupNoiseAfter + read + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + read + + + Case4_Basic_Set_Group + read + + + + Case6_Basic_Execute_NoNoise + read + + + Case6_Basic_Execute_ResponseNoiseBefore + read + + + Case6_Basic_Execute_ResponseNoiseAfter + read + + + Case6_Basic_Execute_ResponseNoiseBeforeAndAfter + read + + + Case6_Basic_Execute_ActionNoiseBefore + read + + + Case6_Basic_Execute_ActionNoiseAfter + read + + + Case6_Basic_Execute_ActionNoiseBeforeAndAfter + read + + + Case6_InvalidNoise + read + + + + Case9_Basic_Execute_Session + read + + + Case9_Basic_Execute_ResponseStatusCodeParam + read + + + Case9_InvalidNoise + read + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Case6_Basic_Execute_NoNoise + + + + Case7_Basic_Execute_Response + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + + + Case12_CommandBeforeX_CommandMakeX + + + Case12_CommandBeforeX_CommandCrcX + + + + + + Response_Noise_1 + + + + + Response_Noise_2 + + 2 + + + + Case6_Basic_Execute_NoNoise + + 1 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 1 + 2 + + + + + Case6_InvalidNoise_NoContent + + + Case6_InvalidNoise_EmptyContent + + + + + Case6_InvalidNoise_EmptyContentParam + + + + + + Case6_InvalidNoise_InvalidContentParam + + aaa + + + + + Case7_Basic_Execute_AfterResponse + + 1 + + + + Case7_Basic_Execute_AfterResponseEmpty + + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 1 + + + + + + + Noise_Pair_1 + + 1 + + + + + Case6_Basic_Execute + + 5000 + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + + 5000 + 5001 + + + + + Case6_InvalidNoise_Responses + + 5000 + 5090 + 5091 + 5092 + + + + Case6_InvalidNoise_NoContent + + + Case6_InvalidNoise_EmptyContent + + + + + Case6_InvalidNoise_NoResponse + + 5000 + + + + Case6_InvalidNoise_EmptyResponse + + 5000 + + + + + Case6_InvalidNoise_InvalidResponse + + 5000 + aaa + + + + + Case7_Basic_Execute_ResponseWithOneParam + + 6000 + 2 + + + + Case7_Basic_Execute_ResponseEmpty + + 6000 + 1 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + + 7000 + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + + + + + + + + Group_Noise_1 + + + + + Group_Noise_2 + + + + + Case3_Basic_GroupAction + action + + 2001 + + + + Case3_Basic_GroupPollAction + action + + 2003 + + + + Case3_InvalidNoise_NoContent + action + + + Case3_InvalidNoise_EmptyContent + action + + + + + Case3_InvalidNoise_EmptyContentAction + action + + + + + + Case3_InvalidNoise_InvalidContentAction + action + + aaa + + + + + Case4_Basic_Execute_GroupDefault + + + 1 + + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + poll + + 1 + + 2 + + + + Case4_Basic_Set_Group + poll + + 3004 + + + + + Case5_Basic_Execute_GroupDefaultNoContent + + + Case5_Basic_Execute_GroupDefaultEmptyContent + + + + + Case6_Basic_Execute_NoNoise + poll + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + poll + + 5001 + + + + + Case6_InvalidNoise + poll + + 5091 + 5092 + 5093 + 5094 + 5095 + 5090 + + + + + Case7_Basic_Execute_ResponseWithOneParam + poll + + 6000 + + + + Case7_Basic_Execute_ResponseEmpty + poll + + 6001 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + poll + + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + poll + + 7001 + + + + + Case9_Basic_Execute_ResponseContentParam + poll + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + poll + + 8001 + + + + Case9_InvalidNoise + poll + + 8090 + 8091 + 8092 + 8093 + 8094 + 8095 + 8096 + + + + + Case10_Basic_Execute_SessionEmpty + poll + + 9000 + + + + + Case11_StartTimer + poll action + + 10001 + + + + Case11_StartTimers + poll action + + 10001 + 10002 + + + + Case11_Timer_beforeAction_Copy + poll + + 10002 + + + + Case11_Timer_beforeAction_RunActions + poll + + 10003 + + + + + + + Noise_Trigger_1_AfterStartup + protocol + + action + + + + + Noise_Trigger_2_EmptyContent + parameter + + action + + + + + Noise_Trigger_3_NoContent + parameter + + action + + + + Case1_Basic_IncrementAction + parameter + + action + + 100 + + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + + action + + + 1 + 101 + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + + action + + + 102 + 1 + + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + + action + + + 1 + 103 + 1 + + + + + Case1_Basic_CopyAction + parameter + + action + + 104 + + + + Case1_Basic_AggregateAction + parameter + + action + + 105 + + + + Case1_Basic_RunActionsAction + parameter + + action + + 106 + + + + Case1_Basic_MultiplyAction_InvalidNoise + parameter + + action + + + aaa + 141 + 142 + 143 + bbb + + + + + + Case1_Nested_IncrementAction_1 + parameter + + action + + 700 + + + + Case1_Nested_IncrementAction_2 + parameter + + action + + 701 + + + + + Case1_WithPrefix_IncrementAction_Prefix + parameter + + action + + 801 + + + + Case1_WithPrefix_IncrementAction + parameter + + action + + 1 + + + + + Case2_Basic_IncrementAction_1 + parameter + + trigger + + 1001 + + + + Case2_Basic_IncrementAction_2 + action + + 1000 + + + + + Case3_Basic_GroupAction + parameter + + action + + 2000 + + + + Case3_Basic_GroupPollAction + parameter + + action + + 2002 + + + + Case3_InvalidNoise + parameter + + action + + 2090 + 2091 + 2092 + 2093 + + + + + Case4_Basic_Execute_GroupDefault + parameter + + action + + 3000 + + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + parameter + + action + + 3003 + + + + Case4_Basic_Set_Group + parameter + + action + + 3004 + + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + + action + + 4000 + + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + + action + + 4001 + + + + + Case6_Basic_Execute_NoNoise + parameter + + action + + 5000 + + + + Case6_Basic_Execute_ResponseNoiseBefore + parameter + + action + + 5001 + + + + + Case6_Basic_Execute_ActionNoiseBefore + parameter + + action + + 5004 + + + + + Case6_InvalidNoise + parameter + + action + + 5090 + + + + + Case7_Basic_Execute_ResponseWithOneParam + response + + action + + 6000 + + + + Case7_Basic_Execute_ResponseEmpty + response + + action + + 6001 + + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + pair + + action + + 7000 + + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + pair + + action + + 7001 + + + + + Case9_Basic_Execute_ResponseContentParam + parameter + + action + + 8000 + + + + Case9_Basic_Execute_ResponseStatusCodeParam + parameter + + action + + 8001 + + + + Case9_InvalidNoise + parameter + + action + + 8090 + + + + + Case10_Basic_Execute_SessionEmpty + session + + action + + 9000 + + + + + + Case11_Timer_beforeAction_ExecuteTimer + action + + 10000 + + + + Case11_Timer_beforeAction_MultipleContent + timer + + action + + 10003 + 10004 + + + + Case11_Timer_beforeAction_Single + timer + + action + + 10004 + + + + + Case12_CommandBeforeEach_MakeCommand + command + + action + + 11000 + + + + Case12_CommandBeforeX_CommandMakeX + command + + action + + 11001 + + + + Case12_CommandBeforeX_CommandCrcX + command + + action + + 11002 + + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + Case1_Basic_IncrementAction + parameter + increment + + + Case1_Basic_PowAction_TriggerNoiseBefore + parameter + pow + + + Case1_Basic_MultiplyAction_TriggerNoiseAfter + parameter + multiply + + + Case1_Basic_MultiplyAction_TriggerNoiseAfterBefore + parameter + multiply + + + + Case1_Basic_CopyAction + parameter + copy + + + + Case1_Basic_AggregateAction + parameter + aggregate + + + + Case1_Basic_RunActionsAction + parameter + run actions + + + Case1_Basic_MultiplyAction_InvalidNoise_EmptyId + parameter + multiply + + + Case1_Basic_MultiplyAction_InvalidNoise_MissingId + parameter + multiply + + + Case1_Basic_MultiplyAction_InvalidNoise_InvalidId + parameter + multiply + + + + Case1_Nested_IncrementAction_1 + parameter + increment + + + Case1_Nested_IncrementAction_2 + parameter + increment + + + + Case1_WithPrefix_IncrementAction + parameter + increment + + + + Case2_Basic_IncrementAction + parameter + increment + + + + Case3_Basic_GroupAction_ExecuteGroup + group + execute + + + Case3_Basic_GroupAction_Increment + parameter + increment + + + Case3_Basic_GroupPollAction_ExecuteGroup + group + execute + + + Case3_Basic_GroupPollAction_Increment + parameter + increment + + + Case3_Basic_InvalidNoise_Group1 + group + execute + + + Case3_Basic_InvalidNoise_EmptyId + group + execute + + + Case3_Basic_InvalidNoise_MissingId + group + execute + + + Case3_Basic_InvalidNoise_InvalidId + group + execute + + + Case3_Basic_InvalidNoise_Group2 + group + execute + + + + Case4_Basic_Execute_GroupDefault + group + execute + + + + Case4_Basic_AddToExecute_GroupNoiseBeforeAndAfter + group + add to execute + + + Case4_Basic_Set_Group + group + set + + + + Case5_Basic_Execute_GroupDefaultNoContent + group + execute + + + Case5_Basic_Execute_GroupDefaultEmptyContent + group + execute + + + + Case6_Basic_Execute_NoNoise + group + execute + + + Case6_Basic_Execute_ResponseNoiseBefore + group + execute + + + + Case6_Basic_Execute_ActionNoiseBefore + group + execute + + + + Case6_InvalidNoise + group + execute + + + + Case7_Basic_Execute_ResponseWithOneParam + group + execute + + + Case7_Basic_Execute_ResponseEmpty + group + execute + + + + Case8_Basic_Execute_PairTimeout_PairOneComandOneResponse + group + execute + + + Case8_Basic_Execute_PairSucceeded_PairEmpty + group + execute + + + + Case9_Basic_Execute_ResponseContentParam + group + execute + + + Case9_Basic_Execute_ResponseStatusCodeParam + group + execute + + + Case9_InvalidNoise + group + execute + + + + Case10_Basic_Execute_SessionEmpty + group + execute + + + + Case11_Timer_beforeAction_ExecuteTimer + group + execute + + + Case11_Timer_beforeAction_Timer1 + timer + start + + + Case11_Timer_beforeAction_Timer2 + timer + start + + + Case11_Timer_beforeAction_Copy + parameter + copy + + + Case11_Timer_beforeAction_RunActions + parameter + run actions + + + + Case12_CommandBeforeEach_MakeCommand + command + make + + + Case12_CommandBeforeX_CommandMakeX + command + make + + + Case12_CommandBeforeX_CommandCrcX + command + crc + + + + + + Case11_Timer_beforeAction_Copy + + 1 + + + + Case11_Timer_beforeAction + + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionAggregate.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionAggregate.xml new file mode 100644 index 00000000..196c87bd --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionAggregate.xml @@ -0,0 +1,503 @@ + + + CheckEndlessLoop_ValidMultipleSequences + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + Aggregate_OneReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_MultipleReturnParam + read + + + Aggregate_Default + read + + + Aggregate_OneGroupby + read + + + Aggregate_MultipleGroupBy1 + read + + + Aggregate_MultipleGroupBy2 + read + + + Aggregate_OneReturn_Default + read + + + Aggregate_OneReturn_Default + read + + + Aggregate_MultipleReturn_Default1 + read + + + Aggregate_MultipleReturn_Default2 + read + + + Aggregate_MultipleReturn_Default2 + read + + + Aggregate_OneGroupBy_Default1 + read + + + Aggregate_OneGroupBy_Default2 + read + + + Aggregate_OneReturn_Default1 + read + + + Aggregate_OneReturn_Default2 + read + + + Aggregate_OneReturn_Default3 + read + + + Aggregate_OneGroupBy_OneReturn1 + read + + + Aggregate_OneGroupBy_OneReturn2 + read + + + Aggregate_MultipleGroupBy_OneReturn1 + read + + + Aggregate_MultipleGroupBy_OneReturn2 + read + + + Aggregate_MultipleGroupBy_OneReturn3 + read + + + Aggregate_MultipleGroupBy_MultipleReturn1 + read + + + Aggregate_MultipleGroupBy_MultipleReturn2 + read + + + Aggregate_MultipleGroupBy_MultipleReturn3 + read + + + Aggregate_MultipleGroupBy_MultipleReturn4 + read + + + Aggregate_OneGroupBy_OneReturn_Default1 + read + + + Aggregate_OneGroupBy_OneReturn_Default2 + read + + + Aggregate_OneGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default1 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default2 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default4 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default1 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default2 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default3 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default4 + read + + + Aggregate_MultipleGroupBy_OneReturn_Default5 + read + + + Aggregate_Weight + read + + + Aggregate_Weight_OneReturn + read + + + Aggregate_Weight_OneReturn + read + + + Aggregate_TriggerParameter + read + + + Aggregate_OnParameter + read + + + Aggregate_WeightParameter + read + + + + + + + + + + Noise_Trigger_1_AfterStartup + protocol + + action + + + + + Noise_Trigger_2_EmptyContent + parameter + + action + + + + + Noise_Trigger_3_NoContent + parameter + + action + + + + Aggregate_EmptyOptions + parameter + + action + + 200 + + + + Aggregate_OneReturn + parameter + + action + + 201 + + + + Aggregate_MultipleReturn + parameter + + action + + 202 + + + + Aggregate_Default + parameter + + action + + 203 + + + + Aggregate_OneGroupBy + parameter + + action + + 204 + + + + Aggregate_MultipleGroupBy + parameter + + action + + 205 + + + + Aggregate_OneReturn_Default + parameter + + action + + 210 + + + + Aggregate_MultipleReturn_Default + parameter + + action + + 211 + + + + Aggregate_OneGroupBy_Default + parameter + + action + + 212 + + + + Aggregate_MultipleGroupBy_Default + parameter + + action + + 213 + + + + Aggregate_OneGroupBy_OneReturn + parameter + + action + + 214 + + + + Aggregate_MultipleGroupBy_OneReturn + parameter + + action + + 215 + + + + Aggregate_MultipleGroupBy_MultipleReturn + parameter + + action + + 216 + + + + Aggregate_OneGroupBy_OneReturn_Default + parameter + + action + + 217 + + + + Aggregate_MultipleGroupBy_OneReturn_Default + parameter + + action + + 218 + + + + Aggregate_MultipleGroupBy_MultipleReturn_Default + parameter + + action + + 219 + + + + Aggregate_Weight + parameter + + action + + 220 + + + + Aggregate_Weight_OneReturn + parameter + + action + + 221 + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + Aggregate_EmptyOptions + parameter + aggregate + + + Aggregate_OneReturn + parameter + aggregate + + + Aggregate_MultipleReturn + parameter + aggregate + + + Aggregate_Default + parameter + aggregate + + + Aggregate_OneGroupBy + parameter + aggregate + + + Aggregate_MultipleGroupBy + parameter + aggregate + + + Aggregate_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleReturn_Default + parameter + aggregate + + + Aggregate_OneGroupBy_Default + parameter + aggregate + + + Aggregate_MultipleGroupby_Default + parameter + aggregate + + + Aggregate_OneGroupBy_OneReturn + parameter + aggregate + + + Aggregate_MultipleGroupBy_OneReturn + parameter + aggregate + + + Aggregate_MultipleGroupBy_MultipleReturn + parameter + aggregate + + + Aggregate_OneGroupBy_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleGroupBy_OneReturn_Default + parameter + aggregate + + + Aggregate_MultipleGroupBy_MultipleReturn_Default + parameter + aggregate + + + Aggregate_Weight + parameter + aggregate + + + Aggregate_Weight_OneReturn + parameter + aggregate + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionMerge.xml b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionMerge.xml new file mode 100644 index 00000000..22b61388 --- /dev/null +++ b/ProtocolTests/Protocol/CheckEndlessLoop/Samples/Validate/Valid/ValidActionMerge.xml @@ -0,0 +1,74 @@ + + + CheckEndlessLoop_ValidMultipleSequences + 1.0.0.1 + + + + Noise_Param_1 + read + + + Noise_Param_2 + read + + + + + + + + + + + + + + Noise_Trigger_1_AfterStartup + protocol + + action + + + + + Noise_Trigger_2_EmptyContent + parameter + + action + + + + + Noise_Trigger_3_NoContent + parameter + + action + + + + + + + + Noise_RunActions_1 + parameter + run actions + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckProtocolTag/CheckProtocolTag.cs b/ProtocolTests/Protocol/CheckProtocolTag/CheckProtocolTag.cs new file mode 100644 index 00000000..d04c8ab6 --- /dev/null +++ b/ProtocolTests/Protocol/CheckProtocolTag/CheckProtocolTag.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.CheckProtocolTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckProtocolTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckProtocolTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckProtocolTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckProtocolTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckProtocolTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.1.1", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Missing tag 'Protocol'.", + HowToFix = "Add Protocol root tag to the document.", + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckProtocolTag(); + + [TestMethod] + public void Protocol_CheckProtocolTag_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckProtocolTag_CheckId() => Generic.CheckId(check, CheckId.CheckProtocolTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/CheckProtocolTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/CheckXMLDeclaration.cs b/ProtocolTests/Protocol/CheckXMLDeclaration/CheckXMLDeclaration.cs new file mode 100644 index 00000000..8c309c1a --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/CheckXMLDeclaration.cs @@ -0,0 +1,158 @@ +namespace SLDisValidatorUnitTests.Protocol.CheckXMLDeclaration +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.CheckXMLDeclaration; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckXMLDeclaration(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckXMLDeclaration_ValidUtf8Declaration() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidUtf8Declaration.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckXMLDeclaration_ValidNoDeclaration() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNoDeclaration.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckXMLDeclaration_ValidNoDeclaration2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckXMLDeclaration_ValidDeclarationWithoutEncoding() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidDeclarationWithoutEncoding.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckXMLDeclaration_InvalidDeclaration() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidDeclaration", + ExpectedResults = new List + { + Error.InvalidDeclaration(null, null, null, "iso-8859-1", "UTF-8"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckXMLDeclaration(); + + [TestMethod] + public void Protocol_CheckXMLDeclaration_InvalidDeclaration() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidDeclaration", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckXMLDeclaration_InvalidDeclaration() + { + // Create ErrorMessage + var message = Error.InvalidDeclaration(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.18.1", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Invalid XML encoding '1'. Possible values '2'.", + HowToFix = "Remove the XML declaration if not set to UTF-8.", + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckXMLDeclaration(); + + [TestMethod] + public void Protocol_CheckXMLDeclaration_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckXMLDeclaration_CheckId() => Generic.CheckId(root, CheckId.CheckXMLDeclaration); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Codefix/InvalidDeclaration.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Codefix/InvalidDeclaration.xml new file mode 100644 index 00000000..7381e20c --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Codefix/InvalidDeclaration.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Invalid/InvalidDeclaration.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Invalid/InvalidDeclaration.xml new file mode 100644 index 00000000..436fa427 --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Invalid/InvalidDeclaration.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidDeclarationWithoutEncoding.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidDeclarationWithoutEncoding.xml new file mode 100644 index 00000000..3a89df6a --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidDeclarationWithoutEncoding.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidNoDeclaration.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidNoDeclaration.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidNoDeclaration.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidUtf8Declaration.xml b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidUtf8Declaration.xml new file mode 100644 index 00000000..0b79f5f2 --- /dev/null +++ b/ProtocolTests/Protocol/CheckXMLDeclaration/Samples/Validate/Valid/ValidUtf8Declaration.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/CheckAsciiAttribute.cs b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/CheckAsciiAttribute.cs new file mode 100644 index 00000000..f02a80f4 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/CheckAsciiAttribute.cs @@ -0,0 +1,239 @@ +namespace SLDisValidatorUnitTests.Protocol.Commands.Command.CheckAsciiAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Commands.Command.CheckAsciiAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckAsciiAttribute(); + + #region Valid Checks + + [TestMethod] + public void Command_CheckAsciiAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Command_CheckAsciiAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckAsciiAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test1", "1"), + + Error.InvalidAttribute(null, null, null, "1;test2;2;test3;3", "2").WithSubResults( + Error.InvalidAttribute(null, null, null, "test2", "2"), + Error.InvalidAttribute(null, null, null, "test3", "2")), + + Error.InvalidAttribute(null, null, null, "1;test4;2", "3").WithSubResults( + Error.InvalidAttribute(null, null, null, "test4", "3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckAsciiAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + + Error.InvalidAttribute(null, null, null, "1001;1002", "2").WithSubResults( + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2")), + + Error.InvalidAttribute(null, null, null, "1;1001;2;1002;3", "3").WithSubResults( + Error.NonExistingId(null, null, null, "1001", "3"), + Error.NonExistingId(null, null, null, "1002", "3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckAsciiAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + + Error.InvalidAttribute(null, null, null, "1001;1002", "2").WithSubResults( + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Command_CheckAsciiAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "10.4.1", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'ascii' in Command '0'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"This attribute allows you to specify which parameters should be sent as ASCII. Possible values:{Environment.NewLine}" + + $" - True: all params as ascii{Environment.NewLine}" + + $" - False: no param as ascii{Environment.NewLine}" + + $" - Semicolon separated list of Param IDs{Environment.NewLine}" + + "Note that this option only makes sense when using unicode feature.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckAsciiAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "10.4.2", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Invalid value '0' in attribute 'ascii'. Command ID '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"This attribute allows you to specify which parameters should be sent as ASCII. Possible values:{Environment.NewLine}" + + $" - True: all params as ascii{Environment.NewLine}" + + $" - False: no param as ascii{Environment.NewLine}" + + $" - Semicolon separated list of Param IDs{Environment.NewLine}" + + "Note that this option only makes sense when using unicode feature.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckAsciiAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "10.4.3", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Attribute 'ascii' references a non-existing 'Param' with ID '0'. Command ID '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"This attribute allows you to specify which parameters should be sent as ASCII. Possible values:{Environment.NewLine}" + + $" - True: all params as ascii{Environment.NewLine}" + + $" - False: no param as ascii{Environment.NewLine}" + + $" - Semicolon separated list of Param IDs{Environment.NewLine}" + + "Note that this option only makes sense when using unicode feature.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckAsciiAttribute(); + + [TestMethod] + public void Command_CheckAsciiAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Command); + + [TestMethod] + public void Command_CheckAsciiAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckAsciiAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..9fd7d6be --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..89f2647f --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..55b2f552 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + 1 non-existing Param + + + 2 non-existing Params + + + Mixture of existing and non-existing params + + 1 + 2 + 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..35f2b047 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,12 @@ + + + + + 1 non-existing Param + + + 2 non-existing Params + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..440f7182 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckAsciiAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + 1001 + 1002 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/CheckCommandLogic.cs b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/CheckCommandLogic.cs new file mode 100644 index 00000000..70c2bda0 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/CheckCommandLogic.cs @@ -0,0 +1,133 @@ +namespace SLDisValidatorUnitTests.Protocol.Commands.Command.CheckCommandLogic +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Commands.Command.CheckCommandLogic; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckCommandLogic(); + + #region Valid Checks + + [TestMethod] + public void Command_CheckCommandLogic_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Command_CheckCommandLogic_ValidOnEach() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnEach.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + #endregion + + #region Invalid Checks + + [TestMethod] + public void Command_CheckCommandLogic_MissingCrcCommandAction() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingCrcCommandAction.xml", + ExpectedResults = new List + { + Error.MissingCrcCommandAction(null, null, null, "1", "2"), + Error.MissingCrcCommandAction(null, null, null, "2", "2"), + Error.MissingCrcCommandAction(null, null, null, "3", "2"), + Error.MissingCrcCommandAction(null, null, null, "4", "2"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Command_CheckCommandLogic_MissingCrcCommandActionEachOverwrite() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingCrcCommandActionEachOverwrite.xml", + ExpectedResults = new List + { + Error.MissingCrcCommandAction(null, null, null, "2", "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Command_CheckCommandLogic_MissingCrcCommandAction() + { + // Create ErrorMessage + var message = Error.MissingCrcCommandAction(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "10.1.1", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "No 'CRC' Action triggered before Command '1'. 'CRC' Param '2'.", + HowToFix = "Make sure a CRC action is triggered before command.", + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckCommandLogic(); + + [TestMethod] + public void Command_CheckCommandLogic_CheckCategory() => Generic.CheckCategory(root, Category.Command); + + [TestMethod] + public void Command_CheckCommandLogic_CheckId() => Generic.CheckId(root, CheckId.CheckCommandLogic); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandAction.xml b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandAction.xml new file mode 100644 index 00000000..cde9ef65 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandAction.xml @@ -0,0 +1,110 @@ + + + + + CrcParam + crc + + + + + + NoTrigger + + 2 + + + + NoAction + + 2 + + + + NoCrcAction + + 2 + + + + TriggerInsteadOfAction + + 2 + + + + + + + DummyTrigger + action + + + + + BeforeCommand2 + command + + action + + + + + BeforeCommand3 + command + + action + + 3 + 4 + + + + BeforeCommand4 + command + + trigger + + 1 + + + + + BeforeResponseEach + response + + action + + 1 + + + + BeforeResponse2 + response + + action + + 1 + + + + + + + CalculateCrcCommand + command + crc + + + CalculateCommandLength + command + length + + + CalculateCrcResponse + response + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandActionEachOverwrite.xml b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandActionEachOverwrite.xml new file mode 100644 index 00000000..a34f3691 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Invalid/MissingCrcCommandActionEachOverwrite.xml @@ -0,0 +1,56 @@ + + + + + CrcParam + crc + + + + + + CrcResponse + + 2 + + + + + + + BeforeCommandEach + command + + action + + 1 + + + + BeforeCommand2 + command + + action + + + + + BeforeCommandEach2 + command + + action + + 1 + + + + + + + CalculateCrcCommand + command + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..12bb0396 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,64 @@ + + + + + CrcParam + crc + + + FixedParamAAA + fixed + + other + string + fixed + 3 + AAA + + + + + + + CrcCommand + + 2 + + + + NoCrcCommand + + 3 + + + + + + + BeforeCommandEach + command + + action + + + + + BeforeCommand2 + command + + action + + 1 + + + + + + + CalculateCrcCommand + command + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/ValidOnEach.xml b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/ValidOnEach.xml new file mode 100644 index 00000000..2026df5f --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckCommandLogic/Samples/Validate/Valid/ValidOnEach.xml @@ -0,0 +1,65 @@ + + + + + CrcParam + crc + + + FixedParamAAA + fixed + + other + string + fixed + 3 + AAA + + + + + + + CrcCommand + + 2 + + + + NoCrcCommand + + 3 + + + + + + + BeforeCommandEach + command + + action + + + + + + BeforeCommandEach2 + command + + action + + 1 + + + + + + + CalculateCrcCommand + command + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..493cedcc --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,334 @@ +namespace SLDisValidatorUnitTests.Protocol.Commands.Command.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Commands.Command.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Command_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Command_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Command_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Command_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "10.5.5", + Category = Category.Command, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "More than one Command with same ID '2'. Command Names '3'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The id attribute is used internally as the identifier for each command.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each command should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "10.5.2", + Category = Category.Command, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'Command@id'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The id attribute is used internally as the identifier for each command.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each command should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "MyName"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "10.5.4", + Category = Category.Command, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Invalid value '2' in attribute 'Command@id'. Command name 'MyName'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The id attribute is used internally as the identifier for each command.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each command should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "10.5.1", + Category = Category.Command, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Missing attribute 'Command@id'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The id attribute is used internally as the identifier for each command.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each command should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "10.5.3", + Category = Category.Command, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed attribute 'Command@id'. Current value '2'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"The id attribute is used internally as the identifier for each command.{Environment.NewLine}" + + $"It is therefore mandatory and needs to follow a number of rules:{Environment.NewLine}" + + $"- Each command should have a unique id.{Environment.NewLine}" + + $"- Should be an unsigned integer.{Environment.NewLine}" + + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Command_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Command); + + [TestMethod] + public void Command_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..33c7839b --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..a397787b --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..a939baf5 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..74333f62 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..41c42a69 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..38671d8e --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..c3b97fab --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/CheckParamTag.cs b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/CheckParamTag.cs new file mode 100644 index 00000000..af58be38 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/CheckParamTag.cs @@ -0,0 +1,212 @@ +namespace SLDisValidatorUnitTests.Protocol.Commands.Command.Content.Param.CheckParamTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Commands.Command.Content.Param.CheckParamTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParamTag(); + + #region Valid Checks + + [TestMethod] + public void Command_CheckParamTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Command_CheckParamTag_EmptyParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyParamTag", + ExpectedResults = new List + { + Error.EmptyParamTag(null, null, null, "1"), + Error.EmptyParamTag(null, null, null, "2"), + Error.EmptyParamTag(null, null, null, "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckParamTag_InvalidParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidParamTag", + ExpectedResults = new List + { + Error.InvalidParamTag(null, null, null, "test1", "1"), + Error.InvalidParamTag(null, null, null, "test2", "2"), + Error.InvalidParamTag(null, null, null, "test3", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckParamTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Command_CheckParamTag_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Command_CheckParamTag_EmptyParamTag() + { + // Create ErrorMessage + var message = Error.EmptyParamTag(null, null, null, "0"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "10.3.2", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Empty tag 'Content/Param' in Command '0'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "Command/Content tag should contain a list of 'Param' tags. The 'Param' tags should refer to the id of an existing Param.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckParamTag_InvalidParamTag() + { + // Create ErrorMessage + var message = Error.InvalidParamTag(null, null, null, "test", "1"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "10.3.3", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Invalid value 'test' in tag 'Content/Param'. Command ID '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "Command/Content tag should contain a list of 'Param' tags. The 'Param' tags should refer to the id of an existing Param.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Command_CheckParamTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "10.3.1", + Category = Category.Command, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Tag 'Content/Param' references a non-existing 'Param' with ID '0'. Command ID '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = "Command/Content tag should contain a list of 'Param' tags. The 'Param' tags should refer to the id of an existing Param.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParamTag(); + + [TestMethod] + public void Command_CheckParamTag_CheckCategory() => Generic.CheckCategory(check, Category.Command); + + [TestMethod] + public void Command_CheckParamTag_CheckId() => Generic.CheckId(check, CheckId.CheckParamTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml new file mode 100644 index 00000000..a08b26a8 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + 1 + + + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml new file mode 100644 index 00000000..a8f6aecd --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + test1 + + + + + 1 + test2 + test3 + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..88597315 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1001 + 1002 + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..098604a1 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f20808dd --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + 1 Param + + 1001 + + + + 4 Params (1 duplicate) + + 1001 + 1002 + 1003 + 1001 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..eb908636 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,105 @@ +namespace SLDisValidatorUnitTests.Protocol.Commands.Command.Name.CheckNameTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Commands.Command.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Command_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Command_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue.xml", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Command_CheckParamTag_EmptyParamTag() + { + // Create ErrorMessage + var message = Error.DuplicatedValue(null, null, null, "0", "1"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "10.2.1", + Category = Category.Command, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Duplicated Command Name '0'. Command IDs '1'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Command_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Command); + + [TestMethod] + public void Command_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..cbfcc038 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..27000ab7 --- /dev/null +++ b/ProtocolTests/Protocol/Commands/Command/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/CheckMinimumRequiredVersionTag.cs b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/CheckMinimumRequiredVersionTag.cs new file mode 100644 index 00000000..8f5d0d54 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/CheckMinimumRequiredVersionTag.cs @@ -0,0 +1,478 @@ +namespace SLDisValidatorUnitTests.Protocol.Compliancies.MinimumRequiredVersion.CheckMinimumRequiredVersionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Compliancies.MinimumRequiredVersion.CheckMinimumRequiredVersionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckMinimumRequiredVersionTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidNoTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_NoTag", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionTooLow() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MinVersionTooLow", + ExpectedResults = new List + { + Error.MinVersionTooLow(null, null, null, "10.0.0.0", "10.1.3.0 - 9963").WithSubResults + ( + Error.MinVersionTooLow_Sub(null, null, null, "10.1.3.0 - 9963", "Chain Grouping Name").WithSubResults + ( + Error.MinVersionFeatureUsedInItemWithId_Sub(null, null, null, "Chain", "Name", "MyChain") + ), + Error.MinVersionTooLow_Sub(null, null, null, "10.1.3.0 - 9963", "Chain Default Selection Field").WithSubResults + ( + Error.MinVersionFeatureUsedInItem_Sub(null, null, null, "Chain") + ) + ) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, " 10.0.0.0 - 4685 ") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckMinimumRequiredVersionTag(); + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionTooLow() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MinVersionTooLow", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckMinimumRequiredVersionTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidDecrease1() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidDecrease1", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidDecrease2() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidDecrease2", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidDecrease3() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidDecrease3", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidDecrease4() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidDecrease4", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidDecrease5() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidDecrease5", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidIncrease() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidIncrease", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_ValidRemoval() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidRemoval", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionIncreased() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MinVersionIncreased", + ExpectedResults = new List + { + ErrorCompare.MinVersionIncreased(null, null, "101.102.103.104 - 10005", "199.102.103.104 - 10005"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionIncreased2() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MinVersionIncreased2", + ExpectedResults = new List + { + ErrorCompare.MinVersionIncreased(null, null, "101.102.103.104 - 10005", "101.199.103.104 - 10005"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionIncreased3() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MinVersionIncreased3", + ExpectedResults = new List + { + ErrorCompare.MinVersionIncreased(null, null, "101.102.103.104 - 10005", "101.102.199.104 - 10005"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionIncreased4() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MinVersionIncreased4", + ExpectedResults = new List + { + ErrorCompare.MinVersionIncreased(null, null, "101.102.103.104 - 10005", "101.102.103.199 - 10005"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionIncreased5() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MinVersionIncreased5", + ExpectedResults = new List + { + ErrorCompare.MinVersionIncreased(null, null, "101.102.103.104 - 10005", "101.102.103.104 - 10099"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionFeatureUsedInItem_Sub() + { + // Create ErrorMessage + var message = Error.MinVersionFeatureUsedInItem_Sub(null, null, null, "Protocol"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.25.4", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Feature used in 'Protocol'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionFeatureUsedInItemWithId_Sub() + { + // Create ErrorMessage + var message = Error.MinVersionFeatureUsedInItemWithId_Sub(null, null, null, "Param", "ID", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.25.3", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Feature used in 'Param' with 'ID' '3'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionTooLow() + { + // Create ErrorMessage + var message = Error.MinVersionTooLow(null, null, null, "9.5.0.0 - 1234", "10.0.0.0 - 1234"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.25.1", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "Minimum required version '9.5.0.0 - 1234' too low. Expected value '10.0.0.0 - 1234'.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = + $"Indicates the minimum DataMiner ver­sion that the driver is compatible with. {Environment.NewLine}" + + "If the DMS software version is less recent than the indicated version, the protocol will not be useable.", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_MinVersionTooLow_Sub() + { + // Create ErrorMessage + var message = Error.MinVersionTooLow_Sub(null, null, null, "10.0.0.0 - 1234", "Test Feature"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.25.2", + Category = Category.Protocol, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = String.Empty, + Description = "'10.0.0.0 - 1234' : 'Test Feature'", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, " 10.0.0.0 - 1234 "); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "1.25.5", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed tag 'MinimumRequiredVersion'. Current value ' 10.0.0.0 - 1234 '.", + HowToFix = String.Empty, + ExampleCode = String.Empty, + Details = String.Empty, + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckMinimumRequiredVersionTag(); + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckMinimumRequiredVersionTag_CheckId() => Generic.CheckId(check, CheckId.CheckMinimumRequiredVersionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/MinVersionTooLow.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/MinVersionTooLow.xml new file mode 100644 index 00000000..e7d02368 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/MinVersionTooLow.xml @@ -0,0 +1,9 @@ + + + 10.1.3.0 - 9963 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..f6b3f13f --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,5 @@ + + + 10.0.0.0 - 4685 + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_New.xml new file mode 100644 index 00000000..594e06fe --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_New.xml @@ -0,0 +1,7 @@ + + + + 101.199.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_Old.xml new file mode 100644 index 00000000..ec9a08e9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased2_Old.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_New.xml new file mode 100644 index 00000000..b26d2b61 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_New.xml @@ -0,0 +1,7 @@ + + + + 101.102.199.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_Old.xml new file mode 100644 index 00000000..ec9a08e9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased3_Old.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_New.xml new file mode 100644 index 00000000..82b8e273 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_New.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.199 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_Old.xml new file mode 100644 index 00000000..ec9a08e9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased4_Old.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_New.xml new file mode 100644 index 00000000..07cef121 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_New.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10099 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_Old.xml new file mode 100644 index 00000000..ec9a08e9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased5_Old.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_New.xml new file mode 100644 index 00000000..08496aca --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_New.xml @@ -0,0 +1,7 @@ + + + + 199.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_Old.xml new file mode 100644 index 00000000..ec9a08e9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Invalid/MinVersionIncreased_Old.xml @@ -0,0 +1,7 @@ + + + + 101.102.103.104 - 10005 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_New.xml new file mode 100644 index 00000000..fb49abdd --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_New.xml @@ -0,0 +1,7 @@ + + + + 9.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease1_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_New.xml new file mode 100644 index 00000000..a5e1278f --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_New.xml @@ -0,0 +1,7 @@ + + + + 11.9.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease2_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_New.xml new file mode 100644 index 00000000..26c335d9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_New.xml @@ -0,0 +1,7 @@ + + + + 11.12.9.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease3_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_New.xml new file mode 100644 index 00000000..adad5f07 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_New.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.9 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease4_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_New.xml new file mode 100644 index 00000000..9db60c0d --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_New.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99998 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidDecrease5_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_New.xml new file mode 100644 index 00000000..d2efa850 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_New.xml @@ -0,0 +1,9 @@ + + + + + + 2.2.2.2 - 6487 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_Old.xml new file mode 100644 index 00000000..c6a2edea --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidIncrease_Old.xml @@ -0,0 +1,9 @@ + + + + + + 1.1.1.1 - 6016 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_New.xml new file mode 100644 index 00000000..958161d9 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_New.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_Old.xml new file mode 100644 index 00000000..4e4ff3c3 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/ValidRemoval_Old.xml @@ -0,0 +1,7 @@ + + + + 11.12.13.14 - 99999 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..d223c2fb --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,7 @@ + + + + 10.1.11.0 - 11027 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..b28e1904 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,7 @@ + + + + 10.1.11.0 - 11027 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/MinVersionTooLow.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/MinVersionTooLow.xml new file mode 100644 index 00000000..29c06963 --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/MinVersionTooLow.xml @@ -0,0 +1,12 @@ + + + + 10.0.0.0 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..0a8e4e2b --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,7 @@ + + + + 10.0.0.0 - 4685 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..9198974b --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,11 @@ + + + + 10.2.0.0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid_NoTag.xml b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid_NoTag.xml new file mode 100644 index 00000000..ad59509b --- /dev/null +++ b/ProtocolTests/Protocol/Compliancies/MinimumRequiredVersion/CheckMinimumRequiredVersionTag/Samples/Validate/Valid/Valid_NoTag.xml @@ -0,0 +1,15 @@ + + + + + DefaultValue + + numeric text + double + next param + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..a82789b1 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,126 @@ +namespace SLDisValidatorUnitTests.Protocol.DVEs.DVEProtocols.DVEProtocol.CheckNameAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.DVEs.DVEProtocols.DVEProtocol.CheckNameAttribute; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_NoTag() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "NoTag", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "Mother - Child2", "200", "Mother - NewChild"), + ErrorCompare.UpdatedValue(null, null, "MotherChild2", "400", "MotherChild 2"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_RemovedItem() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedItem", + ExpectedResults = new List + { + ErrorCompare.RemovedItem(null, null, "Mother - Child2", "200"), + ErrorCompare.RemovedItem(null, null, "MotherChild", "300"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckNameAttribute_UpdatedValue() + { + // Create ErrorMessage + var message = ErrorCompare.UpdatedValue(null, null, "0", "1", "2"); + + string description = "DVE Protocol with Name '0' for Table '1' was changed into '2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_RemovedItem() + { + // Create ErrorMessage + var message = ErrorCompare.RemovedItem(null, null, "0", "1"); + + string description = "DVE Protocol with Name '0' for Table '1' was removed."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckNameAttribute(); + + [TestMethod] + public void Protocol_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckNameAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_New.xml new file mode 100644 index 00000000..f13581ce --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_New.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_Old.xml new file mode 100644 index 00000000..7ff9b50c --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/RemovedItem_Old.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..6c7e8bb5 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..bae2c1e7 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_New.xml new file mode 100644 index 00000000..bae2c1e7 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_New.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_Old.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/NoTag_Old.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..31f938bc --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..7ff9b50c --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/CheckElementPrefixTag.cs b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/CheckElementPrefixTag.cs new file mode 100644 index 00000000..eb6eb3c0 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/CheckElementPrefixTag.cs @@ -0,0 +1,85 @@ +namespace SLDisValidatorUnitTests.Protocol.DVEs.DVEProtocols.DVEProtocol.ElementPrefix.CheckElementPrefixTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.DVEs.DVEProtocols.DVEProtocol.ElementPrefix.CheckElementPrefixTag; + + [TestClass] + public class Compare + { + private readonly ICompare test = new CheckElementPrefixTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckElementPrefixTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(test, data); + } + + #endregion Valid Checks + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckElementPrefixTag_AddedElementPrefix() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedElementPrefix", + ExpectedResults = new List + { + ErrorCompare.AddedElementPrefix(null, null, "MotherChild2", "400"), + ErrorCompare.AddedElementPrefix(null, null, "MotherChild3", "500"), + } + }; + + Generic.Compare(test, data); + } + + [TestMethod] + public void Protocol_CheckElementPrefixTag_RemovedElementPrefix() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedElementPrefix", + ExpectedResults = new List + { + ErrorCompare.RemovedElementPrefix(null, null, "Mother - Child2", "200"), + ErrorCompare.RemovedElementPrefix(null, null, "MotherChild3", "500"), + } + }; + + Generic.Compare(test, data); + } + + #endregion Invalid Checks + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckElementPrefixTag(); + + [TestMethod] + public void Protocol_CheckElementPrefixTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckElementPrefixTag_CheckId() => Generic.CheckId(root, CheckId.CheckElementPrefixTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_New.xml new file mode 100644 index 00000000..1a48041f --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_New.xml @@ -0,0 +1,18 @@ + + + + + true + + + + + + + true + + + + + + diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_Old.xml new file mode 100644 index 00000000..a007b4da --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/AddedElementPrefix_Old.xml @@ -0,0 +1,20 @@ + + + + + true + + + true + + + + + false + + + false + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_New.xml new file mode 100644 index 00000000..1ade9b77 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_New.xml @@ -0,0 +1,19 @@ + + + + + true + + + false + + + + + + + false + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_Old.xml new file mode 100644 index 00000000..f50ff0e3 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Invalid/RemovedElementPrefix_Old.xml @@ -0,0 +1,19 @@ + + + + + true + + + true + + + + + true + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..0b4257b5 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,19 @@ + + + + + true + + + true + + + + + false + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..2bf67467 --- /dev/null +++ b/ProtocolTests/Protocol/DVEs/DVEProtocols/DVEProtocol/ElementPrefix/CheckElementPrefixTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,21 @@ + + + + + true + + + + + + + false + + + true + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/CheckDefaultPageAttribute.cs b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/CheckDefaultPageAttribute.cs new file mode 100644 index 00000000..7c623344 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/CheckDefaultPageAttribute.cs @@ -0,0 +1,370 @@ +namespace SLDisValidatorUnitTests.Protocol.Display.CheckDefaultPageAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Display.CheckDefaultPageAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckDefaultPageAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute.xml", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute.xml", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UnexistingPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexistingPage.xml", + ExpectedResults = new List + { + Error.UnexistingPage(null, null, null, "ThisIsAnUnexistingPage"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute.xml", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " General ") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UnsupportedPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedPage.xml", + ExpectedResults = new List + { + Error.UnsupportedPage(null, null, null, "popupPage"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_InvalidDefaultPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidDefaultPage.xml", + ExpectedResults = new List + { + Error.InvalidDefaultPage(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDefaultPageAttribute(); + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.21.1", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Missing attribute 'defaultPage'.", + HowToFix = "Specify a default page using the defaultPage attribute.", + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.21.2", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'defaultPage'.", + HowToFix = "Specify a default page in the defaultPage attribute.", + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UnexistingPage() + { + // Create ErrorMessage + var message = Error.UnexistingPage(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.21.3", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "The specified defaultPage 'ABC' does not exist.", + HowToFix = String.Empty, + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.21.4", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed attribute 'defaultPage'. Current value 'ABC'.", + HowToFix = String.Empty, + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_InvalidDefaultPage() + { + // Create ErrorMessage + var message = Error.InvalidDefaultPage(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "1.21.5", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "The default page should be a page with name 'General'.", + HowToFix = "Define a page with name 'General' and specify it as the default page.", + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_UnsupportedPage() + { + // Create ErrorMessage + var message = Error.UnsupportedPage(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 6, + FullId = "1.21.6", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Unsupported popup page 'ABC' in defaultPage attribute.", + HowToFix = String.Empty, + ExampleCode = "", + Details = + $"Skyline recommends the following structure for driver pages:{Environment.NewLine}" + + $"- General{Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + $"- Data Page(s){Environment.NewLine}" + + $"- -----------{Environment.NewLine}" + + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDefaultPageAttribute(); + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckDefaultPageAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckDefaultPageAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..ceeaa66b --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..36083811 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/InvalidDefaultPage.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/InvalidDefaultPage.xml new file mode 100644 index 00000000..a2fb9f2d --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/InvalidDefaultPage.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + Main + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..56dd71b3 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnexistingPage.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnexistingPage.xml new file mode 100644 index 00000000..1cf25705 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnexistingPage.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnsupportedPage.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnsupportedPage.xml new file mode 100644 index 00000000..c0c961d9 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UnsupportedPage.xml @@ -0,0 +1,46 @@ + + + + + ParamOnGeneralPage + + true + + + popupPage + 0 + 0 + + + + + + PageButton + write + + other + next param + string + + + true + + + General + 0 + 0 + + + + + pagebutton + + + popup... + popupPage + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..142af8c1 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..5d73f152 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDefaultPageAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDisplayTag/CheckDisplayTag.cs b/ProtocolTests/Protocol/Display/CheckDisplayTag/CheckDisplayTag.cs new file mode 100644 index 00000000..1a37e764 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDisplayTag/CheckDisplayTag.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.Display.CheckDisplayTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Display.CheckDisplayTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckDisplayTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckDisplayTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckDisplayTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.28.1", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Protocol/Display'.", + HowToFix = "", + ExampleCode = "", + Details = "The Protocol/Display tag is mandatory in order to define how pages should be displayed (default page, page order, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDisplayTag(); + + [TestMethod] + public void Protocol_CheckDisplayTag_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckDisplayTag_CheckId() => Generic.CheckId(check, CheckId.CheckDisplayTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..a8df301d --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..9d76ccf1 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/CheckPageOrderAttribute.cs b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/CheckPageOrderAttribute.cs new file mode 100644 index 00000000..c0607afa --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/CheckPageOrderAttribute.cs @@ -0,0 +1,600 @@ +namespace SLDisValidatorUnitTests.Protocol.Display.CheckPageOrderAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Display.CheckPageOrderAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckPageOrderAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_ValidWithDVE() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidWithDVE.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_ValidWithDVEs() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidWithDVEs.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_ValidWithoutWebPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidWithoutWebPage.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_ValidWithWebPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidWithWebPage.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_DuplicateEntries() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateEntries", + ExpectedResults = new List + { + Error.DuplicateEntries(null, null, null, "General"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingPage", + ExpectedResults = new List + { + Error.MissingPage(null, null, null, "Main").WithSubResults( + Error.MissingPage_Sub(null, null, null, "101", "Main"), + Error.MissingPage_Sub(null, null, null, "102", "Main")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingWebPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingWebPage", + ExpectedResults = new List + { + Error.MissingWebPage(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay check")] + public void Protocol_CheckPageOrderAttribute_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + Error.ReferencedParamRTDisplayExpected(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UnexistingPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexistingPage", + ExpectedResults = new List + { + Error.UnexistingPage(null, null, null, "Main"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UnsupportedPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedPage", + ExpectedResults = new List + { + Error.UnsupportedPage(null, null, null, "Settings"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "General "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_WrongWebPagePosition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WrongWebPagePosition", + ExpectedResults = new List + { + Error.WrongWebPagePosition(null, null, null, "Web Interface#http://[Polling Ip]/"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckPageOrderAttribute(); + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_DuplicateEntries() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "DuplicateEntries", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UnsupportedPage() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnsupportedPage", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.22.1", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Missing attribute 'pageOrder'.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.22.2", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Empty attribute 'pageOrder'.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.22.3", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Untrimmed attribute 'pageOrder'. Current value 'ABC'.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UnsupportedPage() + { + // Create ErrorMessage + var message = Error.UnsupportedPage(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.22.4", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Unsupported popup page 'ABC' in 'Protocol/Display@pageOrder' attribute.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingPage() + { + // Create ErrorMessage + var message = Error.MissingPage(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "1.22.5", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Missing page 'ABC' on 'Protocol/Display@pageOrder' attribute.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingWebPage() + { + // Create ErrorMessage + var message = Error.MissingWebPage(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 6, + FullId = "1.22.6", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Missing WebInterface page.", + HowToFix = "Make sure the webInterface page(s) are defined as last and preceded by a separator page.", + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_WrongWebPagePosition() + { + // Create ErrorMessage + var message = Error.WrongWebPagePosition(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 7, + FullId = "1.22.7", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Web page 'ABC' should be defined after all regular pages and the first web page should be preceded by a separator.", + HowToFix = "Make sure the webInterface page(s) are defined as last and preceded by a separator page.", + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_UnexistingPage() + { + // Create ErrorMessage + var message = Error.UnexistingPage(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 8, + FullId = "1.22.8", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "The specified page 'ABC' does not exist.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_DuplicateEntries() + { + // Create ErrorMessage + var message = Error.DuplicateEntries(null, null, null, "ABC"); + + var expected = new ValidationResult + { + ErrorId = 9, + FullId = "1.22.9", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Page 'ABC' has been added more than once to the pageOrder attribute.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = true + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_MissingPage_Sub() + { + // Create ErrorMessage + var message = Error.MissingPage_Sub(null, null, null, "1", "ABC"); + + var expected = new ValidationResult + { + ErrorId = 10, + FullId = "1.22.10", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = String.Empty, + Description = "Param with ID '1' is positioned on page 'ABC' which is not ordered via 'Protocol/Display@pageOrder' attribute.", + HowToFix = String.Empty, + ExampleCode = "", + Details = "Skyline recommends the following structure for driver pages:" + Environment.NewLine + "- General" + Environment.NewLine + "- -----------" + Environment.NewLine + "- Data Page(s)" + Environment.NewLine + "- -----------" + Environment.NewLine + "- WebInterface", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckPageOrderAttribute(); + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckPageOrderAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckPageOrderAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/DuplicateEntries.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/DuplicateEntries.xml new file mode 100644 index 00000000..47c118d1 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/DuplicateEntries.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UnsupportedPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UnsupportedPage.xml new file mode 100644 index 00000000..cccb951d --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UnsupportedPage.xml @@ -0,0 +1,40 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + PageButtonOnGeneral + + true + + + General + 1 + 0 + + + + + pagebutton + + + Settings... + Settings + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..585674d2 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,19 @@ + + virtual + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/DuplicateEntries.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/DuplicateEntries.xml new file mode 100644 index 00000000..f1b16c1e --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/DuplicateEntries.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..ca9cf042 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..56dd71b3 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingPage.xml new file mode 100644 index 00000000..625926ff --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingPage.xml @@ -0,0 +1,53 @@ + + + + + + + GeneralPage_Param1 + + true + + + General + + + + + + GeneralPage_Param2 + + true + + + General + + + + + + + MaingPage_Param1 + + true + + + Main + + + + + + MaingPage_Param2 + + true + + + Main + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingWebPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingWebPage.xml new file mode 100644 index 00000000..db0a1a63 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/MissingWebPage.xml @@ -0,0 +1,29 @@ + + + snmp + + + + PageButtonOnGeneralPage + + true + + + General + 0 + 0 + + + + + pagebutton + + + Test... + Test + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..df5c90d3 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,29 @@ + + + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..bd6b92eb --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,29 @@ + + + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + + WebInterfaceURL + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnexistingPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnexistingPage.xml new file mode 100644 index 00000000..8e2c14a3 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnexistingPage.xml @@ -0,0 +1,18 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnsupportedPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnsupportedPage.xml new file mode 100644 index 00000000..b599ede6 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UnsupportedPage.xml @@ -0,0 +1,40 @@ + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + PageButtonOnGeneral + + true + + + General + 1 + 0 + + + + + pagebutton + + + Settings... + Settings + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..eaefbd9b --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,19 @@ + + virtual + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/WrongWebPagePosition.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/WrongWebPagePosition.xml new file mode 100644 index 00000000..7e2c2cff --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Invalid/WrongWebPagePosition.xml @@ -0,0 +1,19 @@ + + snmpv2 + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..cc32795b --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,23 @@ + + + + snmp + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVE.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVE.xml new file mode 100644 index 00000000..36c60c33 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVE.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + GeneralPage_Param1 + + true + + + General + + + + + + + Dve1000_Param1 + + false + + + DVE Standalone + + + + + + + DVE1000_Table1 + array + + + + + + true + + + General + + + + + table + + + + DVE1000_Table1_Instance + read + + true + + + DVE Read Column + + + + + + DVE1000_Table1_Column2 + read + + true + + + DVE Read Column + + + + + + DVE1000_Table1_Column2 + write + + true + + + DVE Write Column + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVEs.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVEs.xml new file mode 100644 index 00000000..72f6bdf5 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithDVEs.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + GeneralPage_Param1 + + true + + + General + + + + + + + Dve1000_Param1 + + false + + + DVE Page 1000 + + + + + + + DVE1000_Table1 + array + + + + + true + + + table + + + + DVE1000_Table1_Instance + read + + true + + + + DVE1000_Table1_Column2 + read + + true + + + + DVE1000_Table1_Column2 + write + + true + + + + + Dve2000_Param1 + + false + + + DVE Page 2000 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithWebPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithWebPage.xml new file mode 100644 index 00000000..29fdab94 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithWebPage.xml @@ -0,0 +1,31 @@ + + + + snmp + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + + WebInterfaceURL + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithoutWebPage.xml b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithoutWebPage.xml new file mode 100644 index 00000000..c5f5671b --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckPageOrderAttribute/Samples/Validate/Valid/ValidWithoutWebPage.xml @@ -0,0 +1,21 @@ + + + + + + + ParamOnGeneralPage + + true + + + General + 0 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/CheckWideColumnPagesAttribute.cs b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/CheckWideColumnPagesAttribute.cs new file mode 100644 index 00000000..190b7c58 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/CheckWideColumnPagesAttribute.cs @@ -0,0 +1,222 @@ +namespace SLDisValidatorUnitTests.Protocol.Display.CheckWideColumnPagesAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Display.CheckWideColumnPagesAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckWideColumnPagesAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_ValidNoPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNoPage", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_ValidNoWidePage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNoWidePage", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + [Ignore("Disabled as long as the Display Editor automatically adds the empty attribute.")] + public void Protocol_CheckWideColumnPagesAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_UnexistingPage() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexistingPage", + ExpectedResults = new List + { + Error.UnexistingPage(null, null, null, "unexistingPage"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " Wide Page 1;Wide Page 2 ; Wide Page 3 ") + .WithSubResults( + Error.UntrimmedAttribute(null, null, null, " Wide Page 1"), + Error.UntrimmedAttribute(null, null, null, "Wide Page 2 "), + Error.UntrimmedAttribute(null, null, null, " Wide Page 3 ")), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckWideColumnPagesAttribute(); + + [TestMethod] + [Ignore("Disabled as long as the Display Editor automatically adds the empty attribute.")] + public void Protocol_CheckWideColumnPagesAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_UnexistingPage() + { + // Create ErrorMessage + var message = Error.UnexistingPage(null, null, null, "pageName"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.29.2", + Category = Category.Protocol, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "The page 'pageName' specified in 'Protocol/Display@wideColumnPages' does not exist.", + HowToFix = "", + ExampleCode = "", + Details = "The Protocol/Display@wideColumnPages allows to define a semicolon list of pages that should take the whole width available even if it only contains 1 column." + Environment.NewLine + "It should refer to pages that are present in the Protocol/Display@pageOrder attribute and on which at least one parameter is displayed.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "untrimmedValue"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.29.3", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'wideColumnsPages'. Current value 'untrimmedValue'.", + HowToFix = "", + ExampleCode = "", + Details = "The Protocol/Display@wideColumnPages allows to define a semicolon list of pages that should take the whole width available even if it only contains 1 column." + Environment.NewLine + "It should refer to pages that are present in the Protocol/Display@pageOrder attribute and on which at least one parameter is displayed.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckWideColumnPagesAttribute(); + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckWideColumnPagesAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckWideColumnPagesAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..c9229fe2 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..b71c89ba --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,40 @@ + + + + + + WidePage1 + + true + + + Wide Page 1 + + + + + + WidePage2 + + true + + + Wide Page 2 + + + + + + WidePage3 + + true + + + Wide Page 3 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..d2b7be16 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UnexistingPage.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UnexistingPage.xml new file mode 100644 index 00000000..8820a963 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UnexistingPage.xml @@ -0,0 +1,18 @@ + + + + + + ParamOnGeneralPage + + true + + + General + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..95258105 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,40 @@ + + + + + + WidePage1 + + true + + + Wide Page 1 + + + + + + WidePage2 + + true + + + Wide Page 2 + + + + + + WidePage3 + + true + + + Wide Page 3 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..5e3c4115 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,52 @@ + + + + + + NormalPage1 + + true + + + Normal Page 1 + + + + + + NormalPage2 + + true + + + Normal Page 2 + + + + + + + WidePage1 + + true + + + Wide Page 1 + + + + + + WidePage2 + + true + + + Wide Page 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoPage.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoPage.xml new file mode 100644 index 00000000..ff816351 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoPage.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoWidePage.xml b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoWidePage.xml new file mode 100644 index 00000000..3ba61709 --- /dev/null +++ b/ProtocolTests/Protocol/Display/CheckWideColumnPagesAttribute/Samples/Validate/Valid/ValidNoWidePage.xml @@ -0,0 +1,29 @@ + + + + + + NormalPage1 + + true + + + Normal Page 1 + + + + + + NormalPage2 + + true + + + Normal Page 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/CheckOverridePidAttribute.cs b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/CheckOverridePidAttribute.cs new file mode 100644 index 00000000..6033d1cb --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/CheckOverridePidAttribute.cs @@ -0,0 +1,298 @@ +namespace SLDisValidatorUnitTests.Protocol.Display.Pages.Page.Visibility.CheckOverridePidAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Display.Pages.Page.Visibility.CheckOverridePidAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOverridePidAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "Empty"), + Error.EmptyAttribute(null, null, null, "Spaces"), + Error.EmptyAttribute(null, null, null, "Enters"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "Page1_Missing"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, "10 ", "Page1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by check on RTDisplay tag")] + public void Protocol_CheckOverridePidAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + ////Error.ReferencedParamExpectingRTDisplay(null, null, null, "10", "RTDisplay_False"), + ////Error.ReferencedParamExpectingRTDisplay(null, null, null, "11", "NoRTDisplay"), + ////Error.ReferencedParamExpectingRTDisplay(null, null, null, "12", "NoDisplay"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "Leading", " 10"), + Error.UntrimmedAttribute(null, null, null, "Trailing", "11 "), + Error.UntrimmedAttribute(null, null, null, "LeadingAndTrailing", " 12 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckOverridePidAttribute(); + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckOverridePidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "pageName"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "1.27.2", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Page.Visibility@overridePID' in Page 'pageName'.", + HowToFix = "", + ExampleCode = "", + Details = "The attribute 'Visibility@overridePID' is mandatory within a Page/Visibility tag. It should refer to the ID of an existing Param. The referenced Param should have its RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "pageName"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "1.27.1", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'Page.Visibility@overridePID' in Page 'pageName'.", + HowToFix = "", + ExampleCode = "", + Details = "The attribute 'Visibility@overridePID' is mandatory within a Page/Visibility tag. It should refer to the ID of an existing Param. The referenced Param should have its RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "pid", "pageName"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "1.27.4", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Page.Visibility@overridePID' references a non-existing 'Param' with ID 'pid'. Page Name 'pageName'.", + HowToFix = "", + ExampleCode = "", + Details = "The attribute 'Visibility@overridePID' is mandatory within a Page/Visibility tag. It should refer to the ID of an existing Param. The referenced Param should have its RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_ReferencedParamExpectingRTDisplay() + { + // Create ErrorMessage + var message = Error.ReferencedParamExpectingRTDisplay(null, null, null, "pid", "pageName"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "1.27.5", + Category = Category.Protocol, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param 'pid' used as page visibility condition. Page name 'pageName'.", + HowToFix = "", + ExampleCode = "", + Details = "The attribute 'Visibility@overridePID' is mandatory within a Page/Visibility tag. It should refer to the ID of an existing Param. The referenced Param should have its RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "pageName", "untrimmedValue"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "1.27.3", + Category = Category.Protocol, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Page.Visibility@overridePID' in Page 'pageName'. Current value 'untrimmedValue'.", + HowToFix = "", + ExampleCode = "", + Details = "The attribute 'Visibility@overridePID' is mandatory within a Page/Visibility tag. It should refer to the ID of an existing Param. The referenced Param should have its RTDisplay tag set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOverridePidAttribute(); + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Protocol); + + [TestMethod] + public void Protocol_CheckOverridePidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckOverridePidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..94ac105b --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,44 @@ + + + + + + Leading + + + + Trailing + + + + LeadingAndTrailing + + + + + + + + PageVisibility_Leading + read + + true + + + + PageVisibility_Trailing + read + + true + + + + PageVisibility_LeadingAndTrailing + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..850594b8 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,21 @@ + + + + + + Empty + + + + Spaces + + + + Enters + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..1338d404 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,12 @@ + + + + + + Page1_Missing + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..97b6e6b5 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,12 @@ + + + + + + Page1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..a1a2a022 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,44 @@ + + + + + + RTDisplay_False + + + + NoRTDisplay + + + + NoDisplay + + + + + + + + PageVisibility_RTDisplay_False + read + + false + + + + PageVisibility_NoRTDisplay + read + + + + + + PageVisibility_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..00640634 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,44 @@ + + + + + + Leading + + + + Trailing + + + + LeadingAndTrailing + + + + + + + + PageVisibility_Leading + read + + true + + + + PageVisibility_Trailing + read + + true + + + + PageVisibility_LeadingAndTrailing + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..78695049 --- /dev/null +++ b/ProtocolTests/Protocol/Display/Pages/Page/Visibility/CheckOverridePidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,35 @@ + + + + + + Page1 + + + + + + + + PageVisibility_Page1 + read + + true + + + discreet + + + Hide + 0 + + + Display + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/CheckElementTypeTag.cs b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/CheckElementTypeTag.cs new file mode 100644 index 00000000..7485d371 --- /dev/null +++ b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/CheckElementTypeTag.cs @@ -0,0 +1,88 @@ +namespace SLDisValidatorUnitTests.Protocol.ElementType.CheckElementTypeTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ElementType.CheckElementTypeTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckElementTypeTag(); + + [TestMethod] + public void Protocol_CheckElementTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckElementTypeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag.xml", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckElementTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag.xml", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckElementTypeTag_WhiteSpacesTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WhiteSpacesTag.xml", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckElementTypeTag(); + + [TestMethod] + public void Protocol_CheckElementTypeTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckElementTypeTag_CheckId() => Generic.CheckId(root, CheckId.CheckElementTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..ea543ff8 --- /dev/null +++ b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/WhiteSpacesTag.xml b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/WhiteSpacesTag.xml new file mode 100644 index 00000000..714476b0 --- /dev/null +++ b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Invalid/WhiteSpacesTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..30947151 --- /dev/null +++ b/ProtocolTests/Protocol/ElementType/CheckElementTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + Analyzer + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/CheckTableAttribute.cs b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/CheckTableAttribute.cs new file mode 100644 index 00000000..a6a2c9ca --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/CheckTableAttribute.cs @@ -0,0 +1,183 @@ +namespace SLDisValidatorUnitTests.Protocol.ExportRules.ExportRule.CheckTableAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ExportRules.ExportRule.CheckTableAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTableAttribute(); + + #region Valid Checks + + [TestMethod] + public void ExportRule_CheckTableAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ExportRule_CheckTableAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ExportRule_CheckTableAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + string description = "Empty attribute 'ExportRule@table'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0"); + + string description = "Invalid value '0' in attribute 'ExportRule@table'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + string description = "Missing attribute 'ExportRule@table'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void ExportRule_CheckTableAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = "Attribute 'ExportRule@table' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTableAttribute(); + + [TestMethod] + public void ExportRule_CheckTableAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ExportRule); + + [TestMethod] + public void ExportRule_CheckTableAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckTableAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..de32147d --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..8cf4e566 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..887ba7b0 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..e7e14405 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..e93524a1 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3fbf0566 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckTableAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/CheckWhereAttributeAttribute.cs b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/CheckWhereAttributeAttribute.cs new file mode 100644 index 00000000..f3d86fc9 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/CheckWhereAttributeAttribute.cs @@ -0,0 +1,132 @@ +namespace SLDisValidatorUnitTests.Protocol.ExportRules.ExportRule.CheckWhereAttributeAttribute +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ExportRules.ExportRule.CheckWhereAttributeAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckWhereAttributeAttribute(); + + #region Valid Checks + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " id "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'ExportRule@whereAttribute'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "untrimmedValue"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'ExportRule@whereAttribute'. Current value 'untrimmedValue'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckWhereAttributeAttribute(); + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ExportRule); + + [TestMethod] + public void ExportRule_CheckWhereAttributeAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckWhereAttributeAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..357d0ca4 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..9e3000e9 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e2dad42b --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereAttributeAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/CheckWhereTagAttribute.cs b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/CheckWhereTagAttribute.cs new file mode 100644 index 00000000..b3484a9f --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/CheckWhereTagAttribute.cs @@ -0,0 +1,170 @@ +namespace SLDisValidatorUnitTests.Protocol.ExportRules.ExportRule.CheckWhereTagAttribute +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ExportRules.ExportRule.CheckWhereTagAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckWhereTagAttribute(); + + #region Valid Checks + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " Protocol/Params/Param/Name "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'ExportRule@whereTag'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'ExportRule@whereTag'.", + Details = "As soon as whereValue or whereAttribute is being used, the whereTag is needed.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "untrimmedValue"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'ExportRule@whereTag'. Current value 'untrimmedValue'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckWhereTagAttribute(); + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ExportRule); + + [TestMethod] + public void ExportRule_CheckWhereTagAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckWhereTagAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..9a3fed8c --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..3370d65a --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..36cda253 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e2dad42b --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereTagAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/CheckWhereValueAttribute.cs b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/CheckWhereValueAttribute.cs new file mode 100644 index 00000000..e32f2f75 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/CheckWhereValueAttribute.cs @@ -0,0 +1,96 @@ +namespace SLDisValidatorUnitTests.Protocol.ExportRules.ExportRule.CheckWhereValueAttribute +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ExportRules.ExportRule.CheckWhereValueAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckWhereValueAttribute(); + + #region Valid Checks + + [TestMethod] + public void ExportRule_CheckWhereValueAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ExportRule_CheckWhereValueAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ExportRule_CheckWhereValueAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'ExportRule@whereValue'.", + Details = "As soon as whereTag or whereAttribute is being used, the whereValue is needed.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckWhereValueAttribute(); + + [TestMethod] + public void ExportRule_CheckWhereValueAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ExportRule); + + [TestMethod] + public void ExportRule_CheckWhereValueAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckWhereValueAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..7baa94e9 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..eb2744f1 --- /dev/null +++ b/ProtocolTests/Protocol/ExportRules/ExportRule/CheckWhereValueAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/CheckConnectionPidAttribute.cs b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/CheckConnectionPidAttribute.cs new file mode 100644 index 00000000..dc9b4141 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/CheckConnectionPidAttribute.cs @@ -0,0 +1,152 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.CheckConnectionPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.CheckConnectionPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConnectionPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckConnectionPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckConnectionPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckConnectionPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckConnectionPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckConnectionPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckConnectionPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'connectionPid' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckConnectionPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1"); + + string description = "Invalid value '0' in attribute 'connectionPid'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckConnectionPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'connectionPid' references a non-existing 'Param' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConnectionPidAttribute(); + + [TestMethod] + public void Group_CheckConnectionPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckConnectionPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckConnectionPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..d5749f4c --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..4334196f --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..bf5dd488 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..13d75544 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e272933b --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckConnectionPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..7a97c2f4 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,335 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_ValidHttp() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidHttp", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_ValidVirtual() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidVirtual", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Group_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "4.8.5", + Category = Category.Group, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Group with same ID '2'. Group Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each group." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each group should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "4.8.2", + Category = Category.Group, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Group@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each group." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each group should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "4.8.4", + Category = Category.Group, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Group@id'. Group name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each group." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each group should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "4.8.1", + Category = Category.Group, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Group@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each group." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each group should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "4.8.3", + Category = Category.Group, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Group@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each group." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each group should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Group_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..54cbd655 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..44eea046 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..bf1de466 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..215bb559 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..6bfc10cc --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..03d4fa29 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..672632f8 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,18 @@ + + + + + + + + Classic Group 1 + + + + Classic Group 1000 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidHttp.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidHttp.xml new file mode 100644 index 00000000..5a43bc1a --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidHttp.xml @@ -0,0 +1,19 @@ + + http + + + + + Ping Group + + + + Classic Group 1 + + + + Classic Group 1000 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidVirtual.xml b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidVirtual.xml new file mode 100644 index 00000000..2e15a001 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/CheckIdAttribute/Samples/Validate/Valid/ValidVirtual.xml @@ -0,0 +1,19 @@ + + virtual + + + + + + + Classic Group 1 + + + + Classic Group 1000 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..273ae9f1 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Condition.CheckConditionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "currentCondition", "reason", "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "4.9.1", + Category = Category.Group, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition 'currentCondition'. Reason 'reason'. Group ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Group/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "4.9.2", + Category = Category.Group, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Group/Condition' references a non-existing 'Param' with PID '2'. Group ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Group/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void Group_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..93360382 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..5f2be060 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,18 @@ + + + + + + string + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..cbe15cd5 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,8 @@ + + + + + 20]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..18c552e0 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/CheckActionTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/CheckActionTag.cs new file mode 100644 index 00000000..b3cc6c4b --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/CheckActionTag.cs @@ -0,0 +1,163 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.Action.CheckActionTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.Action.CheckActionTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckActionTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckActionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckActionTag_EmptyActionTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyActionTag", + ExpectedResults = new List + { + Error.EmptyActionTag(null, null, null, "1"), + Error.EmptyActionTag(null, null, null, "2"), + Error.EmptyActionTag(null, null, null, "3"), + Error.EmptyActionTag(null, null, null, "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckActionTag_InvalidActionTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidActionTag", + ExpectedResults = new List + { + Error.InvalidActionTag(null, null, null, "test1", "1"), + Error.InvalidActionTag(null, null, null, "test2", "2"), + Error.InvalidActionTag(null, null, null, "test3", "3"), + Error.InvalidActionTag(null, null, null, "test4", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckActionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3"), + Error.NonExistingId(null, null, null, "1004", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckActionTag_NonExistingIdNoActionsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoActionsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckActionTag_EmptyActionTag() + { + // Create ErrorMessage + var message = Error.EmptyActionTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Action' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckActionTag_InvalidActionTag() + { + // Create ErrorMessage + var message = Error.InvalidActionTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Action'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckActionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Action' references a non-existing 'Action' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckActionTag(); + + [TestMethod] + public void Group_CheckActionTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckActionTag_CheckId() => Generic.CheckId(check, CheckId.CheckActionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/EmptyActionTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/EmptyActionTag.xml new file mode 100644 index 00000000..9c5a47da --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/EmptyActionTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + 1 + + 3 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/InvalidActionTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/InvalidActionTag.xml new file mode 100644 index 00000000..d7165309 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/InvalidActionTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + test1 + + + + + 1 + test2 + 3 + + + + + test3 + test4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..979ab3fb --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1002 + 3 + + + + + 1003 + 1004 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingIdNoActionsTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingIdNoActionsTag.xml new file mode 100644 index 00000000..beb21e8a --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Invalid/NonExistingIdNoActionsTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..33df8c42 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Action/CheckActionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,39 @@ + + + + + 1 Action + + 1 + + + + 3 Actions + + 1 + 2 + 3 + + + + + + Content Tag Empty 1 + + + + Content Tag Empty 2 + + + + Content Tag Not Present + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/CheckContentTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/CheckContentTag.cs new file mode 100644 index 00000000..ac2f3f08 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/CheckContentTag.cs @@ -0,0 +1,351 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.CheckContentTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.CheckContentTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckContentTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckContentTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckContentTag_Valid_Only1EmptyGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_Only1EmptyGroup", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckContentTag_IncompatibleContentWithGroupType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IncompatibleContentWithGroupType", + ExpectedResults = new List + { + // Groups of type 'action' + ////Error.IncompatibleContentWithGroupType(null, null, null, "action", "Action", "1"), // Valid + Error.IncompatibleContentWithGroupType(null, null, null, "action", "Pair", "2"), + Error.IncompatibleContentWithGroupType(null, null, null, "action", "Pair", "2"), + Error.IncompatibleContentWithGroupType(null, null, null, "action", "Param", "3"), + Error.IncompatibleContentWithGroupType(null, null, null, "action", "Session", "4"), + Error.IncompatibleContentWithGroupType(null, null, null, "action", "Trigger", "5"), + + // Groups of type 'poll' (explicit) + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Action", "101"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Action", "101"), + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Pair", "102"), // Valid + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Param", "103"), // Valid + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Session", "104"), // Valid + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Trigger", "105"), + + // Groups of type 'poll' (implicit) + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Action", "151"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Action", "151"), + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Pair", "152"), // Valid + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Param", "153"), // Valid + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Session", "154"), // Valid + Error.IncompatibleContentWithGroupType(null, null, null, "poll", "Trigger", "155"), + + // Groups of type 'poll action' + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Action", "201"), // Valid + Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Pair", "202"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Pair", "202"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Param", "203"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Session", "204"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll action", "Trigger", "205"), + + // Groups of type 'poll trigger' + Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Action", "301"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Action", "301"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Pair", "302"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Param", "303"), + Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Session", "304"), + ////Error.IncompatibleContentWithGroupType(null, null, null, "poll trigger", "Trigger", "305"), // Valid + + // Groups of type 'trigger' + Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Action", "401"), + Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Action", "401"), + Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Pair", "402"), + Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Param", "403"), + Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Session", "404"), + ////Error.IncompatibleContentWithGroupType(null, null, null, "trigger", "Trigger", "405"), // Valid + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckContentTag_MaxItems() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MaxItems", + ExpectedResults = new List + { + // Groups of type 'action' + ////Error.MaxItems(null, null, null, "1"), + + // Groups of type 'poll' (implicit) + Error.MaxItems(null, null, null, "102"), + + // Groups of type 'poll' (explicit) + Error.MaxItems(null, null, null, "152"), + + // Groups of type 'poll action' + ////Error.MaxItems(null, null, null, "201"), + + // Groups of type 'poll trigger' + ////Error.MaxItems(null, null, null, "305"), + + // Groups of type 'trigger' + ////Error.MaxItems(null, null, null, "405"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + + public void Group_CheckContentTag_MaxItemsMultipleGet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MaxItemsMultipleGet", + ExpectedResults = new List + { + Error.MaxItemsMultipleGet(null, null, null, "103"), + Error.MaxItemsMultipleGet(null, null, null, "153"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckContentTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckContentTag_MissingTag_MultiThreadedGroups() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag_MultiThreadedGroups", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + Error.MissingTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckContentTag_MixedTypes() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MixedTypes", + ExpectedResults = new List + { + Error.MixedTypes(null, null, null, "Pair;Param", "101"), + Error.MixedTypes(null, null, null, "Pair;Session", "102"), + Error.MixedTypes(null, null, null, "Pair;Param;Session", "103"), + + Error.MixedTypes(null, null, null, "Pair;Param", "111"), + Error.MixedTypes(null, null, null, "Param;Session", "112"), + Error.MixedTypes(null, null, null, "Pair;Param;Session", "113"), + + Error.MixedTypes(null, null, null, "Pair;Session", "121"), + Error.MixedTypes(null, null, null, "Param;Session", "122"), + Error.MixedTypes(null, null, null, "Pair;Param;Session", "123"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckContentTag_MaxItems() + { + // Create ErrorMessage + var message = Error.MaxItems(null, null, null, "groupId"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "4.10.4", + Category = Category.Group, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Group contains more than 10 content elements. Group ID 'groupId'.", + HowToFix = "", + ExampleCode = "", + Details = "It is recommended to limit the Group/Content to a max of 10 tags.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckContentTag_MaxItemsMultipleGet() + { + // Create ErrorMessage + var message = Error.MaxItemsMultipleGet(null, null, null, "groupId"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "4.10.3", + Category = Category.Group, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Group with 'multipleGet' true contains more than 20 content elements. Group ID 'groupId'.", + HowToFix = "", + ExampleCode = "", + Details = "When 'Content@multipleGet' is set to true. It recommended to limit the Group/Content to a max of 20 Param tags.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckContentTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "groupId"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "4.10.5", + Category = Category.Group, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Content' in Group 'groupId'.", + HowToFix = "", + ExampleCode = "", + Details = "Typically, a non-empty 'Group/Content' is mandatory on groups except for the following exceptional cases where the Content tag should be ommitted:" + Environment.NewLine + "- Multi-threaded groups" + Environment.NewLine + "- When the protocol doesn't have any group at all. In that case, it is needed to add a Group without any content.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Group_CheckContentTag_MixedTypes() + { + // Create ErrorMessage + var message = Error.MixedTypes(null, null, null, "contentTypes", "groupId"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "4.10.2", + Category = Category.Group, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unsupported mixed group content 'contentTypes'. Group ID 'groupId'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Group/Type, the Group/Content can only contain certain tags:" + Environment.NewLine + "- 'poll': Can contain multiple instances of one of the below tags but not a mix of them:" + Environment.NewLine + " - 'Param'" + Environment.NewLine + " - 'Pair'" + Environment.NewLine + " - 'Session'" + Environment.NewLine + "- 'action' / 'poll action': Can only contain Action tags." + Environment.NewLine + "- 'trigger' / 'poll trigger': Can only contain Trigger tags.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckContentTag(); + + [TestMethod] + public void Group_CheckContentTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckContentTag_CheckId() => Generic.CheckId(check, CheckId.CheckContentTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/IncompatibleContentWithGroupType.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/IncompatibleContentWithGroupType.xml new file mode 100644 index 00000000..eb24e692 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/IncompatibleContentWithGroupType.xml @@ -0,0 +1,228 @@ + + + + + + + GroupAction_ContentPair + action + + 1 + 2 + + + + GroupAction_ContentParam + action + + 1 + + + + GroupAction_ContentSession + action + + 1 + + + + GroupAction_ContentTrigger + action + + 1 + + + + + + GroupPoll_ContentAction + poll + + 1 + 2 + + + + + + + GroupPoll_ContentTrigger + poll + + 1 + + + + + + GroupPoll_Implicit_ContentAction + + 1 + 2 + + + + + + + GroupPoll_Implicit_ContentTrigger + + 1 + + + + + + + GroupPollAction_ContentPair + poll action + + 1 + 2 + + + + GroupPollAction_ContentParam + poll action + + 1 + + + + GroupPollAction_ContentSession + poll action + + 1 + + + + GroupPollAction_ContentTrigger + poll action + + 1 + + + + + + GroupPollTrigger_ContentAction + poll trigger + + 1 + 2 + + + + GroupPollTrigger_ContentPair + poll trigger + + 1 + + + + GroupPollTrigger_ContentParam + poll trigger + + 1 + + + + GroupPollTrigger_ContentSession + poll trigger + + 1 + + + + + + + GroupTrigger_ContentAction + trigger + + 1 + 2 + + + + GroupTrigger_ContentPair + trigger + + 1 + + + + GroupTrigger_ContentParam + trigger + + 1 + + + + GroupTrigger_ContentSession + trigger + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItems.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItems.xml new file mode 100644 index 00000000..2a436b78 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItems.xml @@ -0,0 +1,42 @@ + + + + + GroupPoll_ContentPair + poll + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + + + + + GroupPoll_Implicit_ContentPair + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItemsMultipleGet.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItemsMultipleGet.xml new file mode 100644 index 00000000..50cc26db --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MaxItemsMultipleGet.xml @@ -0,0 +1,66 @@ + + + + + GroupPoll_ContentParam + poll + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + + + + + GroupPoll_Implicit_ContentParam + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..c8e5ffd1 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,18 @@ + + + + + MissingTag + + + + + GroupPoll_ContentPair + poll + + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag_MultiThreadedGroups.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag_MultiThreadedGroups.xml new file mode 100644 index 00000000..3c8a9cb1 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MissingTag_MultiThreadedGroups.xml @@ -0,0 +1,41 @@ + + + + + MissingTag1 + poll + + + MissingTag2 + + + + + Multi-threaded Group 1.1 + + + Multi-threaded Group 1.2 + + + Multi-threaded Group 2.1 + poll + + + + + + MultiThread Timer 1 + + 10001 + 10002 + + + + MultiThread Timer 2 + + 10010 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MixedTypes.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MixedTypes.xml new file mode 100644 index 00000000..bd94ff38 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Invalid/MixedTypes.xml @@ -0,0 +1,83 @@ + + + + + GroupPoll_Pair_Param + poll + + 25 + 25 + + + + GroupPoll_Pair_Session + poll + + 25 + 25 + + + + GroupPoll_Pair_Param_Session + poll + + 25 + 25 + 25 + + + + + GroupPoll_Param_Pair + + + 25 + 25 + + + + GroupPoll_Param_Session + + + 25 + 25 + + + + GroupPoll_Param_Pair_Session + + + 25 + 25 + 25 + + + + + GroupPoll_Session_Pair + poll + + 25 + 25 + + + + GroupPoll_Session_Param + poll + + 25 + 25 + + + + GroupPoll_Session_Param_Pair + poll + + 25 + 25 + 25 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..075bc1ad --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,300 @@ + + + + + + GroupAction_ContentAction + action + + 1 + + + + + + + + GroupPoll_ContentPair + poll + + 1 + + + + GroupPoll_ContentParam + poll + + 1 + + + + GroupPoll_ContentSession + poll + + 1 + + + + + + + + GroupPoll_Implicit_ContentPair + + 1 + + + + GroupPoll_Implicit_ContentParam + + 1 + + + + GroupPoll_Implicit_ContentSession + + 1 + + + + + + + GroupPollAction_ContentAction + poll action + + 1 + + + + + + + + GroupPollTrigger_ContentTrigger + poll trigger + + 1 + + + + + + + GroupTrigger_ContentTrigger + trigger + + 1 + + + + + + GroupSize_PollParam + poll + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + GroupSize_PollParam_MultipleGet + poll + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + + + Multi-threaded Group 1.1 + + + Multi-threaded Group 1.2 + + + Multi-threaded Group 2.1 + poll + + + + + + Normal Timer 1 + + 1 + + + + + MultiThread Timer 1 + + 10001 + 10002 + + + + MultiThread Timer 2 + + 10010 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid_Only1EmptyGroup.xml b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid_Only1EmptyGroup.xml new file mode 100644 index 00000000..0a56d811 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/CheckContentTag/Samples/Validate/Valid/Valid_Only1EmptyGroup.xml @@ -0,0 +1,16 @@ + + + + + + Dummy Group + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/CheckPairTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/CheckPairTag.cs new file mode 100644 index 00000000..5357bba2 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/CheckPairTag.cs @@ -0,0 +1,166 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.Pair.CheckPairTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.Pair.CheckPairTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPairTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckPairTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckPairTag_EmptyPairTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyPairTag", + ExpectedResults = new List + { + Error.EmptyPairTag(null, null, null, "1"), + Error.EmptyPairTag(null, null, null, "2"), + Error.EmptyPairTag(null, null, null, "3"), + Error.EmptyPairTag(null, null, null, "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckPairTag_InvalidPairTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPairTag", + ExpectedResults = new List + { + Error.InvalidPairTag(null, null, null, "test1", "1"), + Error.InvalidPairTag(null, null, null, "test2", "2"), + Error.InvalidPairTag(null, null, null, "test3", "3"), + Error.InvalidPairTag(null, null, null, "test4", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckPairTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3"), + Error.NonExistingId(null, null, null, "1004", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckPairTag_NonExistingIdNoPairsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoPairsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckPairTag_EmptyPairTag() + { + // Create ErrorMessage + var message = Error.EmptyPairTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Pair' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckPairTag_InvalidPairTag() + { + // Create ErrorMessage + var message = Error.InvalidPairTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Pair'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckPairTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Pair' references a non-existing 'Pair' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } +} + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPairTag(); + + [TestMethod] + public void Group_CheckPairTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckPairTag_CheckId() => Generic.CheckId(check, CheckId.CheckPairTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/EmptyPairTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/EmptyPairTag.xml new file mode 100644 index 00000000..458cd5ad --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/EmptyPairTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + 1 + + 3 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/InvalidPairTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/InvalidPairTag.xml new file mode 100644 index 00000000..60f146a0 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/InvalidPairTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + test1 + + + + + 1 + test2 + 3 + + + + + test3 + test4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..705eb25a --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1002 + 3 + + + + + 1003 + 1004 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingIdNoPairsTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingIdNoPairsTag.xml new file mode 100644 index 00000000..230477a8 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Invalid/NonExistingIdNoPairsTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..7a46eda3 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Pair/CheckPairTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,39 @@ + + + + + 1 Pair + + 1 + + + + 3 Pairs + + 1 + 2 + 3 + + + + + + Content Tag Empty 1 + + + + Content Tag Empty 2 + + + + Content Tag Not Present + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/CheckParamTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/CheckParamTag.cs new file mode 100644 index 00000000..b5e32ed3 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/CheckParamTag.cs @@ -0,0 +1,236 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.Param.CheckParamTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.Param.CheckParamTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParamTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckParamTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckParamTag_EmptyParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyParamTag", + ExpectedResults = new List + { + Error.EmptyParamTag(null, null, null, "1"), + Error.EmptyParamTag(null, null, null, "2"), + Error.EmptyParamTag(null, null, null, "3"), + Error.EmptyParamTag(null, null, null, "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_InvalidParamSuffix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidParamSuffix", + ExpectedResults = new List + { + Error.InvalidParamSuffix(null, null, null, "typo", "1000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_InvalidParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidParamTag", + ExpectedResults = new List + { + Error.InvalidParamTag(null, null, null, "test1", "1"), + Error.InvalidParamTag(null, null, null, "test2", "2"), + Error.InvalidParamTag(null, null, null, "test3", "3"), + Error.InvalidParamTag(null, null, null, "test4", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3"), + Error.NonExistingId(null, null, null, "1004", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_ObsoleteSuffixTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ObsoleteSuffixTable", + ExpectedResults = new List + { + Error.ObsoleteSuffixTable(null, null, null, "1000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckParamTag_SuffixRequiresMultiThreadedTimer() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "SuffixRequiresMultiThreadedTimer", + ExpectedResults = new List + { + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "single", "999"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "instance", "999"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "tablev2", "999"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "getnext", "999"), + + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "single", "1000"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "instance", "1001"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "tablev2", "1002"), + Error.SuffixRequiresMultiThreadedTimer(null, null, null, "getnext", "1003"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckParamTag(); + + [TestMethod] + public void Group_CheckParamTag_ObsoleteSuffixTable() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ObsoleteSuffixTable", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckParamTag_EmptyParamTag() + { + // Create ErrorMessage + var message = Error.EmptyParamTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Param' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckParamTag_InvalidParamTag() + { + // Create ErrorMessage + var message = Error.InvalidParamTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Param'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + [TestMethod] + + public void Group_CheckParamTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Param' references a non-existing 'Param' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParamTag(); + + [TestMethod] + public void Group_CheckParamTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckParamTag_CheckId() => Generic.CheckId(check, CheckId.CheckParamTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Codefix/ObsoleteSuffixTable.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Codefix/ObsoleteSuffixTable.xml new file mode 100644 index 00000000..8371a22f --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Codefix/ObsoleteSuffixTable.xml @@ -0,0 +1,28 @@ + + + + + MultiThread_table + read + + + + + + MultiThreadSuffix_table + + 1000:tablev2 + + + + + + + MultiThread Timer + + 1000 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml new file mode 100644 index 00000000..4efeca1c --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + 1 + + 3 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamSuffix.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamSuffix.xml new file mode 100644 index 00000000..39a98110 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamSuffix.xml @@ -0,0 +1,28 @@ + + + + + MultiThread_typo + read + + + + + + MultiThreadSuffix_table + + 1000:typo + + + + + + + MultiThread Timer + + 1000 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml new file mode 100644 index 00000000..3ca61f9d --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + test1 + + + + + 1 + test2 + 3 + + + + + test3 + test4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..d7cccf45 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1002 + 3 + + + + + 1003 + 1004 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..9f92ead5 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/ObsoleteSuffixTable.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/ObsoleteSuffixTable.xml new file mode 100644 index 00000000..6707d56d --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/ObsoleteSuffixTable.xml @@ -0,0 +1,28 @@ + + + + + MultiThread_table + read + + + + + + MultiThreadSuffix_table + + 1000:table + + + + + + + MultiThread Timer + + 1000 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/SuffixRequiresMultiThreadedTimer.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/SuffixRequiresMultiThreadedTimer.xml new file mode 100644 index 00000000..45190115 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Invalid/SuffixRequiresMultiThreadedTimer.xml @@ -0,0 +1,89 @@ + + + + + SimpleParam_1 + + + SimpleParam_2 + + + SimpleParam_3 + + + + MultiThread_single + read + + + MultiThread_instance + read + + + MultiThread_tablev2 + read + + + MultiThread_getnext + read + + + + + + + MultiThread_AllOptions + + 1 + 1000:single + 1001:instance + 1002:tablev2 + 1003:getnext + + + + + MultiThread_single + + 1 + 1000:single + + + + MultiThread_instance + + 1 + 1001:instance + + + + MultiThread_tablev2 + + 1 + 1002:tablev2 + + + + MultiThread_getnext + + 1 + 1003:getnext + + + + + + + Normal Timer 1 + + 999 + + 1000 + 1001 + 1002 + 1003 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..28b0489b --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,117 @@ + + + + + SimpleParam_1 + + + SimpleParam_2 + + + SimpleParam_3 + + + + MultiThread_single + read + + + MultiThread_instance + read + + + MultiThread_tablev2 + read + + + MultiThread_getnext + read + + + + + + 1 Param + + 1 + + + + 3 Params + + 1 + 2 + 3 + + + + + + Content Tag Empty 1 + + + + Content Tag Empty 2 + + + + Content Tag Not Present + + + + + MultiThread_AllOptions + + 1 + 1000:single + 1001:instance + 1002:tablev2 + 1003:getnext + + + + + MultiThread_single + + 1 + 1000:single + + + + MultiThread_instance + + 1 + 1001:instance + + + + MultiThread_tablev2 + + 1 + 1002:tablev2 + + + + MultiThread_getnext + + 1 + 1003:getnext + + + + + + + MultiThread Timer + + 999 + + 1000 + 1001 + 1002 + 1003 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/CheckSessionTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/CheckSessionTag.cs new file mode 100644 index 00000000..92ad1c2e --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/CheckSessionTag.cs @@ -0,0 +1,163 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.Session.CheckSessionTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.Session.CheckSessionTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckSessionTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckSessionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckSessionTag_EmptySessionTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptySessionTag", + ExpectedResults = new List + { + Error.EmptySessionTag(null, null, null, "1"), + Error.EmptySessionTag(null, null, null, "2"), + Error.EmptySessionTag(null, null, null, "3"), + Error.EmptySessionTag(null, null, null, "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckSessionTag_InvalidSessionTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidSessionTag", + ExpectedResults = new List + { + Error.InvalidSessionTag(null, null, null, "test1", "1"), + Error.InvalidSessionTag(null, null, null, "test2", "2"), + Error.InvalidSessionTag(null, null, null, "test3", "3"), + Error.InvalidSessionTag(null, null, null, "test4", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckSessionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3"), + Error.NonExistingId(null, null, null, "1004", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckSessionTag_NonExistingIdNoHttpTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoHttpTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckSessionTag_EmptySessionTag() + { + // Create ErrorMessage + var message = Error.EmptySessionTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Session' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckSessionTag_InvalidSessionTag() + { + // Create ErrorMessage + var message = Error.InvalidSessionTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Session'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckSessionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Session' references a non-existing 'HTTP Session' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckSessionTag(); + + [TestMethod] + public void Group_CheckSessionTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckSessionTag_CheckId() => Generic.CheckId(check, CheckId.CheckSessionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/EmptySessionTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/EmptySessionTag.xml new file mode 100644 index 00000000..e59f945d --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/EmptySessionTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + 1 + + 3 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/InvalidSessionTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/InvalidSessionTag.xml new file mode 100644 index 00000000..b9f1af38 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/InvalidSessionTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + test1 + + + + + 1 + test2 + 3 + + + + + test3 + test4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..4c2ee86e --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1002 + 3 + + + + + 1003 + 1004 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingIdNoHttpTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingIdNoHttpTag.xml new file mode 100644 index 00000000..813f902c --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Invalid/NonExistingIdNoHttpTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..fedcfb93 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Session/CheckSessionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,39 @@ + + + + + 1 Session + + 1 + + + + 3 Sessions + + 1 + 2 + 3 + + + + + + Content Tag Empty 1 + + + + Content Tag Empty 2 + + + + Content Tag Not Present + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/CheckTriggerTag.cs b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/CheckTriggerTag.cs new file mode 100644 index 00000000..1a7b64ef --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/CheckTriggerTag.cs @@ -0,0 +1,166 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Content.Trigger.CheckTriggerTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Content.Trigger.CheckTriggerTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTriggerTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckTriggerTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckTriggerTag_EmptyTriggerTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTriggerTag", + ExpectedResults = new List + { + Error.EmptyTriggerTag(null, null, null, "1"), + Error.EmptyTriggerTag(null, null, null, "2"), + Error.EmptyTriggerTag(null, null, null, "3"), + Error.EmptyTriggerTag(null, null, null, "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckTriggerTag_InvalidTriggerTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTriggerTag", + ExpectedResults = new List + { + Error.InvalidTriggerTag(null, null, null, "test1", "1"), + Error.InvalidTriggerTag(null, null, null, "test2", "2"), + Error.InvalidTriggerTag(null, null, null, "test3", "3"), + Error.InvalidTriggerTag(null, null, null, "test4", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckTriggerTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3"), + Error.NonExistingId(null, null, null, "1004", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Group_CheckTriggerTag_NonExistingIdNoTriggersTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoTriggersTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Group_CheckTriggerTag_EmptyTriggerTag() + { + // Create ErrorMessage + var message = Error.EmptyTriggerTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Trigger' in Group '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckTriggerTag_InvalidTriggerTag() + { + // Create ErrorMessage + var message = Error.InvalidTriggerTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Trigger'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Group_CheckTriggerTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Trigger' references a non-existing 'Trigger' with ID '0'. Group ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTriggerTag(); + + [TestMethod] + public void Group_CheckTriggerTag_CheckCategory() => Generic.CheckCategory(check, Category.Group); + + [TestMethod] + public void Group_CheckTriggerTag_CheckId() => Generic.CheckId(check, CheckId.CheckTriggerTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/EmptyTriggerTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/EmptyTriggerTag.xml new file mode 100644 index 00000000..109db6e5 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/EmptyTriggerTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + 1 + + 3 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/InvalidTriggerTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/InvalidTriggerTag.xml new file mode 100644 index 00000000..4b893b1a --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/InvalidTriggerTag.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + test1 + + + + + 1 + test2 + 3 + + + + + test3 + test4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..21a7a202 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1 + 1002 + 3 + + + + + 1003 + 1004 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingIdNoTriggersTag.xml b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingIdNoTriggersTag.xml new file mode 100644 index 00000000..36f009f4 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Invalid/NonExistingIdNoTriggersTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..1d3344cc --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Content/Trigger/CheckTriggerTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,39 @@ + + + + + 1 Trigger + + 1 + + + + 3 Triggers + + 1 + 2 + 3 + + + + + + Content Tag Empty 1 + + + + Content Tag Empty 2 + + + + Content Tag Not Present + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..fa49c744 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Groups.Group.Name.CheckNameTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Groups.Group.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Group_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Group_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Group_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Group); + + [TestMethod] + public void Group_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..4ed8d41e --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b219c9b8 --- /dev/null +++ b/ProtocolTests/Protocol/Groups/Group/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..a28a391f --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "8.16.5", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one HTTP Session with same ID '2'. HTTP Session Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "8.16.2", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'HTTP/Session@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "8.16.4", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'HTTP/Session@id'. Session name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "8.16.1", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'HTTP/Session@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "8.16.3", + Category = Category.HTTP, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'HTTP/Session@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void HTTP_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..a4973e5d --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..4258abbf --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..3cfa29b0 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..88908b04 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..bf19505c --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..421420f5 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..952b20bc --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/CheckPasswordAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/CheckPasswordAttribute.cs new file mode 100644 index 00000000..b611c9db --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/CheckPasswordAttribute.cs @@ -0,0 +1,99 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckPasswordAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckPasswordAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPasswordAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPasswordAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPasswordAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPasswordAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPasswordAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'password' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPasswordAttribute(); + + [TestMethod] + public void HTTP_CheckPasswordAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPasswordAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPasswordAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..d935a424 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..a7ef3f42 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..9417c877 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckPasswordAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/CheckProxyPasswordAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/CheckProxyPasswordAttribute.cs new file mode 100644 index 00000000..3260bbfe --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/CheckProxyPasswordAttribute.cs @@ -0,0 +1,96 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckProxyPasswordAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckProxyPasswordAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckProxyPasswordAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'proxyPassword' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckProxyPasswordAttribute(); + + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckProxyPasswordAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckProxyPasswordAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..d1b60e08 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..e09b9fed --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..22a8f0fa --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyPasswordAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/CheckProxyServerAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/CheckProxyServerAttribute.cs new file mode 100644 index 00000000..370cf4c8 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/CheckProxyServerAttribute.cs @@ -0,0 +1,96 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckProxyServerAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckProxyServerAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckProxyServerAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckProxyServerAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckProxyServerAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckProxyServerAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckProxyServerAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'proxyServer' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckProxyServerAttribute(); + + [TestMethod] + public void HTTP_CheckProxyServerAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckProxyServerAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckProxyServerAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..e30cece7 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..23285f12 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a99ce68d --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyServerAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/CheckProxyUserAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/CheckProxyUserAttribute.cs new file mode 100644 index 00000000..fc91b4d4 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/CheckProxyUserAttribute.cs @@ -0,0 +1,96 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckProxyUserAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckProxyUserAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckProxyUserAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckProxyUserAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckProxyUserAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckProxyUserAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckProxyUserAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'proxyUser' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckProxyUserAttribute(); + + [TestMethod] + public void HTTP_CheckProxyUserAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckProxyUserAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckProxyUserAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..7794da63 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..8c1c1926 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..aed380bc --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckProxyUserAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/CheckUsernameAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/CheckUsernameAttribute.cs new file mode 100644 index 00000000..816b1fa2 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/CheckUsernameAttribute.cs @@ -0,0 +1,96 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.CheckUsernameAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.CheckUsernameAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckUsernameAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckUsernameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckUsernameAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckUsernameAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckUsernameAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'userName' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckUsernameAttribute(); + + [TestMethod] + public void HTTP_CheckUsernameAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckUsernameAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckUsernameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..dd2a9bdd --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..5e84d354 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f13c8503 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/CheckUsernameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..326afa15 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,311 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2", "1").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1", "1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2", "1")), + + Error.DuplicatedId(null, null, null, "201", "Duplicate_201_1, Duplicate_201_2, Duplicate_201_3", "2").WithSubResults( + Error.DuplicatedId(null, null, null, "201", "Duplicate_201_1", "2"), + Error.DuplicatedId(null, null, null, "201", "Duplicate_201_2", "2"), + Error.DuplicatedId(null, null, null, "201", "Duplicate_201_3", "2")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "1"), + + Error.InvalidValue(null, null, null, "-2", "2"), + Error.InvalidValue(null, null, null, "1.5", "2"), + Error.InvalidValue(null, null, null, "2,6", "2"), + Error.InvalidValue(null, null, null, "03", "2"), + Error.InvalidValue(null, null, null, "+4", "2"), + Error.InvalidValue(null, null, null, "5x10^1", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 101"), + Error.UntrimmedAttribute(null, null, null, "1", "102 "), + + Error.UntrimmedAttribute(null, null, null, "2", " 101 "), + Error.UntrimmedAttribute(null, null, null, "2", " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3", "4"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "8.17.5", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Connection with same ID '2' in HTTP Session '4'. Connection Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each connection within a session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each connection within a session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "8.17.2", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Connection@id' in HTTP Session '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each connection within a session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each connection within a session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "1"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "8.17.4", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Connection@id'. HTTP Session ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each connection within a session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each connection within a session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "8.17.1", + Category = Category.HTTP, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Connection@id' in HTTP Session '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each connection within a session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each connection within a session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void HTTP_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2", " a "); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "8.17.3", + Category = Category.HTTP, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Connection@id' in HTTP Session '2'. Current value ' a '.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each connection within a session." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each connection within a session should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void HTTP_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..81fdc576 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..e929ac52 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..f239a5ba --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..027f0f34 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..dd99b81e --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..a9e7bf2a --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..84cbd782 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..232ed377 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,152 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.CheckPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.CheckPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Request@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Request@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Request@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..60251cbd --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..0b5118fc --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..2438c831 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..282a830d --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..cc069f6e --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..17256271 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,152 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Data.CheckPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Data.CheckPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Request/Data@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Request/Data@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Request/Data@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..ed5b89c0 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..acf80df9 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..5ea2032f --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..469009e1 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0e6e9d10 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Data/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + test + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/CheckHeaders.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/CheckHeaders.cs new file mode 100644 index 00000000..b6e44293 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/CheckHeaders.cs @@ -0,0 +1,107 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Headers.CheckHeaders +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Headers.CheckHeaders; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckHeaders(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckHeaders_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckHeaders_DuplicateHeaderKeys() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateHeaderKeys", + ExpectedResults = new List + { + Error.DuplicateHeaderKeys(null, null, null, "Accept-Language", "1", "1", true).WithSubResults( + Error.DuplicateHeaderKeys(null, null, null, "Accept-Language", "1", "1", false), + Error.DuplicateHeaderKeys(null, null, null, "Accept-Language", "1", "1", false), + Error.DuplicateHeaderKeys(null, null, null, "Accept-Language", "1", "1", false), + Error.DuplicateHeaderKeys(null, null, null, "Accept-Language", "1", "1", false)), + Error.DuplicateHeaderKeys(null, null, null, "Max-Forwards", "1", "1", true).WithSubResults( + Error.DuplicateHeaderKeys(null, null, null, "Max-Forwards", "1", "1", false), + Error.DuplicateHeaderKeys(null, null, null, "Max-Forwards", "1", "1", false), + Error.DuplicateHeaderKeys(null, null, null, "Max-Forwards", "1", "1", false)) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckHeaders_MissingHeaderForVerb() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingHeaderForVerb", + ExpectedResults = new List + { + Error.MissingHeaderForVerb(null, null, null, "Content-Type", "POST", "1", "1"), + Error.MissingHeaderForVerb(null, null, null, "Content-Type", "PUT", "1", "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckHeaders(); + + [TestMethod] + public void HTTP_CheckHeaders_DuplicateHeaderKeys() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "DuplicateHeaderKeys", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckHeaders(); + + [TestMethod] + public void HTTP_CheckHeaders_CheckCategory() => Generic.CheckCategory(root, Category.HTTP); + + [TestMethod] + public void HTTP_CheckHeaders_CheckId() => Generic.CheckId(root, CheckId.CheckHeaders); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Codefix/DuplicateHeaderKeys.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Codefix/DuplicateHeaderKeys.xml new file mode 100644 index 00000000..b73bda07 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Codefix/DuplicateHeaderKeys.xml @@ -0,0 +1,14 @@ + + + + + + +
nl, en
+
10, 20, 30
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/DuplicateHeaderKeys.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/DuplicateHeaderKeys.xml new file mode 100644 index 00000000..f6b4c996 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/DuplicateHeaderKeys.xml @@ -0,0 +1,19 @@ + + + + + + +
en
+
10
+
nl
+
20
+
en
+
30
+
en
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/MissingHeaderForVerb.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/MissingHeaderForVerb.xml new file mode 100644 index 00000000..f18e28c5 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Invalid/MissingHeaderForVerb.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..05ef7b0a --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/CheckHeaders/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/CheckHeaderTag.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/CheckHeaderTag.cs new file mode 100644 index 00000000..da6d9791 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/CheckHeaderTag.cs @@ -0,0 +1,82 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckHeaderTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckHeaderTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckHeaderTag(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckHeaderTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckHeaderTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, " dsfqfdq "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckHeaderTag(); + + [TestMethod] + public void HTTP_CheckHeaderTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckHeaderTag(); + + [TestMethod] + public void HTTP_CheckHeaderTag_CheckCategory() => Generic.CheckCategory(root, Category.HTTP); + + [TestMethod] + public void HTTP_CheckHeaderTag_CheckId() => Generic.CheckId(root, CheckId.CheckHeaderTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..1fd3ed4c --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,13 @@ + + + + + + +
dsfqfdq
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..0247a730 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,13 @@ + + + + + + +
dsfqfdq
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e0f0d2fa --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckHeaderTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + +
myUser
+
+
+
+
+ + + + + + + +
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/CheckKeyAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/CheckKeyAttribute.cs new file mode 100644 index 00000000..b93721a0 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/CheckKeyAttribute.cs @@ -0,0 +1,196 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckKeyAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckKeyAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckKeyAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckKeyAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckKeyAttribute_EmptyKeyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyKeyAttribute", + ExpectedResults = new List + { + Error.EmptyKeyAttribute(null, null, null, "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_InvalidHeaderKeyForVerb() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidHeaderKeyForVerb", + ExpectedResults = new List + { + Error.InvalidHeaderKeyForVerb(null, null, null, "Content-Length", "GET", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_MissingKeyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingKeyAttribute", + ExpectedResults = new List + { + Error.MissingKeyAttribute(null, null, null, "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_RedundantHeaderKey() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RedundantHeaderKey", + ExpectedResults = new List + { + Error.RedundantHeaderKey(null, null, null, "User-Agent", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_UnknownHeaderKey() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnknownHeaderKey", + ExpectedResults = new List + { + Error.UnknownHeaderKey(null, null, null, "DMQSFlkjiaopjklma", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_UnsupportedHeaderKey() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedHeaderKey", + ExpectedResults = new List + { + Error.UnsupportedHeaderKey(null, null, null, Certainty.Certain, "Content-Length", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_UnsupportedHeaderKeyAcceptEncoding() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedHeaderKeyAcceptEncoding", + ExpectedResults = new List + { + Error.UnsupportedHeaderKey(null, null, null, Certainty.Uncertain, "Accept-Encoding", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void HTTP_CheckKeyAttribute_UntrimmedHeaderKey() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedHeaderKey", + ExpectedResults = new List + { + Error.UntrimmedHeaderKey(null, null, null, " Pragma ", "1", "1"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckKeyAttribute(); + + [TestMethod] + public void HTTP_CheckKeyAttribute_UntrimmedHeaderKey() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedHeaderKey", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckKeyAttribute(); + + [TestMethod] + public void HTTP_CheckKeyAttribute_CheckCategory() => Generic.CheckCategory(root, Category.HTTP); + + [TestMethod] + public void HTTP_CheckKeyAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckKeyAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Codefix/UntrimmedHeaderKey.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Codefix/UntrimmedHeaderKey.xml new file mode 100644 index 00000000..467e3d97 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Codefix/UntrimmedHeaderKey.xml @@ -0,0 +1,13 @@ + + + + + + +
value
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/EmptyKeyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/EmptyKeyAttribute.xml new file mode 100644 index 00000000..f44ff2f4 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/EmptyKeyAttribute.xml @@ -0,0 +1,13 @@ + + + + + + +
20
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/InvalidHeaderKeyForVerb.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/InvalidHeaderKeyForVerb.xml new file mode 100644 index 00000000..3d8a5a85 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/InvalidHeaderKeyForVerb.xml @@ -0,0 +1,13 @@ + + + + + + +
20
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/MissingKeyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/MissingKeyAttribute.xml new file mode 100644 index 00000000..85713add --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/MissingKeyAttribute.xml @@ -0,0 +1,13 @@ + + + + + + +
20
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/RedundantHeaderKey.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/RedundantHeaderKey.xml new file mode 100644 index 00000000..a6543e26 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/RedundantHeaderKey.xml @@ -0,0 +1,13 @@ + + + + + + +
DataMiner/1.0
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnknownHeaderKey.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnknownHeaderKey.xml new file mode 100644 index 00000000..ef7d6020 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnknownHeaderKey.xml @@ -0,0 +1,13 @@ + + + + + + +
20
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKey.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKey.xml new file mode 100644 index 00000000..4942ce68 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKey.xml @@ -0,0 +1,13 @@ + + + + + + +
20
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKeyAcceptEncoding.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKeyAcceptEncoding.xml new file mode 100644 index 00000000..1665fa7f --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UnsupportedHeaderKeyAcceptEncoding.xml @@ -0,0 +1,13 @@ + + + + + + +
pack200-gzip
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UntrimmedHeaderKey.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UntrimmedHeaderKey.xml new file mode 100644 index 00000000..9ef47164 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Invalid/UntrimmedHeaderKey.xml @@ -0,0 +1,13 @@ + + + + + + +
value
+
+
+
+
+
+
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f95fb0b5 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckKeyAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,25 @@ + + + + + + + +
value
+
+
+
+
+ + + + + +
value
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..f42f80a3 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,136 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Headers.Header.CheckPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Request/Headers/Header@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Request/Headers/Header@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Request/Headers/Header@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..1189cd57 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..393d2460 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..6aa050f1 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..272befb4 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + +
+
test
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..c71f36c7 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,154 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Request.Parameters.Parameter.CheckPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Request.Parameters.Parameter.CheckPidAttribute; + + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Request/Parameters/Parameter@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Request/Parameters/Parameter@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Parameter@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Skyline.DataMiner.CICD.Validators.Common.Model.Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..d4e1ff84 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..883cb4e8 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..af5e3987 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..af5e3987 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..1d1206d9 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Request/Parameters/Parameter/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + test + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/CheckStatusCodeAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/CheckStatusCodeAttribute.cs new file mode 100644 index 00000000..859ce4e9 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/CheckStatusCodeAttribute.cs @@ -0,0 +1,152 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Response.CheckStatusCodeAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Response.CheckStatusCodeAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckStatusCodeAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Response@statusCode' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Response@statusCode'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Response@statusCode' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckStatusCodeAttribute(); + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckStatusCodeAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckStatusCodeAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..22de5b4d --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..94cb5ec3 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..5043ab59 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..e74b3d8a --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0baefb83 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/CheckStatusCodeAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..ee47c744 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,155 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Response.Content.CheckPidAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Response.Content.CheckPidAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Response/Content@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Response/Content@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Response/Content@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..6cff5241 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..eaa3e8cd --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..8031badc --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..2dae4baf --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3979c3b5 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Content/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..ca1d8f7a --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,152 @@ +namespace SLDisValidatorUnitTests.Protocol.HTTP.Session.Connection.Response.Headers.Header.CheckPidAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.HTTP.Session.Connection.Response.Headers.Header.CheckPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1", "11") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void HTTP_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0", "11"); + + string description = "Empty attribute 'Response/Headers/Header@pid' in HTTP Session '0'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1", "11"); + + string description = "Invalid value '0' in attribute 'Response/Headers/Header@pid'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void HTTP_CheckPidAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1", "11"); + + string description = "Attribute 'Response/Headers/Header@pid' references a non-existing 'Param' with ID '0'. HTTP Session ID '1'. Connection ID '11'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.HTTP); + + [TestMethod] + public void HTTP_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..eb616424 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..29698b52 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..d18aa9cd --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..47bcb566 --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,15 @@ + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..466cce2a --- /dev/null +++ b/ProtocolTests/Protocol/HTTP/Session/Connection/Response/Headers/Header/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..46fb26d5 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,208 @@ +namespace SLDisValidatorUnitTests.Protocol.Name.CheckNameTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Name.CheckNameTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + [TestMethod] + public void Protocol_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, " TestName "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_WhiteSpaceTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WhiteSpacesTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_InvalidChars() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidChars", + ExpectedResults = new List + { + Error.InvalidChars(null, null, null, "Test/Name", "/"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_InvalidPrefix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPrefix", + ExpectedResults = new List + { + Error.InvalidPrefix(null, null, null, "Production TestName", "Production"), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckNameTag(); + + [TestMethod] + public void Protocol_CheckNameTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckNameTag_InvalidPrefix() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidPrefix", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckNameTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckNameTag_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "This.Is a Name-TTL Corp 13966-555 +(ZZ)", "This.Is a Name-TTL Corp 13966-555 -(ZZ)"), + } + }; + + Generic.Compare(compare, data); + } + + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Protocol_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/InvalidPrefix.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/InvalidPrefix.xml new file mode 100644 index 00000000..6779e2df --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/InvalidPrefix.xml @@ -0,0 +1,3 @@ + + TestName + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..6779e2df --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,3 @@ + + TestName + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..9ef81492 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,3 @@ + + This.Is a Name-TTL Corp 13966-555 -(ZZ) + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..678e5395 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,3 @@ + + This.Is a Name-TTL Corp 13966-555 +(ZZ) + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..c0d65afc --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,3 @@ + + This.Is a Name-TTL Corp 13966-555 +(ZZ) + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..678e5395 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,3 @@ + + This.Is a Name-TTL Corp 13966-555 +(ZZ) + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..eebf02c6 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml new file mode 100644 index 00000000..a2e6744f --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml @@ -0,0 +1,3 @@ + + Test/Name + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidPrefix.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidPrefix.xml new file mode 100644 index 00000000..c30c5d35 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/InvalidPrefix.xml @@ -0,0 +1,3 @@ + + Production TestName + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..8bb40212 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,3 @@ + + TestName + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/WhiteSpacesTag.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/WhiteSpacesTag.xml new file mode 100644 index 00000000..b26ccbf3 --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Invalid/WhiteSpacesTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6779e2df --- /dev/null +++ b/ProtocolTests/Protocol/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + TestName + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..f4fea47a --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Pair_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "9.3.5", + Category = Category.Pair, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Pair with same ID '2'. Pair Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each pair." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each pair should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "9.3.2", + Category = Category.Pair, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Pair@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each pair." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each pair should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "9.3.4", + Category = Category.Pair, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Pair@id'. Pair name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each pair." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each pair should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "9.3.1", + Category = Category.Pair, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Pair@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each pair." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each pair should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "9.3.3", + Category = Category.Pair, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Pair@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each pair." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each pair should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Pair_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..d1876a81 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..bdf481f1 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..1c3f6495 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..f77a8bde --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..3cf8994d --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..a6ffef61 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0de16270 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..52796153 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Condition.CheckConditionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "currentCondition", "reason", "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "9.7.1", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition 'currentCondition'. Reason 'reason'. Pair ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Pair/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "9.7.2", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Pair/Condition' references a non-existing 'Param' with PID '2'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Pair/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void Pair_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..f644d9b1 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..dba6e9db --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,18 @@ + + + + + + string + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..a3fda799 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,8 @@ + + + + + 20]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..05bb9b2e --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/CheckContentTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/CheckContentTag.cs new file mode 100644 index 00000000..ff16d463 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/CheckContentTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Content.CheckContentTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Content.CheckContentTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckContentTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckContentTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckContentTag_ValidEach() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidEach", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckContentTag_MissingClearResponseRoutine() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingClearResponseRoutine", + ExpectedResults = new List + { + // 1 command / 2 responses + Error.MissingClearResponseRoutine(null, null, null, "120").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "121", "122")), + Error.MissingClearResponseRoutine(null, null, null, "125").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "125", "126")), + + // 1 command / 3 responses : Clear others individually + Error.MissingClearResponseRoutine(null, null, null, "130").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "132,133", "131"), + Error.MissingClearResponseRoutine_Sub(null, null, null, "132", "133")), + + // 1 command / 3 responses : Clear others in bulk + Error.MissingClearResponseRoutine(null, null, null, "135").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "137,138", "136")), + + // 1 command / 3 responses : Clear itself + Error.MissingClearResponseRoutine(null, null, null, "140").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "141", "141"), + Error.MissingClearResponseRoutine_Sub(null, null, null, "143", "143")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckContentTag_MissingClearResponseRoutineEach() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingClearResponseRoutineEach", + ExpectedResults = new List + { + // 1 command / 2 responses + Error.MissingClearResponseRoutine(null, null, null, "120").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "122", "122")), + Error.MissingClearResponseRoutine(null, null, null, "125").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "126", "126")), + + // 1 command / 3 responses : Clear others individually + Error.MissingClearResponseRoutine(null, null, null, "130").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "132,133", "131"), + Error.MissingClearResponseRoutine_Sub(null, null, null, "131", "133")), + + // 1 command / 3 responses : Clear others in bulk + Error.MissingClearResponseRoutine(null, null, null, "135").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "137,138", "136")), + + // 1 command / 3 responses : Clear itself + Error.MissingClearResponseRoutine(null, null, null, "140").WithSubResults( + Error.MissingClearResponseRoutine_Sub(null, null, null, "141", "141"), + Error.MissingClearResponseRoutine_Sub(null, null, null, "143", "143")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckContentTag_MissingClearResponseRoutine() + { + // Create ErrorMessage + var message = Error.MissingClearResponseRoutine(null, null, null, "0"); + + string description = "Missing clear response routine for pair '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Pair_CheckContentTag_MissingClearResponseRoutineSub() + { + // Create ErrorMessage + var message = Error.MissingClearResponseRoutine_Sub(null, null, null, "0", "1"); + + string description = "Missing clear response '0' routine after response '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckContentTag(); + + [TestMethod] + public void Pair_CheckContentTag_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckContentTag_CheckId() => Generic.CheckId(check, CheckId.CheckContentTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutine.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutine.xml new file mode 100644 index 00000000..3a4f9b9c --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutine.xml @@ -0,0 +1,414 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1Command_2Responses + 1 Command - 2 Responses + + 100 + 121 + 122 + + + + 1Command_2Responses_With1ResponseOnBadCommand + 1 Command - 2 Responses - With 1 OnBadCommand + + 100 + 125 + 126 + + + + + 1Command_3Responses_ClearOthersIndividually + 1 Command - 3 Responses - Clear Others Individually + + 100 + 131 + 132 + 133 + + + + 1Command_3Responses_ClearOthersInBulk + 1 Command - 3 Responses - Clear Others In Bulk + + 100 + 136 + 137 + 138 + + + + 1Command_3Responses_ClearItself + 1 Command - 3 Responses - Clear Itself + + 100 + 141 + 142 + 143 + + + + + + + Command100 + Command 100 + + 1 + + + + + + + 1Command_2Responses_1 + 1 Command - 2 Responses - 1 + + 121 + + + + 1Command_2Responses_2 + 1 Command - 2 Responses - 2 + + 122 + + + + 1Command_2Responses_With1ResponseOnBadCommand_Normal1 + 1 Command - 2 Responses - With 1 OnBadCommand - Normal 1 + + 125 + + + + 1Command_2Responses_With1ResponseOnBadCommand_Bad1 + 1 Command - 2 Responses - With 1 OnBadCommand - Bad 1 + + 126 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + 1 Command - 3 Responses - Clear Others Individually - 1 + + 131 + + + + 1Command_3Responses_ClearOthersIndividually_2 + 1 Command - 3 Responses - Clear Others Individually - 2 + + 132 + + + + 1Command_3Responses_ClearOthersIndividually_3 + 1 Command - 3 Responses - Clear Others Individually - 3 + + 133 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + 1 Command - 3 Responses - Clear Others In Bulk - 1 + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + 1 Command - 3 Responses - Clear Others In Bulk - 2 + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + 1 Command - 3 Responses - Clear Others In Bulk - 3 + + 138 + + + + + 1Command_3Responses_ClearItself_1 + 1 Command - 3 Responses - Clear Itself - 1 + + 141 + + + + 1Command_3Responses_ClearItself_2 + 1 Command - 3 Responses - Clear Itself - 2 + + 142 + + + + 1Command_3Responses_ClearItself_3 + 1 Command - 3 Responses - Clear Itself - 3 + + 143 + + + + + + + 1Command_2Responses_1 + response + + action + + 122 + + + + + 1Command_2Responses_With1OnBadCommand_NormalResponse + response + + action + + 126 + + + + + + + 1Command_3Responses_ClearOthersIndividually_2 + response + + action + + 131 + 133 + + + + 1Command_3Responses_ClearOthersIndividually_3 + response + + action + + 131 + + + + + + + 1Command_3Responses_ClearOthersInBulk_2 + response + + action + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + response + + action + + 138 + + + + + 1Command_3Responses_ClearItself_1 + response + + action + + 1 + + + + + 1Command_3Responses_ClearItself_2 + response + + action + + 142 + + + + + + + + Noise Action 1 + parameter + run actions + + + Noise Action 2 + parameter + run actions + + + Noise Action 3 + parameter + run actions + + + + + Clear Response 122 + response + clear + + + + Clear Response 126 + response + clear + + + + Clear Response 131 + response + clear + + + + Clear Response 133 + response + clear + + + + + Clear Response 136;138 + response + clear + + + Clear Response 136;137 + response + clear + + + + Clear Response 141 + response + clear + + + Clear Response 142 + response + clear + + + Clear Response 143 + response + clear + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutineEach.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutineEach.xml new file mode 100644 index 00000000..13a57c95 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Invalid/MissingClearResponseRoutineEach.xml @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1Command_2Responses + 1 Command - 2 Responses + + 100 + 121 + 122 + + + + 1Command_2Responses_With1ResponseOnBadCommand + 1 Command - 2 Responses - With 1 OnBadCommand + + 100 + 125 + 126 + + + + 1Command_3Responses_ClearOthersIndividually + 1 Command - 3 Responses - Clear Others Individually + + 100 + 131 + 132 + 133 + + + + 1Command_3Responses_ClearOthersInBulk + 1 Command - 3 Responses - Clear Others In Bulk + + 100 + 136 + 137 + 138 + + + + 1Command_3Responses_ClearItself + 1 Command - 3 Responses - Clear Itself + + 100 + 141 + 142 + 143 + + + + + + + Command100 + Command 100 + + 1 + + + + + + + 1Command_2Responses_1 + 1 Command - 2 Responses - 1 + + 121 + + + + 1Command_2Responses_2 + 1 Command - 2 Responses - 2 + + 122 + + + + 1Command_2Responses_With1ResponseOnBadCommand_Normal1 + 1 Command - 2 Responses - With 1 OnBadCommand - Normal 1 + + 125 + + + + 1Command_2Responses_With1ResponseOnBadCommand_Bad1 + 1 Command - 2 Responses - With 1 OnBadCommand - Bad 1 + + 126 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + 1 Command - 3 Responses - Clear Others Individually - 1 + + 131 + + + + 1Command_3Responses_ClearOthersIndividually_2 + 1 Command - 3 Responses - Clear Others Individually - 2 + + 132 + + + + 1Command_3Responses_ClearOthersIndividually_3 + 1 Command - 3 Responses - Clear Others Individually - 3 + + 133 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + 1 Command - 3 Responses - Clear Others In Bulk - 1 + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + 1 Command - 3 Responses - Clear Others In Bulk - 2 + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + 1 Command - 3 Responses - Clear Others In Bulk - 3 + + 138 + + + + + 1Command_3Responses_ClearItself_1 + 1 Command - 3 Responses - Clear Itself - 1 + + 141 + + + + 1Command_3Responses_ClearItself_2 + 1 Command - 3 Responses - Clear Itself - 2 + + 142 + + + + 1Command_3Responses_ClearItself_3 + 1 Command - 3 Responses - Clear Itself - 3 + + 143 + + + + + + + ResponseEach_After + response + + action + + 100 + + + + + 1Command_2Responses_2 + response + + action + + 121 + + + + 1Command_2Responses_With1OnBadCommand_BadResponse + response + + action + + 125 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + response + + action + + + + + + 1Command_3Responses_ClearOthersIndividually_2 + response + + action + + 1 + 131 + 2 + 133 + 3 + + + + 1Command_3Responses_ClearOthersIndividually_3 + response + + action + + 1 + 132 + + + + + + 1Command_3Responses_ClearOthersInBulk_2 + response + + action + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + response + + action + + 138 + + + + + 1Command_3Responses_ClearItself_1 + response + + action + + 1 + + + + + 1Command_3Responses_ClearItself_3 + response + + action + + 143 + + + + + + + Noise Action 1 + parameter + run actions + + + Noise Action 2 + parameter + run actions + + + Noise Action 3 + parameter + run actions + + + + Clear Response + response + clear + + + + + No Clear Response 121 + response + add to execute + + + + + No Clear Response 125 + parameter + clear + + + + Clear Response 131 + response + clear + + + Clear Response 132 + response + clear + + + Clear Response 133 + response + clear + + + + + Clear Response 136;138 + response + clear + + + Clear Response 136;137 + response + clear + + + + + Clear Response 141 + response + clear + + + + No Clear Response 142 + response + clear + + + + No Clear Response 143 + response + clear length info + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3c2a36af --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,563 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1Command_0Response + 1 Command - 0 Response + + 100 + + + + 1Command_1Responses_NoClear + 1 Command - 1 Responses - No Clear + + 100 + 111 + + + + 1Command_1Responses_Clear + 1 Command - 1 Responses - Clear + + 100 + 115 + + + + + + 1Command_2Responses + 1 Command - 2 Responses + + 100 + 121 + 122 + + + + 1Command_2Responses_With1OnBadCommand + 1 Command - 2 Responses - With 1 OnBadCommand + + 100 + 125 + 126 + + + + 1Command_3Responses_ClearOthersIndividually + 1 Command - 3 Responses - Clear Others Individually + + 100 + 131 + 132 + 133 + + + + 1Command_3Responses_ClearOthersInBulk + 1 Command - 3 Responses - Clear Others In Bulk + + 100 + 136 + 137 + 138 + + + + 1Command_3Responses_ClearItself + 1 Command - 3 Responses - Clear Itself + + 100 + 141 + 142 + 143 + + + + + + 0Command_1Response_NoClear + 0 Command - 1 Response - No Clear + + 201 + + + + 0Command_1Response_Clear + 0 Command - 1 Response - Clear + + 205 + + + + + + 1Command_2Response_GenericClear + 1 Command - 2 Response - Generic Clear + + 100 + 111 + 115 + + + + + + + Command100 + Command 100 + + 1 + + + + + + + 1Command_1Responses_NoClear + 1 Command - 1 Responses - No Clear + + 111 + + + + 1Command_1Responses_Clear + 1 Command - 1 Responses - Clear + + 115 + + + + + 1Command_2Responses_1 + 1 Command - 2 Responses - 1 + + 121 + + + + 1Command_2Responses_2 + 1 Command - 2 Responses - 2 + + 122 + + + + 1Command_2Responses_With1OnBadCommand_NormalResponse + 1 Command - 2 Responses - With 1 OnBadCommand - Normal Response + + 125 + + + + 1Command_2Responses_With1OnBadCommand_BadResponse + 1 Command - 2 Responses - With 1 OnBadCommand - Bad Response + + 126 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + 1 Command - 3 Responses - Clear Others Individually - 1 + + 131 + + + + 1Command_3Responses_ClearOthersIndividually_2 + 1 Command - 3 Responses - Clear Others Individually - 2 + + 132 + + + + 1Command_3Responses_ClearOthersIndividually_3 + 1 Command - 3 Responses - Clear Others Individually - 3 + + 133 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + 1 Command - 3 Responses - Clear Others In Bulk - 1 + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + 1 Command - 3 Responses - Clear Others In Bulk - 2 + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + 1 Command - 3 Responses - Clear Others In Bulk - 3 + + 138 + + + + + 1Command_3Responses_ClearItself_1 + 1 Command - 3 Responses - Clear Itself - 1 + + 141 + + + + 1Command_3Responses_ClearItself_2 + 1 Command - 3 Responses - Clear Itself - 2 + + 142 + + + + 1Command_3Responses_ClearItself_3 + 1 Command - 3 Responses - Clear Itself - 3 + + 143 + + + + + 0Command_1Response_NoClear + 0 Command - 1 Response - No Clear + + 201 + + + + 0Command_1Response_Clear + 0 Command - 1 Response - Clear + + 205 + + + + + + + 1Command_1Responses_Clear + response + + action + + 115 + + + + + 1Command_2Responses_1 + response + + action + + + 1 + 122 + + + + 1Command_2Responses_2 + response + + action + + + 121 + 2 + + + + 1Command_2Responses_With1OnBadCommand_NormalResponse + response + + action + + + 1 + 126 + 2 + + + + 1Command_2Responses_With1OnBadCommand_BadResponse + response + + action + + 125 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + response + + action + + 132 + 133 + + + + 1Command_3Responses_ClearOthersIndividually_2 + response + + action + + 131 + 133 + + + + 1Command_3Responses_ClearOthersIndividually_3 + response + + action + + 131 + 132 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + response + + action + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + response + + action + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + response + + action + + 138 + + + + + 1Command_3Responses_ClearItself_1 + response + + action + + 141 + + + + 1Command_3Responses_ClearItself_2 + response + + action + + 142 + + + + 1Command_3Responses_ClearItself_3 + response + + action + + 143 + + + + + 0Command_1Response_Clear + response + + action + + 205 + + + + + 1Command_1Responses_GenericClear_115 + response + + action + + 300 + + + + 1Command_1Responses_GenericClear_111 + response + + action + + 300 + + + + + + + Noise Action 1 + parameter + run actions + + + Noise Action 2 + parameter + run actions + + + Noise Action 3 + parameter + run actions + + + + Clear Response 115 + response + clear + + + + Clear Response 121 + response + clear + + + Clear Response 122 + response + clear + + + Clear Response 125 + response + clear + + + Clear Response 126 + response + clear + + + + Clear Response 131 + response + clear + + + Clear Response 132 + response + clear + + + Clear Response 133 + response + clear + + + + Clear Response 137;138 + response + clear + + + Clear Response 136;138 + response + clear + + + Clear Response 136;137 + response + clear + + + + Clear Response 141 + response + clear + + + Clear Response 142 + response + clear + + + Clear Response 143 + response + clear + + + + Clear Response 205 + response + clear + + + + Clear Response + response + clear + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/ValidEach.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/ValidEach.xml new file mode 100644 index 00000000..bb38d256 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/CheckContentTag/Samples/Validate/Valid/ValidEach.xml @@ -0,0 +1,466 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1Command_0Response + 1 Command - 0 Response + + 100 + + + + 1Command_1Responses_NoClear + 1 Command - 1 Responses - No Clear + + 100 + 111 + + + + 1Command_1Responses_Clear + 1 Command - 1 Responses - Clear + + 100 + 115 + + + + + + 1Command_2Responses + 1 Command - 2 Responses + + 100 + 121 + 122 + + + + 1Command_2Responses_With1OnBadCommand + 1 Command - 2 Responses - With 1 OnBadCommand + + 100 + 125 + 126 + + + + 1Command_3Responses_ClearOthersIndividually + 1 Command - 3 Responses - Clear Others Individually + + 100 + 131 + 132 + 133 + + + + 1Command_3Responses_ClearOthersInBulk + 1 Command - 3 Responses - Clear Others In Bulk + + 100 + 136 + 137 + 138 + + + + 1Command_3Responses_ClearItself + 1 Command - 3 Responses - Clear Itself + + 100 + 141 + 142 + 143 + + + + + + 0Command_1Response_NoClear + 0 Command - 1 Response - No Clear + + 201 + + + + 0Command_1Response_Clear + 0 Command - 1 Response - Clear + + 205 + + + + + + 1Command_2Response_GenericClear + 1 Command - 2 Response - Generic Clear + + 100 + 111 + 115 + + + + + + + Command100 + Command 100 + + 1 + + + + + + + 1Command_1Responses_NoClear + 1 Command - 1 Responses - No Clear + + 111 + + + + 1Command_1Responses_Clear + 1 Command - 1 Responses - Clear + + 115 + + + + + 1Command_2Responses_1 + 1 Command - 2 Responses - 1 + + 121 + + + + 1Command_2Responses_2 + 1 Command - 2 Responses - 2 + + 122 + + + + 1Command_2Responses_With1OnBadCommand_NormalResponse + 1 Command - 2 Responses - With 1 OnBadCommand - Normal Response + + 125 + + + + 1Command_2Responses_With1OnBadCommand_BadResponse + 1 Command - 2 Responses - With 1 OnBadCommand - Bad Response + + 126 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + 1 Command - 3 Responses - Clear Others Individually - 1 + + 131 + + + + 1Command_3Responses_ClearOthersIndividually_2 + 1 Command - 3 Responses - Clear Others Individually - 2 + + 132 + + + + 1Command_3Responses_ClearOthersIndividually_3 + 1 Command - 3 Responses - Clear Others Individually - 3 + + 133 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + 1 Command - 3 Responses - Clear Others In Bulk - 1 + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + 1 Command - 3 Responses - Clear Others In Bulk - 2 + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + 1 Command - 3 Responses - Clear Others In Bulk - 3 + + 138 + + + + + 1Command_3Responses_ClearItself_1 + 1 Command - 3 Responses - Clear Itself - 1 + + 141 + + + + 1Command_3Responses_ClearItself_2 + 1 Command - 3 Responses - Clear Itself - 2 + + 142 + + + + 1Command_3Responses_ClearItself_3 + 1 Command - 3 Responses - Clear Itself - 3 + + 143 + + + + + 0Command_1Response_NoClear + 0 Command - 1 Response - No Clear + + 201 + + + + 0Command_1Response_Clear + 0 Command - 1 Response - Clear + + 205 + + + + + + + ResponseEach_After + response + + action + + 100 + + + + + 1Command_2Responses_2 + response + + action + + + 1 + 122 + + + + 1Command_2Responses_With1OnBadCommand_BadResponse + response + + action + + + 126 + 2 + + + + + 1Command_3Responses_ClearOthersIndividually_1 + response + + action + + 132 + 133 + + + + 1Command_3Responses_ClearOthersIndividually_2 + response + + action + + 131 + 133 + + + + 1Command_3Responses_ClearOthersIndividually_3 + response + + action + + 131 + 132 + + + + + 1Command_3Responses_ClearOthersInBulk_1 + response + + action + + 136 + + + + 1Command_3Responses_ClearOthersInBulk_2 + response + + action + + 137 + + + + 1Command_3Responses_ClearOthersInBulk_3 + response + + action + + 138 + + + + + 1Command_3Responses_ClearItself_2 + response + + action + + 1 + 142 + 2 + + + + + + + Noise Action 1 + parameter + run actions + + + Noise Action 2 + parameter + run actions + + + Noise Action 3 + parameter + run actions + + + + Clear Response + response + clear + + + + Clear Response 122 + response + clear + + + + Clear Response 126 + response + clear + + + + Clear Response 131 + response + clear + + + Clear Response 132 + response + clear + + + Clear Response 133 + response + clear + + + + Clear Response 137;138 + response + clear + + + Clear Response 136;138 + response + clear + + + Clear Response 136;137 + response + clear + + + + Clear Response 142 + response + clear + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/CheckCommandTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/CheckCommandTag.cs new file mode 100644 index 00000000..ed932134 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/CheckCommandTag.cs @@ -0,0 +1,319 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Content.Command.CheckCommandTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Content.Command.CheckCommandTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckCommandTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckCommandTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckCommandTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckCommandTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "100"), + + Error.InvalidValue(null, null, null, "-2", "200"), + Error.InvalidValue(null, null, null, "1.5", "201"), + Error.InvalidValue(null, null, null, "2,6", "202"), + Error.InvalidValue(null, null, null, "03", "203"), + Error.InvalidValue(null, null, null, "+4", "204"), + Error.InvalidValue(null, null, null, "5x10^1", "205"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckCommandTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckCommandTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckCommandTag_NonExistingIdNoCommands() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoCommands", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckCommandTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 101"), + Error.UntrimmedTag(null, null, null, "2", "102 "), + Error.UntrimmedTag(null, null, null, "3", " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckCommandTag(); + + [TestMethod] + public void Pair_CheckCommandTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckCommandTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "9.4.2", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Content/Command' in Pair '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every pairs should contain one and only one Command tag which should have as value an unsigned number and refer to the id of an existing Command." + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckCommandTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "9.4.4", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Content/Command'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every pairs should contain one and only one Command tag which should have as value an unsigned number and refer to the id of an existing Command." + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckCommandTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "9.4.1", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Content/Command' in Pair '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every pairs should contain one and only one Command tag which should have as value an unsigned number and refer to the id of an existing Command." + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckCommandTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "9.4.5", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Content/Command' references a non-existing 'Command' with ID '2'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every pairs should contain one and only one Command tag which should have as value an unsigned number and refer to the id of an existing Command." + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckCommandTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "9.4.3", + Category = Category.Pair, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Content/Command' in Pair '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every pairs should contain one and only one Command tag which should have as value an unsigned number and refer to the id of an existing Command." + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckCommandTag(); + + [TestMethod] + public void Pair_CheckCommandTag_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckCommandTag_CheckId() => Generic.CheckId(check, CheckId.CheckCommandTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..bb3bbdf9 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,30 @@ + + + + + LeadingSpaces + + 101 + + + + TrailingSpaces + + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..b577bca9 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,18 @@ + + + + + Empty + + + + + + Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..03627440 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,49 @@ + + + + + String + + aaa + + + + + Number_Negative + + -2 + + + + Number_Double_1 + + 1.5 + + + + Number_Double_2 + + 2,6 + + + + Number_LeadingZero + + 03 + + + + Number_LeadingPlusSign + + +4 + + + + Number_ScientificNotation + + 5x10^1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..99e3b59b --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..98a5c9f2 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,20 @@ + + + + + + 9 + + + + + 99 + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingIdNoCommands.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingIdNoCommands.xml new file mode 100644 index 00000000..212dde8b --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/NonExistingIdNoCommands.xml @@ -0,0 +1,16 @@ + + + + + + 9 + + + + + 99 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..b3d4f10f --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,30 @@ + + + + + LeadingSpaces + + 101 + + + + TrailingSpaces + + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..335aaeaf --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Command/CheckCommandTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,21 @@ + + + + + + 101 + + + + + 102 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/CheckResponseTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/CheckResponseTag.cs new file mode 100644 index 00000000..2f06c18b --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/CheckResponseTag.cs @@ -0,0 +1,282 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Content.Response.CheckResponseTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Content.Response.CheckResponseTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckResponseTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckResponseTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckResponseTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "100"), + + Error.InvalidValue(null, null, null, "-2", "200"), + Error.InvalidValue(null, null, null, "1.5", "200"), + Error.InvalidValue(null, null, null, "2,6", "200"), + + Error.InvalidValue(null, null, null, "03", "203"), + Error.InvalidValue(null, null, null, "+4", "203"), + Error.InvalidValue(null, null, null, "5x10^1", "203"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + + Error.NonExistingId(null, null, null, "9", "2"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingIdNoResponses() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoResponses", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + + Error.NonExistingId(null, null, null, "9", "2"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 101"), + Error.UntrimmedTag(null, null, null, "1", "102 "), + + Error.UntrimmedTag(null, null, null, "3", " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckResponseTag(); + + [TestMethod] + public void Pair_CheckResponseTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckResponseTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "9.5.2", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Content/Response' in Pair '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of pairs can contain any number of Response tags." + Environment.NewLine + "Those should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "9.5.4", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Content/Response'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of pairs can contain any number of Response tags." + Environment.NewLine + "Those should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "9.5.5", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Content/Response' references a non-existing 'Response' with ID '2'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of pairs can contain any number of Response tags." + Environment.NewLine + "Those should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "9.5.3", + Category = Category.Pair, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Content/Response' in Pair '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of pairs can contain any number of Response tags." + Environment.NewLine + "Those should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckResponseTag(); + + [TestMethod] + public void Pair_CheckResponseTag_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckResponseTag_CheckId() => Generic.CheckId(check, CheckId.CheckResponseTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..0fb566b5 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,25 @@ + + + + + LeadingOrTrailingSpaces + + 101 + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..d5cd5092 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,18 @@ + + + + + Empty + + + + + + Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..add066e3 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,29 @@ + + + + + String + + aaa + + + + + Number_NonUint + + -2 + 1.5 + 2,6 + + + + Number_Format + + 03 + +4 + 5x10^1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..019f4323 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,23 @@ + + + + + OneResponse + + 9 + + + + TwoResponse + + 9 + 99 + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml new file mode 100644 index 00000000..63f69f1c --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml @@ -0,0 +1,19 @@ + + + + + OneResponse + + 9 + + + + TwoResponse + + 9 + 99 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..ba8d7925 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,25 @@ + + + + + LeadingOrTrailingSpaces + + 101 + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f7455663 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/Response/CheckResponseTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,21 @@ + + + + + + 101 + + + + + 102 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/CheckResponseOnBadCommandTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/CheckResponseOnBadCommandTag.cs new file mode 100644 index 00000000..c6ad0a3c --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/CheckResponseOnBadCommandTag.cs @@ -0,0 +1,278 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Content.ResponseOnBadCommand.CheckResponseOnBadCommandTag +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Content.ResponseOnBadCommand.CheckResponseOnBadCommandTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckResponseOnBadCommandTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckResponseTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckResponseTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "100"), + + Error.InvalidValue(null, null, null, "-2", "200"), + Error.InvalidValue(null, null, null, "1.5", "200"), + Error.InvalidValue(null, null, null, "2,6", "200"), + + Error.InvalidValue(null, null, null, "03", "203"), + Error.InvalidValue(null, null, null, "+4", "203"), + Error.InvalidValue(null, null, null, "5x10^1", "203"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + + Error.NonExistingId(null, null, null, "9", "2"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingIdNoResponses() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoResponses", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "9", "1"), + + Error.NonExistingId(null, null, null, "9", "2"), + Error.NonExistingId(null, null, null, "99", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 101"), + Error.UntrimmedTag(null, null, null, "1", "102 "), + + Error.UntrimmedTag(null, null, null, "3", " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckResponseOnBadCommandTag(); + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "9.6.2", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Content/ResponseOnBadCommand' in Pair '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of a pairs can contain maximum one ResponseOnBadCommand tag." + Environment.NewLine + "It should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "9.6.4", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Content/ResponseOnBadCommand'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of a pairs can contain maximum one ResponseOnBadCommand tag." + Environment.NewLine + "It should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "9.6.5", + Category = Category.Pair, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Content/ResponseOnBadCommand' references a non-existing 'Response' with ID '2'. Pair ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of a pairs can contain maximum one ResponseOnBadCommand tag." + Environment.NewLine + "It should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "9.6.3", + Category = Category.Pair, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Content/ResponseOnBadCommand' in Pair '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of a pairs can contain maximum one ResponseOnBadCommand tag." + Environment.NewLine + "It should have as value an unsigned number and refer to the id of an existing Response." + Environment.NewLine + "A given pair can't refer to the same Response more than once (including both Response and ResponseOnBadCommand tags)." + Environment.NewLine + "" + Environment.NewLine + "Also note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckResponseOnBadCommandTag(); + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_CheckCategory() => Generic.CheckCategory(check, Category.Pair); + + [TestMethod] + public void Pair_CheckResponseOnBadCommandTag_CheckId() => Generic.CheckId(check, CheckId.CheckResponseOnBadCommandTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..b16846eb --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,25 @@ + + + + + LeadingOrTrailingSpaces + + 101 + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..8cdc12f7 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,18 @@ + + + + + Empty + + + + + + Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..b5dcfe26 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,29 @@ + + + + + String + + aaa + + + + + Number_NonUint + + -2 + 1.5 + 2,6 + + + + Number_Format + + 03 + +4 + 5x10^1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..6019c57f --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,23 @@ + + + + + OneResponseOnBadCommand + + 9 + + + + TwoResponseOnBadCommand + + 9 + 99 + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml new file mode 100644 index 00000000..d496ec79 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/NonExistingIdNoResponses.xml @@ -0,0 +1,19 @@ + + + + + OneResponseOnBadCommand + + 9 + + + + TwoResponseOnBadCommand + + 9 + 99 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..f26a4562 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,25 @@ + + + + + LeadingOrTrailingSpaces + + 101 + 102 + + + + LeadingAndTrailingSpaces + + 103 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..1e1b0bb8 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Content/ResponseOnBadCommand/CheckResponseOnBadCommandTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,21 @@ + + + + + + 101 + + + + + 102 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..1c5a0797 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Pairs.Pair.Name.CheckNameTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Pairs.Pair.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Pair_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Pair_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Pair); + + [TestMethod] + public void Pair_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..583934a5 --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..2599f51b --- /dev/null +++ b/ProtocolTests/Protocol/Pairs/Pair/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/CheckParameterGroupsTag.cs b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/CheckParameterGroupsTag.cs new file mode 100644 index 00000000..237560db --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/CheckParameterGroupsTag.cs @@ -0,0 +1,64 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.CheckParameterGroupsTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.CheckParameterGroupsTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckParameterGroupsTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckParameterGroupsTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckParameterGroupsTag_DcfAdded() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DcfAdded", + ExpectedResults = new List + { + ErrorCompare.DcfAdded(null, null), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckParameterGroupsTag(); + + [TestMethod] + public void Protocol_CheckParameterGroupsTag_CheckCategory() => Generic.CheckCategory(root, Category.ParameterGroup); + + [TestMethod] + public void Protocol_CheckParameterGroupsTag_CheckId() => Generic.CheckId(root, CheckId.CheckParameterGroupsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_New.xml b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_New.xml new file mode 100644 index 00000000..0620914a --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_New.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_Old.xml b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_Old.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Invalid/DcfAdded_Old.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..73ca6ae0 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..73ca6ae0 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/CheckParameterGroupsTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/CheckDynamicIdAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/CheckDynamicIdAttribute.cs new file mode 100644 index 00000000..954bc600 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/CheckDynamicIdAttribute.cs @@ -0,0 +1,154 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckDynamicIdAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckDynamicIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDynamicIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "test", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'dynamicId' in ParameterGroup '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1"); + + string description = "Invalid value '0' in attribute 'dynamicId'. ParameterGroup ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Attribute 'dynamicId' references a non-existing 'Table' with PID '0'. ParameterGroup ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDynamicIdAttribute(); + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ParameterGroup); + + [TestMethod] + public void ParameterGroup_CheckDynamicIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDynamicIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..41ec18a4 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..79750df9 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..9b3293c2 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..94b66548 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..87c95f85 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/CheckDynamicIndexAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/CheckDynamicIndexAttribute.cs new file mode 100644 index 00000000..bd7d09c3 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/CheckDynamicIndexAttribute.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckDynamicIndexAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckDynamicIndexAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDynamicIndexAttribute(); + + #region Valid Checks + + [TestMethod] + public void ParameterGroup_CheckDynamicIndexAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ParameterGroup_CheckDynamicIndexAttribute_MissingDynamicIdAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingDynamicIdAttribute", + ExpectedResults = new List + { + Error.MissingDynamicIdAttribute(null, null, null, "1002"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void ParameterGroup_CheckDynamicIndexAttribute_MissingDynamicIdAttribute() + { + // Create ErrorMessage + var message = Error.MissingDynamicIdAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "16.8.1", + Category = Category.ParameterGroup, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Filtering via 'Group@dynamicIndex' attribute requires a 'Group@dynamicId' attribute. ParameterGroup ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "'Group@dynamicIndex' attribute allows to filter on Display Keys before creating dynamic DCF interfaces." + Environment.NewLine + "Such filter is applied on the table referred to via the 'Group@dynamicId' attribute." + Environment.NewLine + "This means that the presence of a 'Group@dynamicIndex' attribute while there is no 'Group@dynamicIndex' doesn't make sense.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDynamicIndexAttribute(); + + [TestMethod] + public void ParameterGroup_CheckDynamicIndexAttribute_CheckCategory() => Generic.CheckCategory(check, Category.ParameterGroup); + + [TestMethod] + public void ParameterGroup_CheckDynamicIndexAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDynamicIndexAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Invalid/MissingDynamicIdAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Invalid/MissingDynamicIdAttribute.xml new file mode 100644 index 00000000..738993b5 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Invalid/MissingDynamicIdAttribute.xml @@ -0,0 +1,21 @@ + + + + + + + + + DCF_Interfaces_Table + array + + + + + + DCF_Interfaces_TableInstance + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..5959c9e8 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckDynamicIndexAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DcfInterface_AlarmLinking_1 + read + + + DcfInterface_AlarmLinking_2 + read + + + DcfInterface_AlarmLinking_3 + read + + + + DcfInterfacesTable + array + + + + + + + DcfInterfacesTable_Instance + read + + + DcfInterfacesTable_Column2 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/CheckGroupTag.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/CheckGroupTag.cs new file mode 100644 index 00000000..a7319963 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/CheckGroupTag.cs @@ -0,0 +1,111 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckGroupTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckGroupTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckGroupTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckGroupTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckGroupTag_IncompatibleParamReferences() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IncompatibleParamReferences", + ExpectedResults = new List + { + Error.IncompatibleParamReferences(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckGroupTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckGroupTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckGroupTag_DcfParameterGroupRemoved() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DcfParameterGroupRemoved", + ExpectedResults = new List + { + ErrorCompare.DcfParameterGroupRemoved(null, null, "1"), + ErrorCompare.DcfParameterGroupRemoved(null, null, "3"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckGroupTag(); + + [TestMethod] + public void Protocol_CheckGroupTag_CheckCategory() => Generic.CheckCategory(root, Category.ParameterGroup); + + [TestMethod] + public void Protocol_CheckGroupTag_CheckId() => Generic.CheckId(root, CheckId.CheckGroupTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_New.xml new file mode 100644 index 00000000..b1a22ec2 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_New.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_Old.xml new file mode 100644 index 00000000..ddc5c0cb --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Invalid/DcfParameterGroupRemoved_Old.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..ddc5c0cb --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..ddc5c0cb --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Invalid/IncompatibleParamReferences.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Invalid/IncompatibleParamReferences.xml new file mode 100644 index 00000000..b1a6bea7 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Invalid/IncompatibleParamReferences.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + DCF_Interface_Standalone_1 + read + + + DCF_Interface_Standalone_2 + read + + + DCF_Interface_Standalone_3 + read + + + + DCF_Interfaces_Table + array + + + + + + DCF_Interfaces_TableInstance + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..263dc9ce --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DcfInterface_AlarmLinking_1 + read + + + DcfInterface_AlarmLinking_2 + read + + + DcfInterface_AlarmLinking_3 + read + + + + DcfInterfacesTable + array + + + + + + + DcfInterfacesTable_Instance + read + + + DcfInterfacesTable_Column2 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..19a634e6 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,181 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckIdAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_OutOfRangeId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "OutOfRangeId", + ExpectedResults = new List + { + Error.OutOfRangeId(null, null, null, Certainty.Uncertain, "10001"), + Error.OutOfRangeId(null, null, null, Certainty.Certain, "100001"), + Error.OutOfRangeId(null, null, null, Certainty.Uncertain, " 10002 "), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIdAttribute(); + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIdAttribute(); + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(root, Category.ParameterGroup); + + [TestMethod] + public void ParameterGroup_CheckIdAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..2c6877fe --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..5d61f668 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..ee02d549 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..31b6ac83 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..998f9468 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml new file mode 100644 index 00000000..44a9ad99 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..9cbc044d --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..03f3a0c9 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..797b746f --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,211 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckNameAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckNameAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_InvalidChars() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidChars", + ExpectedResults = new List + { + Error.InvalidChars(null, null, null, "Invalid\\Char", "\\"), + Error.InvalidChars(null, null, null, " Invalid\\Char3 ", "\\"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_LengthyValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "LengthyValue", + ExpectedResults = new List + { + Error.LengthyValue(null, null, null, "RidiculousLongNameThatIsTooLongToHandle"), + Error.LengthyValue(null, null, null, " RidiculousLongNameThatIsTooLongToHandle3 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", "TestName "), + Error.UntrimmedAttribute(null, null, null, "2", " TestName2 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckNameAttribute_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckNameAttribute_DcfParameterGroupNameChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DcfParameterGroupNameChanged", + ExpectedResults = new List + { + ErrorCompare.DcfParameterGroupNameChanged(null, null, "1", "Stand Alone Input", "Rename"), + ErrorCompare.DcfParameterGroupNameChanged(null, null, "2", "Outputs", ""), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix test = new CheckNameAttribute(); + + [TestMethod] + public void Protocol_CheckNameAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(test, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameAttribute(); + + [TestMethod] + public void Protocol_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(root, Category.ParameterGroup); + + [TestMethod] + public void Protocol_CheckNameAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..48c41cff --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_New.xml new file mode 100644 index 00000000..c5ce8480 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_New.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_Old.xml new file mode 100644 index 00000000..83ac18fb --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Invalid/DcfParameterGroupNameChanged_Old.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..246691f2 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..a1424580 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..66adf5dc --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..305b7cde --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/InvalidChars.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/InvalidChars.xml new file mode 100644 index 00000000..85d8fdf1 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/InvalidChars.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/LengthyValue.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/LengthyValue.xml new file mode 100644 index 00000000..ab09ed6a --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/LengthyValue.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..3c2e00aa --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..484bbfed --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..df002ac6 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/CheckTypeAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/CheckTypeAttribute.cs new file mode 100644 index 00000000..6a6a1585 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/CheckTypeAttribute.cs @@ -0,0 +1,65 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.CheckTypeAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.CheckTypeAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckTypeAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckTypeAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckTypeAttribute_DcfParameterGroupTypeChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DcfParameterGroupTypeChanged", + ExpectedResults = new List + { + ErrorCompare.DcfParameterGroupTypeChanged(null, null, "1", "In", "Inout"), + ErrorCompare.DcfParameterGroupTypeChanged(null, null, "2", "Out", "In"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeAttribute(); + + [TestMethod] + public void Protocol_CheckTypeAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckTypeAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckTypeAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_New.xml new file mode 100644 index 00000000..6567dbab --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_New.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_Old.xml new file mode 100644 index 00000000..5f3675c3 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Invalid/DcfParameterGroupTypeChanged_Old.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..dbc4b1fd --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..5f3675c3 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..6bbceb56 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,97 @@ +namespace SLDisValidatorUnitTests.Protocol.ParameterGroups.Group.Params.Param.CheckIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.ParameterGroups.Group.Params.Param.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "101", "1000"), + + Error.NonExistingId(null, null, null, "101", "1001"), + Error.NonExistingId(null, null, null, "102", "1001"), + + Error.NonExistingId(null, null, null, "101", "1002"), + Error.NonExistingId(null, null, null, "102", "1002"), + + Error.NonExistingId(null, null, null, "1002", "1100"), + + Error.NonExistingId(null, null, null, "101", "1200"), + Error.NonExistingId(null, null, null, "1002", "1200"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckIdAttribute_DuplicateParamInParameterGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateParamInParameterGroup", + ExpectedResults = new List + { + Error.DuplicateParamInParameterGroup(null, null, null, "10", "1").WithSubResults( + Error.DuplicateParamInParameterGroup(null, null, null, "10", "1"), + Error.DuplicateParamInParameterGroup(null, null, null, "10", "1")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIdAttribute(); + + [TestMethod] + public void Protocol_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(root, Category.ParameterGroup); + + [TestMethod] + public void Protocol_CheckIdAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicateParamInParameterGroup.xml b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicateParamInParameterGroup.xml new file mode 100644 index 00000000..33230666 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicateParamInParameterGroup.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..85b23d72 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DcfInterface_AlarmLinking_3 + read + + + + DcfInterfacesTable + array + + + + + + + DcfInterfacesTable_Instance + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..8b4353a4 --- /dev/null +++ b/ProtocolTests/Protocol/ParameterGroups/Group/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DcfInterface_AlarmLinking_1 + read + + + DcfInterface_AlarmLinking_2 + read + + + DcfInterface_AlarmLinking_3 + read + + + + DcfInterfacesTable + array + + + + + + DcfInterfacesTable_Instance + read + + + DcfInterfacesTable_Column2 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/CheckLoadSequenceAttribute.cs b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/CheckLoadSequenceAttribute.cs new file mode 100644 index 00000000..1880bb7f --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/CheckLoadSequenceAttribute.cs @@ -0,0 +1,216 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.CheckLoadSequenceAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.CheckLoadSequenceAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckLoadSequenceAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1"), + Error.NonExistingId(null, null, null, "2"), + Error.NonExistingId(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckLoadSequenceAttribute_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + Error.ReferencedParamRTDisplayExpected(null, null, null, "1"), + Error.ReferencedParamRTDisplayExpected(null, null, null, "2"), + Error.ReferencedParamRTDisplayExpected(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_ReferencedParamSaveExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamSaveExpected", + ExpectedResults = new List + { + Error.ReferencedParamSaveExpected(null, null, null, "2"), + Error.ReferencedParamSaveExpected(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 3;2;1 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckLoadSequenceAttribute(); + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckLoadSequenceAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.56.1", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Params@loadSequence'.", + HowToFix = "", + ExampleCode = "", + Details = "'Params@loadSequence' expects a semicolon separated list of Param IDs allowing to define the order in which saved parameter values are loaded in SLElement." + Environment.NewLine + "Referenced parameters are expected to:" + Environment.NewLine + "- Have the save attribute set to 'true'" + Environment.NewLine + "- Have the RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.56.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Params@loadSequence'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "'Params@loadSequence' expects a semicolon separated list of Param IDs allowing to define the order in which saved parameter values are loaded in SLElement." + Environment.NewLine + "Referenced parameters are expected to:" + Environment.NewLine + "- Have the save attribute set to 'true'" + Environment.NewLine + "- Have the RTDisplay tag set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckLoadSequenceAttribute(); + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckLoadSequenceAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckLoadSequenceAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..ccaadf9a --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + true + + + + read_2 + read + + true + + + + read_3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..3e489faa --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..4cc17eca --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..1e7e172f --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + false + + + + read_2 + read + + + + + + read_3 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamSaveExpected.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamSaveExpected.xml new file mode 100644 index 00000000..8b0db302 --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/ReferencedParamSaveExpected.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + true + + + + read_2_NoSave + read + + true + + + + read_3_SaveFalse + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..62a69fba --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + true + + + + read_2 + read + + true + + + + read_3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..150bf835 --- /dev/null +++ b/ProtocolTests/Protocol/Params/CheckLoadSequenceAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + true + + + + read_2 + read + + true + + + + read_3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/CheckAlarmTag.cs b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/CheckAlarmTag.cs new file mode 100644 index 00000000..e657b7ab --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/CheckAlarmTag.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Alarm.CheckAlarmTag +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Alarm.CheckAlarmTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckAlarmTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckAlarmTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckAlarmTag_MissingDefaultThreshold() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingDefaultThreshold", + ExpectedResults = new List + { + Error.MissingDefaultThreshold(null, null, null, "101"), + Error.MissingDefaultThreshold(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckAlarmTag_MissingDefaultThreshold() + { + // Create ErrorMessage + var message = Error.MissingDefaultThreshold(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "2.5.1", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "Missing default thresholds on some monitored parameters.", + Description = "Missing default thresholds on monitored parameter. Param ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "When possible, default thresholds should be provided on monitored parameter as starting point to make things easier for a user when configuring alarm templates.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckAlarmTag(); + + [TestMethod] + public void Param_CheckAlarmTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckAlarmTag_CheckId() => Generic.CheckId(check, CheckId.CheckAlarmTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Invalid/MissingDefaultThreshold.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Invalid/MissingDefaultThreshold.xml new file mode 100644 index 00000000..ee650765 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Invalid/MissingDefaultThreshold.xml @@ -0,0 +1,22 @@ + + + + + + Monitored_Standalone_NoThreshold + + true + + + + Monitored_Standalone_EmptyThresholds + + + true + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..ed355273 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckAlarmTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,49 @@ + + + + + + Monitored_Standalone_WithInfoThreshold + + true + * + + + + Monitored_Standalone_WithCriticalHighThreshold + + true + Something + + + + Monitored_Standalone_WithNormalThreshold + + true + Something + + + + + + NotMonitored_NoAlarm + + + NotMonitored_NoMonitored + + + + NotMonitored_MonitoredFalse + + false + + + + NotMonitored_MonitoredTypo + + typo + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..94aaefb4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,226 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Alarm.CheckOptionsAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Alarm.CheckOptionsAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + // Threshold + Error.NonExistingId(null, null, null, "1000", "100"), + Error.NonExistingId(null, null, null, "1001", "100"), + + // Properties + Error.NonExistingId(null, null, null, "1002", "100"), + Error.NonExistingId(null, null, null, "1003", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay check")] + public void Param_CheckOptionsAttribute_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "100", " threshold:1000,1001;propertyNames:Prop1,Prop2,Prop3;properties:|aaa|1002|*value:*1003 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_UpdatedThresholdAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedThresholdAlarmType", + ExpectedResults = new List + { + ErrorCompare.UpdatedThresholdAlarmType(null, null, "102,2206", "1", "104,2206"), + ErrorCompare.UpdatedThresholdAlarmType(null, null, "102,2206", "2", "105,2206"), + ErrorCompare.UpdatedThresholdAlarmType(null, null, "102,2206", "3", "106,2208"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_AddedThresholdAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedThresholdAlarmType", + ExpectedResults = new List + { + ErrorCompare.AddedThresholdAlarmType(null, null, "102,2206", "1"), + ErrorCompare.AddedThresholdAlarmType(null, null, "102,2206", "2"), + ErrorCompare.AddedThresholdAlarmType(null, null, "102,2206", "3"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_RemovedThresholdAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedThresholdAlarmType", + ExpectedResults = new List + { + ErrorCompare.RemovedThresholdAlarmType(null, null, "102,2206", "1"), + ErrorCompare.RemovedThresholdAlarmType(null, null, "102,2206", "2"), + ErrorCompare.RemovedThresholdAlarmType(null, null, "102,2206", "3"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..83ed4745 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..c4c25de1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,41 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + Read_1000 + read + + true + + + + Read_1001 + read + + true + + + + Read_1002 + read + + true + + + + Read_1003 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_New.xml new file mode 100644 index 00000000..fb21457f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_New.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_Old.xml new file mode 100644 index 00000000..d89b264e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/AddedThresholdAlarmType_Old.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_New.xml new file mode 100644 index 00000000..c793dab5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_New.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_Old.xml new file mode 100644 index 00000000..d99296d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedThresholdAlarmType_Old.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_New.xml new file mode 100644 index 00000000..dcab6b47 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_New.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_Old.xml new file mode 100644 index 00000000..d99296d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedThresholdAlarmType_Old.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..8d35ea40 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..8d53ca93 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..078ad012 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..1b047bf9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,41 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..1ecf63a2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..4896a65d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,41 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + Read_1000 + read + + true + + + + Read_1001 + read + + true + + + + Read_1002 + read + + true + + + + Read_1003 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..79db2abd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,103 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + + + + + AlarmProtperties_Table1 + array + + + + + + true + + + + AlarmProtperties_Table1_Instance + read + + true + + + + AlarmProtperties_Table1_Column2 + read + + true + + + + + + + Read_1000 + read + + true + + + + Read_1001 + read + + true + + + + Read_1002 + read + + true + + + + Read_1003 + read + + true + + + + + Table1 + array + + + + + + + true + + + + Table1_Instance + read + + true + + + + Table1_Column2 + read + + true + + + + Table1_Column3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/CheckTypeAttribute.cs b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/CheckTypeAttribute.cs new file mode 100644 index 00000000..2dea9d57 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/CheckTypeAttribute.cs @@ -0,0 +1,109 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Alarm.CheckTypeAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Alarm.CheckTypeAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckTypeAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTypeAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTypeAttribute_RemovedNormalizationAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedNormalizationAlarmType", + ExpectedResults = new List + { + ErrorCompare.RemovedNormalizationAlarmType(null, null, "absolute:2214,100", "1"), + ErrorCompare.RemovedNormalizationAlarmType(null, null, "absolute:2214", "2"), + ErrorCompare.RemovedNormalizationAlarmType(null, null, "relative:2214,100", "3"), + ErrorCompare.RemovedNormalizationAlarmType(null, null, "relative:2214", "4"), + ErrorCompare.RemovedNormalizationAlarmType(null, null, "relative", "5"), + ErrorCompare.RemovedNormalizationAlarmType(null, null, "absolute", "6"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckTypeAttribute_UpdatedNormalizationAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedNormalizationAlarmType", + ExpectedResults = new List + { + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "absolute:2214,100", "1", "relative:2214,100"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "absolute:2214", "2", "relative:2214"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "absolute", "3", "relative"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "relative", "4", "absolute"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "relative:2214,100", "5", "relative:2214"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "relative:2214", "6", "relative:2214,100"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "relative:2214,100", "7", "relative"), + ErrorCompare.UpdatedNormalizationAlarmType(null, null, "absolute:2214", "8", "absolute"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckTypeAttribute_AddedNormalizationAlarmType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedNormalizationAlarmType", + ExpectedResults = new List + { + ErrorCompare.AddedNormalizationAlarmType(null, null, "absolute:205", "1"), + ErrorCompare.AddedNormalizationAlarmType(null, null, "relative:1000001", "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeAttribute(); + + [TestMethod] + public void Param_CheckTypeAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckTypeAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckTypeAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_New.xml new file mode 100644 index 00000000..bfc2fc09 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_New.xml @@ -0,0 +1,16 @@ + + + + + + true + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_Old.xml new file mode 100644 index 00000000..7b8b129f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/AddedNormalizationAlarmType_Old.xml @@ -0,0 +1,16 @@ + + + + + + true + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_New.xml new file mode 100644 index 00000000..21d65337 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_New.xml @@ -0,0 +1,34 @@ + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_Old.xml new file mode 100644 index 00000000..031184fb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/RemovedNormalizationAlarmType_Old.xml @@ -0,0 +1,34 @@ + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_New.xml new file mode 100644 index 00000000..4edc6ac9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_New.xml @@ -0,0 +1,88 @@ + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + After Startup + protocol + + action + + 1 + + + + + + + AfterStartup + group + execute + + + id:10 != 1 + Normalize7 + parameter + normalize + + + id:10 != 1 + Normalize8 + parameter + normalize + + + + + + AfterStartup + AfterStartup + poll action + + 3 + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_Old.xml new file mode 100644 index 00000000..69619fc4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Invalid/UpdatedNormalizationAlarmType_Old.xml @@ -0,0 +1,44 @@ + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..e980c5e3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,226 @@ + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + + + + + + + + + true + + + + + false + + + + + true + + + + + + + + + true + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + After Startup + protocol + + action + + 1 + + + + + + + AfterStartup + group + execute + + + Normalize3 + parameter + normalize + + + Normalize4 + parameter + normalize + + + + + + AfterStartup + AfterStartup + poll action + + 2 + 3 + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..db43d57f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/CheckTypeAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,172 @@ + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + + + + + + + false + + + + + + + + + + + + + false + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + + + + + + false + + + + + + + + + + + + + false + + + + + false + + + + + + + + + + + false + + + + + + + + + + + + + false + + + + + false + + + + + + + + + + + + + false + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/CheckDisabledIfAttribute.cs b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/CheckDisabledIfAttribute.cs new file mode 100644 index 00000000..2fcdc450 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/CheckDisabledIfAttribute.cs @@ -0,0 +1,304 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Alarm.Monitored.CheckDisabledIfAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Alarm.Monitored.CheckDisabledIfAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDisabledIfAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisabledIfAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisabledIfAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckDisabledIfAttribute_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + Error.ReferencedParamRTDisplayExpected(null, null, null, "1001", "1"), + Error.ReferencedParamRTDisplayExpected(null, null, null, "1002", "2"), + Error.ReferencedParamRTDisplayExpected(null, null, null, "1003", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_ReferencedParamWrongType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongType", + ExpectedResults = new List + { + Error.ReferencedParamWrongType(null, null, null, "write", "1001"), + Error.ReferencedParamWrongType(null, null, null, "write bit", "1002"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1001,value1"), + Error.UntrimmedAttribute(null, null, null, "2", "1002,0 "), + Error.UntrimmedAttribute(null, null, null, "3", " 1003,0 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckDisabledIfAttribute(); + + [TestMethod] + public void Param_CheckDisabledIfAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDisabledIfAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "pid"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Monitored@disabledIf' in Param 'pid'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "attributeValue", "pid"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'attributeValue' in attribute 'Monitored@disabledIf'. Param ID 'pid'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "referencedPid", "pid"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Monitored@disabledIf' references a non-existing 'Param' with ID 'referencedPid'. Param ID 'pid'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_ReferencedParamRTDisplayExpected() + { + // Create ErrorMessage + var message = Error.ReferencedParamRTDisplayExpected(null, null, null, "referencedPid", "referencingPid"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param 'referencedPid' referenced by a 'Monitored@disabledIf' attribute. Param ID 'referencingPid'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_ReferencedParamWrongType() + { + // Create ErrorMessage + var message = Error.ReferencedParamWrongType(null, null, null, "referencedParamType", "referencedPid"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid Param Type 'referencedParamType' on Param referenced by a 'Monitored@disabledIf' attribute. Param ID 'referencedPid'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDisabledIfAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "pid", "untrimmedValue"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Monitored@disabledIf' in Param 'pid'. Current value 'untrimmedValue'.", + Details = "Monitored@disabledIf attribute should follow the following format 'pid,value' where:" + Environment.NewLine + "- pid: refers to the ID of an existing parameter." + Environment.NewLine + " The referenced Param is expected to:" + Environment.NewLine + " - Have RTDisplay tag set to 'true'." + Environment.NewLine + "- value: correspond to the value of the referenced parameter which will cause the monitoring to be disabled." + Environment.NewLine + " When using discreet values, it is only possible to set a condition on the discreet value, not on the display value.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDisabledIfAttribute(); + + [TestMethod] + public void Param_CheckDisabledIfAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDisabledIfAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDisabledIfAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..7334883f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,79 @@ + + + + + + Leading + read + + true + + + true + + + + Trailing + read + + true + + + true + + + + LeadingAndTrailing + read + + true + + + true + + + + + + Condition_Read_String + read + + true + + + string + + + + Condition_Read_Number + read + + true + + + number + + + + Condition_Read_Discreet + read + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..a973eac6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + EmptyAttribute + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..cf0887c0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,12 @@ + + + + + NoComma + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..8408f765 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,16 @@ + + + + + Alarmed_ConditionOnNonExisting1001 + read + + true + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..a82bbfd9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,60 @@ + + + + + + Alarmed_ConditionOn_RTDisplayFalse + read + + true + + + true + + + + Alarmed_ConditionOn_NoRTDisplay + read + + true + + + true + + + + Alarmed_ConditionOn_NoDisplay + read + + true + + + true + + + + + + Condition_Read_RTDisplayFalse + read + + false + + + + Condition_Read_NoRTDisplay + read + + + + + + Condition_Read_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml new file mode 100644 index 00000000..5653a912 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml @@ -0,0 +1,43 @@ + + + + + + Alarmed_ConditionOnWrite + read + + true + + + true + + + + Alarmed_ConditionOnWriteBit + read + + true + + + true + + + + + + Condition_Write + write + + true + + + + Condition_WriteBit + write bit + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..0c4eca33 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,79 @@ + + + + + + Leading + read + + true + + + true + + + + Trailing + read + + true + + + true + + + + LeadingAndTrailing + read + + true + + + true + + + + + + Condition_Read_String + read + + true + + + string + + + + Condition_Read_Number + read + + true + + + number + + + + Condition_Read_Discreet + read + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..8284277a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckDisabledIfAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,79 @@ + + + + + + Alarmed_ConditionOnString + read + + true + + + true + + + + Alarmed_ConditionOnNumber + read + + true + + + true + + + + Alarmed_ConditionOnDiscreet + read + + true + + + true + + + + + + Condition_Read_String + read + + true + + + string + + + + Condition_Read_Number + read + + true + + + number + + + + Condition_Read_Discreet + read + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/CheckMonitoredTag.cs b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/CheckMonitoredTag.cs new file mode 100644 index 00000000..cf4701dc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/CheckMonitoredTag.cs @@ -0,0 +1,192 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Alarm.Monitored.CheckMonitoredTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Alarm.Monitored.CheckMonitoredTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckMonitoredTag(); + + #region Valid + [TestMethod] + public void Param_CheckMonitoredTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + #endregion + + #region Invalid + [TestMethod] + public void Param_CheckMonitoredTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), // Empty + Error.EmptyTag(null, null, null, "101"), // Spaces + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckMonitoredTag_InvalidTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTag", + ExpectedResults = new List + { + Error.InvalidTag(null, null, null, "invalidValue", "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckMonitoredTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckMonitoredTag_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "101"), + Error.RTDisplayExpected(null, null, null, "102"), + Error.RTDisplayExpected(null, null, null, "103"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckMonitoredTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", " true"), + + Error.UntrimmedTag(null, null, null, "200", "false "), + Error.UntrimmedTag(null, null, null, "201", " false "), + } + }; + + Generic.Validate(test, data); + } + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckMonitoredTag(); + + [TestMethod] + public void Param_CheckMonitoredTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckMonitoredTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckMonitoredTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckMonitoredTag_RemovedAlarming() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedAlarming", + ExpectedResults = new List + { + ErrorCompare.RemovedAlarming(null, null, "1"), + ErrorCompare.RemovedAlarming(null, null, "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckMonitoredTag(); + + [TestMethod] + public void Param_CheckMonitoredTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckMonitoredTag_CheckId() => Generic.CheckId(root, CheckId.CheckMonitoredTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..db9ef2a5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,34 @@ + + + + + AlarmTrue_RTDisplayTrue + + true + + + true + + + + + AlarmFalse_RTDisplayTrue + + false + + + true + + + + AlarmFalse_RTDisplayFalse + + false + + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_New.xml new file mode 100644 index 00000000..7cdfdf78 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_New.xml @@ -0,0 +1,13 @@ + + + + + false + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_Old.xml new file mode 100644 index 00000000..d8fd4d34 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Invalid/RemovedAlarming_Old.xml @@ -0,0 +1,14 @@ + + + + + true + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..04236577 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,19 @@ + + + + + true + + + + + true + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..800e7b9b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,14 @@ + + + + + true + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..2540cbc8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,18 @@ + + + + + Empty + + + + + + Space + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/InvalidTag.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/InvalidTag.xml new file mode 100644 index 00000000..573fd6f5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/InvalidTag.xml @@ -0,0 +1,12 @@ + + + + + Empty + + invalidValue + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..6ddd18f3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..01ca5f03 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,33 @@ + + + + + AlarmTrue_RTDisplayFalse + + true + + + false + + + + AlarmTrue_NoRTDisplay + + true + + + + + + + AlarmTrue_NoDisplay + + true + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..8ecd6571 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,34 @@ + + + + + AlarmTrue_RTDisplayTrue + + true + + + true + + + + + AlarmFalse_RTDisplayTrue + + false + + + true + + + + AlarmFalse_RTDisplayFalse + + false + + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a701ff12 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Alarm/Monitored/CheckMonitoredTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,52 @@ + + + + + AlarmTrue_RTDisplayTrue + + true + + + true + + + + + AlarmFalse_RTDisplayTrue + + false + + + true + + + + AlarmFalse_RTDisplayFalse + + false + + + false + + + + AlarmFalse_NoRTDisplay + + false + + + + + + + AlarmFalse_NoDisplay + + false + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/CheckArrayOptionsTag.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/CheckArrayOptionsTag.cs new file mode 100644 index 00000000..359eef7b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/CheckArrayOptionsTag.cs @@ -0,0 +1,83 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckArrayOptionsTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckArrayOptionsTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckArrayOptionsTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckArrayOptionsTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckArrayOptionsTag_DisplayColumnChangedToNaming() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisplayColumnChangedToNaming", + ExpectedResults = new List + { + ErrorCompare.DisplayColumnChangedToNaming(null, null, "0", "100", "naming=/103"), + ErrorCompare.DisplayColumnChangedToNaming(null, null, "1", "200", "naming=*103,105"), + ErrorCompare.DisplayColumnChangedToNaming(null, null, "1", "300", "naming=*103,105"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckArrayOptionsTag_DisplayColumnChangeToNamingFormat() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisplayColumnChangeToNamingFormat", + ExpectedResults = new List + { + ErrorCompare.DisplayColumnChangeToNamingFormat(null, null, "0", "100", ",string,1512,discreet,1514"), + ErrorCompare.DisplayColumnChangeToNamingFormat(null, null, "1", "200", ";Hello World;1512;Hello World,1514"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckArrayOptionsTag(); + + [TestMethod] + public void Param_CheckArrayOptionsTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckArrayOptionsTag_CheckId() => Generic.CheckId(root, CheckId.CheckArrayOptionsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_New.xml new file mode 100644 index 00000000..99390aef --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_New.xml @@ -0,0 +1,18 @@ + + + + SomeTable + Some Table + + ,string,1512,discreet,1514 + + + + SomeTable2 + Some Table 2 + + ;Hello World;1512;Hello World,1514 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_Old.xml new file mode 100644 index 00000000..5ff9d17a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangeToNamingFormat_Old.xml @@ -0,0 +1,16 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_New.xml new file mode 100644 index 00000000..f7817d5b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_New.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_Old.xml new file mode 100644 index 00000000..41642b9c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Invalid/DisplayColumnChangedToNaming_Old.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..c8865634 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..ac6ca5d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckArrayOptionsTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/CheckDisplayColumnAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/CheckDisplayColumnAttribute.cs new file mode 100644 index 00000000..d0bdb02b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/CheckDisplayColumnAttribute.cs @@ -0,0 +1,100 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckDisplayColumnAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckDisplayColumnAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckDisplayColumnAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_DisplayColumnRemoved() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisplayColumnRemoved", + ExpectedResults = new List + { + ErrorCompare.DisplayColumnRemoved(null, null, "1", "100"), + ErrorCompare.DisplayColumnRemoved(null, null, "2", "200"), + ErrorCompare.DisplayColumnRemoved(null, null, "1", "300"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_DisplayColumnAdded() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisplayColumnAdded", + ExpectedResults = new List + { + ErrorCompare.DisplayColumnAdded(null, null, "1", "100"), + ErrorCompare.DisplayColumnAdded(null, null, "2", "200"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_DisplayColumnContentChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisplayColumnContentChanged", + ExpectedResults = new List + { + ErrorCompare.DisplayColumnContentChanged(null, null, "1", "100", "2"), + ErrorCompare.DisplayColumnContentChanged(null, null, "2", "200", "1"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDisplayColumnAttribute(); + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckDisplayColumnAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckDisplayColumnAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_New.xml new file mode 100644 index 00000000..0d1ec85d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_New.xml @@ -0,0 +1,16 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_Old.xml new file mode 100644 index 00000000..20452367 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnAdded_Old.xml @@ -0,0 +1,16 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_New.xml new file mode 100644 index 00000000..e9785d5c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_New.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_Old.xml new file mode 100644 index 00000000..482d42e6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnContentChanged_Old.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_New.xml new file mode 100644 index 00000000..979a0539 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_New.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_Old.xml new file mode 100644 index 00000000..482d42e6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Invalid/DisplayColumnRemoved_Old.xml @@ -0,0 +1,22 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + SomeTable3 + Some Table 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..5931d284 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,38 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + NotATable + This is not a table. + + + SomeTable4 + Some Table 4 + + + + + SomeTable5 + Some Table5 + + + + + SomeTable6 + Some Table 6 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..2a927da8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayColumnAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,38 @@ + + + + SomeTable + Some Table + + + + + SomeTable2 + Some Table 2 + + + + + NotATable + This is not a table. + + + SomeTable4 + Some Table 4 + + + + + SomeTable5 + Some Table5 + + + + + SomeTable6 + Some Table 6 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/CheckDisplayKey.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/CheckDisplayKey.cs new file mode 100644 index 00000000..0019108a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/CheckDisplayKey.cs @@ -0,0 +1,407 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckDisplayKey +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckDisplayKey; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckDisplayKey(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayKey_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_ValidIssuesToIgnore() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidIssuesToIgnore", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayKey_DisplayColumnSameAsPK() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayColumnSameAsPK", + ExpectedResults = new List + { + Error.DisplayColumnSameAsPK(null, null, null, "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayColumnUnrecommended() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayColumnUnrecommended", + ExpectedResults = new List + { + Error.DisplayColumnUnrecommended(null, null, null, "1000", false), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayKeyColumnInvalidInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayKeyColumnInvalidInterpreteType", + ExpectedResults = new List + { + // NamingFormat (only old displayColumn attribute requires the Interprete/type to be string) + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "double", "1002"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "1102"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "double", "1209"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "1309"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "double", "1509"), + + // Naming option (only old displayColumn attribute requires the Interprete/type to be string) + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "2002"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "double", "2109"), + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "2209"), + + // DisplayColumn attribute + Error.DisplayColumnUnrecommended(null, null, null, "3000", false), + Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "double", "3002"), + + // No option -> default to PK -> already covered by check on PK. + ////Error.DisplayKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "10001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayKeyColumnInvalidMeasurementType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayKeyColumnInvalidMeasurementType", + ExpectedResults = new List + { + // NamingFormat (only old displayColumn attribute requires the Interprete/type to be string/doube) + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "analog", "1002"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "button", "1102"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "chart", "1209"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "digital threshold", "1309"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "discreet", "1509"), + + // Naming option (only old displayColumn attribute requires the Interprete/type to be string) + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "matrix", "2002"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "pagebutton", "2109"), + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "progress", "2209"), + + // DisplayColumn attribute + Error.DisplayColumnUnrecommended(null, null, null, "3000", false), + Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "title", "3002"), + + // No option -> default to PK -> Already covered by check on PK + ////Error.DisplayKeyColumnInvalidMeasurementType(null, null, null, "togglebutton", "10001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayKeyColumnInvalidType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayKeyColumnInvalidType", + ExpectedResults = new List + { + // NamingFormat + Error.DisplayKeyColumnInvalidType(null, null, null, "write", "1002"), + Error.DisplayKeyColumnInvalidType(null, null, null, "group", "1102"), + Error.DisplayKeyColumnInvalidType(null, null, null, "read bit", "1209"), + Error.DisplayKeyColumnInvalidType(null, null, null, "write bit", "1309"), + //Error.DisplayKeyColumnInvalidType(null, null, null, "dummy", "1509"), // Covered by Param.GetColumns + + // Naming option + Error.DisplayKeyColumnInvalidType(null, null, null, "write", "2002"), + Error.DisplayKeyColumnInvalidType(null, null, null, "write", "2109"), + Error.DisplayKeyColumnInvalidType(null, null, null, "write", "2209"), + + // DisplayColumn attribute + Error.DisplayColumnUnrecommended(null, null, null, "3000", false), + Error.DisplayKeyColumnInvalidType(null, null, null, "write", "3002"), + + // No option -> default to PK -> Already covered by check on PK. + ////Error.DisplayKeyColumnInvalidType(null, null, null, "header", "10001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayKeyColumnMissing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DisplayKeyColumnMissing", + ExpectedResults = new List + { + // NamingFormat + Error.DisplayKeyColumnMissing(null, null, null, "1200"), + Error.DisplayKeyColumnMissing(null, null, null, "1300"), + Error.DisplayKeyColumnMissing(null, null, null, "1500"), + + // Naming option + Error.DisplayKeyColumnMissing(null, null, null, "2100"), + Error.DisplayKeyColumnMissing(null, null, null, "2200"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DuplicateDisplayKeyColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateDisplayKeyColumn", + ExpectedResults = new List + { + Error.DuplicateDisplayKeyColumn(null, null, null, "1200"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DuplicateDisplayKeyDefinition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateDisplayKeyDefinition", + ExpectedResults = new List + { + Error.DuplicateDisplayKeyDefinition(null, null, null, "1000"), + Error.DuplicateDisplayKeyDefinition(null, null, null, "2000"), + Error.DuplicateDisplayKeyDefinition(null, null, null, "3000"), + Error.DuplicateDisplayKeyDefinition(null, null, null, "4000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_UnexpectedIdxSuffix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedIdxSuffix", + ExpectedResults = new List + { + // NamingFormat + Error.UnexpectedIdxSuffix(null, null, null, "1001"), + + Error.UnexpectedIdxSuffix(null, null, null, "1101"), + + Error.UnexpectedIdxSuffix(null, null, null, "1201"), + Error.UnexpectedIdxSuffix(null, null, null, "1202"), + + Error.UnexpectedIdxSuffix(null, null, null, "1301"), + Error.UnexpectedIdxSuffix(null, null, null, "1302"), + Error.UnexpectedIdxSuffix(null, null, null, "1303"), + + Error.UnexpectedIdxSuffix(null, null, null, "1501"), + Error.UnexpectedIdxSuffix(null, null, null, "1502"), + + // Naming option + Error.UnexpectedIdxSuffix(null, null, null, "2001"), + + Error.UnexpectedIdxSuffix(null, null, null, "2101"), + Error.UnexpectedIdxSuffix(null, null, null, "2102"), + + Error.UnexpectedIdxSuffix(null, null, null, "2201"), + Error.UnexpectedIdxSuffix(null, null, null, "2202"), + + // displayColumn + Error.DisplayColumnUnrecommended(null, null, null, "3000", false), + Error.UnexpectedIdxSuffix(null, null, null, "3001"), + + // NoDisplayKey -> defaults to PK + Error.UnexpectedIdxSuffix(null, null, null, "10002"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckDisplayKey(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayKey_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayKey_FormatChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "FormatChanged", + ExpectedResults = new List + { + // Naming to Naming + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "/102,103", "ArrayOptions@options:naming", "*102,103", "100"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "\\102,103,104", "ArrayOptions@options:naming", "*102,103,104", "110"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "/102,103", "ArrayOptions@options:naming", "*102,103", "150"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "\\102,103,104", "ArrayOptions@options:naming", "*102,103,104", "160"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "/102", "ArrayOptions@options:naming", "/202", "200"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "\\102,103", "ArrayOptions@options:naming", "\\212,213", "210"), + + // Naming to NamingFormat + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "/102,103", "ArrayOptions/NamingFormat", ",102,*,103,", "1000"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "\\102,103,104", "ArrayOptions/NamingFormat", ",102,*,103,\\,104,", "1010"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "/102", "ArrayOptions/NamingFormat", ",1052,", "1050"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions@options:naming", "\\102,103", "ArrayOptions/NamingFormat", ",1062,\\,1063,", "1060"), + + // NamingFormat to Naming + ErrorCompare.FormatChanged(null, null, "ArrayOptions/NamingFormat", ",102,/,103,", "ArrayOptions@options:naming", "*102,103", "2000"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions/NamingFormat", ",102,\\,103,\\,104,", "ArrayOptions@options:naming", "*102,103,104", "2010"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions/NamingFormat", ",102,", "ArrayOptions@options:naming", "/2052", "2050"), + ErrorCompare.FormatChanged(null, null, "ArrayOptions/NamingFormat", ",102,\\,103,", "ArrayOptions@options:naming", "\\2062,2063", "2060"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_FormatRemoved() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "FormatRemoved", + ExpectedResults = new List + { + // Naming + ErrorCompare.FormatRemoved(null, null, "ArrayOptions@options:naming", "1000"), + ErrorCompare.FormatRemoved(null, null, "ArrayOptions@options:naming", "1010"), + ErrorCompare.FormatRemoved(null, null, "ArrayOptions@options:naming", "1020"), + + // NamingFormat + ErrorCompare.FormatRemoved(null, null, "ArrayOptions/NamingFormat", "2000"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDisplayKey(); + + [TestMethod] + public void Param_CheckDisplayKey_DuplicateDisplayKeyDefinition() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "DuplicateDisplayKeyDefinition", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDisplayKey_DisplayColumnSameAsPK() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "DisplayColumnSameAsPK", + }; + + Generic.Fix(codeFix, data); + } + + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDisplayKey(); + + [TestMethod] + public void Param_CheckDisplayKey_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckDisplayKey_CheckId() => Generic.CheckId(root, CheckId.CheckDisplayKey); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DisplayColumnSameAsPK.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DisplayColumnSameAsPK.xml new file mode 100644 index 00000000..73ee0adc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DisplayColumnSameAsPK.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DuplicateDisplayKeyDefinition.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DuplicateDisplayKeyDefinition.xml new file mode 100644 index 00000000..1100b0dc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Codefix/DuplicateDisplayKeyDefinition.xml @@ -0,0 +1,29 @@ + + + + + DisplayColumn_And_Naming + + + + + DisplayColumn_And_NamingFormat + + + + + + Naming_And_NamingFormat + + + + + + DisplayColumn_And_Naming_And_NamingFormat + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_New.xml new file mode 100644 index 00000000..fcd14bac --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_New.xml @@ -0,0 +1,87 @@ + + + + + NamingToNaming_SeparatorChange1_2Parts + + + + + NamingToNaming_SeparatorChange1_3Parts + + + + + + NamingToNaming_SeparatorChange2_2Parts + + + + + NamingToNaming_SeparatorChange2_3Parts + + + + + + NamingToNaming_ContentChange_1Parts + + + + + NamingToNaming_ContentChange_2Parts + + + + + + + NamingToNamingFormat_SeparatorChange1_2Parts + + ,102,*,103, + + + + NamingToNamingFormat_SeparatorChange1_3Parts + + ,102,*,103,\,104, + + + + + NamingToNamingFormat_ContentChange1_1Parts + + ,1052, + + + + NamingToNamingFormat_ContentChange1_2Parts + + ,1062,\,1063, + + + + + + NamingFormatToNaming_SeparatorChange1_2Parts + + + + + NamingFormatToNaming_SeparatorChange1_3Parts + + + + + + NamingFormatToNaming_ContentChange1_1Parts + + + + + NamingFormatToNaming_ContentChange1_2Parts + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_Old.xml new file mode 100644 index 00000000..99a985ab --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatChanged_Old.xml @@ -0,0 +1,87 @@ + + + + + NamingToNaming_SeparatorChange1_2Parts + + + + + NamingToNaming_SeparatorChange1_3Parts + + + + + + NamingToNaming_SeparatorChange2_2Parts + + + + + NamingToNaming_SeparatorChange2_3Parts + + + + + + NamingToNaming_ContentChange_1Parts + + + + + NamingToNaming_ContentChange_2Parts + + + + + + + NamingToNamingFormat_SeparatorChange1_2Parts + + + + + NamingToNamingFormat_SeparatorChange1_3Parts + + + + + + NamingToNamingFormat_ContentChange1_1Parts + + + + + NamingToNamingFormat_ContentChange1_2Parts + + + + + + + NamingFormatToNaming_SeparatorChange1_2Parts + + ,102,/,103, + + + + NamingFormatToNaming_SeparatorChange1_3Parts + + ,102,\,103,\,104, + + + + + NamingFormatToNaming_ContentChange1_1Parts + + ,102, + + + + NamingFormatToNaming_ContentChange1_2Parts + + ,102,\,103, + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_New.xml new file mode 100644 index 00000000..105537cb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_New.xml @@ -0,0 +1,27 @@ + + + + + RemovedNaming_Basic + + + + + RemovedNaming_OtherOptions + + + + + RemovedNaming_OtherSeparator + + + + + + + RemovedNamingFormat + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_Old.xml new file mode 100644 index 00000000..eaf75615 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Invalid/FormatRemoved_Old.xml @@ -0,0 +1,28 @@ + + + + + RemovedNaming_Basic + + + + + RemovedNaming_OtherOptions + + + + + RemovedNaming_OtherSeparator + + + + + + + RemovedNamingFormat + + ,2002, + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..1cf6c21a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,255 @@ + + + + + + NoneToNone_1 + + + + + NoneToNone_2 + + + + + NoneToNone_3 + + + + + NoneToNone_Invalid_2 + + + + + + NoneToNone_InvalidNaming_1 + + + + + NoneToNone_InvalidNaming_2 + + + + + NoneToNone_InvalidNaming_3 + + + + + NoneToNone_InvalidNaming_4 + + + + + NoneToNone_InvalidNaming_5 + + + + + + NoneToNone_InvalidNamingFormat_1 + + + + + + + + NamingToNaming_DefaultSeparator_1Part + + + + + NamingToNaming_DefaultSeparator_2Parts + + + + + NamingToNaming_DefaultSeparator_3Parts + + + + + + NamingToNaming_OtherSeparator1_1Part + + + + + NamingToNaming_OtherSeparator1_2Parts + + + + + NamingToNaming_OtherSeparator1_3Parts + + + + + + NamingToNaming_OtherSeparator2_1Part + + + + + NamingToNaming_OtherSeparator2_2Parts + + + + + NamingToNaming_OtherSeparator2_3Parts + + + + + + + NamingToNamingFormat_DefaultSeparator_1Part + + ,102, + + + + NamingToNamingFormat_DefaultSeparator_2Parts + + ,102,/,103, + + + + NamingToNamingFormat_DefaultSeparator_3Parts + + ,102,/,103,/,104, + + + + + NamingToNamingFormat_OtherSeparator1_1Part + + ,102, + + + + NamingToNamingFormat_OtherSeparator1_2Parts + + ,102,\,103, + + + + NamingToNamingFormat_OtherSeparator1_3Parts + + ,102,\,103,\,104, + + + + + NamingToNamingFormat_OtherSeparator2_1Part + + ,102, + + + + NamingToNamingFormat_OtherSeparator2_2Parts + + ,102,*,103, + + + + NamingToNamingFormat_OtherSeparator2_3Parts + + ,102,*,103,*,104, + + + + + + NamingFormatToNaming_DefaultSeparator_1Part + + + + + NamingFormatToNaming_DefaultSeparator_2Parts + + + + + NamingFormatToNaming_DefaultSeparator_3Parts + + + + + + NamingFormatToNaming_OtherSeparator1_1Part + + + + + NamingFormatToNaming_OtherSeparator1_2Parts + + + + + NamingFormatToNaming_OtherSeparator1_3Parts + + + + + + NamingFormatToNaming_OtherSeparator2_1Part + + + + + NamingFormatToNaming_OtherSeparator2_2Parts + + + + + NamingFormatToNaming_OtherSeparator2_3Parts + + + + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_1Part + + ,102, + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_2Parts + + ,102,*,103, + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_3Parts + + ,102,*,103,*,104, + + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_1Part + + $102 + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_2Parts + + ;102;*;103 + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_3Parts + + ;102;*;103;*;104 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..b36fb0fb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,255 @@ + + + + + + NoneToNone_1 + + + + + NoneToNone_2 + + + + + NoneToNone_3 + + + + + NoneToNone_Invalid_2 + + + + + + NoneToNone_InvalidNaming_1 + + + + + NoneToNone_InvalidNaming_2 + + + + + NoneToNone_InvalidNaming_3 + + + + + NoneToNone_InvalidNaming_4 + + + + + NoneToNone_InvalidNaming_5 + + + + + + NoneToNone_InvalidNamingFormat_1 + + + + + + + + NamingToNaming_DefaultSeparator_1Part + + + + + NamingToNaming_DefaultSeparator_2Parts + + + + + NamingToNaming_DefaultSeparator_3Parts + + + + + + NamingToNaming_OtherSeparator1_1Part + + + + + NamingToNaming_OtherSeparator1_2Parts + + + + + NamingToNaming_OtherSeparator1_3Parts + + + + + + NamingToNaming_OtherSeparator2_1Part + + + + + NamingToNaming_OtherSeparator2_2Parts + + + + + NamingToNaming_OtherSeparator2_3Parts + + + + + + + NamingToNamingFormat_DefaultSeparator_1Part + + + + + NamingToNamingFormat_DefaultSeparator_2Parts + + + + + NamingToNamingFormat_DefaultSeparator_3Parts + + + + + + NamingToNamingFormat_OtherSeparator1_1Part + + + + + NamingToNamingFormat_OtherSeparator1_2Parts + + + + + NamingToNamingFormat_OtherSeparator1_3Parts + + + + + + NamingToNamingFormat_OtherSeparator2_1Part + + + + + NamingToNamingFormat_OtherSeparator2_2Parts + + + + + NamingToNamingFormat_OtherSeparator2_3Parts + + + + + + + NamingFormatToNaming_DefaultSeparator_1Part + + ,102, + + + + NamingFormatToNaming_DefaultSeparator_2Parts + + ,102,/,103, + + + + NamingFormatToNaming_DefaultSeparator_3Parts + + ,102,/,103,/,104, + + + + + NamingFormatToNaming_OtherSeparator1_1Part + + ,102, + + + + NamingFormatToNaming_OtherSeparator1_2Parts + + ,102,\,103, + + + + NamingFormatToNaming_OtherSeparator1_3Parts + + ,102,\,103,\,104, + + + + + NamingFormatToNaming_OtherSeparator2_1Part + + ,102, + + + + NamingFormatToNaming_OtherSeparator2_2Parts + + ,102,*,103, + + + + NamingFormatToNaming_OtherSeparator2_3Parts + + ,102,*,103,*,104, + + + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_1Part + + ,102 + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_2Parts + + ,102,*,103 + + + + NamingFormatToNamingFormat_AddMeaninglessSeparators_3Parts + + ,102,*,103,*,104 + + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_1Part + + $102$ + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_2Parts + + ;102;*;103; + + + + NamingFormatToNamingFormat_RemoveMeaninglessSeparators_3Parts + + ;102;*;103;*;104; + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnSameAsPK.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnSameAsPK.xml new file mode 100644 index 00000000..12348ea5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnSameAsPK.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnUnrecommended.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnUnrecommended.xml new file mode 100644 index 00000000..3b48aac2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayColumnUnrecommended.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidInterpreteType.xml new file mode 100644 index 00000000..15076f51 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidInterpreteType.xml @@ -0,0 +1,449 @@ + + + + + + NamingFormat_1LocalColumn_1Separator + array + + + + + + + + NamingFormat_1LocalColumn_1Separator_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + read + + double + + + true + + + string + + + + + NamingFormat_1LocalColumn_2Separators + array + + + + + + + + NamingFormat_1LocalColumn_2Separators_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + read + + high nibble + + + true + + + string + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read + + double + + + true + + + string + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + read + + high nibble + + + true + + + string + + + + + NamingFormat_2LocalColumns + array + + + + + + + + + NamingFormat_2LocalColumns_Instance + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + read + + double + + + true + + + string + + + + + + Naming_1LocalColumn + array + + + + + + + Naming_1LocalColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_Column2 [IDX] + Naming_1LocalColumn_Column2 [IDX] + read + + high nibble + + + true + + + string + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + + Naming_1LocalColumn_1RemoveColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + read + + double + + + true + + + string + + + + + Naming_2LocalColumns + array + + + + + + + + Naming_2LocalColumns_Instance + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + read + + high nibble + + + true + + + string + + + + + + DisplayColumn + array + + + + + + + DisplayColumn_Instance + read + + string + + + true + + + string + + + + DisplayColumn_DK [IDX] + DisplayColumn_DK [IDX] + read + + double + + + true + + + string + + + + + + NoDisplayKey + array + + + + + + NoDisplayKey_Instance [IDX] + NoDisplayKey_Instance [IDX] + read + + high nibble + + + true + + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidMeasurementType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidMeasurementType.xml new file mode 100644 index 00000000..a98e7885 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidMeasurementType.xml @@ -0,0 +1,479 @@ + + + + + + NamingFormat_1LocalColumn_1Separator + array + + + + + + + true + + + + NamingFormat_1LocalColumn_1Separator_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + read + + string + + + true + + + analog + + + + + NamingFormat_1LocalColumn_2Separators + array + + + + + + + true + + + + NamingFormat_1LocalColumn_2Separators_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + read + + string + + + true + + + button + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + true + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read + + string + + + true + + + chart + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + true + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + read + + string + + + true + + + digital threshold + + + + + NamingFormat_2LocalColumns + array + + + + + + + + true + + + + NamingFormat_2LocalColumns_Instance + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + discreet + + + + + + Naming_1LocalColumn + array + + + + + + true + + + + Naming_1LocalColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_Column2 [IDX] + Naming_1LocalColumn_Column2 [IDX] + read + + string + + + true + + + matrix + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + true + + + + Naming_1LocalColumn_1RemoveColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + read + + string + + + true + + + pagebutton + + + + + Naming_2LocalColumns + array + + + + + + + true + + + + Naming_2LocalColumns_Instance + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + progress + + + + + + DisplayColumn + array + + + + + + true + + + + DisplayColumn_Instance + read + + string + + + true + + + string + + + + DisplayColumn_DK [IDX] + DisplayColumn_DK [IDX] + read + + string + + + true + + + title + + + + + + NoDisplayKey + array + + + + + true + + + + NoDisplayKey_Instance [IDX] + NoDisplayKey_Instance [IDX] + read + + string + + + true + + + togglebutton + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidType.xml new file mode 100644 index 00000000..8b8ea891 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnInvalidType.xml @@ -0,0 +1,451 @@ + + + + + + NamingFormat_1LocalColumn_1Separator + array + + + + + + + + NamingFormat_1LocalColumn_1Separator_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + write + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_2Separators + array + + + + + + + + NamingFormat_1LocalColumn_2Separators_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + group + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read bit + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + write bit + + string + + + true + + + string + + + + + NamingFormat_2LocalColumns + array + + + + + + + + + NamingFormat_2LocalColumns_Instance + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + + dummy + + string + + + true + + + string + + + + + + Naming_1LocalColumn + array + + + + + + + Naming_1LocalColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_Column2 [IDX] + Naming_1LocalColumn_Column2 [IDX] + write + + string + + + true + + + string + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + + Naming_1LocalColumn_1RemoveColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + write + + string + + + true + + + string + + + + + Naming_2LocalColumns + array + + + + + + + + Naming_2LocalColumns_Instance + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + write + + string + + + true + + + string + + + + + + DisplayColumn + array + + + + + + + DisplayColumn_Instance + read + + string + + + true + + + string + + + + DisplayColumn_DK [IDX] + DisplayColumn_DK [IDX] + write + + string + + + true + + + string + + + + + + NoDisplayKey + array + + + + + + NoDisplayKey_Instance [IDX] + NoDisplayKey_Instance [IDX] + + write + + string + + + true + + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnMissing.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnMissing.xml new file mode 100644 index 00000000..e01ea334 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DisplayKeyColumnMissing.xml @@ -0,0 +1,283 @@ + + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_2LocalColumns + array + + + + + + + + + NamingFormat_2LocalColumns_Instance + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + + Naming_1LocalColumn_1RemoveColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + read + + string + + + true + + + string + + + + + Naming_2LocalColumns + array + + + + + + + + Naming_2LocalColumns_Instance + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyColumn.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyColumn.xml new file mode 100644 index 00000000..c044aeba --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyColumn.xml @@ -0,0 +1,71 @@ + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_DK1 [IDX] + NamingFormat_1LocalColumn_1HardCoded_DK1 [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_DK2 [IDX] + NamingFormat_1LocalColumn_1HardCoded_DK2 [IDX] + read + + string + + + true + + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyDefinition.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyDefinition.xml new file mode 100644 index 00000000..a5cf4067 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/DuplicateDisplayKeyDefinition.xml @@ -0,0 +1,31 @@ + + + + + + + DisplayColumn_And_Naming + + + + + DisplayColumn_And_NamingFormat + + + + + + Naming_And_NamingFormat + + + + + + DisplayColumn_And_Naming_And_NamingFormat + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/UnexpectedIdxSuffix.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/UnexpectedIdxSuffix.xml new file mode 100644 index 00000000..2dc71f74 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Invalid/UnexpectedIdxSuffix.xml @@ -0,0 +1,479 @@ + + + + + + NamingFormat_1LocalColumn_1Separator + array + + + + + + + + NamingFormat_1LocalColumn_1Separator_Instance + NamingFormat_1LocalColumn_Instance [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_2Separators + array + + + + + + + + NamingFormat_1LocalColumn_2Separators_Instance + NamingFormat_1LocalColumn_2Separators_Instance [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + NamingFormat_1LocalColumn_1HardCoded_Instance [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + NamingFormat_1LocalColumn_1HardCoded_Column2 [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + NamingFormat_1LocalColumn_1RemoteColumn_Instance [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + NamingFormat_1LocalColumn_1RemoteColumn_Column2 [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK [IDX] + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_2LocalColumns + array + + + + + + + + + NamingFormat_2LocalColumns_Instance + NamingFormat_2LocalColumns_Instance [IDX] + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + NamingFormat_2LocalColumns_Column2 [IDX] + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + Naming_1LocalColumn + array + + + + + + + Naming_1LocalColumn_Instance + Naming_1LocalColumn_Instance [idx] + read + + string + + + true + + + string + + + + Naming_1LocalColumn_Column2 [IDX] + Naming_1LocalColumn_Column2 [IDX] + read + + string + + + true + + + string + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + + Naming_1LocalColumn_1RemoveColumn_Instance + Naming_1LocalColumn_1RemoveColumn_Instance [IDX] + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + Naming_1LocalColumn_1RemoveColumn_Column2_FK [IDX] + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + read + + string + + + true + + + string + + + + + Naming_2LocalColumns + array + + + + + + + + Naming_2LocalColumns_Instance + Naming_2LocalColumns_Instance [IDX] + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + Naming_2LocalColumns_Column2 [IDX] + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + DisplayColumn + array + + + + + + + DisplayColumn_Instance + DisplayColumn_Instance [IDX] + read + + string + + + true + + + string + + + + DisplayColumn_DK [IDX] + DisplayColumn_DK [IDX] + read + + string + + + true + + + string + + + + + + NoDisplayKey + array + + + + + + + NoDisplayKey_Instance [IDX] + NoDisplayKey_Instance [IDX] + read + + string + + + true + + + string + + + + NoDisplayKey_Column2 + NoDisplayKey_Column2 [IDX] + read + + string + + + true + + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..93f5a13e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,449 @@ + + + + + + NamingFormat_1LocalColumn_1Separator + array + + + + + + + + NamingFormat_1LocalColumn_1Separator_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + NamingFormat_1LocalColumn_1Separator_Column2 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_2Separators + array + + + + + + + + NamingFormat_1LocalColumn_2Separators_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + NamingFormat_1LocalColumn_2Separators_Column2 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1HardCoded + array + + + + + + + + + NamingFormat_1LocalColumn_1HardCoded_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + NamingFormat_1LocalColumn_1HardCoded_Column3 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_1LocalColumn_1RemoteColumn + array + + + + + + + + + + NamingFormat_1LocalColumn_1RemoteColumn_Instance + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column2 + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column3_FK + read + + string + + + true + + + string + + + + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + NamingFormat_1LocalColumn_1RemoteColumn_Column4 [IDX] + read + + string + + + true + + + string + + + + + NamingFormat_2LocalColumns + array + + + + + + + + + NamingFormat_2LocalColumns_Instance + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + NamingFormat_2LocalColumns_Column3 [IDX] + NamingFormat_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + Naming_1LocalColumn + array + + + + + + + Naming_1LocalColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_Column2 [IDX] + Naming_1LocalColumn_Column2 [IDX] + read + + string + + + true + + + string + + + + + Naming_1LocalColumn_1RemoveColumn + array + + + + + + + + Naming_1LocalColumn_1RemoveColumn_Instance + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column2_FK + read + + string + + + true + + + string + + + + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + Naming_1LocalColumn_1RemoveColumn_Column3 [IDX] + read + + string + + + true + + + string + + + + + Naming_2LocalColumns + array + + + + + + + + Naming_2LocalColumns_Instance + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column2 + read + + string + + + true + + + string + + + + Naming_2LocalColumns_Column3 [IDX] + Naming_2LocalColumns_Column3 [IDX] + read + + string + + + true + + + string + + + + + + + + + NoDisplayKey + array + + + + + + NoDisplayKey_Instance [IDX] + NoDisplayKey_Instance [IDX] + read + + string + + + true + + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/ValidIssuesToIgnore.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/ValidIssuesToIgnore.xml new file mode 100644 index 00000000..2618533d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckDisplayKey/Samples/Validate/Valid/ValidIssuesToIgnore.xml @@ -0,0 +1,222 @@ + + + + + + + + NamingFormat_EmptyTag + array + + + + + + + + NamingFormat_EmptyTag_Instance + read + + string + + + true + + + string + + + + NamingFormat_EmptyTag_Column2 + read + + string + + + true + + + string + + + + + NamingFormat_EmptyCDATA + array + + + + + + + + NamingFormat_EmptyCDATA_Instance + read + + string + + + true + + + string + + + + NamingFormat_EmptyCDATA_Column2 + read + + string + + + true + + + string + + + + + NamingFormat_1Separator + array + + + + + + + + NamingFormat_1Separator_Instance + read + + string + + + true + + + string + + + + NamingFormat_1Separator_Column2 + read + + string + + + true + + + string + + + + + + Naming_Empty1 + array + + + + + + + Naming_Empty1_Instance + read + + string + + + true + + + string + + + + Naming_Empty1_Column2 + read + + string + + + true + + + string + + + + + Naming_Empty2 + array + + + + + + + Naming_Empty2_Instance + read + + string + + + true + + + string + + + + Naming_Empty2_Column2 + read + + string + + + true + + + string + + + + + Naming_Empty3 + array + + + + + + + Naming_Empty3_Instance + read + + string + + + true + + + string + + + + Naming_Empty3_Column2 + read + + string + + + true + + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/CheckIndexAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/CheckIndexAttribute.cs new file mode 100644 index 00000000..e2079d7f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/CheckIndexAttribute.cs @@ -0,0 +1,264 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckIndexAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckIndexAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIndexAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIndexAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIndexAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_InvalidAttributeValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttributeValue", + ExpectedResults = new List + { + Error.InvalidAttributeValue(null, null, null, "1100", " 01 "), + Error.InvalidAttributeValue(null, null, null, "1200", "01"), + Error.InvalidAttributeValue(null, null, null, "1300", "+1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_InvalidColumnInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnInterpreteType", + ExpectedResults = new List + { + // PK: Invalid Interprete/Type + Error.InvalidColumnInterpreteType(null, null, null, "double", "1001"), // TableSyntax1 + Error.InvalidColumnInterpreteType(null, null, null, "high nibble", "1101"), // TableSyntax2 + + // PK: No Interprete + Error.InvalidColumnInterpreteType(null, null, null, "UNDEFINED", "2001"), + + // PK: No Interprete/Type + Error.InvalidColumnInterpreteType(null, null, null, "UNDEFINED", "2101"), + + // View Tables + Error.InvalidColumnInterpreteType(null, null, null, "double", "1001"), // Currently referring to the base PK and not the duplicated one + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_InvalidColumnMeasurementType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnMeasurementType", + ExpectedResults = new List + { + // PK: Invalid Measurement/Type + Error.InvalidColumnMeasurementType(null, null, null, "analog", "1001"), + Error.InvalidColumnMeasurementType(null, null, null, "button", "1101"), + + // PK: No Measurement + Error.InvalidColumnMeasurementType(null, null, null, "UNDEFINED", "2001"), + + // PK: No Measurement/Type + Error.InvalidColumnMeasurementType(null, null, null, "UNDEFINED", "2101"), + + // View Tables + Error.InvalidColumnMeasurementType(null, null, null, "analog", "1001"), // Currently referring to the base PK and not the duplicated one + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_InvalidColumnType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnType", + ExpectedResults = new List + { + // PK: Invalid Param/Type + Error.InvalidColumnType(null, null, null, "write", "1001"), + + // View Tables + Error.InvalidColumnType(null, null, null, "write", "1001"), // Currently referring to the base PK and not the duplicated one + + // Note that missing type and other forbidden types such as bus, dummy, etc are covered by Param.CheckColumns() + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_NonExistingColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumn", + ExpectedResults = new List + { + Error.NonExistingColumn(null, null, null, " 0 ", "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_UnrecommendedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedValue", + ExpectedResults = new List + { + Error.UnrecommendedValue(null, null, null, " 1 ", "1000", "0"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1000", " 0 "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIndexAttribute(); + + [TestMethod] + public void Param_CheckIndexAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckIndexAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIndexAttribute(); + + [TestMethod] + public void Param_CheckIndexAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckIndexAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIndexAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..fe440275 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + MyTable + + + + + + MyTable_Instance + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..fe440275 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,18 @@ + + + + + MyTable + + + + + + MyTable_Instance + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..db467cd6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,20 @@ + + + + + MyTable + array + + + + + + MyTable_Instance + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..5abdc3d0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + MyTable + + + + + + MyTable_Instance + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml new file mode 100644 index 00000000..43fed362 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml @@ -0,0 +1,21 @@ + + + + + MyTable1 + + + + + MyTable2 + + + + + MyTable3 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnInterpreteType.xml new file mode 100644 index 00000000..13dba213 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnInterpreteType.xml @@ -0,0 +1,70 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + double + + + + + TableSyntax2 + array + + + + + + TableSyntax2_Instance + read + + high nibble + + + + + + NoInterprete + array + + + + + + NoInterprete_Instance + read + + + + NoInterpreteType + array + + + + + + NoInterpreteType_Instance + read + + + + + + + ViewTable + array + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnMeasurementType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnMeasurementType.xml new file mode 100644 index 00000000..f9e07b91 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnMeasurementType.xml @@ -0,0 +1,109 @@ + + + + + + TableSyntax1 + array + + + true + + + + TableSyntax1_Instance + read + + string + + + true + + + analog + + + + + TableSyntax2 + array + + + + + true + + + + TableSyntax2_Instance + read + + string + + + true + + + button + + + + + + NoMeasurement + array + + + + + true + + + + NoMeasurement_Instance + read + + string + + + true + + + + + NoMeasurementType + array + + + + + true + + + + NoMeasurementType_Instance + read + + string + + + true + + + + + + + + ViewTable + array + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnType.xml new file mode 100644 index 00000000..ad4b2a96 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/InvalidColumnType.xml @@ -0,0 +1,76 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + write + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + + bus + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + NoType + array + + + + + + NoType_Instance + + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..db63352c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,18 @@ + + + + + MyTable + + + + + + MyTable_Instance + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/NonExistingColumn.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/NonExistingColumn.xml new file mode 100644 index 00000000..09952cc1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/NonExistingColumn.xml @@ -0,0 +1,11 @@ + + + + + MyTable + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UnrecommendedValue.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UnrecommendedValue.xml new file mode 100644 index 00000000..78764a37 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UnrecommendedValue.xml @@ -0,0 +1,13 @@ + + + + + MyTable + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..ed25cebf --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,20 @@ + + + + + MyTable + array + + + + + + MyTable_Instance + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..ed09a06c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckIndexAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,59 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/CheckLoggerTable.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/CheckLoggerTable.cs new file mode 100644 index 00000000..369c3476 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/CheckLoggerTable.cs @@ -0,0 +1,71 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckLoggerTable +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckLoggerTable; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckLoggerTable(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLoggerTable_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLoggerTable_RemovedLoggerColumn() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedLoggerColumn", + ExpectedResults = new List + { + ErrorCompare.RemovedLoggerColumn(null, null, "105", "100"), + ErrorCompare.RemovedLoggerColumn(null, null, "203", "200"), + ErrorCompare.RemovedLoggerColumn(null, null, "204", "200"), + ErrorCompare.RemovedLoggerColumn(null, null, "304", "300"), + ErrorCompare.RemovedLoggerColumn(null, null, "401", "400"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckLoggerTable(); + + [TestMethod] + public void Param_CheckLoggerTable_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckLoggerTable_CheckId() => Generic.CheckId(root, CheckId.CheckLoggerTable); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_New.xml new file mode 100644 index 00000000..8763909a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_New.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_Old.xml new file mode 100644 index 00000000..6f8a6af3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Invalid/RemovedLoggerColumn_Old.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..b816fc86 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..37b5330f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckLoggerTable/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..06b0dfd0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckOptionsAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckOptionsAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidNamingOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNamingOption", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidViewTables() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidViewTables", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "100"), // Empty + Error.EmptyAttribute(null, null, null, "200"), // Spaces + Error.EmptyAttribute(null, null, null, "300"), // ColumnOptions & attribute + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_NamingEmpty() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NamingEmpty", + ExpectedResults = new List + { + Error.NamingEmpty(null, null, null, "1000"), + Error.NamingEmpty(null, null, null, "1100"), + Error.NamingEmpty(null, null, null, "10000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_NamingRefersToNonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NamingRefersToNonExistingParam", + ExpectedResults = new List + { + Error.NamingRefersToNonExistingParam(null, null, null, "1009", "1000"), + Error.NamingRefersToNonExistingParam(null, null, null, "1109", "1100"), + + Error.NamingRefersToNonExistingParam(null, null, null, "10008", "10000"), + Error.NamingRefersToNonExistingParam(null, null, null, "10009", "10000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_PreserveStateShouldBeAvoided() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "PreserveStateShouldBeAvoided", + ExpectedResults = new List + { + Error.PreserveStateShouldBeAvoided(null, null, null, "1"), + Error.PreserveStateShouldBeAvoided(null, null, null, "2"), + Error.PreserveStateShouldBeAvoided(null, null, null, "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1000", " ;naming=/1002"), + Error.UntrimmedAttribute(null, null, null, "1100", ";naming=/1101,1102 "), + + Error.UntrimmedAttribute(null, null, null, "10000", " ;volatile;view=1000;naming=/10001,10002 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewTableDirectViewInvalidColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewTableDirectViewInvalidColumn", + ExpectedResults = new List + { + Error.ViewTableDirectViewInvalidColumn(null, null, null, "12345", "100"), + Error.ViewTableDirectViewInvalidColumn(null, null, null, "201", "200"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewTableFilterChangeInvalidColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewTableFilterChangeInvalidColumns", + ExpectedResults = new List + { + Error.ViewTableFilterChangeInvalidColumns(null, null, null, "1001, 1002", "20").WithSubResults( + Error.ViewTableFilterChangeInvalidColumns(null, null, null, "1001", "20"), + Error.ViewTableFilterChangeInvalidColumns(null, null, null, "1002", "20")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewTableInvalidReference() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewTableInvalidReference", + ExpectedResults = new List + { + Error.ViewTableInvalidReference(null, null, null, Severity.Critical, "10", "10"), + Error.ViewTableInvalidReference(null, null, null, Severity.Major, "12345", "11"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckNamingFormatTag_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_LoggerTable() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "LoggerTable", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_RemovedLoggerTableDatabaseLink() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedLoggerTableDatabaseLink", + ExpectedResults = new List + { + ErrorCompare.RemovedLoggerTableDatabaseLink(null, null, "100"), + ErrorCompare.RemovedLoggerTableDatabaseLink(null, null, "200"), + ErrorCompare.RemovedLoggerTableDatabaseLink(null, null, "300"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..d95cd029 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,24 @@ + + + + + Empty + + + + + + Spaces + + + + + + ColumnOptionsAndAttribute + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..18381013 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_New.xml new file mode 100644 index 00000000..defaea58 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_New.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_Old.xml new file mode 100644 index 00000000..20304f46 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedLoggerTableDatabaseLink_Old.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_New.xml new file mode 100644 index 00000000..64035c00 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_New.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_Old.xml new file mode 100644 index 00000000..36bee2b8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/LoggerTable_Old.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..81f6b8e2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..81f6b8e2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..bf944617 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,24 @@ + + + + + Empty + + + + + + Spaces + + + + + + ColumnOptionsAndAttribute + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingEmpty.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingEmpty.xml new file mode 100644 index 00000000..5b961f8b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingEmpty.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingRefersToNonExistingParam.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingRefersToNonExistingParam.xml new file mode 100644 index 00000000..616972a0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/NamingRefersToNonExistingParam.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/PreserveStateShouldBeAvoided.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/PreserveStateShouldBeAvoided.xml new file mode 100644 index 00000000..d4c6140d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/PreserveStateShouldBeAvoided.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..7a19a38f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableDirectViewInvalidColumn.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableDirectViewInvalidColumn.xml new file mode 100644 index 00000000..cdebb934 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableDirectViewInvalidColumn.xml @@ -0,0 +1,20 @@ + + + + array + + + + + + array + + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableFilterChangeInvalidColumns.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableFilterChangeInvalidColumns.xml new file mode 100644 index 00000000..1b0d4ebc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableFilterChangeInvalidColumns.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableInvalidReference.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableInvalidReference.xml new file mode 100644 index 00000000..3f308bee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Invalid/ViewTableInvalidReference.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..072364e2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + array + + + + + + + + + read + + + read + + + read + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidNamingOption.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidNamingOption.xml new file mode 100644 index 00000000..18381013 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidNamingOption.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidViewTables.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidViewTables.xml new file mode 100644 index 00000000..d4d7dd5c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckOptionsAttribute/Samples/Validate/Valid/ValidViewTables.xml @@ -0,0 +1,42 @@ + + + + + + array + + + + + + read + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/CheckPartialAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/CheckPartialAttribute.cs new file mode 100644 index 00000000..0e2300a4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/CheckPartialAttribute.cs @@ -0,0 +1,69 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.CheckPartialAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.CheckPartialAttribute; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckPartialAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckPartialAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckPartialAttribute_EnabledPartial() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "EnabledPartial", + ExpectedResults = new List + { + ErrorCompare.EnabledPartial(null, null, "1"), + ErrorCompare.EnabledPartial(null, null, "2"), + ErrorCompare.EnabledPartial(null, null, "3"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckPartialAttribute(); + + [TestMethod] + public void Param_CheckPartialAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckPartialAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckPartialAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_New.xml new file mode 100644 index 00000000..b92291af --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_New.xml @@ -0,0 +1,25 @@ + + + + + + + true + + + + + + + true + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_Old.xml new file mode 100644 index 00000000..d40bc376 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Invalid/EnabledPartial_Old.xml @@ -0,0 +1,25 @@ + + + + + + + true + + + + + + + true + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..6d263c88 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,64 @@ + + + + + + + + + true + + + + + + + + true + + + + + + + + true + + + + + + true + + + + + + + + true + + + + + + + + + false + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..72dcef56 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/CheckPartialAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,64 @@ + + + + + + + + + true + + + + + + + + true + + + + + + + + true + + + + + + true + + + + + + + + true + + + + + + + + + false + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/CheckColumnOptionTag.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/CheckColumnOptionTag.cs new file mode 100644 index 00000000..67da580c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/CheckColumnOptionTag.cs @@ -0,0 +1,68 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckColumnOptionTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckColumnOptionTag; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckColumnOptionTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckColumnOptionTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckColumnOptionTag_RemovedColumnOptionTag() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedColumnOptionTag", + ExpectedResults = new List + { + ErrorCompare.RemovedColumnOptionTag(null, null, "1004", "1000"), + ErrorCompare.RemovedColumnOptionTag(null, null, "2002", "2000"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckColumnOptionTag(); + + [TestMethod] + public void Param_CheckColumnOptionTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckColumnOptionTag_CheckId() => Generic.CheckId(root, CheckId.CheckColumnOptionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_New.xml new file mode 100644 index 00000000..ef50612b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_New.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + true + + + + + + + + + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_Old.xml new file mode 100644 index 00000000..d107c0d3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Invalid/RemovedColumnOptionTag_Old.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + true + + + + + + + + + + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..783c1de8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..10470038 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckColumnOptionTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/CheckIdxAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/CheckIdxAttribute.cs new file mode 100644 index 00000000..4e63548c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/CheckIdxAttribute.cs @@ -0,0 +1,91 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckIdxAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckIdxAttribute; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckIdxAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIdxAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIdxAttribute_UpdatedIdxValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedIdxValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedIdxValue(null, null, "102", "2", "1", "100"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckIdxAttribute_UpdatedIdxValue_Parent() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedIdxValue_Parent", + ExpectedResults = new List + { + ErrorCompare.UpdatedIdxValue_Parent(null, null, "100").WithSubResults( + ErrorCompare.UpdatedIdxValue(null, null, "101", "0", "4", "100"), + ErrorCompare.UpdatedIdxValue(null, null, "105", "4", "0", "100")), + + ErrorCompare.UpdatedIdxValue_Parent(null, null, "200").WithSubResults( + //ErrorCompare.UpdatedIdxValue(null, null, "202", "1", "3", "200"), // Ignoring displayKey + ErrorCompare.UpdatedIdxValue(null, null, "203", "1", "2", "200"), + ErrorCompare.UpdatedIdxValue(null, null, "204", "2", "1", "200")) + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIdxAttribute(); + + [TestMethod] + public void Param_CheckIdxAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckIdxAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIdxAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_New.xml new file mode 100644 index 00000000..8a29a59b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_New.xml @@ -0,0 +1,17 @@ + + + + + SingleChange + array + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Old.xml new file mode 100644 index 00000000..2515be17 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Old.xml @@ -0,0 +1,17 @@ + + + + + SingleChange + array + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_New.xml new file mode 100644 index 00000000..1292e9f2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_New.xml @@ -0,0 +1,35 @@ + + + + + WithoutDisplayKey + array + + + + + + + + + true + + + + + WithDisplayKey + array + + + + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_Old.xml new file mode 100644 index 00000000..36b743d6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Invalid/UpdatedIdxValue_Parent_Old.xml @@ -0,0 +1,35 @@ + + + + + WithoutDisplayKey + array + + + + + + + + + true + + + + + WithDisplayKey + array + + + + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..4e4754bb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,113 @@ + + + + + + RTDisplay_MatchingColumns + array + + + + + + + + + true + + + + + RTDisplay_NoArrayOptions + array + + + true + + + + + RTDisplay_EmptyArrayOptions + array + + + + + true + + + + + RTDisplay_AddingColumns + array + + + + + + + + + + true + + + + + RTDisplay_RemovingColumns + array + + + + + + true + + + + + RTDisplay_ChangeOnlyOnDisplayKeyColumn + array + + + + + + + + + true + + + + + RTDisplay_FixingCodeOrder + array + + + + + + + + + true + + + + + + NoRTDisplay_ChangingColumns + array + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..d7ee8b75 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckIdxAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,116 @@ + + + + + + RTDisplay_MatchingColumns + array + + + + + + + + + true + + + + + RTDisplay_NoArrayOptions + array + + + true + + + + + RTDisplay_EmptyArrayOptions + array + + + + + true + + + + + RTDisplay_AddingColumns + array + + + + + + + + + true + + + + + RTDisplay_RemovingColumns + array + + + + + + + + + true + + + + + RTDisplay_ChangeOnlyOnDisplayKeyColumn + array + + + + + + + + + true + + + + + RTDisplay_FixingCodeOrder + array + + + + + + + + + true + + + + + + NoRTDisplay_ChangingColumns + array + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..03b072f4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,300 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckOptionsAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckOptionsAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidRelations_ChildrenToParent() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidRelations_ChildrenToParent", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidRelations_NToMRelation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidRelations_NToMRelation", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidRelations_ParentToChildren() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidRelations_ParentToChildren", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidRelations_RecursiveRelations() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidRelations_RecursiveRelations", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckOptionsAttribute_ColumnOptionExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnOptionExpectingRTDisplay", + ExpectedResults = new List + { + Error.ColumnOptionExpectingRTDisplay(null, null, null, "1002", "xPox", "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ForeignKeyColumnInvalidInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyColumnInvalidInterpreteType", + ExpectedResults = new List + { + Error.ForeignKeyColumnInvalidInterpreteType(null, null, null, "double", "2002"), + Error.ForeignKeyColumnInvalidInterpreteType(null, null, null, "high nibble", "3002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ForeignKeyColumnInvalidMeasurementType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyColumnInvalidMeasurementType", + ExpectedResults = new List + { + Error.ForeignKeyColumnInvalidMeasurementType(null, null, null, "analog", "2002"), + Error.ForeignKeyColumnInvalidMeasurementType(null, null, null, "discreet", "3002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ForeignKeyColumnInvalidType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyColumnInvalidType", + ExpectedResults = new List + { + Error.ForeignKeyColumnInvalidType(null, null, null, "write", "2002"), + Error.ForeignKeyColumnInvalidType(null, null, null, "read bit", "3002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ForeignKeyMissingRelation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyMissingRelation", + ExpectedResults = new List + { + // Relation 1 : 2 levels + Error.ForeignKeyMissingRelation(null, null, null, "1000", "1100", "1102"), + + // Relation 2 : 3 levels + Error.ForeignKeyMissingRelation(null, null, null, "2000", "2100", "2102"), + Error.ForeignKeyMissingRelation(null, null, null, "2100", "2200", "2202"), + + // Relation 3 : 4 levels + Error.ForeignKeyMissingRelation(null, null, null, "3000", "3100", "3102"), + Error.ForeignKeyMissingRelation(null, null, null, "3100", "3200", "3202"), + Error.ForeignKeyMissingRelation(null, null, null, "3200", "3300", "3302"), + + // Relation 10 : N to M relation + Error.ForeignKeyMissingRelation(null, null, null, "10000", "10100", "10102"), + Error.ForeignKeyMissingRelation(null, null, null, "10200", "10100", "10103"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ForeignKeyMissingRelation_NoRelations() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyMissingRelation_NoRelations", + ExpectedResults = new List + { + // Relation 1 : 2 levels + Error.ForeignKeyMissingRelation(null, null, null, "1000", "1100", "1102"), + + // Relation 2 : 3 levels + Error.ForeignKeyMissingRelation(null, null, null, "2000", "2100", "2102"), + Error.ForeignKeyMissingRelation(null, null, null, "2100", "2200", "2202"), + + // Relation 3 : 4 levels + Error.ForeignKeyMissingRelation(null, null, null, "3000", "3100", "3102"), + Error.ForeignKeyMissingRelation(null, null, null, "3100", "3200", "3202"), + Error.ForeignKeyMissingRelation(null, null, null, "3200", "3300", "3302"), + + // Relation 10 : N to M relation + Error.ForeignKeyMissingRelation(null, null, null, "10000", "10100", "10102"), + Error.ForeignKeyMissingRelation(null, null, null, "10200", "10100", "10103"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckOptionsAttribute_ForeignKeyTargetExpectingRTDisplayOnPK() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ForeignKeyTargetExpectingRTDisplayOnPK", + ExpectedResults = new List + { + Error.ForeignKeyTargetExpectingRTDisplayOnPK(null, null, null, "1001", "foreignKey=1000", "2000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewInvalidColumnReference() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewInvalidColumnReference", + ExpectedResults = new List + { + Error.ViewInvalidColumnReference(null, null, null, Severity.Critical, "101", "100"), + Error.ViewInvalidColumnReference(null, null, null, Severity.Major, "52", "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewInvalidCombinationFilterChange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewInvalidCombinationFilterChange", + ExpectedResults = new List + { + Error.ViewInvalidCombinationFilterChange(null, null, null, "10"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ViewInvalidSyntax() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ViewInvalidSyntax", + ExpectedResults = new List + { + Error.ViewInvalidSyntax(null, null, null, "0", "10"), + Error.ViewInvalidSyntax(null, null, null, "1", "10"), + Error.ViewInvalidSyntax(null, null, null, "2", "10"), + Error.ViewInvalidSyntax(null, null, null, "3", "10"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ColumnOptionExpectingRTDisplay.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ColumnOptionExpectingRTDisplay.xml new file mode 100644 index 00000000..90f0a953 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ColumnOptionExpectingRTDisplay.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidInterpreteType.xml new file mode 100644 index 00000000..fce5348f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidInterpreteType.xml @@ -0,0 +1,108 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + string + + + true + + + string + + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + string + + + true + + + string + + + + TableLevel2_FkTo1000 + read + + double + + + true + + + number + + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + string + + + true + + + string + + + + TableLevel3_FkTo2000 + read + + high nibble + + + true + + + number + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidMeasurementType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidMeasurementType.xml new file mode 100644 index 00000000..604632d5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidMeasurementType.xml @@ -0,0 +1,114 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + string + + + true + + + string + + + + + TableLevel2 + array + + + + + + true + + + + TableLevel2_Instance + read + + string + + + true + + + string + + + + TableLevel2_FkTo1000 + read + + string + + + true + + + analog + + + + + TableLevel3 + array + + + + + + true + + + + TableLevel3_Instance + read + + string + + + true + + + string + + + + TableLevel3_FkTo2000 + read + + string + + + true + + + discreet + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidType.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidType.xml new file mode 100644 index 00000000..4b76297f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyColumnInvalidType.xml @@ -0,0 +1,182 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + string + + + true + + + string + + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + string + + + true + + + string + + + + TableLevel2_FkTo1000 + write + + string + + + true + + + analog + + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + string + + + true + + + string + + + + TableLevel3_FkTo2000 + read bit + + string + + + true + + + discreet + + + + + TableLevel4 + array + + + + + + + TableLevel4_Instance + read + + string + + + true + + + string + + + + TableLevel4_FkTo2000 + + + + string + + + true + + + discreet + + + + + TableLevel5 + array + + + + + + + TableLevel5_Instance + read + + string + + + true + + + string + + + + TableLevel5_FkTo2000 + + bus + + string + + + true + + + discreet + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation.xml new file mode 100644 index 00000000..4d2a5556 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation.xml @@ -0,0 +1,273 @@ + + + + + + Relation1TableLevel1 + array + + + + + + Relation1TableLevel1_Instance + read + + + + Relation1TableLevel2 + array + + + + + + + Relation1TableLevel2_Instance + read + + + Relation1TableLevel2_FkTo1000 + read + + string + + + true + + + string + + + + + + Relation2TableLevel1 + array + + + + + + Relation2TableLevel1_Instance + read + + + + Relation2TableLevel2 + array + + + + + + + Relation2TableLevel2_Instance + read + + + Relation2TableLevel2_FkTo2000 + read + + string + + + true + + + string + + + + + Relation2TableLevel3 + array + + + + + + + Relation2TableLevel3_Instance + read + + + Relation2TableLevel3_FkTo2100 + read + + string + + + true + + + string + + + + + + Relation3TableLevel1 + array + + + + + + Relation3TableLevel1_Instance + read + + + + Relation3TableLevel2 + array + + + + + + + Relation3TableLevel2_Instance + read + + + Relation3TableLevel2_FkTo2000 + read + + string + + + true + + + string + + + + + Relation3TableLevel3 + array + + + + + + + Relation3TableLevel3_Instance + read + + + Relation3TableLevel3_FkTo2100 + read + + string + + + true + + + string + + + + + Relation3TableLevel4 + array + + + + + + + Relation3TableLevel4_Instance + read + + + Relation3TableLevel4_FkTo2200 + read + + string + + + true + + + string + + + + + + NToMParentTable + array + + + + + + NToMParentTable_Instance + read + + + + NToMIntermediateTable + array + + + + + + + + NToMIntermediateTable_Instance + read + + + NToMIntermediateTable_FkTo10000 + read + + string + + + true + + + string + + + + NToMIntermediateTable_FkTo10200 + read + + string + + + true + + + string + + + + + NToMChildrenTable + array + + + + + + NToMChildrenTable_Instance + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation_NoRelations.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation_NoRelations.xml new file mode 100644 index 00000000..7c9666f3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyMissingRelation_NoRelations.xml @@ -0,0 +1,273 @@ + + + + + + Relation1TableLevel1 + array + + + + + + Relation1TableLevel1_Instance + read + + + + Relation1TableLevel2 + array + + + + + + + Relation1TableLevel2_Instance + read + + + Relation1TableLevel2_FkTo1000 + read + + string + + + true + + + string + + + + + + Relation2TableLevel1 + array + + + + + + Relation2TableLevel1_Instance + read + + + + Relation2TableLevel2 + array + + + + + + + Relation2TableLevel2_Instance + read + + + Relation2TableLevel2_FkTo2000 + read + + string + + + true + + + string + + + + + Relation2TableLevel3 + array + + + + + + + Relation2TableLevel3_Instance + read + + + Relation2TableLevel3_FkTo2100 + read + + string + + + true + + + string + + + + + + Relation3TableLevel1 + array + + + + + + Relation3TableLevel1_Instance + read + + + + Relation3TableLevel2 + array + + + + + + + Relation3TableLevel2_Instance + read + + + Relation3TableLevel2_FkTo2000 + read + + string + + + true + + + string + + + + + Relation3TableLevel3 + array + + + + + + + Relation3TableLevel3_Instance + read + + + Relation3TableLevel3_FkTo2100 + read + + string + + + true + + + string + + + + + Relation3TableLevel4 + array + + + + + + + Relation3TableLevel4_Instance + read + + + Relation3TableLevel4_FkTo2200 + read + + string + + + true + + + string + + + + + + NToMParentTable + array + + + + + + NToMParentTable_Instance + read + + + + NToMIntermediateTable + array + + + + + + + + NToMIntermediateTable_Instance + read + + + NToMIntermediateTable_FkTo10000 + read + + string + + + true + + + string + + + + NToMIntermediateTable_FkTo10200 + read + + string + + + true + + + string + + + + + NToMChildrenTable + array + + + + + + NToMChildrenTable_Instance + read + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyTargetExpectingRTDisplayOnPK.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyTargetExpectingRTDisplayOnPK.xml new file mode 100644 index 00000000..90f0a953 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ForeignKeyTargetExpectingRTDisplayOnPK.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidColumnReference.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidColumnReference.xml new file mode 100644 index 00000000..16141fdf --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidColumnReference.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidCombinationFilterChange.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidCombinationFilterChange.xml new file mode 100644 index 00000000..d11e62f0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidCombinationFilterChange.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidSyntax.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidSyntax.xml new file mode 100644 index 00000000..fa25317d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Invalid/ViewInvalidSyntax.xml @@ -0,0 +1,15 @@ + + + + + array + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..dbfe2ce7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,89 @@ + + + + + + DveTable + array + + + + + + + DvePK + read + + + DveViewColumn + read + + true + + + + + + RelationalTable + array + + + + + + + RelationalPK + read + + + RelationalForeignKey + read + + string + + + true + + + string + + + + + + ViewTable + array + + + + + + + + ViewSyntax1 + read + + true + + + + ViewSyntax2 + read + + true + + + + ViewSyntax3 + read + + true + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ChildrenToParent.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ChildrenToParent.xml new file mode 100644 index 00000000..f155d1ea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ChildrenToParent.xml @@ -0,0 +1,108 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + string + + + true + + + string + + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + string + + + true + + + string + + + + TableLevel2_FkTo1000 + read + + string + + + true + + + string + + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + string + + + true + + + string + + + + TableLevel3_FkTo2000 + read + + string + + + true + + + string + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_NToMRelation.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_NToMRelation.xml new file mode 100644 index 00000000..4f88021c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_NToMRelation.xml @@ -0,0 +1,81 @@ + + + + + + + NToMParentTable + array + + + + + + NToMParentTable_Instance + read + + + + NToMIntermediateTable + array + + + + + + + + NToMIntermediateTable_Instance + read + + + NToMIntermediateTable_FkTo10000 + read + + string + + + true + + + string + + + + NToMIntermediateTable_FkTo10200 + read + + string + + + true + + + string + + + + + NToMChildrenTable + array + + + + + + NToMChildrenTable_Instance + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ParentToChildren.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ParentToChildren.xml new file mode 100644 index 00000000..9512c7df --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_ParentToChildren.xml @@ -0,0 +1,108 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + string + + + true + + + string + + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + string + + + true + + + string + + + + TableLevel2_FkTo1000 + read + + string + + + true + + + string + + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + string + + + true + + + string + + + + TableLevel3_FkTo2000 + read + + string + + + true + + + string + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_RecursiveRelations.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_RecursiveRelations.xml new file mode 100644 index 00000000..e311c16c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckOptionsAttribute/Samples/Validate/Valid/ValidRelations_RecursiveRelations.xml @@ -0,0 +1,114 @@ + + + + + TableRecursive + array + + + + + + + TableRecursive_Instance + read + + + TableRecursive_FkRecursive + read + + string + + + true + + + string + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + + + TableLevel2Recursive + array + + + + + + + + TableLevel2Recursive_Instance + read + + + TableLevel2Recursive_FkTo11000 + read + + string + + + true + + + string + + + + TableLevel2Recursive_FkRecursive + read + + string + + + true + + + string + + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo12000 + read + + string + + + true + + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/CheckPidAttribute.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/CheckPidAttribute.cs new file mode 100644 index 00000000..1348f366 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/CheckPidAttribute.cs @@ -0,0 +1,255 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckPidAttribute +{ + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckPidAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPidAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckPidAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckPidAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1100"), + Error.EmptyAttribute(null, null, null, "1200"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckPidAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1100"), + Error.MissingAttribute(null, null, null, "1200"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckPidAttribute_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + // Syntax 2 + Error.NonExistingParam(null, null, null, "1101", "1100"), + + // View Table + Error.NonExistingParam(null, null, null, "10001", "10000"), + Error.NonExistingParam(null, null, null, "10002", "10000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckPidAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + // Syntax 2 + Error.UntrimmedAttribute(null, null, null, "1100", " 1101"), + Error.UntrimmedAttribute(null, null, null, "1100", "1102 "), + + // Syntax 3 + Error.UntrimmedAttribute(null, null, null, "1200", " 1201 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckPidAttribute(); + + [TestMethod] + public void Param_CheckPidAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckPidAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "tablePid"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.63.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'ColumnOption@pid' in Param 'tablePid'.", + HowToFix = "", + ExampleCode = "", + Details = "The ColumnOption@pid attribute is mandatory and should be filled in with the ID of an existing column Param.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckPidAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "tablePid"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.63.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'ColumnOption@pid' in table 'tablePid'.", + HowToFix = "", + ExampleCode = "", + Details = "The ColumnOption@pid attribute is mandatory and should be filled in with the ID of an existing column Param.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckPidAttribute_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "columnPid", "tablePid"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.63.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'ColumnOption@pid' references a non-existing 'column' with PID 'columnPid'. Table PID 'tablePid'.", + HowToFix = "", + ExampleCode = "", + Details = "The ColumnOption@pid attribute is mandatory and should be filled in with the ID of an existing column Param.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckPidAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "tablePid", "untrimmedValue"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.63.3", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'ColumnOption@pid' in Table 'tablePid'. Current value 'untrimmedValue'.", + HowToFix = "", + ExampleCode = "", + Details = "The ColumnOption@pid attribute is mandatory and should be filled in with the ID of an existing column Param.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPidAttribute(); + + [TestMethod] + public void Param_CheckPidAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckPidAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPidAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..78225f27 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,44 @@ + + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + TableSyntax3 + array + + + + + + TableSyntax3_Instance + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..27005e68 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,52 @@ + + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + TableSyntax3 + array + + + + + + + TableSyntax3_Instance + read + + string + + + + TableSyntax3_Column2 + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..d7cafa35 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,51 @@ + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + TableSyntax3 + array + + + + + + + TableSyntax3_Instance + read + + string + + + + TableSyntax3_Column2 + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..13fe494f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,60 @@ + + + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + read + + string + + + + + + TableSyntax2 + array + + + + + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..252a3bab --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,44 @@ + + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + TableSyntax3 + array + + + + + + TableSyntax3_Instance + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..ed09a06c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/ColumnOption/CheckPidAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,59 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/CheckNamingFormatTag.cs b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/CheckNamingFormatTag.cs new file mode 100644 index 00000000..e351cb88 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/CheckNamingFormatTag.cs @@ -0,0 +1,239 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.ArrayOptions.NamingFormat.CheckNamingFormatTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.NamingFormat.CheckNamingFormatTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckNamingFormatTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckNamingFormatTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckNamingFormatTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), // Empty + Error.EmptyTag(null, null, null, "200"), // Empty CDATA tag + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_MissingDynamicPart() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingDynamicPart", + ExpectedResults = new List + { + Error.MissingDynamicPart(null, null, null, "100"), + Error.MissingDynamicPart(null, null, null, "200"), + Error.MissingDynamicPart(null, null, null, "300"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + // Table Syntax 1 + Error.NonExistingParam(null, null, null, "1009", "1000"), + + // Table Syntax 1 + Error.NonExistingParam(null, null, null, "1109", "1100"), + + // View Table + Error.NonExistingParam(null, null, null, "10008", "10000"), + Error.NonExistingParam(null, null, null, "10009", "10000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + // Table Syntax 1 + Error.UntrimmedTag(null, null, null, "1000", " ,HardCodedPart1,1002,HardCodedPart2"), + + // Table Syntax 1 + Error.UntrimmedTag(null, null, null, "1100", ",1101,:,1102 "), + + // View Table + Error.UntrimmedTag(null, null, null, "10000", ",10001,:,10002 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckNamingFormatTag(); + + [TestMethod] + public void Param_CheckNamingFormatTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckNamingFormatTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "tablePid"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.65.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'ArrayOptions/NamingFormat' in Table 'tablePid'.", + HowToFix = "", + ExampleCode = "", + Details = "'ArrayOptions/NamingFormat' tag should start by a separator followed by a separated list of display key parts." + Environment.NewLine + "- Numeric parts will be considered as dynamic display key parts and should refer to an existing Param." + Environment.NewLine + "- Non-Numeric parts will be considered as hard-coded display key parts." + Environment.NewLine + "" + Environment.NewLine + "NamingFormat should contain, at least, 1 dynamic part.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "referencedPid", "tablePid"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.65.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'ArrayOptions/NamingFormat' references a non-existing 'Param' with ID 'referencedPid'. Table PID 'tablePid'.", + HowToFix = "", + ExampleCode = "", + Details = "'ArrayOptions/NamingFormat' tag should start by a separator followed by a separated list of display key parts." + Environment.NewLine + "- Numeric parts will be considered as dynamic display key parts and should refer to an existing Param." + Environment.NewLine + "- Non-Numeric parts will be considered as hard-coded display key parts." + Environment.NewLine + "" + Environment.NewLine + "NamingFormat should contain, at least, 1 dynamic part.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckNamingFormatTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "tablePid", "untrimmedValue"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.65.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'ArrayOptions/NamingFormat' in Table 'tablePid'. Current value 'untrimmedValue'.", + HowToFix = "", + ExampleCode = "", + Details = "'ArrayOptions/NamingFormat' tag should start by a separator followed by a separated list of display key parts." + Environment.NewLine + "- Numeric parts will be considered as dynamic display key parts and should refer to an existing Param." + Environment.NewLine + "- Non-Numeric parts will be considered as hard-coded display key parts." + Environment.NewLine + "" + Environment.NewLine + "NamingFormat should contain, at least, 1 dynamic part.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckNamingFormatTag(); + + [TestMethod] + public void Param_CheckNamingFormatTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckNamingFormatTag_CheckId() => Generic.CheckId(check, CheckId.CheckNamingFormatTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..22305853 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,63 @@ + + + + + + TableSyntax1 + array + + ,HardCodedPart1,1002,HardCodedPart2 + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + ,1101,:,1102 + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..a185892d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,18 @@ + + + + + Empty + + + + + + EmptyCDATA + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/MissingDynamicPart.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/MissingDynamicPart.xml new file mode 100644 index 00000000..9063414d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/MissingDynamicPart.xml @@ -0,0 +1,24 @@ + + + + + 1Separator + + + + + + 1HardCoded + + + + + + 2HardCoded + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..e7cfeaa2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,63 @@ + + + + + + TableSyntax1 + array + + ,HardCodedPart1,1009,HardCodedPart2 + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + ,1101,:,1109 + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + ,10008,:,10002,:,10009 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..79aaa1fa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,63 @@ + + + + + + TableSyntax1 + array + + ,HardCodedPart1,1002,HardCodedPart2 + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + ,1101,:,1102 + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..671ccc6b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/ArrayOptions/NamingFormat/CheckNamingFormatTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,63 @@ + + + + + + TableSyntax1 + array + + ,HardCodedPart1,1002,HardCodedPart2 + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + read + + string + + + + + TableSyntax2 + array + + ,1101,:,1102 + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + read + + string + + + + + + ViewTable + array + + ,10001,:,10002 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckColumns/CheckColumns.cs b/ProtocolTests/Protocol/Params/Param/CheckColumns/CheckColumns.cs new file mode 100644 index 00000000..211df56f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckColumns/CheckColumns.cs @@ -0,0 +1,116 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.CheckColumns +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.CheckColumns; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckColumns(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckColumns_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckColumns_ColumnInvalidType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnInvalidType", + ExpectedResults = new List + { + // Table Syntax 1 + Error.ColumnInvalidType(null, null, null, "array", "1001"), + Error.ColumnInvalidType(null, null, null, "bus", "1002"), + + // Table Syntax 2 + Error.ColumnInvalidType(null, null, null, "crc", "1101"), + Error.ColumnInvalidType(null, null, null, "dataminer info", "1102"), + + // Table Syntax 3 + Error.ColumnInvalidType(null, null, null, "discreet info", "1201"), + Error.ColumnInvalidType(null, null, null, "dummy", "1202"), + + // View Table + Error.ColumnInvalidType(null, null, null, "array", "10001"), + Error.ColumnInvalidType(null, null, null, "bus", "10002"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckColumns_ColumnInvalidType() + { + // Create ErrorMessage + var message = Error.ColumnInvalidType(null, null, null, "columnType", "columnPid"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.64.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'columnType' in tag 'Param/Type' for column. Possible values 'read, write, group, read bit, write bit'. Column PID 'columnPid'.", + HowToFix = "", + ExampleCode = "", + Details = "A column should be of Param/Type 'read', 'write', 'group', 'read bit' or 'write bit'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckColumns(); + + [TestMethod] + public void Param_CheckColumns_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckColumns_CheckId() => Generic.CheckId(check, CheckId.CheckColumns); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Invalid/ColumnInvalidType.xml b/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Invalid/ColumnInvalidType.xml new file mode 100644 index 00000000..51b01a56 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Invalid/ColumnInvalidType.xml @@ -0,0 +1,82 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + array + + string + + + + TableSyntax1_Column2 + bus + + string + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + crc + + string + + + + TableSyntax2_Column2 + dataminer info + + string + + + + + TableSyntax3 + array + + + + + + + TableSyntax3_Instance + discreet info + + string + + + + TableSyntax3_Column2 + dummy + + string + + + + + + ViewTable + array + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..bce66afa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckColumns/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,79 @@ + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2 + + typo + + string + + + + TableSyntax1_Column3 + + + + string + + + + + TableSyntax2 + array + + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2 + + typo + + string + + + + TableSyntax2_Column3 + + + + string + + + + + + ViewTable + array + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/CheckHistorySetAttribute.cs b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/CheckHistorySetAttribute.cs new file mode 100644 index 00000000..3603187a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/CheckHistorySetAttribute.cs @@ -0,0 +1,65 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.CheckHistorySetAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.CheckHistorySetAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckHistorySetAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckHistorySetAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckHistorySetAttribute_EnabledHistorySet() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "EnabledHistorySet", + ExpectedResults = new List + { + ErrorCompare.EnabledHistorySet(null, null, "1"), + ErrorCompare.EnabledHistorySet(null, null, "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckHistorySetAttribute(); + + [TestMethod] + public void Param_CheckHistorySetAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckHistorySetAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckHistorySetAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_New.xml b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_New.xml new file mode 100644 index 00000000..0d4f6f89 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_New.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_Old.xml new file mode 100644 index 00000000..c0f3ef38 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Invalid/EnabledHistorySet_Old.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..256339e5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..9ca1c65e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckHistorySetAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..5012112f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,544 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.CheckIdAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.CheckIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIdAttribute(); + + #region Valid + + [TestMethod] + public void Param_CheckIdAttribute_Mediation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Mediation", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_Normal() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Normal", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_Service() + { + // Another unit test covers the full list of parameters. + // See SLDisValidatorUnitTests\Helpers\Software Parameters\Skyline Service Definition Basic + + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Service", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_Sla() + { + // Another unit test covers the full list of parameters. + // See SLDisValidatorUnitTests\Helpers\Software Parameters\Skyline SLA Definition Basic + + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Sla", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_Spectrum() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Spectrum", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid + + [TestMethod] + public void Param_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Currently ignored as it shouldn't give any results back...")] + public void Param_CheckIdAttribute_InvalidUseOfDataMinerModulesIdRange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfDataMinerModulesIdRange", + ExpectedResults = new List + { + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfEnhancedServiceIdRange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfEnhancedServiceIdRange", + ExpectedResults = new List + { + Error.InvalidUseOfEnhancedServiceIdRange(null, null, null, "1"), + Error.InvalidUseOfEnhancedServiceIdRange(null, null, null, "999"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfMediationIdRange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfMediationIdRange", + ExpectedResults = new List + { + Error.InvalidUseOfMediationIdRange(null, null, null, "70000"), + Error.InvalidUseOfMediationIdRange(null, null, null, "79999"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfSlaIdRange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfSlaIdRange", + ExpectedResults = new List + { + Error.InvalidUseOfSlaIdRange(null, null, null, "1"), + Error.InvalidUseOfSlaIdRange(null, null, null, "2999"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfSpectrumIdRange() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfSpectrumIdRange", + ExpectedResults = new List + { + Error.InvalidUseOfSpectrumIdRange(null, null, null, "50000"), + Error.InvalidUseOfSpectrumIdRange(null, null, null, "59999"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfSpectrumIdRange2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidUseOfSpectrumIdRange2", + ExpectedResults = new List + { + Error.InvalidUseOfSpectrumIdRange(null, null, null, "64000"), + Error.InvalidUseOfSpectrumIdRange(null, null, null, "64299"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_OutOfRangeId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "OutOfRangeId", + ExpectedResults = new List + { + Error.OutOfRangeId(null, null, null, "0"), + Error.OutOfRangeId(null, null, null, "64300"), + Error.OutOfRangeId(null, null, null, "69999"), + Error.OutOfRangeId(null, null, null, "100000"), + Error.OutOfRangeId(null, null, null, "999999"), + Error.OutOfRangeId(null, null, null, "10000000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckIdAttribute_RTDisplayExpectedOnSpectrumParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpectedOnSpectrumParam", + ExpectedResults = new List + { + Error.RTDisplayExpectedOnSpectrumParam(null, null, null, "64000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Command_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingParam() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MissingParam", + ExpectedResults = new List + { + ErrorCompare.MissingParam(null, null, "Standalone_MissingReadOnly", "read", "1"), + ErrorCompare.MissingParam(null, null, "Standalone_MissingRead", "read", "100"), + ErrorCompare.MissingParam(null, null, "Standalone_MissingWriteOnly", "write", "200"), + ErrorCompare.MissingParam(null, null, "Standalone_MissingWrite", "write", "350"), + + ErrorCompare.MissingParam(null, null, "Table_MissingWrite", "write", "1052"), + } + }; + + Generic.Compare(compare, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + string description = "Missing attribute 'Param@id'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + string description = "Empty attribute 'Param@id'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidId() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "0", "MyName"); + + string description = "Invalid value '0' in attribute 'Param@id'. Param name 'MyName'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_OutOfRangeId() + { + // Create ErrorMessage + var message = Error.OutOfRangeId(null, null, null, "0"); + + string description = "Out of range Param ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfSpectrumIdRange() + { + // Create ErrorMessage + var message = Error.InvalidUseOfSpectrumIdRange(null, null, null, "0"); + + string description = "Invalid use of Spectrum ID range for Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfMediationIdRange() + { + // Create ErrorMessage + var message = Error.InvalidUseOfMediationIdRange(null, null, null, "0"); + + string description = "Invalid use of Mediation ID range for Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfDataMinerModulesIdRange() + { + // Create ErrorMessage + var message = Error.InvalidUseOfDataMinerModulesIdRange(null, null, null, "0"); + + string description = "Invalid use of DataMiner Modules ID range for Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfEnhancedServiceIdRange() + { + // Create ErrorMessage + var message = Error.InvalidUseOfEnhancedServiceIdRange(null, null, null, "0"); + + string description = "Invalid use of Enhanced Service ID range for Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidUseOfSlaIdRange() + { + // Create ErrorMessage + var message = Error.InvalidUseOfSlaIdRange(null, null, null, "0"); + + string description = "Invalid use of SLA ID range for Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "0", "MyParam1, MyParam2"); + + string description = "More than one Param with same ID '0'. Param Names 'MyParam1, MyParam2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingParam() + { + // Create ErrorMessage + var message = ErrorCompare.MissingParam(null, null, "0", "1", "2"); + + string description = "Missing displayed Param. Param Name '0'. Param Type '1'. Param ID '2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..51c0fe4d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_New.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_New.xml new file mode 100644 index 00000000..6ce59163 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_New.xml @@ -0,0 +1,85 @@ + + + + + + + + Standalone_MissingRead + write + + true + + + + + + + + Standalone_MissingWrite + read + + true + + + + + + Table + array + + + + + + true + + + + Table_Instance + read + + true + + + + Table_MissingWrite + read + + true + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_Old.xml new file mode 100644 index 00000000..d2cdfeea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Invalid/MissingParam_Old.xml @@ -0,0 +1,85 @@ + + + + + Standalone_MissingReadOnly + read + + true + + + + + Standalone_MissingRead + read + + true + + + + Standalone_MissingRead + write + + true + + + + + + Standalone_MissingWriteOnly + write + + true + + + + + Standalone_MissingWrite + read + + true + + + + Standalone_MissingWrite + write + + true + + + + + Table + array + + + + + + true + + + + Table_Instance + read + + true + + + + Table_MissingWrite + read + + true + + + + Table_MissingWrite + write + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..046d27d5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,72 @@ + + + + + ExistingRead + read + + true + + + + ExistingReadWrite + read + + true + + + + ExistingReadWrite + write + + true + + + + ExistingWrite + write + + true + + + + + + NewRead + read + + true + + + + NewReadWrite + read + + true + + + + NewReadWrite + write + + true + + + + NewWrite + write + + true + + + + + + TrimRead + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..d1ebb546 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,108 @@ + + + + + ExistingRead + read + + true + + + + ExistingReadWrite + read + + true + + + + ExistingReadWrite + write + + true + + + + ExistingWrite + write + + true + + + + + + + + + TrimRead + read + + true + + + + + + RemovedReadRTDisplayFalse + read + + false + + + + RemovedReadNoRTDisplayTag + read + + + + + RemovedReadNoDisplayTag + read + + + RemovedWriteRTDisplayFalse + read + + false + + + + RemovedWriteNoRTDisplayTag + read + + + + + RemovedWriteNoDisplayTag + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..8dcc1370 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,12 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..873002de --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,14 @@ + + + + + Empty + read + + + Spaces + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfDataMinerModulesIdRange.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfDataMinerModulesIdRange.xml new file mode 100644 index 00000000..2ef831c2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfDataMinerModulesIdRange.xml @@ -0,0 +1,12 @@ + + + + WrongName1 + Wrong Description 1 + + + WrongName2 + Wrong Description 2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfEnhancedServiceIdRange.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfEnhancedServiceIdRange.xml new file mode 100644 index 00000000..200864d1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfEnhancedServiceIdRange.xml @@ -0,0 +1,13 @@ + + service + + + WrongName1 + Wrong Description 1 + + + WrongName2 + Wrong Description 2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfMediationIdRange.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfMediationIdRange.xml new file mode 100644 index 00000000..10bb3632 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfMediationIdRange.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSlaIdRange.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSlaIdRange.xml new file mode 100644 index 00000000..b9cedca1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSlaIdRange.xml @@ -0,0 +1,13 @@ + + sla + + + IncorrectName1 + Incorrect Description 1 + + + IncorrectName2 + Incorrect Description 2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange.xml new file mode 100644 index 00000000..676a51a0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange.xml @@ -0,0 +1,21 @@ + + + + + WrongName1 + Wrong Description 1 + + + WrongName2 + Wrong Description 2 + + + InvalidRangeMin + Invalid Range Min + + + InvalidRangeMax + Invalid Range Max + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange2.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange2.xml new file mode 100644 index 00000000..26153c1f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidUseOfSpectrumIdRange2.xml @@ -0,0 +1,12 @@ + + + + WrongName1 + Wrong Description 1 + + + WrongName2 + Wrong Description 2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..664eb468 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,33 @@ + + + + String + read + + + + Number_Negative + read + + + Number_Double_1 + read + + + Number_Double_2 + read + + + Number_LeadingZero + read + + + Number_LeadingPlusSign + read + + + Number_ScientificNotation + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..d139a9f1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,10 @@ + + + + + Missing + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml new file mode 100644 index 00000000..f73be3eb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/OutOfRangeId.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/RTDisplayExpectedOnSpectrumParam.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/RTDisplayExpectedOnSpectrumParam.xml new file mode 100644 index 00000000..1cd8cc28 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/RTDisplayExpectedOnSpectrumParam.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..41931de1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Mediation.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Mediation.xml new file mode 100644 index 00000000..475b534c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Mediation.xml @@ -0,0 +1,102 @@ + + Base Information Platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO_CorrectName1 + TODO Correct Description 1 + + + TODO_CorrectName2 + TODO Correct Description 2 + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Normal.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Normal.xml new file mode 100644 index 00000000..87a525ca --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Normal.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO_CorrectName1 + Correct Description 1 + + + TODO_CorrectName2 + Correct Description 2 + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Service.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Service.xml new file mode 100644 index 00000000..ea2482d0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Service.xml @@ -0,0 +1,114 @@ + + service + + + + + + + + + Service Severity + Service Severity + + + active_service_alarms_category + Category (Active Service Alarms) + + + + + + + + + + + NonSlaOnly_First + + + NonSlaOnly_Last + + + + + + + AlwaysAllowed_First_3000 + + + AlwaysAllowed_Last_49999 + + + + + NonSpectrumOnly_First + + + NonSpectrumOnly_Last + + + + + AlwaysAllowed_First_60001 + + + AlwaysAllowed_Last_63999 + + + + + + + + + + + + + + TODO_CorrectName1 + Correct Description 1 + + + TODO_CorrectName2 + Correct Description 2 + + + + + + + + AlwaysAllowed_First_1000000 + + + AlwaysAllowed_Last_9999999 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Sla.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Sla.xml new file mode 100644 index 00000000..f8b881bd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Sla.xml @@ -0,0 +1,98 @@ + + sla + + + + + + + + + + + + + + + read_service_name + Service Name + + + show_active_alarms + Active Alarms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CorrectName1 + Correct Description 1 + + + CorrectName2 + Correct Description 2 + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Spectrum.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Spectrum.xml new file mode 100644 index 00000000..70ac658b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Spectrum.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO_CorrectName1 + Correct Description 1 + + + TODO_CorrectName1 + Correct Description 1 + + + + + + + + + + + CorrectName1 + Correct Description 1 + + + CorrectName2 + Correct Description 2 + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..bda160b7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/CheckTrendingAttribute.cs b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/CheckTrendingAttribute.cs new file mode 100644 index 00000000..febb779e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/CheckTrendingAttribute.cs @@ -0,0 +1,160 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.CheckTrendingAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.CheckTrendingAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckTrendingAttribute(); + + #region Valid + [TestMethod] + public void Param_CheckTrendingAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + #endregion + + #region Invalid + [TestMethod] + public void Param_CheckTrendingAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "100"), // Empty + Error.EmptyAttribute(null, null, null, "101"), // Spaces + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckTrendingAttribute_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100"), + Error.RTDisplayExpected(null, null, null, "101"), + Error.RTDisplayExpected(null, null, null, "102"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTrendingAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "100", " true"), + + Error.UntrimmedAttribute(null, null, null, "200", "false "), + Error.UntrimmedAttribute(null, null, null, "201", " false "), + } + }; + + Generic.Validate(test, data); + } + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckTrendingAttribute(); + + [TestMethod] + public void Param_CheckTrendingAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckTrendingAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTrendingAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTrendingAttribute_DisabledTrending() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DisabledTrending", + ExpectedResults = new List + { + ErrorCompare.DisabledTrending(null, null, "1"), + ErrorCompare.DisabledTrending(null, null, "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTrendingAttribute(); + + [TestMethod] + public void Param_CheckTrendingAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckTrendingAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckTrendingAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..285b63b5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,28 @@ + + + + + TrendingTrue_RTDisplayTrue + read + + true + + + + + TrendingFalse_RTDisplayTrue + read + + true + + + + TrendingFalse_RTDisplayFalse + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_New.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_New.xml new file mode 100644 index 00000000..b3ae6eee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_New.xml @@ -0,0 +1,14 @@ + + + + + true + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_Old.xml new file mode 100644 index 00000000..39a0cd45 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Invalid/DisabledTrending_Old.xml @@ -0,0 +1,14 @@ + + + + + true + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..e57f65f8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,42 @@ + + + + + + + + true + + + + + + true + + + + + + true + + + + + + + + false + + + + + + false + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..2bcc2de9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,44 @@ + + + + + + + + true + + + + + + true + + + + + + true + + + + + + + + false + + + + + + false + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..0874ab1e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..1a6f080c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,27 @@ + + + + + TrendingTrue_RTDisplayFalse + read + + false + + + + TrendingTrue_NoRTDisplay + read + + + + + + TrendingTrue_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..de2be5d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,28 @@ + + + + + TrendingTrue_RTDisplayTrue + read + + true + + + + + TrendingFalse_RTDisplayTrue + read + + true + + + + TrendingFalse_RTDisplayFalse + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..31c6938e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/CheckTrendingAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,59 @@ + + + + + TrendingTrue_RTDisplayTrue + read + + true + + + + + TrendingFalse_RTDisplayTrue + read + + true + + + + TrendingFalse_RTDisplayFalse + read + + false + + + + TrendingFalse_NoRTDisplay + read + + + + + + TrendingFalse_NoDisplay + read + + + + + + NoTrending_RTDisplayTrue + read + + true + + + + + NoTrending_RTDisplayFalse + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/CheckColumnDefinitionTag.cs b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/CheckColumnDefinitionTag.cs new file mode 100644 index 00000000..17cae7cc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/CheckColumnDefinitionTag.cs @@ -0,0 +1,67 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Database.ColumnDefinition.CheckColumnDefinitionTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Database.ColumnDefinition.CheckColumnDefinitionTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckColumnDefinitionTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckColumnDefinitionTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckColumnDefinitionTag_ChangedLoggerDataType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ChangedLoggerDataType", + ExpectedResults = new List + { + ErrorCompare.ChangedLoggerDataType(null, null, "VARCHAR(50)", "1", "VARCHAR(10)"), + ErrorCompare.ChangedLoggerDataType(null, null, "TEXT", "2", "VARCHAR(20)"), + ErrorCompare.ChangedLoggerDataType(null, null, "TEXT", "3", "DOUBLE"), + ErrorCompare.ChangedLoggerDataType(null, null, "VARCHAR(20)", "4", "SMALLINT"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckColumnDefinitionTag(); + + [TestMethod] + public void Param_CheckColumnDefinitionTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckColumnDefinitionTag_CheckId() => Generic.CheckId(root, CheckId.CheckColumnDefinitionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_New.xml b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_New.xml new file mode 100644 index 00000000..7864d566 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_New.xml @@ -0,0 +1,24 @@ + + + + + VARCHAR(10) + + + + + VARCHAR(20) + + + + + DOUBLE + + + + + SMALLINT + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_Old.xml b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_Old.xml new file mode 100644 index 00000000..09349233 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Invalid/ChangedLoggerDataType_Old.xml @@ -0,0 +1,24 @@ + + + + + VARCHAR(50) + + + + + TEXT + + + + + TEXT + + + + + VARCHAR(20) + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..504b52aa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,26 @@ + + + + + VARCHAR(100) + + + + + TEXT + + + + + BLOB + + + + + VARCHAR(20) + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..16c25f5f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Database/ColumnDefinition/CheckColumnDefinitionTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,26 @@ + + + + + VARCHAR(50) + + + + + TEXT + + + + + BLOB + + + + + VARCHAR(20) + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/CheckIdTag.cs b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/CheckIdTag.cs new file mode 100644 index 00000000..3d1a7c78 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/CheckIdTag.cs @@ -0,0 +1,308 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Dependencies.Id.CheckIdTag +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Dependencies.Id.CheckIdTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIdTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIdTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "10"), + Error.EmptyTag(null, null, null, "10"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "11", "10"), + Error.NonExistingId(null, null, null, "12 ", "10"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by check on RTDisplay")] + public void Param_CheckIdTag_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "10"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by check on RTDisplay")] + public void Param_CheckIdTag_RTDisplayExpectedOnReferencedParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpectedOnReferencedParam", + ExpectedResults = new List + { + Error.RTDisplayExpectedOnReferencedParam(null, null, null, "11", "10"), + + Error.RTDisplayExpectedOnReferencedParam(null, null, null, "21", "20"), + + Error.RTDisplayExpectedOnReferencedParam(null, null, null, "31", "30"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "10", " 11"), + Error.UntrimmedTag(null, null, null, "10", "12 "), + Error.UntrimmedTag(null, null, null, "10", " 13 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdTag(); + + [TestMethod] + public void Param_CheckIdTag_EmptyTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyTag", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Param_CheckIdTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckIdTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "pid"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.67.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Dependencies/Id' in Param 'pid'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Dependencies/Id' tag should contain the ID of an existing Param. Both the referencing and the referenced Param should have their RTDisplay tag set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "referencedPid", "pid"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.67.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Dependencies/Id' references a non-existing 'Param' with ID 'referencedPid'. Param ID 'pid'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Dependencies/Id' tag should contain the ID of an existing Param. Both the referencing and the referenced Param should have their RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdTag_RTDisplayExpected() + { + // Create ErrorMessage + var message = Error.RTDisplayExpected(null, null, null, "pid"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.67.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param 'pid' containing 'Dependencies/Id' tag(s).", + HowToFix = "", + ExampleCode = "", + Details = "A 'Dependencies/Id' tag should contain the ID of an existing Param. Both the referencing and the referenced Param should have their RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdTag_RTDisplayExpectedOnReferencedParam() + { + // Create ErrorMessage + var message = Error.RTDisplayExpectedOnReferencedParam(null, null, null, "referencedPid", "referencingPid"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "2.67.5", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param 'referencedPid' referenced by a 'Dependencies/Id' tag. Param ID 'referencingPid'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Dependencies/Id' tag should contain the ID of an existing Param. Both the referencing and the referenced Param should have their RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "pid", "untrimmedValue"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.67.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Dependencies/Id' in Param 'pid'. Current value 'untrimmedValue'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Dependencies/Id' tag should contain the ID of an existing Param. Both the referencing and the referenced Param should have their RTDisplay tag set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdTag(); + + [TestMethod] + public void Param_CheckIdTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckIdTag_CheckId() => Generic.CheckId(check, CheckId.CheckIdTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/EmptyTag.xml new file mode 100644 index 00000000..90df5814 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/EmptyTag.xml @@ -0,0 +1,13 @@ + + + + + ButtonWithDependencies + write + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..8f98117a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,40 @@ + + + + + ButtonWithDependencies + write + + 11 + 12 + 13 + + + true + + + + + ButtonWithDependencies_Dependency1 + read + + true + + + + ButtonWithDependencies_Dependency2 + read + + true + + + + ButtonWithDependencies_Dependency3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..315e7c61 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,17 @@ + + + + + ButtonWithDependencies + write + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..49133dcf --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,32 @@ + + + + + ButtonWithDependencies + write + + 11 + 12 + + + true + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..cf63300f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,59 @@ + + + + + ButtonWithDependencies_RTDisplayFalse + write + + 11 + + + false + + + + ButtonWithDependencies_RTDisplayFalse_Dependency1 + read + + true + + + + + ButtonWithDependencies_NoRTDisplay + write + + 21 + + + + + + + ButtonWithDependencies_NoRTDisplay_Dependency1 + read + + true + + + + + ButtonWithDependencies_NoDisplay + write + + 31 + + + + + ButtonWithDependencies_NoDisplay_Dependency1 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpectedOnReferencedParam.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpectedOnReferencedParam.xml new file mode 100644 index 00000000..c556f717 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/RTDisplayExpectedOnReferencedParam.xml @@ -0,0 +1,40 @@ + + + + + ButtonWithDependencies + write + + 11 + 12 + 13 + + + true + + + + + ButtonWithDependencies_Dependency1 + read + + + + ButtonWithDependencies_Dependency2 + read + + + + + + ButtonWithDependencies_Dependency3 + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..164ad38f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,40 @@ + + + + + ButtonWithDependencies + write + + 11 + 12 + 13 + + + true + + + + + ButtonWithDependencies_Dependency1 + read + + true + + + + ButtonWithDependencies_Dependency2 + read + + true + + + + ButtonWithDependencies_Dependency3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..8f98117a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Dependencies/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,40 @@ + + + + + ButtonWithDependencies + write + + 11 + 12 + 13 + + + true + + + + + ButtonWithDependencies_Dependency1 + read + + true + + + + ButtonWithDependencies_Dependency2 + read + + true + + + + ButtonWithDependencies_Dependency3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/CheckDescriptionTag.cs b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/CheckDescriptionTag.cs new file mode 100644 index 00000000..10254af7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/CheckDescriptionTag.cs @@ -0,0 +1,275 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Description.CheckDescriptionTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Description.CheckDescriptionTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckDescriptionTag(); + + #region Valid + [TestMethod] + public void Param_CheckDescriptionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + #endregion + + #region Invalid + [TestMethod] + public void Param_CheckDescriptionTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Duplicate Read", "100, 101").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate Read", "100"), + Error.DuplicatedValue(null, null, null, "Duplicate Read", "101")), + + Error.DuplicatedValue(null, null, null, "Duplicate Write", "110, 111").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate Write", "110"), + Error.DuplicatedValue(null, null, null, "Duplicate Write", "111")), + + Error.DuplicatedValue(null, null, null, "Duplicate Read-Write", "120, 220, 121, 221").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate Read-Write", "120"), + Error.DuplicatedValue(null, null, null, "Duplicate Read-Write", "220"), + + Error.DuplicatedValue(null, null, null, "Duplicate Read-Write", "121"), + Error.DuplicatedValue(null, null, null, "Duplicate Read-Write", "221")), + + Error.DuplicatedValue(null, null, null, "Duplicate_Different_Casing", "1000, 1001").WithSubResults( + Error.DuplicatedValue(null, null, null, "Duplicate_Different_Casing", "1000"), + Error.DuplicatedValue(null, null, null, "Duplicate_different_Casing", "1001")), + + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "Duplicate_different_Casing", "Duplicate_Different_Casing", "1001")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), // Empty + Error.EmptyTag(null, null, null, "101"), // Spaces + + Error.EmptyTag(null, null, null, "200"), // Exported + Error.EmptyTag(null, null, null, "201"), // RTDisplay_True + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), // Read + Error.MissingTag(null, null, null, "201"), // Write + + Error.MissingTag(null, null, null, "102"), // ReadWrite + Error.MissingTag(null, null, null, "202"), // ReadWrite + + Error.MissingTag(null, null, null, "103"), // Title Begin + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", " Leading Space"), + Error.UntrimmedTag(null, null, null, "101", "Trailing Spaces "), + Error.UntrimmedTag(null, null, null, "102", " Untrimmed Spaces "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_WrongCasing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WrongCasing", + ExpectedResults = new List + { + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "space separator", "Space Separator", "100"), + Error.WrongCasing_Sub(null, null, null, "underscore_Separator_1", "Underscore_Separator_1", "101"), + + Error.WrongCasing_Sub(null, null, null, "in Starting_With_Preposition", "In Starting_With_Preposition", "200"), + Error.WrongCasing_Sub(null, null, null, "Ending_With_Preposition in", "Ending_With_Preposition In", "201")) + } + }; + + Generic.Validate(test, data); + } + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDescriptionTag(); + + [TestMethod] + public void Param_CheckDescriptionTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_WrongCasing() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "WrongCasing", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckDescriptionTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDescriptionTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDescriptionTag_RemovedItem() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedItem", + ExpectedResults = new List + { + ErrorCompare.RemovedItem(null, null, "RTDisplay True", "1"), + ErrorCompare.RemovedItem(null, null, "Trending True", "100"), + ErrorCompare.RemovedItem(null, null, "Monitored True", "200"), + + ErrorCompare.RemovedItem(null, null, "Export True", "300"), + ErrorCompare.RemovedItem(null, null, "Export 1000", "301"), + ErrorCompare.RemovedItem(null, null, "Export 1000 And 2000", "302"), + + ErrorCompare.RemovedItem(null, null, "My Table", "1000"), + ErrorCompare.RemovedItem(null, null, "Column1 RTDisplay True (My Table)", "1001"), + ErrorCompare.RemovedItem(null, null, "Column2 RTDisplay Default1 (My Table)", "1002"), + ErrorCompare.RemovedItem(null, null, "Column3 RTDisplay Default2 (My Table)", "1003"), + ErrorCompare.RemovedItem(null, null, "Column4 RTDisplay False (My Table)", "1004"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckDescriptionTag_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "1", "RTDisplay True", "Changed RTDisplay True"), + ErrorCompare.UpdatedValue(null, null, "100", "Trending True", "Changed Trending True"), + ErrorCompare.UpdatedValue(null, null, "200", "Monitored True", "Changed Monitored True"), + + ErrorCompare.UpdatedValue(null, null, "300", "Export True", "Changed Export True"), + ErrorCompare.UpdatedValue(null, null, "301", "Export 1000", "Changed Export 1000"), + ErrorCompare.UpdatedValue(null, null, "302", "Export 1000 And 2000", "Changed Export 1000 And 2000"), + + ErrorCompare.UpdatedValue(null, null, "1000", "My Table", "Changed My Table"), + ErrorCompare.UpdatedValue(null, null, "1001", "Column1 RTDisplay True (My Table)", "Changed Column1 RTDisplay True (My Table)"), + ErrorCompare.UpdatedValue(null, null, "1002", "Column2 RTDisplay Default1 (My Table)", "Changed Column2 RTDisplay Default1 (My Table)"), + ErrorCompare.UpdatedValue(null, null, "1003", "Column3 RTDisplay Default2 (My Table)", "Changed Column3 RTDisplay Default2 (My Table)"), + ErrorCompare.UpdatedValue(null, null, "1004", "Column4 RTDisplay False (My Table)", "Changed Column4 RTDisplay False (My Table)"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDescriptionTag(); + + [TestMethod] + public void Param_CheckDescriptionTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckDescriptionTag_CheckId() => Generic.CheckId(root, CheckId.CheckDescriptionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..a60c1f15 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + LeadingSpace + Leading Space + + + TrailingSpaces + Trailing Spaces + + + LeadingAndTrailingSpaces + Untrimmed Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/WrongCasing.xml new file mode 100644 index 00000000..bc86dca3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Codefix/WrongCasing.xml @@ -0,0 +1,25 @@ + + + + + + + SeparatorSpace + Space Separator + + + SeparatorUnderscore + Underscore_Separator_1 + + + + PrepositionLeading + In Starting_With_Preposition + + + PrepositionTrailing + Ending_With_Preposition In + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_New.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_New.xml new file mode 100644 index 00000000..0baad6db --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_New.xml @@ -0,0 +1,72 @@ + + + + + RTDisplay_True + + true + + + + + Trending_True + + + + Monitored_True + + true + + + + + Export_True + + + Export_1000 + + + Export_1000And2000 + + + + + MyTable + array + + + + + + + + true + + + + MyTable_Instance + read + + true + + + + MyTable_RTDisplay_Default_1 + read + + + MyTable_RTDisplay_Default_2 + read + + + + + MyTable_RTDisplay_False + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_Old.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_Old.xml new file mode 100644 index 00000000..827156b9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/RemovedItem_Old.xml @@ -0,0 +1,83 @@ + + + + + RTDisplay_True + RTDisplay True + + true + + + + + Trending_True + Trending True + + + + Monitored_True + Monitored True + + true + + + + + Export_True + Export True + + + Export_1000 + Export 1000 + + + Export_1000And2000 + Export 1000 And 2000 + + + + + MyTable + My Table + array + + + + + + + + true + + + + MyTable_Instance + Column1 RTDisplay True (My Table) + read + + true + + + + MyTable_RTDisplay_Default_1 + Column2 RTDisplay Default1 (My Table) + read + + + MyTable_RTDisplay_Default_2 + Column3 RTDisplay Default2 (My Table) + read + + + + + MyTable_RTDisplay_False + Column4 RTDisplay False (My Table) + read + + false + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..098a7f56 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,83 @@ + + + + + RTDisplay_True + Changed RTDisplay True + + true + + + + + Trending_True + Changed Trending True + + + + Monitored_True + Changed Monitored True + + true + + + + + Export_True + Changed Export True + + + Export_1000 + Changed Export 1000 + + + Export_1000And2000 + Changed Export 1000 And 2000 + + + + + MyTable + Changed My Table + array + + + + + + + + true + + + + MyTable_Instance + Changed Column1 RTDisplay True (My Table) + read + + true + + + + MyTable_RTDisplay_Default_1 + Changed Column2 RTDisplay Default1 (My Table) + read + + + MyTable_RTDisplay_Default_2 + Changed Column3 RTDisplay Default2 (My Table) + read + + + + + MyTable_RTDisplay_False + Changed Column4 RTDisplay False (My Table) + read + + false + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..005d53ff --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,83 @@ + + + + + RTDisplay_True + RTDisplay True + + true + + + + + Trending_True + Trending True + + + + Monitored_True + Monitored True + + true + + + + + Export_True + Export True + + + Export_1000 + Export 1000 + + + Export_1000And2000 + Export 1000 And 2000 + + + + + MyTable + My Table + array + + + + + + + + true + + + + MyTable_Instance + Column1 RTDisplay True (My Table) + read + + true + + + + MyTable_RTDisplay_Default_1 + Column2 RTDisplay Default1 (My Table) + read + + + MyTable_RTDisplay_Default_2 + Column3 RTDisplay Default2 (My Table) + read + + + + + MyTable_RTDisplay_False + Column4 RTDisplay False (My Table) + read + + false + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..a3f3a969 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,308 @@ + + + + + + Displayed_SameDescription + Displayed Same Description + + true + + + + Displayed_EmptyDescription + + + true + + + + + Displayed_TrimBefore + Displayed Trim Before + + true + + + + Displayed_TrimAfter + Displayed Trim After + + true + + + + Displayed_Trim + Displayed Trim + + true + + + + + Displayed_CasingChanges + Displayed Casing Changes + + true + + + + + Displayed_IdxSuffixAdded_1 + Displayed IDX Suffix Added_1 [IDX] + + true + + + + Displayed_IdxSuffixAdded_3 + Displayed IDX Suffix Added_2[idx] + + true + + + + Displayed_IdxSuffixAdded_3 + Displayed IDX Suffix Added_3 [IDX] (Table Description) + + true + + + + Displayed_IdxSuffixImproved_1 + Displayed IDX Suffix Improved_1 [IDX] (Table Description) + + true + + + + Displayed_IdxSuffixImproved_2 + Displayed IDX Suffix Improved_2 [IDX] (Table Description) + + true + + + + Displayed_IdxSuffixImproved_3 + Displayed IDX Suffix Improved_3 [IDX] (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_1 + Displayed IDX Suffix Removed_1 + + true + + + + Displayed_IdxSuffixRemoved_2 + Displayed IDX Suffix Removed_2 + + true + + + + Displayed_IdxSuffixRemoved_3 + Displayed IDX Suffix Removed_3 (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_4 + Displayed IDX Suffix Removed_4 (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_5 + Displayed IDX Suffix Removed_5 (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_6 + Displayed IDX Suffix Removed_6 (Table Description) + + true + + + + + Displayed_Adding_FromNoDescription + Displayed - Adding - From No Description + + true + + + + Displayed_Adding_FromEmptyDescription + Displayed - Adding - From Empty Description + + true + + + + + DisplayedTable + My Displayed Table + array + + + + + + true + + + + DisplayedTableInstance + Instance (My Displayed Table) + read + + true + + + + DisplayedTable_Column2 + Column 2 (My Displayed Table) + read + + true + + + + + + NonDisplayed_RTDisplay_Default_1 + Changed Description + + + NonDisplayed_RTDisplay_Default_2 + Changed Description + + + + + NonDisplayed_RTDisplay_False + Changed Description + + false + + + + + NonDisplayed_Trending_Default + Changed Description + + + NonDisplayed_Trending_False + Changed Description + + + + + NonDisplayed_Trending_Typo + Changed Description + + false + + + + + NonDisplayed_Alarm_Default_1 + Changed Description + + + NonDisplayed_Alarm_Default_2 + Changed Description + + + + NonDisplayed_Alarm_False + Changed Description + + + + false + + + + NonDisplayed_Alarm_Typo + Changed Description + + false + + + false + + + + + NonDisplayed_Export_Default + Changed Description + + + NonDisplayed_Export_False + Changed Description + + + + + NonDisplayed_Export_Typo + Changed Description + + false + + + + + NonDisplayedTable + Non Displayed Table + array + + + + + + + + + + NonDisplayedTable_Instance + Instance (Non Displayed Table) + read + + + NonDisplayedTable_RTDisplayFalse + RTDisplay False (Non Displayed Table) + read + + false + + + + NonDisplayedTable_TrendingFalse + Trending False (Non Displayed Table) + read + + + NonDisplayedTable_MonitoredFalse + Monitored False (Non Displayed Table) + read + + false + + + + NonDisplayedTable_ExportFalse + Export False (Non Displayed Table) + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..5fee2e56 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,307 @@ + + + + + + Displayed_SameDescription + Displayed Same Description + + true + + + + Displayed_EmptyDescription + + + true + + + + + Displayed_TrimBefore + Displayed Trim Before + + true + + + + Displayed_TrimAfter + Displayed Trim After + + true + + + + Displayed_Trim + Displayed Trim + + true + + + + + Displayed_CasingChanges + displayed casing changes + + true + + + + + Displayed_IdxSuffixAdded_1 + Displayed IDX Suffix Added_1 + + true + + + + Displayed_IdxSuffixAdded_2 + Displayed IDX Suffix Added_2 + + true + + + + Displayed_IdxSuffixAdded_3 + Displayed IDX Suffix Added_3 (Table Description) + + true + + + + Displayed_IdxSuffixImproved_1 + Displayed IDX Suffix Improved_1[IDX] (Table Description) + + true + + + + Displayed_IdxSuffixImproved_2 + Displayed IDX Suffix Improved_2 [IDX](Table Description) + + true + + + + Displayed_IdxSuffixImproved_3 + Displayed IDX Suffix Improved_3[IDX](Table Description) + + true + + + + Displayed_IdxSuffixRemoved_1 + Displayed IDX Suffix Removed_1 [IDX] + + true + + + + Displayed_IdxSuffixRemoved_2 + Displayed IDX Suffix Removed_2[idx] + + true + + + + Displayed_IdxSuffixRemoved_3 + Displayed IDX Suffix Removed_3 [IDX] (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_4 + Displayed IDX Suffix Removed_4[IDX] (Table Description) + + true + + + + Displayed_IdxSuffixRemoved_5 + Displayed IDX Suffix Removed_5 [IDX](Table Description) + + true + + + + Displayed_IdxSuffixRemoved_6 + Displayed IDX Suffix Removed_6[IDX](Table Description) + + true + + + + + Displayed_Adding_FromNoDescription + + true + + + + Displayed_Adding_FromEmptyDescription + + + true + + + + + DisplayedTable + My Displayed Table + array + + + + + + true + + + + DisplayedTableInstance + Instance (My Displayed Table) + read + + true + + + + DisplayedTable_Column2 + Column 2 (My Displayed Table) + read + + true + + + + + + NonDisplayed_RTDisplay_Default_1 + This Description + + + NonDisplayed_RTDisplay_Default_2 + This Description + + + + + NonDisplayed_RTDisplay_False + This Description + + false + + + + + NonDisplayed_Trending_Default + This Description + + + NonDisplayed_Trending_False + This Description + + + + + NonDisplayed_Trending_Typo + This Description + + false + + + + + NonDisplayed_Alarm_Default_1 + This Description + + + NonDisplayed_Alarm_Default_2 + This Description + + + + NonDisplayed_Alarm_False + This Description + + + + false + + + + NonDisplayed_Alarm_Typo + This Description + + false + + + false + + + + + NonDisplayed_Export_Default + This Description + + + NonDisplayed_Export_False + This Description + + + + + + + NonDisplayedTable + Non Displayed Table + array + + + + + + + + + + NonDisplayedTable_Instance + Instance (Non Displayed Table) + read + + + NonDisplayedTable_RTDisplayFalse + RTDisplay False (Non Displayed Table) + read + + false + + + + NonDisplayedTable_TrendingFalse + Trending False (Non Displayed Table) + read + + + NonDisplayedTable_MonitoredFalse + Monitored False (Non Displayed Table) + read + + false + + + + NonDisplayedTable_ExportFalse + Export False (Non Displayed Table) + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..3b71607c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,59 @@ + + + + + Duplicate Read + Duplicate Read + read + + + Duplicate Read + Duplicate Read + read + + + + Duplicate Write + Duplicate Write + write + + + Duplicate Write + Duplicate Write + write + + + + Duplicate ReadWrite + Duplicate Read-Write + read + + + Duplicate ReadWrite + Duplicate Read-Write + write + + + Duplicate ReadWrite + Duplicate Read-Write + read + + + Duplicate ReadWrite + Duplicate Read-Write + write + + + + Duplicate_Different_Casing + Duplicate_Different_Casing + read + + + Duplicate_different_Casing + Duplicate_different_Casing + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..d49e0a73 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,26 @@ + + + + + Empty + + + + Spaces + + + + + Exported + + + + RTDisplay_True + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..e264e64c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,44 @@ + + + + + Missing_Read + read + + true + + + + Missing_Write + write + + true + + + + Missing_ReadWrite + read + + true + + + + Missing_ReadWrite + write + + true + + + + Missing_BeginTitle + fixed + + true + + + title + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..16a79681 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + LeadingSpace + Leading Space + + + TrailingSpaces + Trailing Spaces + + + LeadingAndTrailingSpaces + Untrimmed Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/WrongCasing.xml new file mode 100644 index 00000000..cab382c8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Invalid/WrongCasing.xml @@ -0,0 +1,25 @@ + + + + + + + SeparatorSpace + space separator + + + SeparatorUnderscore + underscore_Separator_1 + + + + PrepositionLeading + in Starting_With_Preposition + + + PrepositionTrailing + Ending_With_Preposition in + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e6ed8d5c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Description/CheckDescriptionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,127 @@ + + + + + ValidDescription_Read + A Valid Description (Read) + read + + true + + + + ValidDescription_Write + A Valid Description (Write) + write + + true + + + + ValidDuplicate_ReadWrite + A Valid Duplicate (Read Write) + read + + true + + + + ValidDuplicate_ReadWrite + A Valid Duplicate (Read Write) + write + + true + + + + + Casing_InPreposition + Casing in Preposition + read + + true + + + + Casing_ForPreposition + Casing for Preposition + read + + true + + + + + NoDescription_Button + write + + true + + + button + + + + NoDescription_PageButton + write + + true + + + pagebutton + + + + NoDescription_EndTitle + fixed + + true + + + title + + + + + NoDescription_NoDisplay + write + + + NoDescription_NoRTDisplay + write + + + + + NoDescription_RTDisplayFalse + write + + false + + + + + EmptyDescription_Button + + write + + true + + + button + + + + EmptyDescription_PageButton + + write + + true + + + pagebutton + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/CheckDisplayTag.cs b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/CheckDisplayTag.cs new file mode 100644 index 00000000..847e64fb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/CheckDisplayTag.cs @@ -0,0 +1,116 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.CheckDisplayTag +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.CheckDisplayTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.60.1", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Display' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Param/Display' should always contain, at least, one child tag.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDisplayTag_CheckId() => Generic.CheckId(check, CheckId.CheckDisplayTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Codefix/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Codefix/EmptyTag.xml new file mode 100644 index 00000000..0a6a80a8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Codefix/EmptyTag.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + EmptyLines + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..6c4a8a8f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,16 @@ + + + + + Empty + + + + EmptyLines + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0578a227 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,23 @@ + + + + + NoDisplay + + + + Display_WithRTDisplay + + true + + + + Display_WithUnits + + + % + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/CheckPositionsTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/CheckPositionsTag.cs new file mode 100644 index 00000000..42a6c35b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/CheckPositionsTag.cs @@ -0,0 +1,177 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Positions.CheckPositionsTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Positions.CheckPositionsTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPositionsTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckPositionsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckPositionsTag_Valid_DVE() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_DVE", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckPositionsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckPositionsTag_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, ""), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckPositionsTag(); + + [TestMethod] + public void Param_CheckPositionsTag_EmptyTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckPositionsTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.57.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Display/Positions' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Display/Positions' should always have, at least, one Position tag.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckPositionsTag_RTDisplayExpected() + { + // Create ErrorMessage + var message = Error.RTDisplayExpected(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.57.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param '2' which is positioned.", + HowToFix = "", + ExampleCode = "", + Details = "A positioned Param (with Display/Positions tag) requires its RTDisplay to be set to true in order to be properly displayed." + Environment.NewLine + "Note that an exception to this rule can be made when a Param is only meant to be displayed on a DVE protocol and not on the main one.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPositionsTag(); + + [TestMethod] + public void Param_CheckPositionsTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckPositionsTag_CheckId() => Generic.CheckId(check, CheckId.CheckPositionsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Codefix/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Codefix/EmptyTag.xml new file mode 100644 index 00000000..aef48a27 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Codefix/EmptyTag.xml @@ -0,0 +1,15 @@ + + + + + RTDisplayFalse + + false + + + + NoRTDisplay + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..b4f6a9eb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,21 @@ + + + + + RTDisplayFalse + + false + + + + + + NoRTDisplay + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..67007139 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,32 @@ + + + + + RTDisplayFalse + + false + + + Page1 + 0 + 0 + + + + + + NoRTDisplay + + + + + Page1 + 0 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..4a7b0116 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,18 @@ + + + + + + true + + + Page1 + 0 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid_DVE.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid_DVE.xml new file mode 100644 index 00000000..0ab4dc1e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/CheckPositionsTag/Samples/Validate/Valid/Valid_DVE.xml @@ -0,0 +1,52 @@ + + + + + + + + + Standalone_OnMain_NotOnDVE + read + + true + + + Page1 + 0 + 0 + + + + + + Standalone_OnMain_OnDVE + read + + true + + + Page1 + 0 + 1 + + + + + + Standalone_NotOnMain_OnDVE + read + + false + + + Page1 + 0 + 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/CheckColumnTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/CheckColumnTag.cs new file mode 100644 index 00000000..982c3ed2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/CheckColumnTag.cs @@ -0,0 +1,155 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Positions.Position.Column.CheckColumnTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Positions.Position.Column.CheckColumnTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckColumnTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckColumnTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckColumnTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckColumnTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckColumnTag_InvalidTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTag", + ExpectedResults = new List + { + Error.InvalidTag(null, null, null, "abc", "1"), + Error.InvalidTag(null, null, null, "-1", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckColumnTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckColumnTag_UnrecommendedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedValue", + ExpectedResults = new List + { + Error.UnrecommendedValue(null, null, null, "Page2", "1, 2").WithSubResults( + Error.UnrecommendedValue(null, null, null, "Page2", "1"), + Error.UnrecommendedValue(null, null, null, "Page2", "2")), + Error.UnrecommendedValue(null, null, null, "Page3", "10").WithSubResults( + Error.UnrecommendedValue(null, null, null, "Page3", "10")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckColumnTag(); + + [TestMethod] + public void Param_CheckColumnTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckColumnTag(); + + [TestMethod] + public void Param_CheckColumnTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckColumnTag_CheckId() => Generic.CheckId(root, CheckId.CheckColumnTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..58add106 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page2 + 0 + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..a581e435 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page1 + + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/InvalidTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/InvalidTag.xml new file mode 100644 index 00000000..ddcfdfa0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/InvalidTag.xml @@ -0,0 +1,22 @@ + + + + + + + + Page1 + abc + 0 + + + Page2 + -1 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..bfd93b1d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,16 @@ + + + + + + + + Page1 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UnrecommendedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UnrecommendedValue.xml new file mode 100644 index 00000000..2abaeca9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UnrecommendedValue.xml @@ -0,0 +1,39 @@ + + + + + + + Page2 + 2 + 0 + + + + + + + + + Page2 + 2 + 1 + + + + + + + + + + + Page3 + 2 + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..a046960a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page2 + 0 + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..40db0c5c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Column/CheckColumnTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,27 @@ + + + + + + + + Page1 + 0 + 0 + + + Page2 + 1 + 1 + + + Page3 + 1 + 10 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/CheckPageTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/CheckPageTag.cs new file mode 100644 index 00000000..2032b442 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/CheckPageTag.cs @@ -0,0 +1,214 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Positions.Position.Page.CheckPageTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Positions.Position.Page.CheckPageTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckPageTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckPageTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckRangeTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "My Page", "100").WithSubResults( + Error.DuplicatedValue(null, null, null, "My Page", "100"), + Error.DuplicatedValue(null, null, null, "My Page", "100")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), + Error.EmptyTag(null, null, null, "101"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", " Leading Space"), + Error.UntrimmedTag(null, null, null, "100", "Trailing Spaces "), + Error.UntrimmedTag(null, null, null, "100", " Leading and Trailing Spaces "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_WrongCasing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WrongCasing", + ExpectedResults = new List + { + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "wrong casing", "Wrong Casing", "100")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckPageTag(); + + [TestMethod] + public void Param_CheckPageTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckPageTag_WrongCasing() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "WrongCasing", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckPageTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckPageTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckPageTag_RemovedFromPage() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedFromPage", + ExpectedResults = new List + { + ErrorCompare.RemovedFromPage(null, null, "1", "Page2"), + ErrorCompare.RemovedFromPage(null, null, "2", "Page1"), + ErrorCompare.RemovedFromPage(null, null, "3", "Page With Spaces"), + ErrorCompare.RemovedFromPage(null, null, "3", "Page4"), + ErrorCompare.RemovedFromPage(null, null, "4", "Page With Spaces"), + ErrorCompare.RemovedFromPage(null, null, "5", "Page With Spaces"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckPageTag(); + + [TestMethod] + public void Param_CheckPageTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckPageTag_CheckId() => Generic.CheckId(root, CheckId.CheckPageTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..d1008496 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,21 @@ + + + + + + + + Leading Space + + + Trailing Spaces + + + Leading and Trailing Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/WrongCasing.xml new file mode 100644 index 00000000..a5f3162c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Codefix/WrongCasing.xml @@ -0,0 +1,18 @@ + + + + + + + WrongCasing + + + + Wrong Casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_New.xml new file mode 100644 index 00000000..e0a6b59a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_New.xml @@ -0,0 +1,56 @@ + + + + + + + true + + + Page1 + + + + + + + + + true + + + Page2 + + + + + + + + + true + + + Page3 + + + + + + + + + true + + + + + + + true + + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_Old.xml new file mode 100644 index 00000000..769675e6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Invalid/RemovedFromPage_Old.xml @@ -0,0 +1,73 @@ + + + + + + + true + + + Page1 + + + Page2 + + + + + + + + + true + + + Page1 + + + + + + + + + true + + + Page With Spaces + + + Page3 + + + Page4 + + + + + + + + + true + + + Page With Spaces + + + + + + + + + true + + + Page With Spaces + + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..0fc62d55 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,206 @@ + + + + + + MatchingPositions_NoPosition + + true + + + + MatchingPositions_1Page + + true + + + Page With Spaces + + + + + + MatchingPositions_2Pages + + true + + + Page1 + + + Page2 + + + + + + + + AddingPositions_From0To1Page + + true + + + Page With Spaces + + + + + + AddingPositions_From1To2Pages + + true + + + Page1 + + + Page2 + + + + + + + + NewParam_NoPosition + + true + + + + NewParam_1Page + + true + + + NewPages + + + + + + + + PageCasingChanges_1Page + + true + + + Casing Changes + + + + + + PageCasingChanges_2Pages + + true + + + Casing Changes + + + Other Casing Changes + + + + + + + + TrimmedPages_TrimBefore + + true + + + Trim Before + + + + + + TrimmedPages_TrimAfter + + true + + + Trim After + + + + + + TrimmedPages_Trim + + true + + + Trim Before + + + Trim After + + + Trim Before And After + + + + + + + + RTDisplayFalse_From1To0Position + + false + + + + + + RTDisplayFalse_From1PageToNoPositions + + false + + + + RTDisplayFalse_From2To1Page + + false + + + Page1 + + + + + + + + NoRTDisplay_From1To0Position + + false + + + + + + NoRTDisplay_From1PageToNoPositions + + false + + + + NoRTDisplay_From2To1Page + + false + + + Page1 + + + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..3f9944c1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,219 @@ + + + + + + MatchingPositions_NoPosition + + true + + + + MatchingPositions_1Page + + true + + + Page With Spaces + + + + + + MatchingPositions_2Pages + + true + + + Page1 + + + Page2 + + + + + + + + AddingPositions_From0To1Page + + + + + AddingPositions_From1To2Pages + + true + + + Page1 + + + + + + + + + + + PageCasingChanges_1Page + + true + + + caSing changes + + + + + + PageCasingChanges_2Pages + + true + + + caSing changes + + + Other casiNg chAnges + + + + + + + + TrimmedPages_TrimBefore + + true + + + Trim Before + + + + + + TrimmedPages_TrimAfter + + true + + + Trim After + + + + + + TrimmedPages_Trim + + true + + + Trim Before + + + Trim After + + + Trim Before And After + + + + + + + + RTDisplayFalse_From1To0Position + + false + + + Page1 + + + + + + RTDisplayFalse_From1PageToNoPositions + + false + + + Page1 + + + + + + RTDisplayFalse_From2To1Page + + false + + + Page1 + + + Page2 + + + + + + + + NoRTDisplay_From1To0Position + + false + + + Page1 + + + + + + NoRTDisplay_From1PageToNoPositions + + false + + + Page1 + + + + + + NoRTDisplay_From2To1Page + + false + + + Page1 + + + Page2 + + + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..9dd3d006 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,19 @@ + + + + + TwiceOnSamePage + + + + My Page + + + My Page + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..fe820d2a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,26 @@ + + + + + Empty + + + + + + + + + + Spaces + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..e179cfc4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,15 @@ + + + + + NoPage + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..5e51c601 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,21 @@ + + + + + + + + Leading Space + + + Trailing Spaces + + + Leading and Trailing Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/WrongCasing.xml new file mode 100644 index 00000000..e3a4bc14 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Invalid/WrongCasing.xml @@ -0,0 +1,18 @@ + + + + + + + WrongCasing + + + + wrong casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..c5b62d65 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Page/CheckPageTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,52 @@ + + + + + Normal_Page + + + + My Valid Page Name + + + + + + + CPE_Page + + + + CPEIntegration_My Valid Page Name + + + + + + + + Title_End_Generic + fixed + + true + + + General + 0 + 11 + + + General + 8 + 1 + + + + + title + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/CheckRowTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/CheckRowTag.cs new file mode 100644 index 00000000..db194d44 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/CheckRowTag.cs @@ -0,0 +1,249 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Positions.Position.Row.CheckRowTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Positions.Position.Row.CheckRowTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckRowTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckRowTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckRowTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckRowTag_InvalidTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTag", + ExpectedResults = new List + { + Error.InvalidTag(null, null, null, "abc", "1"), + Error.InvalidTag(null, null, null, "-1", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckRowTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckRowTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckRowTag(); + + [TestMethod] + public void Param_CheckRowTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckRowTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.43.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Position/Row' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRowTag_InvalidTag() + { + // Create ErrorMessage + var message = Error.InvalidTag(null, null, null, "abc", "100"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.43.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'abc' in tag 'Position/Row'. Param ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRowTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.43.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Position/Row' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRowTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.43.4", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Position/Row' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckRowTag(); + + [TestMethod] + public void Param_CheckRowTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckRowTag_CheckId() => Generic.CheckId(check, CheckId.CheckRowTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..7c143e2c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page2 + 0 + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..ca6d524f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page1 + 0 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/InvalidTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/InvalidTag.xml new file mode 100644 index 00000000..f8689143 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/InvalidTag.xml @@ -0,0 +1,22 @@ + + + + + + + + Page1 + 0 + abc + + + Page2 + 0 + -1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..fcc161c0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,16 @@ + + + + + + + + Page1 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..08dbf141 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + + + + Page2 + 0 + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..035953d0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Positions/Position/Row/CheckRowTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,27 @@ + + + + + + + + Page1 + 0 + 0 + + + Page2 + 1 + 1 + + + Page3 + 1 + 10 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/CheckRTDisplayTag.cs b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/CheckRTDisplayTag.cs new file mode 100644 index 00000000..49871017 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/CheckRTDisplayTag.cs @@ -0,0 +1,1447 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.RTDisplay.CheckRTDisplayTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.RTDisplay.CheckRTDisplayTag; + + using PageOrderError = SLDisValidator2.Tests.Protocol.Display.CheckPageOrderAttribute.Error; + using PageVisibilityError = SLDisValidator2.Tests.Protocol.Display.Pages.Page.Visibility.CheckOverridePidAttribute.Error; + using ParamAlarmingDisabledIfError = SLDisValidator2.Tests.Protocol.Params.Param.Alarm.Monitored.CheckDisabledIfAttribute.Error; + using ParamAlarmingError = SLDisValidator2.Tests.Protocol.Params.Param.Alarm.Monitored.CheckMonitoredTag.Error; + using ParamAlarmOptionsError = SLDisValidator2.Tests.Protocol.Params.Param.Alarm.CheckOptionsAttribute.Error; + using ParamColumnOptionsError = SLDisValidator2.Tests.Protocol.Params.Param.ArrayOptions.ColumnOption.CheckOptionsAttribute.Error; + using ParamDependenciesError = SLDisValidator2.Tests.Protocol.Params.Param.Dependencies.Id.CheckIdTag.Error; + using ParamDiscreetDependencyValuesError = SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckDependencyValuesAttribute.Error; + using ParamDiscreetsDependencyIdError = SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.CheckDependencyId.Error; + using ParamIdError = SLDisValidator2.Tests.Protocol.Params.Param.CheckIdAttribute.Error; + using ParamMeasTypeOptionsError = SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Type.CheckOptionsAttribute.Error; + using ParamNameError = SLDisValidator2.Tests.Protocol.Params.Param.Name.CheckNameTag.Error; + using ParamPositionsError = SLDisValidator2.Tests.Protocol.Params.Param.Display.Positions.CheckPositionsTag.Error; + using ParamsLoadSequenceError = SLDisValidator2.Tests.Protocol.Params.CheckLoadSequenceAttribute.Error; + using ParamTrendingError = SLDisValidator2.Tests.Protocol.Params.Param.CheckTrendingAttribute.Error; + using ParamVirtualIdError = SLDisValidator2.Tests.Protocol.Params.Param.Type.CheckVirtualAttribute.Error; + using ProtocolTypeOptionsError = SLDisValidator2.Tests.Protocol.Type.CheckOptionsAttribute.Error; + using RelationsError = SLDisValidator2.Tests.Protocol.Relations.Relation.CheckPathAttribute.Error; + using TrapMapAlarmError = SLDisValidator2.Tests.Protocol.Params.Param.SNMP.TrapOID.CheckMapAlarmAttribute.Error; + using TreeControlExtraDetailsColumnIdError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDiscreetColumnIdAttribute.Error; + using TreeControlExtraDetailsTableIdError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDetailsTableIdAttribute.Error; + using TreeControlExtraTabParameterError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraTab.Tab.CheckParameterAttribute.Error; + using TreeControlHierarchyPathError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.CheckPathAttribute.Error; + using TreeControlHierarchyTableConditionError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckConditionAttribute.Error; + using TreeControlHierarchyTableIdError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckIdAttribute.Error; + using TreeControlParameterIdError = SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.CheckParameterIdAttribute.Error; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckRTDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_DveTables() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_DveTables", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_Pages() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_Pages", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_PageVisibility() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_PageVisibility", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamAlarming() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamAlarming", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamAlarmingDisabledIf() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamAlarmingDisabledIf", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamAlarmOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamAlarmOptions", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamDependencies() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamDependencies", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamDiscreetDependencyValues() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamDiscreetDependencyValues", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamDiscreetsDependencyId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamDiscreetsDependencyId", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamPositions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamPositions", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamsLoadSequence() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamsLoadSequence", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamTrending() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamTrending", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_ParamVirtualSource() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ParamVirtualSource", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_Relations() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_Relations", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_Spectrum() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_Spectrum", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TableColumnOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TableColumnOptions", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TableContextMenu() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TableContextMenu", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TableDisplayedColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TableDisplayedColumns", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TableViewColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TableViewColumns", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TrapMapAlarm() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TrapMapAlarm", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControl() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControl", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControlExtraDetails() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControlExtraDetails", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControlExtraTabs() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControlExtraTabs", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControlHierarchyPath() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControlHierarchyPath", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControlHierarchyTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControlHierarchyTable", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_Valid_TreeControlParameterId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_TreeControlParameterId", + ExpectedResults = new List() + }; + + Generic.FullValidate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckRTDisplayTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "InvalidValue", "1"), + Error.InvalidValue(null, null, null, " InvalidValue_Untrimmed ", "2"), + } + }; + + Generic.Validate(check, data); + } + + + #region RTDisplay Expected + [TestMethod] + [Ignore("todo when several (combine-able) types of RTDisplayExpected results are implemented.")] + public void Param_CheckRTDisplayTag_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + //Error.RTDisplayExpected(null, null, null, "101").WithSubResults( + // TreeControlParameterIdError.ParamRTDisplayExpected(null, null, null, "101")) + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_DveTables() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_DveTables", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + ProtocolTypeOptionsError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")), + + Error.RTDisplayExpected(null, null, null, "2000").WithSubResults( + ProtocolTypeOptionsError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_Pages() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_Pages", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100").WithSubResults( + PageOrderError.ReferencedParamRTDisplayExpected(null, null, null, "100")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_PageVisibility() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_PageVisibility", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "10").WithSubResults( + PageVisibilityError.ReferencedParamExpectingRTDisplay(null, null, null, "10", "RTDisplay_False")), + + Error.RTDisplayExpected(null, null, null, "11").WithSubResults( + PageVisibilityError.ReferencedParamExpectingRTDisplay(null, null, null, "11", "NoRTDisplay")), + + Error.RTDisplayExpected(null, null, null, "12").WithSubResults( + PageVisibilityError.ReferencedParamExpectingRTDisplay(null, null, null, "12", "NoDisplay")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamAlarming() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamAlarming", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "101").WithSubResults( + ParamAlarmingError.RTDisplayExpected(null, null, null, "101")), + + Error.RTDisplayExpected(null, null, null, "102").WithSubResults( + ParamAlarmingError.RTDisplayExpected(null, null, null, "102")), + + Error.RTDisplayExpected(null, null, null, "103").WithSubResults( + ParamAlarmingError.RTDisplayExpected(null, null, null, "103")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamAlarmingDisabledIf() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamAlarmingDisabledIf", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1001").WithSubResults( + ParamAlarmingDisabledIfError.ReferencedParamRTDisplayExpected(null, null, null, "1001", "1")), + + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + ParamAlarmingDisabledIfError.ReferencedParamRTDisplayExpected(null, null, null, "1002", "2")), + + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamAlarmingDisabledIfError.ReferencedParamRTDisplayExpected(null, null, null, "1003", "3")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamAlarmOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamAlarmOptions", + ExpectedResults = new List + { + #region standalone + // Thresholds + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1000", "100")), + + Error.RTDisplayExpected(null, null, null, "1001").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1001", "100")), + + // Properties + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1002", "100")), + + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1003", "100")), + #endregion + + #region Tables + Error.RTDisplayExpected(null, null, null, "10000").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10000", "502"), + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10000", "502"), + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10000", "502"), + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10000", "502")), + + // Thresholds + Error.RTDisplayExpected(null, null, null, "10001").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10001", "502")), + + Error.RTDisplayExpected(null, null, null, "10002").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10002", "502")), + + // Properties + Error.RTDisplayExpected(null, null, null, "10003").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10003", "502")), + + Error.RTDisplayExpected(null, null, null, "10004").WithSubResults( + ParamAlarmOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "10004", "502")), + #endregion + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamDependencies() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamDependencies", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "10").WithSubResults( + ParamDependenciesError.RTDisplayExpected(null, null, null, "10")), + Error.RTDisplayExpected(null, null, null, "11").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "11", "10")), + Error.RTDisplayExpected(null, null, null, "12").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "12", "10")), + Error.RTDisplayExpected(null, null, null, "13").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "13", "10")), + + Error.RTDisplayExpected(null, null, null, "20").WithSubResults( + ParamDependenciesError.RTDisplayExpected(null, null, null, "20")), + Error.RTDisplayExpected(null, null, null, "21").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "21", "20")), + Error.RTDisplayExpected(null, null, null, "22").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "22", "20")), + Error.RTDisplayExpected(null, null, null, "23").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "23", "20")), + + Error.RTDisplayExpected(null, null, null, "30").WithSubResults( + ParamDependenciesError.RTDisplayExpected(null, null, null, "30")), + Error.RTDisplayExpected(null, null, null, "31").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "31", "30")), + Error.RTDisplayExpected(null, null, null, "32").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "32", "30")), + Error.RTDisplayExpected(null, null, null, "33").WithSubResults( + ParamDependenciesError.RTDisplayExpectedOnReferencedParam(null, null, null, "33", "30")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamDiscreetDependencyValues() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamDiscreetDependencyValues", + ExpectedResults = new List + { + // Discreet 1 + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1002", "999")), + + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1003", "999")), + + Error.RTDisplayExpected(null, null, null, "1004").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1004", "999")), + + Error.RTDisplayExpected(null, null, null, "1005").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1005", "999")), + + Error.RTDisplayExpected(null, null, null, "1006").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1006", "999")), + + Error.RTDisplayExpected(null, null, null, "1007").WithSubResults( + ParamDiscreetDependencyValuesError.ReferencedParamExpectingRTDisplay(null, null, null, "1007", "999")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamDiscreetsDependencyId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamDiscreetsDependencyId", + ExpectedResults = new List + { + // Read Param + Error.RTDisplayExpected(null, null, null, "100").WithSubResults( + ParamDiscreetsDependencyIdError.ReferencedParamRTDisplayExpected(null, null, null, "100", "1000")), + + Error.RTDisplayExpected(null, null, null, "101").WithSubResults( + ParamDiscreetsDependencyIdError.ReferencedParamRTDisplayExpected(null, null, null, "101", "1001")), + + Error.RTDisplayExpected(null, null, null, "102").WithSubResults( + ParamDiscreetsDependencyIdError.ReferencedParamRTDisplayExpected(null, null, null, "102", "1002")), + + // ReadBit param + Error.RTDisplayExpected(null, null, null, "200").WithSubResults( + ParamDiscreetsDependencyIdError.ReferencedParamRTDisplayExpected(null, null, null, "200", "2000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamPositions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamPositions", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1").WithSubResults( + ParamPositionsError.RTDisplayExpected(null, null, null, "1")), + + Error.RTDisplayExpected(null, null, null, "2").WithSubResults( + ParamPositionsError.RTDisplayExpected(null, null, null, "2")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamsLoadSequence() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamsLoadSequence", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1").WithSubResults( + ParamsLoadSequenceError.ReferencedParamRTDisplayExpected(null, null, null, "1")), + + Error.RTDisplayExpected(null, null, null, "2").WithSubResults( + ParamsLoadSequenceError.ReferencedParamRTDisplayExpected(null, null, null, "2")), + + Error.RTDisplayExpected(null, null, null, "3").WithSubResults( + ParamsLoadSequenceError.ReferencedParamRTDisplayExpected(null, null, null, "3")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamTrending() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamTrending", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100").WithSubResults( + ParamTrendingError.RTDisplayExpected(null, null, null, "100")), + + Error.RTDisplayExpected(null, null, null, "101").WithSubResults( + ParamTrendingError.RTDisplayExpected(null, null, null, "101")), + + Error.RTDisplayExpected(null, null, null, "102").WithSubResults( + ParamTrendingError.RTDisplayExpected(null, null, null, "102")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_ParamVirtualSource() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_ParamVirtualSource", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100").WithSubResults( + ParamVirtualIdError.RTDisplayExpected(null, null, null, "100")), + + Error.RTDisplayExpected(null, null, null, "110").WithSubResults( + ParamVirtualIdError.RTDisplayExpected(null, null, null, "110")), + + Error.RTDisplayExpected(null, null, null, "120").WithSubResults( + ParamVirtualIdError.RTDisplayExpected(null, null, null, "120")), + + Error.RTDisplayExpected(null, null, null, "130").WithSubResults( + ParamVirtualIdError.RTDisplayExpected(null, null, null, "130")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_Relations() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_Relations", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + RelationsError.ReferencedParamExpectingRTDisplay(null, null, null, "1000"), + RelationsError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")), + + Error.RTDisplayExpected(null, null, null, "2000").WithSubResults( + RelationsError.ReferencedParamExpectingRTDisplay(null, null, null, "2000"), + RelationsError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")), + + Error.RTDisplayExpected(null, null, null, "3000").WithSubResults( + RelationsError.ReferencedParamExpectingRTDisplay(null, null, null, "3000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_Spectrum() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_Spectrum", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "64000").WithSubResults( + ParamIdError.RTDisplayExpectedOnSpectrumParam(null, null, null, "64000")), + + Error.RTDisplayExpected(null, null, null, "64001").WithSubResults( + ParamIdError.RTDisplayExpectedOnSpectrumParam(null, null, null, "64001")), + + Error.RTDisplayExpected(null, null, null, "64002").WithSubResults( + ParamIdError.RTDisplayExpectedOnSpectrumParam(null, null, null, "64002")), + + + Error.RTDisplayExpected(null, null, null, "64299").WithSubResults( + ParamIdError.RTDisplayExpectedOnSpectrumParam(null, null, null, "64299")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TableColumnOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TableColumnOptions", + ExpectedResults = new List + { + // Displayed Table + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1003", "enableHeaderAvg", "1000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1003", "enableHeatmap", "1000")), + Error.RTDisplayExpected(null, null, null, "1053").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1053", "enableHeaderAvg", "1000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1053", "enableHeatmap", "1000")), + + Error.RTDisplayExpected(null, null, null, "1004").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1004", "rowTextColoring", "1000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1004", "selectionSetVar", "1000")), + Error.RTDisplayExpected(null, null, null, "1054").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1054", "rowTextColoring", "1000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1054", "selectionSetVar", "1000")), + + Error.RTDisplayExpected(null, null, null, "1005").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1005", "xpos", "1000")), + Error.RTDisplayExpected(null, null, null, "1055").WithSubResults( + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1055", "xpos", "1000")), + + // Exported Table (no errors since all columns have export="true" which is validated by another check) + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TableContextMenu() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TableContextMenu", + ExpectedResults = new List + { + // QAction Feedback + Error.RTDisplayExpected(null, null, null, "998").WithSubResults( + ParamNameError.RTDisplayExpectedOnQActionFeedback(null, null, null, "998")), + + // Context Menu + Error.RTDisplayExpected(null, null, null, "999").WithSubResults( + ParamNameError.RTDisplayExpectedOnContextMenu(null, null, null, "999")), +} + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TableDisplayedColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TableDisplayedColumns", + ExpectedResults = new List + { + // Displayed Table + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1003", "1000")), + Error.RTDisplayExpected(null, null, null, "1053").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1053", "1000")), + + Error.RTDisplayExpected(null, null, null, "1004").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1004", "1000")), + Error.RTDisplayExpected(null, null, null, "1054").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1054", "1000")), + + Error.RTDisplayExpected(null, null, null, "1005").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1005", "1000")), + Error.RTDisplayExpected(null, null, null, "1055").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1055", "1000")), + + // Exported Table (no errors since all columns have export="true" which is validated by another check) + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TableViewColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TableViewColumns", + ExpectedResults = new List + { + // Normal Table + Error.RTDisplayExpected(null, null, null, "1001").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1001", "1000"), + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "2001", "2000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "2001", "view=1001", "2000")), + + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1002", "1000"), + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "2002", "2000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "2002", "view=1002", "2000")), + Error.RTDisplayExpected(null, null, null, "1052").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1052", "1000"), + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1052", "2000"), + // Ideally, below one should replace above one. + //ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "2052", "2000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1052", "view=1002", "2000")), + + Error.RTDisplayExpected(null, null, null, "1003").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1003", "1000"), + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "2003", "2000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "2003", "view=1003", "2000")), + Error.RTDisplayExpected(null, null, null, "1053").WithSubResults( + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1053", "1000"), + ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "1053", "2000"), + // Ideally, below one should replace above one. + //ParamMeasTypeOptionsError.ReferencedParamRTDisplayExpected(null, null, null, "2053", "2000"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1053", "view=1003", "2000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TrapMapAlarm() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TrapMapAlarm", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100").WithSubResults( + TrapMapAlarmError.RTDisplayExpected(null, null, null, "100")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlExtraDetails() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlExtraDetails", + ExpectedResults = new List + { + // detailsTableId + Error.RTDisplayExpected(null, null, null, "1100").WithSubResults( + TreeControlExtraDetailsTableIdError.ReferencedTableExpectingRTDisplay(null, null, null, "1100")), + + Error.RTDisplayExpected(null, null, null, "2100").WithSubResults( + TreeControlExtraDetailsTableIdError.ReferencedTableExpectingRTDisplay(null, null, null, "2100")), + + // discreetColumnId + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + TreeControlExtraDetailsColumnIdError.ReferencedColumnExpectingRTDisplay(null, null, null, "1002")), + + Error.RTDisplayExpected(null, null, null, "2002").WithSubResults( + TreeControlExtraDetailsColumnIdError.ReferencedColumnExpectingRTDisplay(null, null, null, "2002"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "2002", "foreignKey=1000", "2000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlExtraTabs() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlExtraTabs", + ExpectedResults = new List + { + // Tabs on table 1000 level + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")/*, + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "1000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "1000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "1000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")*/), + + Error.RTDisplayExpected(null, null, null, "1102").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "1102"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "1102", "foreignKey=1000", "1100")), + Error.RTDisplayExpected(null, null, null, "1100").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "1100")), + + Error.RTDisplayExpected(null, null, null, "2").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "2")), + + Error.RTDisplayExpected(null, null, null, "4000").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "4000")), + + + // Tabs on table 2000 level + Error.RTDisplayExpected(null, null, null, "2000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")/*, + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "2000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "2000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")*/), + + Error.RTDisplayExpected(null, null, null, "2102").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "2102"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "2102", "foreignKey=2000", "2100")), + Error.RTDisplayExpected(null, null, null, "2100").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "2100")), + + Error.RTDisplayExpected(null, null, null, "3").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "3")), + + + // Tabs on table 3000 level + Error.RTDisplayExpected(null, null, null, "3000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "3000")/*, + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "3000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "3000"), + TreeControlExtraTabTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "3000")*/), + + Error.RTDisplayExpected(null, null, null, "3102").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "3102"), + ParamColumnOptionsError.ColumnOptionExpectingRTDisplay(null, null, null, "3102", "foreignKey=3000", "3100")), + Error.RTDisplayExpected(null, null, null, "3100").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "3100")), + + Error.RTDisplayExpected(null, null, null, "4").WithSubResults( + TreeControlExtraTabParameterError.ReferencedParamExpectingRTDisplay(null, null, null, "4")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlHierarchyPath() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlHierarchyPath", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")), + + Error.RTDisplayExpected(null, null, null, "2000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")), + + Error.RTDisplayExpected(null, null, null, "3000").WithSubResults( + TreeControlHierarchyPathError.ReferencedParamExpectingRTDisplay(null, null, null, "3000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlHierarchyTableCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlHierarchyTableCondition", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1002").WithSubResults( + TreeControlHierarchyTableConditionError.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "101"), + TreeControlHierarchyTableConditionError.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "101")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlHierarchyTableId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlHierarchyTableId", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "1000").WithSubResults( + TreeControlHierarchyTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "1000")), + + Error.RTDisplayExpected(null, null, null, "2000").WithSubResults( + TreeControlHierarchyTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "2000")), + + Error.RTDisplayExpected(null, null, null, "3000").WithSubResults( + TreeControlHierarchyTableIdError.ReferencedParamExpectingRTDisplay(null, null, null, "3000")), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected_TreeControlParameterId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected_TreeControlParameterId", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "101").WithSubResults( + TreeControlParameterIdError.ReferencedParamExpectingRTDisplay(null, null, null, "101")), + + Error.RTDisplayExpected(null, null, null, "102").WithSubResults( + TreeControlParameterIdError.ReferencedParamExpectingRTDisplay(null, null, null, "102")), + + Error.RTDisplayExpected(null, null, null, "103").WithSubResults( + TreeControlParameterIdError.ReferencedParamExpectingRTDisplay(null, null, null, "103")), + } + }; + + Generic.FullValidate(check, data); + } + #endregion + + + #region RTDisplay Unexpected + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayUnexpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayUnexpected", + ExpectedResults = new List + { + Error.RTDisplayUnexpected(null, null, null, "1000"), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayUnexpected_TableColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayUnexpected_TableColumns", + ExpectedResults = new List + { + // RTDisplay true on table + Error.RTDisplayUnexpected(null, null, null, "1001"), + Error.RTDisplayUnexpected(null, null, null, "1002"), + Error.RTDisplayUnexpected(null, null, null, "1052"), + + // RTDisplay false on table + Error.RTDisplayUnexpected(null, null, null, "2001"), + Error.RTDisplayUnexpected(null, null, null, "2002"), + Error.RTDisplayUnexpected(null, null, null, "2052"), + } + }; + + Generic.FullValidate(check, data); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayUnexpected_TrapMapAlarm() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayUnexpected_TrapMapAlarm", + ExpectedResults = new List + { + Error.RTDisplayUnexpected(null, null, null, "200"), + } + }; + + Generic.FullValidate(check, data); + } + + #endregion + + + [TestMethod] + public void Param_CheckRTDisplayTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + // RTDisplay not needed + Error.UntrimmedTag(null, null, null, "1000", " false "), + + // RTDisplay with onAppLevel + Error.UntrimmedTag(null, null, null, "2000", " true "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckRTDisplayTag(); + + [TestMethod] + public void Param_CheckRTDisplayTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckRTDisplayTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "2.7.1", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Empty tag 'RTDisplay' in Param '1'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "invalidValue", "100"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "2.7.3", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Invalid value 'invalidValue' in tag 'RTDisplay'. Possible values 'true, false'. Param ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayExpected() + { + // Create ErrorMessage + var message = Error.RTDisplayExpected(null, null, null, "100"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "2.7.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "RTDisplay(true) expected on Param '100'.", + HowToFix = "Double check the subresults to evaluate if the features requiring RTDisplay are to be removed or if RTDisplay actually has to be set to true.", + ExampleCode = "", + Details = "This protocol contains some feature(s) requiring this Param to need the RTDisplay tag to be set true (see subresults).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_RTDisplayUnexpected() + { + // Create ErrorMessage + var message = Error.RTDisplayUnexpected(null, null, null, "100"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "2.7.5", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Unexpected RTDisplay(true) on Param '100'.", + HowToFix = "Double check if this Param requires RTDisplay for reasons that are outside the scope of this driver (Visios, automation scripts, etc)." + Environment.NewLine + "- If so, suppress this result and explain why RTDisplay is required via the suppression comment." + Environment.NewLine + "- If not, remove the full Display tag containing this RTDisplay tag.", + ExampleCode = "", + Details = "This protocol doesn't contain anything that would justify the need of the RTDisplay tag being true.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRTDisplayTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "1", " true "); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "2.7.2", + Category = Category.Param, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Untrimmed tag 'RTDisplay' in Param '1'. Current value ' true '.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckRTDisplayTag(); + + [TestMethod] + public void Param_CheckRTDisplayTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckRTDisplayTag_CheckId() => Generic.CheckId(check, CheckId.CheckRTDisplayTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..cdd2671b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,23 @@ + + + + + + NoRTDisplay_DummyParam + dummy + + false + + + + + + NoRTDisplay_DummyParam + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..a85d8b58 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,25 @@ + + + + + Empty + + + + + + Spaces + + + + + + Enter + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..5a25d70c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,18 @@ + + + + + InvalidValue + + InvalidValue + + + + InvalidValue_Untrimmed + + InvalidValue_Untrimmed + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..94336796 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,34 @@ + + + + + + RTDisplay_DisplayedParam_1 + read + + + + General + 0 + 0 + + + + + + RTDisplay_DisplayedParam_2 + read + + false + + + General + 2 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_DveTables.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_DveTables.xml new file mode 100644 index 00000000..b7cfc93a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_DveTables.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + false + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_PageVisibility.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_PageVisibility.xml new file mode 100644 index 00000000..a1a2a022 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_PageVisibility.xml @@ -0,0 +1,44 @@ + + + + + + RTDisplay_False + + + + NoRTDisplay + + + + NoDisplay + + + + + + + + PageVisibility_RTDisplay_False + read + + false + + + + PageVisibility_NoRTDisplay + read + + + + + + PageVisibility_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Pages.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Pages.xml new file mode 100644 index 00000000..16f1f60d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Pages.xml @@ -0,0 +1,15 @@ + + + + + + + WebInterfaceURL + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmOptions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmOptions.xml new file mode 100644 index 00000000..d21754aa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmOptions.xml @@ -0,0 +1,116 @@ + + + + + AlarmProtperties_Standalone_1000 + read + + true + + + true + + + + + AlarmProtperties_Table1 + array + + + + + + true + + + Page + 0 + 0 + + + + + + AlarmProtperties_Table1_Instance + read + + true + + + + AlarmProtperties_Table1_Column2 + read + + true + + + true + + + + + Read_1000_RTDisplayFalse + read + + false + + + + Read_1000_NoRTDisplay + read + + + + + Read_1002_NoDisplay + read + + + Read_1003_NoDisplay + read + + + + Table1 + array + + + + + + + + + + Table1_Instance + read + + + + Table1_Column2 + read + + + + Table1_Column3 + read + + + + Table1_Column4 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarming.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarming.xml new file mode 100644 index 00000000..01ca5f03 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarming.xml @@ -0,0 +1,33 @@ + + + + + AlarmTrue_RTDisplayFalse + + true + + + false + + + + AlarmTrue_NoRTDisplay + + true + + + + + + + AlarmTrue_NoDisplay + + true + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmingDisabledIf.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmingDisabledIf.xml new file mode 100644 index 00000000..a82bbfd9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamAlarmingDisabledIf.xml @@ -0,0 +1,60 @@ + + + + + + Alarmed_ConditionOn_RTDisplayFalse + read + + true + + + true + + + + Alarmed_ConditionOn_NoRTDisplay + read + + true + + + true + + + + Alarmed_ConditionOn_NoDisplay + read + + true + + + true + + + + + + Condition_Read_RTDisplayFalse + read + + false + + + + Condition_Read_NoRTDisplay + read + + + + + + Condition_Read_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDependencies.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDependencies.xml new file mode 100644 index 00000000..73656245 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDependencies.xml @@ -0,0 +1,107 @@ + + + + + ButtonWithDependencies_RTDisplayFalse + write + + 11 + 12 + 13 + + + false + + + + ButtonWithDependencies_RTDisplayFalse_Dependency1 + read + + false + + + + ButtonWithDependencies_RTDisplayFalse_Dependency2 + read + + + + + + ButtonWithDependencies_RTDisplayFalse_Dependency3 + read + + + + + ButtonWithDependencies_NoRTDisplay + write + + 21 + 22 + 23 + + + + + + + ButtonWithDependencies_NoRTDisplay_Dependency1 + read + + false + + + + ButtonWithDependencies_NoRTDisplay_Dependency2 + read + + + + + + ButtonWithDependencies_NoRTDisplay_Dependency3 + read + + + + + ButtonWithDependencies_NoDisplay + write + + 31 + 32 + 33 + + + + + ButtonWithDependencies_NoDisplay_Dependency1 + read + + false + + + + ButtonWithDependencies_NoDisplay_Dependency2 + read + + + + + + ButtonWithDependencies_NoDisplay_Dependency3 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetDependencyValues.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetDependencyValues.xml new file mode 100644 index 00000000..1ca3e8ee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetDependencyValues.xml @@ -0,0 +1,93 @@ + + + + + + MyTable_ContextMenu + write + + true + + + discreet + + + + + + + + MyTable + array + + + + + + + + + + + true + + + General + 0 + 0 + + + + + + MyTable_Instance + read + + + + MyTable_Column2 + read + + + + MyTable_Column3 + read + + + + MyTable_Column4 + read + + + + MyTable_Column5 + read + + + + MyTable_Column6 + read + + + + MyTable_Column7 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetsDependencyId.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetsDependencyId.xml new file mode 100644 index 00000000..3239c574 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamDiscreetsDependencyId.xml @@ -0,0 +1,61 @@ + + + + + Read_RTDisplayFalse + read + + false + + + + Read_NoRTDisplay + read + + + + + + Read_NoDisplay + read + + + + + ReadBit_RTDisplayFalse + read bit + + false + + + + + DependencyId_ToRead_RTDisplayFalse + + + + + + DependencyId_ToRead_NoRTDisplay + + + + + + DependencyId_ToRead_NoDisplay + + + + + + + DependencyId_ToReadBit_RTDisplayFalse + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamPositions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamPositions.xml new file mode 100644 index 00000000..67007139 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamPositions.xml @@ -0,0 +1,32 @@ + + + + + RTDisplayFalse + + false + + + Page1 + 0 + 0 + + + + + + NoRTDisplay + + + + + Page1 + 0 + 0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamTrending.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamTrending.xml new file mode 100644 index 00000000..1a6f080c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamTrending.xml @@ -0,0 +1,27 @@ + + + + + TrendingTrue_RTDisplayFalse + read + + false + + + + TrendingTrue_NoRTDisplay + read + + + + + + TrendingTrue_NoDisplay + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamVirtualSource.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamVirtualSource.xml new file mode 100644 index 00000000..5285b1b0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamVirtualSource.xml @@ -0,0 +1,35 @@ + + + + + + Source_NoFilter + read + + false + + + + Source_ProtocolFilter + read + + + + + + Source_ProtocolFilter_ParamFilter + read + + + + Source_ParamFilter + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamsLoadSequence.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamsLoadSequence.xml new file mode 100644 index 00000000..1e7e172f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_ParamsLoadSequence.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + false + + + + read_2 + read + + + + + + read_3 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Relations.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Relations.xml new file mode 100644 index 00000000..55ef5194 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Relations.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + TableLevel1_RTDisplayFalse + array + + + + + false + + + + TableLevel1_Instance + read + + + true + + + + + TableLevel2_NoRTDisplay + array + + + + + + + + + + TableLevel2_Instance + read + + + true + + + + TableLevel2_FkTo1000 + read + + + true + + + + + TableLevel3_NoDisplay + array + + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Spectrum.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Spectrum.xml new file mode 100644 index 00000000..affa5b9a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_Spectrum.xml @@ -0,0 +1,42 @@ + + + + + + + OtherParam + + + + + TODO_CorrectName_64000 + Correct Description 64000 + + false + + + + TODO_CorrectName_64001 + Correct Description 64001 + + + + + + TODO_CorrectName_64002 + Correct Description 64002 + + + + + TODO_CorrectName_64299 + Correct Description 64299 + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableColumnOptions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableColumnOptions.xml new file mode 100644 index 00000000..63c951b7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableColumnOptions.xml @@ -0,0 +1,168 @@ + + + + + table_RTDisplayTrue + array + + + + + + + + + true + + + General + 0 + 0 + + + + + + table_RTDisplayTrue_1001_Instance + read + + + + table_RTDisplayTrue_1002_RTDisplayTrue + read + + + true + + + + table_RTDisplayTrue_1002_RTDisplayTrue + write + + + true + + + + table_RTDisplayTrue_1003_RTDisplayFalse + read + + false + + + + table_RTDisplayTrue_1003_RTDisplayFalse + write + + false + + + + table_RTDisplayTrue_1004_NoRTDisplay + read + + + + + + table_RTDisplayTrue_1004_NoRTDisplay + write + + + + + + table_RTDisplayTrue_1005_NoDisplay + read + + + + table_RTDisplayTrue_1005_NoDisplay + write + + + + + table_ExportTrue + array + + + + + + + + + + table_ExportTrue_2001_Instance + read + + true + + + + table_ExportTrue_2002_RTDisplayTrue + read + + true + + + + table_ExportTrue_2002_RTDisplayTrue + write + + true + + + + table_ExportTrue_2003_RTDisplayFalse + read + + false + + + + table_ExportTrue_2003_RTDisplayFalse + write + + false + + + + table_ExportTrue_2004_NoRTDisplay + read + + + + + + table_ExportTrue_2004_NoRTDisplay + write + + + + + + table_ExportTrue_2005_NoDisplay + read + + + + table_ExportTrue_2005_NoDisplay + write + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableContextMenu.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableContextMenu.xml new file mode 100644 index 00000000..9f3cb9db --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableContextMenu.xml @@ -0,0 +1,94 @@ + + + + + Table1_QActionFeedback + read + + + + Table1_ContextMenu + write + + numeric text + double + next param + + + + discreet + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableDisplayedColumns.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableDisplayedColumns.xml new file mode 100644 index 00000000..69a08fb3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableDisplayedColumns.xml @@ -0,0 +1,181 @@ + + + + + table_RTDisplayTrue + array + + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + table_RTDisplayTrue_1001_Instance + read + + true + + + + table_RTDisplayTrue_1002_RTDisplayTrue + read + + true + + + + table_RTDisplayTrue_1002_RTDisplayTrue + write + + true + + + + table_RTDisplayTrue_1003_RTDisplayFalse + read + + false + + + + table_RTDisplayTrue_1003_RTDisplayFalse + write + + false + + + + table_RTDisplayTrue_1004_NoRTDisplay + read + + + + + + table_RTDisplayTrue_1004_NoRTDisplay + write + + + + + + table_RTDisplayTrue_1005_NoDisplay + read + + + + table_RTDisplayTrue_1005_NoDisplay + write + + + + + table_ExportTrue + array + + + + + + + + + false + + + General + 0 + 0 + + + + + table + + + + table_ExportTrue_2001_Instance + read + + true + + + + table_ExportTrue_2002_RTDisplayTrue + read + + true + + + + table_ExportTrue_2002_RTDisplayTrue + write + + true + + + + table_ExportTrue_2003_RTDisplayFalse + read + + false + + + + table_ExportTrue_2003_RTDisplayFalse + write + + false + + + + table_ExportTrue_2004_NoRTDisplay + read + + + + + + table_ExportTrue_2004_NoRTDisplay + write + + + + + + table_ExportTrue_2005_NoDisplay + read + + + + table_ExportTrue_2005_NoDisplay + write + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableViewColumns.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableViewColumns.xml new file mode 100644 index 00000000..75a79a34 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TableViewColumns.xml @@ -0,0 +1,88 @@ + + + + + + Table + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + Table_Instance + read + + false + + + + Table_Column2 + read + + + + + + Table_Column2 + write + + + + + + Table_Column3 + read + + + + Table_Column3 + write + + + + + + ViewTable + array + + + + + + + true + + + General + 1 + 0 + + + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TrapMapAlarm.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TrapMapAlarm.xml new file mode 100644 index 00000000..1f3c9a8a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TrapMapAlarm.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraDetails.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraDetails.xml new file mode 100644 index 00000000..8abefefa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraDetails.xml @@ -0,0 +1,157 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Level1 + array + + + + + + true + + + + Level1_Instance + read + + + true + + + + Level1_Column2 + read + + + discreet + + + + + Level1_ExtraDetails + array + + + + + + + + Level1_ExtraDetails_Instance + read + + true + + + + Level1_ExtraDetails_Column2 + read + + true + + + + + Level2 + array + + + + + + true + + + + Level2_Instance + read + + + true + + + + Level2_Column2_FkTo1000 + read + + + discreet + + + + + Level2_ExtraDetails + array + + + + + + + + Level2_ExtraDetails_Instance + read + + true + + + + Level2_ExtraDetails_Column2_FkTo1000 + read + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraTabs.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraTabs.xml new file mode 100644 index 00000000..ddbda721 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlExtraTabs.xml @@ -0,0 +1,227 @@ + + + + + Read_RTDisplayTrue + read + + true + + + + Read_RTDisplayFalse + read + + false + + + + Read_NoRTDisplay + read + + + + + Read_NoDisplay + read + + + + TreeControl_ParameterId + read + + true + + + + + Table_Level1_RTDisplayFalse + array + + + + + false + + + + Table_Level1_RTDisplayFalse_Instance + read + + + true + + + + + Table_Level1.1_RTDisplayFalse + array + + + + + + false + + + + Table_Level1.1_RTDisplayFalse_Instance + read + + false + + + + Table_Level1.1_RTDisplayFalse_FkTo1000 + read + + false + + + + + Table_Level2_NoRTDisplay + array + + + + + + + + + Table_Level2_NoRTDisplay_Instance + read + + + true + + + + Table_Level2_NoRTDisplay_FkTo1000 + read + + + true + + + + + Table_Level2.1_NoRTDisplay + array + + + + + + + + + Table_Level2.1_NoRTDisplay_Instance + read + + + + Table_Level2.1_NoRTDisplay_FkTo2000 + read + + + + + Table_Level3_NoDisplay + array + + + + + + + Table_Level3_NoDisplay_Instance + read + + + true + + + + Table_Level3_NoDisplay_FKto2000 + read + + + true + + + + + Table_Level3.1_NoDisplay + array + + + + + + + Table_Level3.1_NoDisplay_Instance + read + + true + + + + Table_Level3.1_NoDisplay_FKto3000 + read + + + + + Table_Level4_NoDisplay + array + + + + + + + Table_Level4_NoDisplay_Instance + read + + + Table_Level4_NoDisplay_FKto3000 + read + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyPath.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyPath.xml new file mode 100644 index 00000000..1cf8d74c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyPath.xml @@ -0,0 +1,69 @@ + + + + + TreeControl_ParameterId + read + + true + + + + + Table_Level1_RTDisplayFalse + array + + + + + false + + + + Table_Level1_RTDisplayFalse_Instance + read + + true + + + + + Table_Level2_NoRTDisplay + array + + + + + + + + Table_Level2_NoRTDisplay_Instance + read + + true + + + + + Table_Level3_NoDisplay + array + + + + + + Table_Level3_NoDisplay_Instance + read + + true + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableCondition.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableCondition.xml new file mode 100644 index 00000000..33f7c298 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableCondition.xml @@ -0,0 +1,144 @@ + + + + + + + + + TreeControl_ParameterId + dummy + + true + + + + + Table_Level1 + array + + + + + true + + + + Table_Level1_Instance + read + + + true + + + + Table_Level1_TypeForCondition + read + + + + + AAA + AAA + + + BBB + BBB + + + + + + + Table_Level2_AAA + array + + + + + + true + + + + Table_Level2_AAA_Instance + read + + + true + + + + Table_Level2_AAA_FkTo1000 + read + + true + + + + + Table_Level2_BBB + array + + + + + + true + + + + Table_Level2_BBB_Instance + read + + + + Table_Level2_BBB_FkTo1000 + read + + true + + + + + Table_Level3 + array + + + + + + true + + + + Table_Level3_Instance + read + + + Table_Level3_FkTo2000 + read + + true + + + + + + + +
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableId.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableId.xml new file mode 100644 index 00000000..2206ad10 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlHierarchyTableId.xml @@ -0,0 +1,73 @@ + + + + + TreeControl_ParameterId + dummy + + true + + + + + Table_Level1_RTDisplayFalse + array + + + + + false + + + + Table_Level1_RTDisplayFalse_Instance + read + + true + + + + + Table_Level2_NoRTDisplay + array + + + + + + + + Table_Level2_NoRTDisplay_Instance + read + + true + + + + + Table_Level3_NoDisplay + array + + + + + + Table_Level3_NoDisplay_Instance + read + + true + + + + + + + +
+
+
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlParameterId.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlParameterId.xml new file mode 100644 index 00000000..04a1d380 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayExpected_TreeControlParameterId.xml @@ -0,0 +1,32 @@ + + + + + TreeControl_ParameterId_RTDisplayFalse + read + + false + + + + TreeControl_ParameterId_RTDisplayMissing + read + + + + + TreeControl_ParameterId_DisplayMissing + read + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected.xml new file mode 100644 index 00000000..9c47fef5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected.xml @@ -0,0 +1,13 @@ + + + + + NoRTDisplay_DummyParam + dummy + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TableColumns.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TableColumns.xml new file mode 100644 index 00000000..d26713a6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TableColumns.xml @@ -0,0 +1,84 @@ + + + + + table_RTDisplayTrue + array + + + + + + true + + + General + 0 + 0 + + + + + table + + + + table_RTDisplayTrue_Instance + read + + true + + + + table_RTDisplayTrue_1002 + read + + true + + + + table_RTDisplayTrue_1002 + write + + true + + + + + table_RTDisplayFalse + array + + + + + + false + + + table + + + + table_RTDisplayFalse_Instance + read + + true + + + + table_RTDisplayFalse_1002 + read + + true + + + + table_RTDisplayFalse_1002 + write + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TrapMapAlarm.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TrapMapAlarm.xml new file mode 100644 index 00000000..4e31c9ef --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/RTDisplayUnexpected_TrapMapAlarm.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLScripting + Trap Received Via SLScripting + dummy + + true + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..ff53bee3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,23 @@ + + + + + + NoRTDisplay_DummyParam + dummy + + false + + + + + + NoRTDisplay_DummyParam + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d553b31f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,36 @@ + + + + + + + + + NoRTDisplay_DummyParam + dummy + + + + + NoRTDisplay_DummyParam + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_DveTables.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_DveTables.xml new file mode 100644 index 00000000..24f9958d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_DveTables.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + true + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + true + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_PageVisibility.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_PageVisibility.xml new file mode 100644 index 00000000..a213bdb5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_PageVisibility.xml @@ -0,0 +1,35 @@ + + + + + + Page1 + + + + + + + + PageVisibility_Page1 + read + + true + + + discreet + + + Hide + 0 + + + Display + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Pages.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Pages.xml new file mode 100644 index 00000000..097aeeea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Pages.xml @@ -0,0 +1,15 @@ + + + + + + + WebInterfaceURL + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmOptions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmOptions.xml new file mode 100644 index 00000000..d5841668 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmOptions.xml @@ -0,0 +1,110 @@ + + + + + + Standalone_WithAlarmProperties_100 + read + + true + + + true + + + + Standalone_WithAlarmProperties_100_Threshold_101 + read + + true + + + + Standalone_WithAlarmProperties_100_Threshold_102 + read + + true + + + + Standalone_WithAlarmProperties_100_PropertyValue_111 + read + + true + + + + Standalone_WithAlarmProperties_100_PropertyValue_112 + read + + true + + + + + + Table_WithAlarmProtperties + array + + + + + + true + + + Page + 0 + 0 + + + + + + Table_WithAlarmProtperties_Instance + read + + + Table_WithAlarmProtperties_Column2 + read + + true + + + true + + + + + Table1 + array + + + + + + + true + + + + Table1_Instance + read + + + Table1_Column2_PropertyValue_10002 + read + + true + + + + Table1_Column3_PropertyValue_10003 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarming.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarming.xml new file mode 100644 index 00000000..2211f2d6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarming.xml @@ -0,0 +1,52 @@ + + + + + AlarmTrue_RTDisplayTrue + + true + + + true + + + + + AlarmFalse_RTDisplayTrue + + false + + + true + + + + AlarmFalse_RTDisplayFalse + + false + + + false + + + + AlarmFalse_NoRTDisplay + + false + + + + + + + AlarmFalse_NoDisplay + + false + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmingDisabledIf.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmingDisabledIf.xml new file mode 100644 index 00000000..82681d09 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamAlarmingDisabledIf.xml @@ -0,0 +1,79 @@ + + + + + + Alarmed_ConditionOnString + read + + true + + + true + + + + Alarmed_ConditionOnNumber + read + + true + + + true + + + + Alarmed_ConditionOnDiscreet + read + + true + + + true + + + + + + Condition_Read_String + read + + true + + + string + + + + Condition_Read_Number + read + + true + + + number + + + + Condition_Read_Discreet + read + + true + + + discreet + + + Disabled + 0 + + + Enabled + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDependencies.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDependencies.xml new file mode 100644 index 00000000..edd06733 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDependencies.xml @@ -0,0 +1,62 @@ + + + + + ButtonWithDependencies + write + + 11 + 22 + 13 + 24 + + + true + + + + + ButtonWithDependencies_DependencyOnRead + read + + true + + + + ButtonWithDependencies_DependencyOnWrite + write + + true + + + + ButtonWithDependencies_DependencyOnReadWithWrite + read + + true + + + + ButtonWithDependencies_DependencyOnReadWithWrite + write + + true + + + + ButtonWithDependencies_DependencyOnWriteWithRead + read + + true + + + + ButtonWithDependencies_DependencyOnWriteWithRead + write + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetDependencyValues.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetDependencyValues.xml new file mode 100644 index 00000000..19604ced --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetDependencyValues.xml @@ -0,0 +1,176 @@ + + + + + + DynamicDropDown_Box + + + + + + + + + + + + + + + DynamicDropDown_ListOfValues + + true + + + + + + MyTable_ContextMenu + write + + true + + + discreet + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyTable + array + + + + + + + + + + + + + + + + + + MyTable_Instance + read + + + + MyTable_Column1002 + read + + true + + + + MyTable_Column1003 + read + + true + + + + MyTable_Column1004 + read + + true + + + + MyTable_Column1005 + read + + true + + + + MyTable_Column1006 + read + + true + + + + MyTable_Column1007 + read + + true + + + + MyTable_Column2001 + read + + true + + + + MyTable_Column2002 + read + + true + + + + MyTable_Column2003 + read + + true + + + + MyTable_Column3001 + read + + true + + + + MyTable_Column4001 + read + + true + + + + MyTable_Column5001 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetsDependencyId.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetsDependencyId.xml new file mode 100644 index 00000000..30aee9cd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamDiscreetsDependencyId.xml @@ -0,0 +1,35 @@ + + + + + Read_RTDisplayTrue + read + + true + + + + + ReadBit_RTDisplayTrue + read bit + + true + + + + + DependencyId_ToRead_RTDisplayFalse + + + + + + + DependencyId_ToReadBit_RTDisplayFalse + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamPositions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamPositions.xml new file mode 100644 index 00000000..ce5afe9a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamPositions.xml @@ -0,0 +1,83 @@ + + + + + + + + + Standalone_OnMain_NotOnDVE + read + + true + + + Page1 + 0 + 0 + + + + + + Standalone_OnMain_OnDVE + read + + true + + + Page1 + 0 + 1 + + + + + + Standalone_NotOnMain_OnDVE + read + + false + + + Page1 + 0 + 2 + + + + + + + + Standalone_NoRTDisplay_NoValidPosition + read + + false + + + + + + + 0 + 0 + + + Page2 + + 0 + + + Page2 + 0 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamTrending.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamTrending.xml new file mode 100644 index 00000000..f13e80a0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamTrending.xml @@ -0,0 +1,59 @@ + + + + + TrendingTrue_RTDisplayTrue + read + + true + + + + + TrendingFalse_RTDisplayTrue + read + + true + + + + TrendingFalse_RTDisplayFalse + read + + false + + + + TrendingFalse_NoRTDisplay + read + + + + + + TrendingFalse_NoDisplay + read + + + + + + NoTrending_RTDisplayTrue + read + + true + + + + + NoTrending_RTDisplayFalse + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamVirtualSource.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamVirtualSource.xml new file mode 100644 index 00000000..6e65d1a7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamVirtualSource.xml @@ -0,0 +1,59 @@ + + + + + + OtherParam + + + + + + Source_NoFilter + read + + true + + + + Source_ProtocolFilter + read + + true + + + + Source_ProtocolFilter_ParamFilter + read + + true + + + + Source_ParamFilter + read + + true + + + + + + Destination_NoFilter + read + + + Destination_ProtocolFilter + read + + + Destination_ProtocolFilter_ParamFilter + read + + + Destination_ParamFilter + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamsLoadSequence.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamsLoadSequence.xml new file mode 100644 index 00000000..ccaadf9a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_ParamsLoadSequence.xml @@ -0,0 +1,27 @@ + + + + + read_1 + read + + true + + + + read_2 + read + + true + + + + read_3 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Relations.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Relations.xml new file mode 100644 index 00000000..e79cd1ca --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Relations.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + TableLevel1 + array + + + + + true + + + + TableLevel1_Instance + read + + + true + + + + + TableLevel2 + array + + + + + + true + + + + TableLevel2_Instance + read + + + true + + + + TableLevel2_FkTo1000 + read + + true + + + + + TableLevel3 + array + + + + + + true + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Spectrum.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Spectrum.xml new file mode 100644 index 00000000..01d2245c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_Spectrum.xml @@ -0,0 +1,27 @@ + + + + + + + OtherParam + + + + + TODO_CorrectName_64000 + Correct Description 64000 + + true + + + + TODO_CorrectName_64299 + Correct Description 64299 + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableColumnOptions.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableColumnOptions.xml new file mode 100644 index 00000000..5d9746b7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableColumnOptions.xml @@ -0,0 +1,173 @@ + + + + + table_RTDisplayTrue + array + + + + + + + + + + table_RTDisplayTrue_Instance + read + + + table_RTDisplayTrue_DisplayedColumn_1002 + read + + true + + + + table_RTDisplayTrue_DisplayedColumn_1002 + write + + true + + + + table_RTDisplayTrue_NonDisplayedColumn_1003 + read + + + table_RTDisplayTrue_NonDisplayedColumn_1003 + write + + + table_RTDisplayTrue_DisplayedColumn_1004 + read + + true + + + + table_RTDisplayTrue_DisplayedColumn_1004 + write + + true + + + + table_RTDisplayTrue_NonDisplayedColumn_1005 + read + + + table_RTDisplayTrue_NonDisplayedColumn_1005 + write + + + + table_ExportTrue + array + + + + + + + + + + table_ExportTrue_Instance + read + + true + + + + table_ExportTrue_DisplayedColumn_2002 + read + + true + + + + table_ExportTrue_DisplayedColumn_2002 + write + + true + + + + table_ExportTrue_NonDisplayedColumn_2003 + read + + + table_ExportTrue_NonDisplayedColumn_2003 + write + + + table_ExportTrue_DisplayedColumn_2004 + read + + true + + + + table_ExportTrue_DisplayedColumn_2004 + write + + true + + + + table_ExportTrue_NonDisplayedColumn_2005 + read + + + table_ExportTrue_NonDisplayedColumn_2005 + write + + + + table_RTDisplayFalse_ExportFalse + array + + + + + + + + table_RTDisplayFalse_ExportFalse_10001_RTDisplayFalse + read + + false + + + + table_RTDisplayFalse_ExportFalse_10002_NoRTDisplay + read + + + + + + table_RTDisplayFalse_ExportFalse_10002_NoRTDisplay + write + + + + + + table_RTDisplayFalse_ExportFalse_10003_NoDisplay + read + + + + table_RTDisplayFalse_ExportFalse_10003_NoDisplay + write + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableContextMenu.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableContextMenu.xml new file mode 100644 index 00000000..c40aa03a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableContextMenu.xml @@ -0,0 +1,58 @@ + + + + + Table1_QActionFeedback + read + + true + + + + Table1_ContextMenu + write + + numeric text + double + next param + + + true + + + discreet + + + + + + + Table1 + array + + + + + true + + + General + 0 + 0 + + + + + table + + + + Table1Instance + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableDisplayedColumns.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableDisplayedColumns.xml new file mode 100644 index 00000000..249e7e9e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableDisplayedColumns.xml @@ -0,0 +1,328 @@ + + + + + table_RTDisplayTrue + array + + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + table_RTDisplayTrue_Instance + read + + other + string + next param + + + true + + + string + + + + table_RTDisplayTrue_DisplayedColumn_1002 + read + + other + string + next param + + + true + + + string + + + + table_RTDisplayTrue_DisplayedColumn_1002 + write + + other + string + next param + + + true + + + string + + + + table_RTDisplayTrue_NonDisplayedColumn_1003 + read + + other + string + next param + + + + table_RTDisplayTrue_NonDisplayedColumn_1003 + write + + other + string + next param + + + + table_RTDisplayTrue_DisplayedColumn_1004 + read + + other + string + next param + + + true + + + string + + + + table_RTDisplayTrue_DisplayedColumn_1004 + write + + other + string + next param + + + true + + + string + + + + table_RTDisplayTrue_NonDisplayedColumn_1005 + read + + other + string + next param + + + + table_RTDisplayTrue_NonDisplayedColumn_1005 + write + + other + string + next param + + + + + table_ExportTrue + array + + + + + + + + + false + + + General + 0 + 0 + + + + + table + + + + table_ExportTrue_Instance + read + + other + string + next param + + + true + + + string + + + + table_ExportTrue_DisplayedColumn_2002 + read + + other + string + next param + + + true + + + string + + + + table_ExportTrue_DisplayedColumn_2002 + write + + other + string + next param + + + true + + + string + + + + table_ExportTrue_NonDisplayedColumn_2003 + read + + other + string + next param + + + + table_ExportTrue_NonDisplayedColumn_2003 + write + + other + string + next param + + + + table_ExportTrue_DisplayedColumn_2004 + read + + other + string + next param + + + true + + + string + + + + table_ExportTrue_DisplayedColumn_2004 + write + + other + string + next param + + + true + + + string + + + + table_ExportTrue_NonDisplayedColumn_2005 + read + + other + string + next param + + + + table_ExportTrue_NonDisplayedColumn_2005 + write + + other + string + next param + + + + + table_RTDisplayFalse_ExportFalse + array + + + + + + + false + + + table + + + + table_RTDisplayFalse_ExportFalse_10001_RTDisplayFalse + read + + false + + + + table_RTDisplayFalse_ExportFalse_10002_NoRTDisplay + read + + + + + + table_RTDisplayFalse_ExportFalse_10002_NoRTDisplay + write + + + + + + table_RTDisplayFalse_ExportFalse_10003_NoDisplay + read + + + + table_RTDisplayFalse_ExportFalse_10003_NoDisplay + write + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableViewColumns.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableViewColumns.xml new file mode 100644 index 00000000..406815ae --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TableViewColumns.xml @@ -0,0 +1,72 @@ + + + + + + Table_Syntax3 + array + + + + + + true + + + General + 0 + 0 + + + + + table + + + + Table_Instance + read + + true + + + + Table_Column2 + read + + true + + + + Table_Column2 + write + + true + + + + + + ViewTable + array + + + + + + true + + + General + 1 + 0 + + + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TrapMapAlarm.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TrapMapAlarm.xml new file mode 100644 index 00000000..ffba7372 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TrapMapAlarm.xml @@ -0,0 +1,28 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + true + + + true + * + + + + + TrapReceiver_SLScripting + Trap Received Via SLScripting + dummy + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControl.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControl.xml new file mode 100644 index 00000000..b4be27bb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControl.xml @@ -0,0 +1,58 @@ + + + + + TreeControl_ParameterId + read + + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraDetails.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraDetails.xml new file mode 100644 index 00000000..9964a118 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraDetails.xml @@ -0,0 +1,157 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Level1 + array + + + + + + true + + + + Level1_Instance + read + + + true + + + + Level1_Column2 + read + + true + + + discreet + + + + + Level1_ExtraDetails + array + + + + + + true + + + + Level1_ExtraDetails_Instance + read + + + + Level1_ExtraDetails_Column2 + read + + true + + + + + Level2 + array + + + + + + true + + + + Level2_Instance + read + + + true + + + + Level2_Column2_FkTo1000 + read + + true + + + discreet + + + + + Level2_ExtraDetails + array + + + + + + true + + + + Level2_ExtraDetails_Instance + read + + + + Level2_ExtraDetails_Column2_FkTo1000 + read + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraTabs.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraTabs.xml new file mode 100644 index 00000000..cc23df75 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlExtraTabs.xml @@ -0,0 +1,230 @@ + + + + + Read_RTDisplayTrue_1 + read + + true + + + + Read_RTDisplayTrue_2 + read + + true + + + + Read_RTDisplayTrue_3 + read + + true + + + + Read_RTDisplayTrue_4 + read + + true + + + + + TreeControl_ParameterId + read + + true + + + + + Table_Level1 + array + + + + + true + + + + Table_Level1_Instance + read + + + true + + + + + Table_Level1.1 + array + + + + + + true + + + + Table_Level1.1_Instance + read + + + Table_Level1.1_FkTo1000 + read + + true + + + + + Table_Level2 + array + + + + + + true + + + + Table_Level2_Instance + read + + + true + + + + Table_Level2_FkTo1000 + read + + true + + + + + Table_Level2.1 + array + + + + + + true + + + + Table_Level2.1_Instance + read + + + Table_Level2.1_FkTo2000 + read + + true + + + + + Table_Level3 + array + + + + + + true + + + + Table_Level3_Instance + read + + + true + + + + Table_Level3_FKto2000 + read + + true + + + + + Table_Level3.1 + array + + + + + + true + + + + Table_Level3.1_Instance + read + + + Table_Level3.1_FKto3000 + read + + true + + + + + Table_Level4 + array + + + + + + true + + + + Table_Level4_Instance + read + + + Table_Level4_FKto3000 + read + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyPath.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyPath.xml new file mode 100644 index 00000000..2af2f70a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyPath.xml @@ -0,0 +1,92 @@ + + + + + + + + + TreeControl_ParameterId + read + + true + + + + + Table_Level1 + array + + + + + true + + + + Table_Level1_Instance + read + + + true + + + + + Table_Level2 + array + + + + + + true + + + + Table_Level2_Instance + read + + + true + + + + Table_Level2_FkTo1000 + read + + true + + + + + Table_Level3 + array + + + + + + true + + + + Table_Level3_Instance + read + + + Table_Level3_FkTo2000 + read + + true + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyTable.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyTable.xml new file mode 100644 index 00000000..82379e7b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlHierarchyTable.xml @@ -0,0 +1,144 @@ + + + + + + + + + TreeControl_ParameterId + dummy + + true + + + + + Table_Level1 + array + + + + + true + + + + Table_Level1_Instance + read + + + true + + + + Table_Level1_TypeForCondition + read + + true + + + + + AAA + AAA + + + BBB + BBB + + + + + + + Table_Level2_AAA + array + + + + + + true + + + + Table_Level2_AAA_Instance + read + + + true + + + + Table_Level2_AAA_FkTo1000 + read + + true + + + + + Table_Level2_BBB + array + + + + + + true + + + + Table_Level2_BBB_Instance + read + + + + Table_Level2_BBB_FkTo1000 + read + + true + + + + + Table_Level3 + array + + + + + + true + + + + Table_Level3_Instance + read + + + Table_Level3_FkTo2000 + read + + true + + + + + + + +
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlParameterId.xml b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlParameterId.xml new file mode 100644 index 00000000..f53f016e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/RTDisplay/CheckRTDisplayTag/Samples/Validate/Valid/Valid_TreeControlParameterId.xml @@ -0,0 +1,36 @@ + + + + + TreeControl_ParameterId_1 + read + + true + + + + TreeControl_ParameterId_2 + read + + true + + + + TreeControl_ParameterId_3 + read + + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/CheckRangeTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/CheckRangeTag.cs new file mode 100644 index 00000000..9bdfc825 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/CheckRangeTag.cs @@ -0,0 +1,283 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Range.CheckRangeTag +{ + using System.Collections.Generic; + + using FluentAssertions; + using FluentAssertions.Equivalency; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Range.CheckRangeTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckRangeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckRangeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckRangeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_LowShouldBeSmallerThanHigh() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "LowShouldBeSmallerThanHigh", + ExpectedResults = new List + { + Error.LowShouldBeSmallerThanHigh(null, null, null, rangeLow: "1", rangeHigh: "1", paramId: "100"), + Error.LowShouldBeSmallerThanHigh(null, null, null, rangeLow: "1", rangeHigh: "0", paramId: "101"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "number", "2"), + Error.MissingTag(null, null, null, "analog", "4"), + Error.MissingTag(null, null, null, "progress", "5"), + Error.MissingTag(null, null, null, "number", "102"), + Error.MissingTag(null, null, null, "analog", "104"), + Error.MissingTag(null, null, null, "progress", "105"), + Error.MissingTag(null, null, null, "number", "202"), + Error.MissingTag(null, null, null, "number", "252"), + Error.MissingTag(null, null, null, "analog", "204"), + Error.MissingTag(null, null, null, "analog", "254"), + Error.MissingTag(null, null, null, "progress", "205"), + Error.MissingTag(null, null, null, "progress", "255"), + Error.MissingTag(null, null, null, "number", "1102"), + Error.MissingTag(null, null, null, "number", "1152"), + Error.MissingTag(null, null, null, "analog", "1104"), + Error.MissingTag(null, null, null, "analog", "1154"), + Error.MissingTag(null, null, null, "progress", "1105"), + Error.MissingTag(null, null, null, "progress", "1155"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_MissingTagTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTagTable", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "number", "1002"), + Error.MissingTag(null, null, null, "analog", "1004"), + Error.MissingTag(null, null, null, "progress", "1005"), + Error.MissingTag(null, null, null, "number", "1010"), + Error.MissingTag(null, null, null, "number", "1011"), + Error.MissingTag(null, null, null, "number", "1012"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_UnsupportedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedTag", + ExpectedResults = new List + { + Error.UnsupportedTag(null, null, null, "discreet", "3"), + Error.UnsupportedTag(null, null, null, "button", "6"), + Error.UnsupportedTag(null, null, null, "chart", "7"), + Error.UnsupportedTag(null, null, null, "digital threshold", "8"), + Error.UnsupportedTag(null, null, null, "togglebutton", "9"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckRangeTag_UnsupportedTagTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedTagTable", + ExpectedResults = new List + { + Error.UnsupportedTag(null, null, null, "table", "1000"), + Error.UnsupportedTag(null, null, null, "primary key", "1001"), + Error.UnsupportedTag(null, null, null, "discreet", "1003"), + Error.UnsupportedTag(null, null, null, "button", "1006"), + Error.UnsupportedTag(null, null, null, "chart", "1007"), + Error.UnsupportedTag(null, null, null, "digital threshold", "1008"), + Error.UnsupportedTag(null, null, null, "togglebutton", "1009"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckRangeTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Display/Range' in Param '2'.", + Details = "", + HowToFix = "Either add 'Range/Low' and/or 'Range/High' tag(s), either remove the empty 'Display/Range' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, ExcludePropertiesForErrorMessagesIncludingExtra); + + EquivalencyAssertionOptions ExcludePropertiesForErrorMessagesIncludingExtra(EquivalencyAssertionOptions options) + { + Generic.ExcludePropertiesForErrorMessages(options); + + options.Including(x => x.HowToFix); + + return options; + } + } + + [TestMethod] + public void Param_CheckRangeTag_LowShouldBeSmallerThanHigh() + { + // Create ErrorMessage + var message = Error.LowShouldBeSmallerThanHigh(null, null, null, "10", "1", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Range/Low '10' should be smaller than Range/High '1'. Param ID '2'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRangeTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "number", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "Missing tag 'Display/Range' in some parameters.", + Description = "Missing 'Display/Range' tag for 'number' Param with ID '2'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckRangeTag_UnsupportedTag() + { + // Create ErrorMessage + var message = Error.UnsupportedTag(null, null, null, "button", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unsupported 'Display/Range' tag for 'button' Param with ID '2'.", + Details = "For certain types of Param, a range does not make sense (ex: table param).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckRangeTag(); + + [TestMethod] + public void Param_CheckRangeTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckRangeTag_CheckId() => Generic.CheckId(root, CheckId.CheckRangeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..c689dae0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,62 @@ + + + + + ReadOnlyNumber_Empty + read + + true + + + Standalone Params + 0 + 0 + + + + + + number + + + + ReadOnlyNumber_Spaces + read + + true + + + Standalone Params + 0 + 1 + + + + + + number + + + + ReadOnlyNumber_Enters + read + + true + + + Standalone Params + 0 + 2 + + + + + + + + number + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/LowShouldBeSmallerThanHigh.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/LowShouldBeSmallerThanHigh.xml new file mode 100644 index 00000000..4e30df88 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/LowShouldBeSmallerThanHigh.xml @@ -0,0 +1,48 @@ + + + + + ReadOnlyNumber_Equal + read + + true + + + Standalone Params + 0 + 0 + + + + 1 + 1 + + + + number + + + + ReadOnlyNumber_BiggerLow + read + + true + + + Standalone Params + 0 + 0 + + + + 1 + 0 + + + + number + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..1d657703 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,1095 @@ + + + + + + ReadOnlyNumber + read + + true + + + Standalone Params + 0 + 1 + + + + + number + + + + + ReadOnlyAnalog + read + + true + + + Standalone Params + 0 + 3 + + + + + analog + + + + ReadOnlyProgress + read + + true + + + Standalone Params + 0 + 4 + + + + + progress + + + + + + + + + + + WriteOnlyNumber + write + + true + + + Standalone Params + 1 + 1 + + + + + number + + + + + WriteOnlyAnalog + write + + true + + + Standalone Params + 1 + 3 + + + + + analog + + + + WriteOnlyProgress + write + + true + + + Standalone Params + 1 + 4 + + + + + progress + + + + + + + + + ReadWriteNumber + read + + true + + + Standalone Params + 2 + 1 + + + + + number + + + + ReadWriteNumber + write + + true + + + Standalone Params + 2 + 1 + + + + + number + + + + + ReadWriteAnalog + read + + true + + + Standalone Params + 2 + 3 + + + + + analog + + + + ReadWriteAnalog + write + + true + + + Standalone Params + 2 + 3 + + + + + analog + + + + ReadWriteProgress + read + + true + + + Standalone Params + 2 + 4 + + + + + progress + + + + ReadWriteProgress + write + + true + + + Standalone Params + 2 + 4 + + + + + progress + + + + + + + + + + + + ReadWriteTable + Read Write Table + array + + + + + + + + + + + + + true + + + Tables + 0 + 1 + + + + + table + + + + ReadWriteStringColumn + read + + true + + + string + + + + ReadWriteStringColumn + write + + true + + + string + + + + ReadWriteNumberColumn + read + + true + + + number + + + + ReadWriteNumberColumn + write + + true + + + number + + + + ReadWriteDiscreetColumn + read + + true + + + discreet + + + + ReadWriteDiscreetColumn + write + + true + + + discreet + + + + ReadWriteAnalogColumn + read + + true + + + analog + + + + ReadWriteAnalogColumn + write + + true + + + analog + + + + ReadWriteProgressColumn + read + + true + + + progress + + + + ReadWriteProgressColumn + write + + true + + + progress + + + + ReadWriteButtonColumn + read + + true + + + discreet + + + + ReadWriteButtonColumn + write + + true + + + button + + + + ReadWriteChartColumn + read + + true + + + chart + + + + ReadWriteChartColumn + write + + true + + + chart + + + + ReadWriteDigitalThresholdColumn + read + + true + + + digital threshold + + + + ReadWriteDigitalThresholdColumn + write + + true + + + digital threshold + + + + ReadWriteToggleButtonColumn + read + + true + + + discreet + + + + ReadWriteToggleButtonColumn + write + + true + + + togglebutton + + + + ReadWriteDateTimeColumn + read + + true + + 0 + 1 + + + + number + + + + ReadWriteDateTimeColumn + write + + true + + 0 + 1 + + + + number + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTagTable.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTagTable.xml new file mode 100644 index 00000000..4a93a1fe --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/MissingTagTable.xml @@ -0,0 +1,157 @@ + + + + NormalTable + array + + + + + + + + + + + + + + + true + + + Page + 0 + 0 + + + + + table + + + + NormalStringColumn + read + + true + + + string + + + + NormalNumberColumn + read + + true + + + number + + + + NormalDiscreetColumn + read + + true + + + discreet + + + + NormalAnalogColumn + read + + true + + + analog + + + + NormalProgressColumn + read + + true + + + progress + + + + NormalButtonColumn + write + + true + + + button + + + + NormalChartColumn + read + + true + + + chart + + + + NormalDigitalThresholdColumn + read + + true + + + digital threshold + + + + NormalToggleButtonColumn + write + + true + + + togglebutton + + + + NormalReadWriteColumn + ReadWriteColumn + read + + true + + + number + + + + NormalReadWriteColumn + ReadWriteColumn + write + + true + + + number + + + + NormalIndexColumByOptions + NormalIndexColumByOptions + read + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTag.xml new file mode 100644 index 00000000..319215f9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTag.xml @@ -0,0 +1,299 @@ + + + + NormalStringParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + string + + + + NormalNumberParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + number + + + + NormalDiscreetParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + discreet + + + + NormalAnalogParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + analog + + + + NormalProgressParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + progress + + + + NormalButtonParam + write + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + 14 + + + button + + + + NormalChartParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + chart + + + + NormalDigitalThresholdParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + digital threshold + + + + NormalToggleButtonParam + write + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + togglebutton + + + + NormalDateTimeParameter + DateTimeParameter + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + number + + + + NormalDateTimeParameter + DateTimeParameter + write + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + number + + + + NormalReadWriteParam + NormalReadWriteParam + read + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + number + + + + NormalReadWriteParam + NormalReadWriteParam + write + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + number + + + + NormalReadParamForDependencies + NormalReadParamForDependencies + read + + true + + 0 + 1 + + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTagTable.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTagTable.xml new file mode 100644 index 00000000..3456957d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Invalid/UnsupportedTagTable.xml @@ -0,0 +1,194 @@ + + + + NormalTable + array + + + + + + + + + + + + + + + true + + + Page + 0 + 0 + + + + 0 + 1 + + + + table + + + + NormalStringColumn + read + + true + + 0 + 1 + + + + string + + + + NormalNumberColumn + read + + true + + 0 + 1 + + + + number + + + + NormalDiscreetColumn + read + + true + + 0 + 1 + + + + discreet + + + + NormalAnalogColumn + read + + true + + 0 + 1 + + + + analog + + + + NormalProgressColumn + read + + true + + 0 + 1 + + + + progress + + + + NormalButtonColumn + write + + true + + 0 + 1 + + + + button + + + + NormalChartColumn + read + + true + + 0 + 1 + + + + chart + + + + NormalDigitalThresholdColumn + read + + true + + 0 + 1 + + + + digital threshold + + + + NormalToggleButtonColumn + write + + true + + 0 + 1 + + + + togglebutton + + + + NormalReadWriteColumn + ReadWriteColumn + read + + true + + 0 + 1 + + + + number + + + + NormalIndexColumByOptions + NormalIndexColumByOptions + read + + true + + 0 + 1 + + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..29ef2f54 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/CheckRangeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,1353 @@ + + + + + + ReadOnlyString + read + + true + + + Standalone Params + 0 + 0 + + + + + string + + + + ReadOnlyNumber + read + + true + + + Standalone Params + 0 + 1 + + + + 0 + 1 + + + + number + + + + ReadOnlyDiscreet + read + + true + + + Standalone Params + 0 + 2 + + + + + discreet + + + + ReadOnlyAnalog + read + + true + + + Standalone Params + 0 + 3 + + + + 0 + 1 + + + + analog + + + + ReadOnlyProgress + read + + true + + + Standalone Params + 0 + 4 + + + + 0 + 1 + + + + progress + + + + + ReadOnlyChart + read + + true + + + Standalone Params + 0 + 7 + + + + + chart + + + + ReadOnlyDigitalThreshold + read + + true + + + Standalone Params + 0 + 8 + + + + + digital threshold + + + + + ReadOnlyDateTime + DateTime + read + + true + + + Standalone Params + 0 + 11 + + + + 0 + 1 + + + + number + + + + + + WriteOnlyString + write + + true + + + Standalone Params + 1 + 0 + + + + + string + + + + WriteOnlyNumber + write + + true + + + Standalone Params + 1 + 1 + + + + 0 + 1 + + + + number + + + + WriteOnlyDiscreet + write + + true + + + Standalone Params + 1 + 2 + + + + + discreet + + + + WriteOnlyAnalog + write + + true + + + Standalone Params + 1 + 3 + + + + 0 + 1 + + + + analog + + + + WriteOnlyProgress + write + + true + + + Standalone Params + 1 + 4 + + + + 0 + 1 + + + + progress + + + + WriteOnlyButton + write + + true + + + Standalone Params + 1 + 5 + + + + + button + + + + WriteOnlyChart + write + + true + + + Standalone Params + 1 + 6 + + + + + chart + + + + WriteOnlyDigitalThreshold + write + + true + + + Standalone Params + 1 + 7 + + + + + digital threshold + + + + WriteOnlyToggleButton + write + + true + + + Standalone Params + 1 + 8 + + + + + togglebutton + + + + WriteOnlyDateTime + DateTime + write + + true + + + Standalone Params + 1 + 9 + + + + 0 + 1 + + + + number + + + + WriteOnlyDateTimeHour + DateTimeHour + write + + true + + + Standalone Params + 1 + 9 + + + + 0 + 1 + + + + number + + + + + + ReadWriteString + read + + true + + + Standalone Params + 2 + 0 + + + + + string + + + + ReadWriteString + write + + true + + + Standalone Params + 2 + 0 + + + + + string + + + + ReadWriteNumber + read + + true + + + Standalone Params + 2 + 1 + + + + 0 + 1 + + + + number + + + + ReadWriteNumber + write + + true + + + Standalone Params + 2 + 1 + + + + 0 + 1 + + + + number + + + + ReadWriteDiscreet + read + + true + + + Standalone Params + 2 + 2 + + + + + discreet + + + + ReadWriteDiscreet + write + + true + + + Standalone Params + 2 + 2 + + + + + discreet + + + + ReadWriteAnalog + read + + true + + + Standalone Params + 2 + 3 + + + + 0 + 1 + + + + analog + + + + ReadWriteAnalog + write + + true + + + Standalone Params + 2 + 3 + + + + 0 + 1 + + + + analog + + + + ReadWriteProgress + read + + true + + + Standalone Params + 2 + 4 + + + + 0 + 1 + + + + progress + + + + ReadWriteProgress + write + + true + + + Standalone Params + 2 + 4 + + + + 0 + 1 + + + + progress + + + + ReadWriteButton + read + + true + + + Standalone Params + 2 + 5 + + + + + discreet + + + + ReadWriteButton + write + + true + + + Standalone Params + 2 + 5 + + + + + button + + + + ReadWriteChart + read + + true + + + Standalone Params + 2 + 6 + + + + + chart + + + + ReadWriteChart + write + + true + + + Standalone Params + 2 + 6 + + + + + chart + + + + ReadWriteDigitalThreshold + read + + true + + + Standalone Params + 2 + 7 + + + + + digital threshold + + + + ReadWriteDigitalThreshold + write + + true + + + Standalone Params + 2 + 7 + + + + + digital threshold + + + + ReadWriteToggleButton + read + + true + + + Standalone Params + 2 + 8 + + + + + discreet + + + + ReadWriteToggleButton + write + + true + + + Standalone Params + 2 + 8 + + + + + togglebutton + + + + ReadWriteDateTime + DateTime + read + + true + + + Standalone Params + 2 + 9 + + + + 0 + 1 + + + + number + + + + ReadWriteDateTime + DateTime + write + + true + + + Standalone Params + 2 + 9 + + + + 0 + 1 + + + + number + + + + + + ReadOnlyNotDisplayedString + read + + string + + + + ReadOnlyNotDisplayedNumber + read + + number + + + + ReadOnlyNotDisplayedDiscreet + read + + discreet + + + + ReadOnlyNotDisplayedAnalog + read + + analog + + + + ReadOnlyNotDisplayedProgress + read + + progress + + + + + ReadOnlyNotDisplayedChart + read + + chart + + + + ReadOnlyNotDisplayedDigitalThreshold + read + + digital threshold + + + + + ReadOnlyNotDisplayedDateTime + DateTime + read + + number + + + + + + ReadOnlyTable + Read Only Table + array + + + + + + + + + + + + true + + + Tables + 0 + 0 + + + + + table + + + + ReadOnlyStringColumn + read + + true + + + string + + + + ReadOnlyNumberColumn + read + + true + + 0 + 1 + + + + number + + + + ReadOnlyDiscreetColumn + read + + true + + + discreet + + + + ReadOnlyAnalogColumn + read + + true + + 0 + 1 + + + + analog + + + + ReadOnlyProgressColumn + read + + true + + 0 + 1 + + + + progress + + + + + ReadOnlyChartColumn + read + + true + + + chart + + + + ReadOnlyDigitalThresholdColumn + read + + true + + + digital threshold + + + + + ReadOnlyDateTimeColumn + read + + true + + 0 + 1 + + + + number + + + + + + ReadWriteTable + Read Write Table + array + + + + + + + + + + + + + true + + + Tables + 0 + 1 + + + + + table + + + + ReadWriteStringColumn + read + + true + + + string + + + + ReadWriteStringColumn + write + + true + + + string + + + + ReadWriteNumberColumn + read + + true + + 0 + 1 + + + + number + + + + ReadWriteNumberColumn + write + + true + + 0 + 1 + + + + number + + + + ReadWriteDiscreetColumn + read + + true + + + discreet + + + + ReadWriteDiscreetColumn + write + + true + + + discreet + + + + ReadWriteAnalogColumn + read + + true + + 0 + 1 + + + + analog + + + + ReadWriteAnalogColumn + write + + true + + 0 + 1 + + + + analog + + + + ReadWriteProgressColumn + read + + true + + 0 + 1 + + + + progress + + + + ReadWriteProgressColumn + write + + true + + 0 + 1 + + + + progress + + + + ReadWriteButtonColumn + read + + true + + + discreet + + + + ReadWriteButtonColumn + write + + true + + + button + + + + ReadWriteChartColumn + read + + true + + + chart + + + + ReadWriteChartColumn + write + + true + + + chart + + + + ReadWriteDigitalThresholdColumn + read + + true + + + digital threshold + + + + ReadWriteDigitalThresholdColumn + write + + true + + + digital threshold + + + + ReadWriteToggleButtonColumn + read + + true + + + discreet + + + + ReadWriteToggleButtonColumn + write + + true + + + togglebutton + + + + ReadWriteDateTimeColumn + read + + true + + 0 + 1 + + + + number + + + + ReadWriteDateTimeColumn + write + + true + + 0 + 1 + + + + number + + + + + + ReadOnlyNotDisplayedTable + Read Only Not Displayed Table + array + + + + + + + + + + + + table + + + + ReadOnlyNotDisplayedStringColumn + read + + string + + + + ReadOnlyNotDisplayedNumberColumn + read + + number + + + + ReadOnlyNotDisplayedDiscreetColumn + read + + discreet + + + + ReadOnlyNotDisplayedAnalogColumn + read + + analog + + + + ReadOnlyNotDisplayedProgressColumn + read + + progress + + + + + ReadOnlyNotDisplayedChartColumn + read + + chart + + + + ReadOnlyNotDisplayedDigitalThresholdColumn + read + + digital threshold + + + + + ReadOnlyNotDisplayedDateTimeColumn + read + + number + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/CheckHighTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/CheckHighTag.cs new file mode 100644 index 00000000..f6507bd5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/CheckHighTag.cs @@ -0,0 +1,307 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Range.High.CheckHighTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Range.High.CheckHighTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckHighTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckHighTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckHighTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckHighTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "abc", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckHighTag_LogarithmicLowerOrEqualToZero() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "LogarithmicLowerOrEqualToZero", + ExpectedResults = new List + { + Error.LogarithmicLowerOrEqualToZero(null, null, null, "0", "1"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "-1", "2"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "-10.5", "3"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "", "4"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckHighTag_UntrimmedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedValue", + ExpectedResults = new List + { + Error.UntrimmedValue(null, null, null, "1", " 18"), + Error.UntrimmedValue(null, null, null, "2", "18 "), + Error.UntrimmedValue(null, null, null, "3", " 18 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckHighTag_WriteDifferentThanRead() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WriteDifferentThanRead", + ExpectedResults = new List + { + Error.WriteDifferentThanRead(null, null, null, "9", "8", "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckHighTag(); + + [TestMethod] + public void Param_CheckHighTag_UntrimmedValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedValue", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare check = new CheckHighTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckHighTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckHighTag_UpdatedHighRange() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedHighRange", + ExpectedResults = new List + { + ErrorCompare.UpdatedHighRange(null, null, "100", "1", "80"), + } + }; + + Generic.Compare(check, data); + } + + [TestMethod] + public void Param_CheckHighTag_AddedHighRange() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedHighRange", + ExpectedResults = new List + { + ErrorCompare.AddedHighRange(null, null, "100", "1"), + ErrorCompare.AddedHighRange(null, null, "100", "2"), + } + }; + + Generic.Compare(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckHighTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + Severity = Severity.Minor, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Range/High' in Param '2'.", + Details = "If present, the 'Range/High' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be bigger than the one in the 'Range/Low' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckHighTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Minor, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '1' in tag 'Range/High'. Param ID '2'.", + Details = "If present, the 'Range/High' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be bigger than the one in the 'Range/Low' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckHighTag_UntrimmedValue() + { + // Create ErrorMessage + var message = Error.UntrimmedValue(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Range/High' in Param '1'. Current value '2'.", + Details = "If present, the 'Range/High' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be bigger than the one in the 'Range/Low' tag.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckHighTag_LogarithmicLowerOrEqualToZero() + { + // Create ErrorMessage + var message = Error.LogarithmicLowerOrEqualToZero(null, null, null, "rangeHigh", "paramId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Range/High 'rangeHigh' should be bigger than zero due to Trending@logarithmic 'true'. Param ID 'paramId'.", + Details = "When Trending@logarithmic is set to 'true', both 'Range/Low' and 'Range/High' should be bigger than 0.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckHighTag(); + + [TestMethod] + public void Param_CheckHighTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckHighTag_CheckId() => Generic.CheckId(root, CheckId.CheckHighTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Codefix/UntrimmedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Codefix/UntrimmedValue.xml new file mode 100644 index 00000000..fa2062ac --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Codefix/UntrimmedValue.xml @@ -0,0 +1,30 @@ + + + + + Leading + + + 18 + + + + + Trailing + + + 18 + + + + + LeadingAndTrailing + + + 18 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_New.xml new file mode 100644 index 00000000..517d0717 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_New.xml @@ -0,0 +1,20 @@ + + + + + true + + 100 + + + + + + true + + 100 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_Old.xml new file mode 100644 index 00000000..5eb8c27c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/AddedHighRange_Old.xml @@ -0,0 +1,16 @@ + + + + + true + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_New.xml new file mode 100644 index 00000000..b2dd5dca --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_New.xml @@ -0,0 +1,12 @@ + + + + + true + + 80 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_Old.xml new file mode 100644 index 00000000..e955d655 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Invalid/UpdatedHighRange_Old.xml @@ -0,0 +1,12 @@ + + + + + true + + 100 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..ec174074 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,106 @@ + + + + + + + 100 + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + false + + 10 + + + + + + false + + 10 + + + + + + + + false + + 10 + + + + + + + 10 + + + + + + + + true + + 10 + + + + + + true + + 10 + + + + + + + + true + + 10 + + + + + + true + + 10 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..7a6a8989 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,106 @@ + + + + + + + 100 + + + + + + + + + 100 + + + + + + + 100 + + + + + + + 100 + + + + + + + + + 10 + + + + + + + + false + + + + + + + false + + + + + + + false + + 100 + + + + + + + 100 + + + + + + + + false + + + + + + + false + + + + + + + false + + 100 + + + + + + + 100 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..19729b02 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,32 @@ + + + + + Empty + + + + + + + + Spaces + + + + + + + + Enters + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..2f3c10df --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + Invalid_String + + + abc + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml new file mode 100644 index 00000000..21a0ad11 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml @@ -0,0 +1,41 @@ + + + + + Zero + + + + 0 + + + + + NegativeInteger + + + + -1 + + + + + NegativeDouble + + + + -10.5 + + + + + MissingHigh + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/UntrimmedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/UntrimmedValue.xml new file mode 100644 index 00000000..b5752cf5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/UntrimmedValue.xml @@ -0,0 +1,30 @@ + + + + + Leading + + + 18 + + + + + Trailing + + + 18 + + + + + LeadingAndTrailing + + + 18 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml new file mode 100644 index 00000000..68c329e2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml @@ -0,0 +1,24 @@ + + + + + ReadWrite_DifferentHigh + read + + + 8 + + + + + ReadWrite_DifferentHigh + write + + + 9 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b5a66835 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/High/CheckHighTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,54 @@ + + + + + ReadOnly + read + + + 1 + + + + + + WriteOnly + write + + + 1 + + + + + + ReadWrite + read + + + 1 + + + + + ReadWrite + write + + + 1 + + + + + ReadOnly_Logarithmic + read + + + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/CheckLowTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/CheckLowTag.cs new file mode 100644 index 00000000..9b812d45 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/CheckLowTag.cs @@ -0,0 +1,307 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Range.Low.CheckLowTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Range.Low.CheckLowTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckLowTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLowTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLowTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckLowTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "abc", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckLowTag_LogarithmicLowerOrEqualToZero() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "LogarithmicLowerOrEqualToZero", + ExpectedResults = new List + { + Error.LogarithmicLowerOrEqualToZero(null, null, null, "0", "1"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "-1", "2"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "-10.5", "3"), + Error.LogarithmicLowerOrEqualToZero(null, null, null, "", "4"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckLowTag_UntrimmedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedValue", + ExpectedResults = new List + { + Error.UntrimmedValue(null, null, null, "1", " 18"), + Error.UntrimmedValue(null, null, null, "2", "18 "), + Error.UntrimmedValue(null, null, null, "3", " 18 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckLowTag_WriteDifferentThanRead() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WriteDifferentThanRead", + ExpectedResults = new List + { + Error.WriteDifferentThanRead(null, null, null, "9", "8", "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckLowTag(); + + [TestMethod] + public void Param_CheckLowTag_UntrimmedValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedValue", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckLowTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLowTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLowTag_UpdatedLowRange() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedLowRange", + ExpectedResults = new List + { + ErrorCompare.UpdatedLowRange(null, null, "60", "1", "80"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckLowTag_AddedLowRange() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedLowRange", + ExpectedResults = new List + { + ErrorCompare.AddedLowRange(null, null, "10", "1"), + ErrorCompare.AddedLowRange(null, null, "10", "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckLowTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + Severity = Severity.Minor, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Range/Low' in Param '2'.", + Details = "If present, the 'Range/Low' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be smaller than the one in the 'Range/High' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLowTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Minor, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '1' in tag 'Range/Low'. Param ID '2'.", + Details = "If present, the 'Range/Low' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be smaller than the one in the 'Range/High' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLowTag_UntrimmedValue() + { + // Create ErrorMessage + var message = Error.UntrimmedValue(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Range/Low' in Param '1'. Current value '2'.", + Details = "If present, the 'Range/Low' tag should be filled in with a numerical value." + Environment.NewLine + "Its value should be smaller than the one in the 'Range/High' tag.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLowTag_LogarithmicLowerOrEqualToZero() + { + // Create ErrorMessage + var message = Error.LogarithmicLowerOrEqualToZero(null, null, null, "rangeLow", "paramId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Range/Low 'rangeLow' should be bigger than zero due to Trending@logarithmic 'true'. Param ID 'paramId'.", + Details = "When Trending@logarithmic is set to 'true', both 'Range/Low' and 'Range/High' should be bigger than 0.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckLowTag(); + + [TestMethod] + public void Param_CheckLowTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckLowTag_CheckId() => Generic.CheckId(root, CheckId.CheckLowTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Codefix/UntrimmedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Codefix/UntrimmedValue.xml new file mode 100644 index 00000000..2d430867 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Codefix/UntrimmedValue.xml @@ -0,0 +1,30 @@ + + + + + Leading + + + 18 + + + + + Trailing + + + 18 + + + + + LeadingAndTrailing + + + 18 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_New.xml new file mode 100644 index 00000000..aad4ad90 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_New.xml @@ -0,0 +1,20 @@ + + + + + true + + 10 + + + + + + true + + 10 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_Old.xml new file mode 100644 index 00000000..5eb8c27c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/AddedLowRange_Old.xml @@ -0,0 +1,16 @@ + + + + + true + + + + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_New.xml new file mode 100644 index 00000000..e7768488 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_New.xml @@ -0,0 +1,12 @@ + + + + + true + + 80 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_Old.xml new file mode 100644 index 00000000..d4bdacd2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Invalid/UpdatedLowRange_Old.xml @@ -0,0 +1,12 @@ + + + + + true + + 60 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..59b17e28 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,106 @@ + + + + + + + 100 + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + false + + 100 + + + + + + false + + 100 + + + + + + + + false + + 10 + + + + + + + 10 + + + + + + + + false + + 100 + + + + + + false + + 100 + + + + + + + + true + + 1000 + + + + + + true + + 1000 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..1309a0ad --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,106 @@ + + + + + + + 100 + + + + + + + + + 100 + + + + + + + 100 + + + + + + + 100 + + + + + + + + + 100 + + + + + + + + false + + + + + + + false + + + + + + + false + + 100 + + + + + + + 100 + + + + + + + + false + + + + + + + false + + + + + + + false + + 100 + + + + + + + 100 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..7855b1b7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,32 @@ + + + + + Empty + + + + + + + + Spaces + + + + + + + + Enters + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..4c8196b0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + Invalid_String + + + abc + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml new file mode 100644 index 00000000..8c54e7e5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/LogarithmicLowerOrEqualToZero.xml @@ -0,0 +1,41 @@ + + + + + Zero + + + + 0 + + + + + NegativeInteger + + + + -1 + + + + + NegativeDouble + + + + -10.5 + + + + + MissingLow + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/UntrimmedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/UntrimmedValue.xml new file mode 100644 index 00000000..55147882 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/UntrimmedValue.xml @@ -0,0 +1,30 @@ + + + + + Leading + + + 18 + + + + + Trailing + + + 18 + + + + + LeadingAndTrailing + + + 18 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml new file mode 100644 index 00000000..eb28804d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Invalid/WriteDifferentThanRead.xml @@ -0,0 +1,24 @@ + + + + + ReadWrite_DifferentLow + read + + + 8 + + + + + ReadWrite_DifferentLow + write + + + 9 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..1b158dfb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Range/Low/CheckLowTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,54 @@ + + + + + ReadOnly + read + + + 1 + + + + + + WriteOnly + write + + + 1 + + + + + + ReadWrite + read + + + 1 + + + + + ReadWrite + write + + + 1 + + + + + ReadOnly_Logarithmic + read + + + + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..e7a3e261 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Trending.Type.CheckTypeTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Trending.Type.CheckTypeTag; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTypeTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTypeTag_UpdatedTrendType() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedTrendType", + ExpectedResults = new List + { + ErrorCompare.UpdatedTrendType(null, null, "Average", "1", "Max"), + ErrorCompare.UpdatedTrendType(null, null, "Average", "2", "Min"), + ErrorCompare.UpdatedTrendType(null, null, "Average", "3", "Sum"), + ErrorCompare.UpdatedTrendType(null, null, "Sum", "4", "Average"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckTypeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_New.xml new file mode 100644 index 00000000..a0e8dc04 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_New.xml @@ -0,0 +1,27 @@ + + + + + + max + + + + + + + min + + + + + + + sum + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_Old.xml new file mode 100644 index 00000000..a5900078 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedTrendType_Old.xml @@ -0,0 +1,28 @@ + + + + + + average + + + + + + + + + + + + + + + + + sum + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..df3b6b1b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,18 @@ + + + + + + average + + + + + + + average + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..7d7249f5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Trending/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,15 @@ + + + + + + average + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/CheckUnitsTag.cs b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/CheckUnitsTag.cs new file mode 100644 index 00000000..04ebafbc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/CheckUnitsTag.cs @@ -0,0 +1,214 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Display.Units.CheckUnitsTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Display.Units.CheckUnitsTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckUnitsTag(); + + [TestMethod] + public void Param_CheckUnitsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_InvalidTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTag", + ExpectedResults = new List + { + Error.InvalidTag(null, null, null, "aaf", "1"), + Error.InvalidTag(null, null, null, "bbx", "2"), + Error.InvalidTag(null, null, null, "bbx", "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_OutdatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "OutdatedValue", + ExpectedResults = new List + { + Error.OutdatedValue(null, null, null, "am/yr", "am/Year", "2"), + Error.OutdatedValue(null, null, null, "am/yr", "am/Year", "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_UnsupportedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedTag", + ExpectedResults = new List + { + Error.UnsupportedTag(null, null, null, "button", "1"), + Error.UnsupportedTag(null, null, null, "chart", "2"), + Error.UnsupportedTag(null, null, null, "digital threshold", "3"), + Error.UnsupportedTag(null, null, null, "discreet", "4"), + Error.UnsupportedTag(null, null, null, "matrix", "5"), + Error.UnsupportedTag(null, null, null, "pagebutton", "6"), + Error.UnsupportedTag(null, null, null, "string", "8"), + Error.UnsupportedTag(null, null, null, "table", "9"), + Error.UnsupportedTag(null, null, null, "title", "10"), + Error.UnsupportedTag(null, null, null, "togglebutton", "11"), + Error.UnsupportedTag(null, null, null, "table", "1000"), + Error.UnsupportedTag(null, null, null, "togglebutton", "1002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_ExcessiveTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveTag", + ExpectedResults = new List + { + Error.ExcessiveTag(null, null, null, "Units", "missing Measurement tag", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "number", "2"), + Error.MissingTag(null, null, null, "analog", "4"), + Error.MissingTag(null, null, null, "progress", "5"), + Error.MissingTag(null, null, null, "number", "102"), + Error.MissingTag(null, null, null, "analog", "104"), + Error.MissingTag(null, null, null, "progress", "105"), + Error.MissingTag(null, null, null, "number", "202"), + Error.MissingTag(null, null, null, "number", "252"), + Error.MissingTag(null, null, null, "analog", "204"), + Error.MissingTag(null, null, null, "analog", "254"), + Error.MissingTag(null, null, null, "progress", "205"), + Error.MissingTag(null, null, null, "progress", "255"), + Error.MissingTag(null, null, null, "number", "1002"), + Error.MissingTag(null, null, null, "analog", "1003"), + Error.MissingTag(null, null, null, "progress", "1004"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " %"), + Error.UntrimmedTag(null, null, null, "2", "% "), + Error.UntrimmedTag(null, null, null, "3", " % "), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckUnitsTag(); + + [TestMethod] + public void Param_CheckUnitsTag_OutdatedValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "OutdatedValue", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckUnitsTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckUnitsTag(); + + [TestMethod] + public void Param_CheckUnitsTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckUnitsTag_CheckId() => Generic.CheckId(root, CheckId.CheckUnitsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/OutdatedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/OutdatedValue.xml new file mode 100644 index 00000000..5ec230b8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/OutdatedValue.xml @@ -0,0 +1,22 @@ + + + + + true + am/Year + + + number + + + + + true + am/Year + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..92f8f15e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,31 @@ + + + + + true + % + + + number + + + + + true + % + + + number + + + + + true + % + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..cfc41a78 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,22 @@ + + + + + true + + + + number + + + + + true + + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/ExcessiveTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/ExcessiveTag.xml new file mode 100644 index 00000000..ad6b8985 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/ExcessiveTag.xml @@ -0,0 +1,9 @@ + + + + + dB + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/InvalidTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/InvalidTag.xml new file mode 100644 index 00000000..e205d092 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/InvalidTag.xml @@ -0,0 +1,31 @@ + + + + + true + aaf + + + number + + + + + true + bbx + + + number + + + + + true + bbx + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..d2202aa1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,279 @@ + + + + + ReadOnlyNumber + read + + true + + + Standalone Params + 0 + 2 + + + + + number + + + + ReadOnlyAnalog + read + + true + + + Standalone Params + 0 + 4 + + + + + analog + + + + ReadOnlyProgress + read + + true + + + Standalone Params + 0 + 5 + + + + + progress + + + + + + WriteOnlyNumber + write + + true + + + Standalone Params + 1 + 2 + + + + + number + + + + WriteOnlyAnalog + write + + true + + + Standalone Params + 1 + 4 + + + + + analog + + + + WriteOnlyProgress + write + + true + + + Standalone Params + 1 + 5 + + + + + progress + + + + + + ReadWriteNumber + read + + true + + + Standalone Params + 2 + 2 + + + + + number + + + + ReadWriteNumber + write + + true + + + Standalone Params + 2 + 2 + + + + + number + + + + ReadWriteAnalog + read + + true + + + Standalone Params + 2 + 4 + + + + + analog + + + + ReadWriteAnalog + write + + true + + + Standalone Params + 2 + 4 + + + + + analog + + + + ReadWriteProgress + read + + true + + + Standalone Params + 2 + 5 + + + + + progress + + + + ReadWriteProgress + write + + true + + + Standalone Params + 2 + 5 + + + + + progress + + + + + + ReadOnlyTable + Read Only Table + array + + + + + + + + true + + + Tables + 0 + 0 + + + + + table + + + + ReadOnlyStringColumn + read + + true + + + number + + + + ReadOnlyNumberColumn + read + + true + + + number + + + + ReadOnlyAnalogColumn + read + + true + + + analog + + + + ReadOnlyProgressColumn + read + + true + + + progress + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/OutdatedValue.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/OutdatedValue.xml new file mode 100644 index 00000000..f01fb69c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/OutdatedValue.xml @@ -0,0 +1,22 @@ + + + + + true + am/yr + + + number + + + + + true + am/yr + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UnsupportedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UnsupportedTag.xml new file mode 100644 index 00000000..be8318f9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UnsupportedTag.xml @@ -0,0 +1,152 @@ + + + + + + false + dB + + + button + + + + + false + dB + + + chart + + + + + false + dB + + + digital threshold + + + + + false + dB + + + discreet + + + + + false + dB + + + matrix + + + + + false + dB + + + pagebutton + + + + + false + dB + + + progress + + + + + false + dB + + + string + + + + + false + dB + + + table + + + + + false + dB + + + title + + + + + false + dB + + + togglebutton + + + + + table + array + + + + + + true + A + + + table + + + + tablePrimaryKey + read + + other + next param + string + + + true + A + + + number + + + + tableToggleButton + read + + other + next param + string + + + true + A + + + togglebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..cded2304 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,31 @@ + + + + + true + % + + + number + + + + + true + % + + + number + + + + + true + % + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..ca9ac800 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Display/Units/CheckUnitsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,533 @@ + + + + + RTDisplayNumber + + true + % + + + number + + + + RTDisplayAnalog + + true + kSamples/min + + + analog + + + + RTDisplayProgress + + true + % + + + progress + + + + + + RTDisplayButton + + true + + + button + + + + RTDisplayChart + + true + + + chart + + + + RTDisplayDigitalThreshold + + true + + + digital threshold + + + + RTDisplayDiscreet + + true + + + discreet + + + + RTDisplayMatrix + + true + + + matrix + + + + RTDisplayPageButton + + true + + + pagebutton + + + + RTDisplayString + + true + + + string + + + + RTDisplayTable + + true + + + table + + + + RTDisplayTitle + + true + + + title + + + + RTDisplayToggleButton + + true + + + togglebutton + + + + RTDisplayDateTime + read + + true + + + Standalone Params + 0 + 11 + + + + + number + + + + RTDisplayTime + read + + true + + + Standalone Params + 0 + 11 + + + + + number + + + + + + NonRTDisplayNumber + + + + number + + + + NonRTDisplayAnalog + + + + analog + + + + NonRTDisplayProgress + + + + progress + + + + NonRTDisplayButton + + + + button + + + + NonRTDisplayChart + + + + chart + + + + NonRTDisplayDigitalThreshold + + + + digital threshold + + + + NonRTDisplayDiscreet + + + + discreet + + + + NonRTDisplayMatrix + + + + matrix + + + + NonRTDisplayPageButton + + + + pagebutton + + + + NonRTDisplayString + + + + string + + + + NonRTDisplayTable + + + + table + + + + NonRTDisplayTitle + + + + title + + + + NonRTDisplayToggleButton + + + + togglebutton + + + + NonRTDisplayDateTime + + + + number + + + + NonRTDisplayToggleTime + + + + number + + + + + + RTDisplayFalseNumber + + false + + + number + + + + RTDisplayFalseAnalog + + false + + + analog + + + + RTDisplayFalseProgress + + false + + + progress + + + + RTDisplayFalseButton + + false + + + button + + + + RTDisplayFalseChart + + false + + + chart + + + + RTDisplayFalseDigitalThreshold + + false + + + digital threshold + + + + RTDisplayFalseDiscreet + + false + + + discreet + + + + RTDisplayFalseMatrix + + false + + + matrix + + + + RTDisplayFalsePageButton + + false + + + pagebutton + + + + RTDisplayFalseString + + false + + + string + + + + RTDisplayFalseTable + + false + + + table + + + + RTDisplayFalseTitle + + false + + + title + + + + RTDisplayFalseToggleButton + + false + + + togglebutton + + + + RTDisplayFalseDateTime + + false + + + number + + + + RTDisplayFalseTime + + false + + + number + + + + + + ReadOnlyTable + Read Only Table + array + + + + + + + + + + + + true + + + Tables + 0 + 0 + + + + + table + + + + ReadOnlyPrimaryKeyColumn + read + + true + + + number + + + + ReadOnlyNumberColumn + read + + true + % + + + number + + + + ReadOnlyDiscreetColumn + read + + true + + + discreet + + + + ReadOnlyAnalogColumn + read + + true + % + + + analog + + + + ReadOnlyProgressColumn + read + + true + % + + + progress + + + + ReadOnlyChartColumn + read + + true + + + chart + + + + ReadOnlyDigitalThresholdColumn + read + + true + + + digital threshold + + + + ReadOnlyDateTimeColumn + read + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/CheckIncludesTag.cs b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/CheckIncludesTag.cs new file mode 100644 index 00000000..b3cbc28a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/CheckIncludesTag.cs @@ -0,0 +1,116 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Information.Includes.CheckIncludesTag +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Information.Includes.CheckIncludesTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIncludesTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIncludesTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIncludesTag_ObsoleteTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ObsoleteTag", + ExpectedResults = new List + { + Error.ObsoleteTag(null, null, null, "1"), + Error.ObsoleteTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIncludesTag(); + + [TestMethod] + public void Param_CheckIncludesTag_ObsoleteTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ObsoleteTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckIncludesTag_ObsoleteTag() + { + // Create ErrorMessage + var message = Error.ObsoleteTag(null, null, null, "pid"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.66.1", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Obsolete tag 'Information/Includes'. Param ID 'pid'.", + HowToFix = "", + ExampleCode = "", + Details = "'Information/Includes' tag was only used in the past by SystemDisplay. Today, it is considered obsolete.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIncludesTag(); + + [TestMethod] + public void Param_CheckIncludesTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckIncludesTag_CheckId() => Generic.CheckId(check, CheckId.CheckIncludesTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Codefix/ObsoleteTag.xml b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Codefix/ObsoleteTag.xml new file mode 100644 index 00000000..1da2b884 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Codefix/ObsoleteTag.xml @@ -0,0 +1,16 @@ + + + + + Empty Includes + + + + + Fully Filled Includes + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Invalid/ObsoleteTag.xml b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Invalid/ObsoleteTag.xml new file mode 100644 index 00000000..d331bc2e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Invalid/ObsoleteTag.xml @@ -0,0 +1,24 @@ + + + + + Empty Includes + + + + + + + Fully Filled Includes + + + range + steps + time + units + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..91932100 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Includes/CheckIncludesTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,12 @@ + + + + + With Subtext only + + This is my subtext. + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/CheckSubtextTag.cs b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/CheckSubtextTag.cs new file mode 100644 index 00000000..4c907b11 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/CheckSubtextTag.cs @@ -0,0 +1,120 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Information.Subtext.CheckSubtextTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Information.Subtext.CheckSubtextTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckSubtextTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckSubtextTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckSubtextTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "6"), + Error.EmptyTag(null, null, null, "8"), + Error.EmptyTag(null, null, null, "1000"), + Error.EmptyTag(null, null, null, "1001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckSubtextTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + Error.MissingTag(null, null, null, "101"), + Error.MissingTag(null, null, null, "102"), + Error.MissingTag(null, null, null, "103"), + Error.MissingTag(null, null, null, "104"), + Error.MissingTag(null, null, null, "105"), + + Error.MissingTag(null, null, null, "200"), + Error.MissingTag(null, null, null, "201"), + + Error.MissingTag(null, null, null, "300"), + Error.MissingTag(null, null, null, "301"), + + Error.MissingTag(null, null, null, "600"), + + Error.MissingTag(null, null, null, "1000"), + Error.MissingTag(null, null, null, "1001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckSubtextTag_WhiteSpacesTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WhiteSpacesTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "6"), + Error.EmptyTag(null, null, null, "8"), + Error.EmptyTag(null, null, null, "1000"), + Error.EmptyTag(null, null, null, "1001"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckSubtextTag(); + + [TestMethod] + public void Param_CheckSubtextTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckSubtextTag_CheckId() => Generic.CheckId(root, CheckId.CheckSubtextTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..575aa89a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + true + + + TestPage + 0 + 0 + + + + + + + + + write + + true + + + TestPage + 0 + 0 + + + + + button + + + + + + + read + + true + + + Page + 10 + 1 + + + + + + + + + + true + + + TestPage + 0 + 0 + + + + + + tableName + tableDescription + array + + + + + + + + true + + + Page + 0 + 0 + + + + + table + + + + tableNameInstance + Instance (tableDescription) + + + + read + + other + next param + string + + + true + + + string + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..3210a366 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,287 @@ + + + + + PositionedReadOnly_NoSubText + + + + true + + + TestPage + 0 + 0 + + + + + + PositionedReadOnly_NoInformation + + true + + + TestPage + 0 + 0 + + + + + + PositionedReadOnly_String_NoSubText + + + + true + + + TestPage + 0 + 0 + + + + + string + + + + PositionedReadOnly_String_NoInformation + + true + + + TestPage + 0 + 0 + + + + + string + + + + PositionedReadOnly_Number_NoSubText + + + + true + + + TestPage + 0 + 0 + + + + + number + + + + PositionedReadOnly_Number_NoInformation + + true + + + TestPage + 0 + 0 + + + + + number + + + + + PositionedWriteOnly_Button_NoSubText + write + + + true + + + TestPage + 0 + 0 + + + + + button + + + + PositionedWriteOnly_Button_NoInformation + write + + true + + + TestPage + 0 + 0 + + + + + button + + + + + PositionedReadWrite_NoSubText + read + + + + true + + + TestPage + 0 + 0 + + + + + + PositionedReadWrite_NoSubText + write + + true + + + TestPage + 0 + 0 + + + + + + PositionedReadWrite_NoInformation + read + + true + + + TestPage + 0 + 0 + + + + + + PositionedReadWrite_NoInformation + write + + true + + + TestPage + 0 + 0 + + + + + + + PositionedTreeControl + read + + true + + + Page + 10 + 1 + + + + + + + PositionedDynamicDropdown + read + + true + + + TestPage + 0 + 0 + + + + + discreet + + + + + PositionedDynamicDropdown_List + read + + true + + + string + + + + + table1 + Table 1 + array + + + + + + + true + + + Page + 0 + 0 + + + + + table + + + + table1_Instance + Instance (Table 1) + + + read + + other + next param + string + + + true + + + string + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/WhiteSpacesTag.xml b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/WhiteSpacesTag.xml new file mode 100644 index 00000000..a295908b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Invalid/WhiteSpacesTag.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + true + + + TestPage + 0 + 0 + + + + + + + + + write + + true + + + TestPage + 0 + 0 + + + + + button + + + + + + + read + + true + + + Page + 10 + 1 + + + + + + + + + read + + true + + + Page + 11 + 1 + + + + + + tableName + tableDescription + array + + + + + + + + true + + + Page + 0 + 0 + + + + + table + + + + tableNameInstance + Instance (tableDescription) + + + + read + + other + next param + string + + + true + + + string + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e27cba1e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Information/Subtext/CheckSubtextTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,183 @@ + + + + + + + + This is a valid Text. + + + true + + + TestPage + 0 + 0 + + + + + + + + + + true + + + TestPage + 0 + 0 + + + + + + + + + + true + + + TestPage + 0 + 0 + + + + + + + + + Title_Begin_Title + Title + fixed + + true + + + title + + + + ButtonParam + + + This is the button that will refresh something? + + time + range + steps + units + + + write + + numeric text + next param + double + + + true + + + Page + 0 + 0 + + + + + button + + + Refresh + 1 + + + + + + + Valid Subtext! + + read + + true + + + Page + 10 + 1 + + + + + + tableName + tableDescription + array + + + + + tableInformation + + + true + + + Page + 0 + 0 + + + + + table + + + + tableNameInstance + Instance (tableDescription) + + This is the key used internally by DataMiner to identify the table entries. + + read + + other + next param + string + + + true + + + string + + + + + This is a valid Text. + + read bit + + true + + + TestPage + 0 + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/CheckDefaultValueTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/CheckDefaultValueTag.cs new file mode 100644 index 00000000..3a1af370 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/CheckDefaultValueTag.cs @@ -0,0 +1,199 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.DefaultValue.CheckDefaultValueTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.DefaultValue.CheckDefaultValueTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDefaultValueTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDefaultValueTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDefaultValueTag_NotYetSupportedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NotYetSupportedTag", + ExpectedResults = new List + { + // Table Syntax 1 (not yet supported by the TryGetTable helper) + Error.NotYetSupportedTag(null, null, null, "1002"), + Error.NotYetSupportedTag(null, null, null, "1003"), + + // Table Syntax 2 + Error.NotYetSupportedTag(null, null, null, "1102"), + Error.NotYetSupportedTag(null, null, null, "1103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDefaultValueTag_UnsupportedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedTag", + ExpectedResults = new List + { + // Various Param Types + Error.UnsupportedTag(null, null, null, "1"), + Error.UnsupportedTag(null, null, null, "2"), + Error.UnsupportedTag(null, null, null, "3"), + Error.UnsupportedTag(null, null, null, "4"), + Error.UnsupportedTag(null, null, null, "5"), + Error.UnsupportedTag(null, null, null, "6"), + Error.UnsupportedTag(null, null, null, "7"), + Error.UnsupportedTag(null, null, null, "8"), + Error.UnsupportedTag(null, null, null, "9"), + Error.UnsupportedTag(null, null, null, "10"), + Error.UnsupportedTag(null, null, null, "11"), + Error.UnsupportedTag(null, null, null, "12"), + Error.UnsupportedTag(null, null, null, "13"), + Error.UnsupportedTag(null, null, null, "14"), + Error.UnsupportedTag(null, null, null, "15"), + Error.UnsupportedTag(null, null, null, "16"), + Error.UnsupportedTag(null, null, null, "17"), + Error.UnsupportedTag(null, null, null, "18"), + + // String Write Params + Error.UnsupportedTag(null, null, null, "151"), + Error.UnsupportedTag(null, null, null, "152"), + + // Double Write Params + Error.UnsupportedTag(null, null, null, "251"), + Error.UnsupportedTag(null, null, null, "252"), + + // Table Params + Error.UnsupportedTag(null, null, null, "1000"), + Error.UnsupportedTag(null, null, null, "1100"), + Error.UnsupportedTag(null, null, null, "1200"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDefaultValueTag_ValueIncompatibleWithInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ValueIncompatibleWithInterpreteType", + ExpectedResults = new List + { + Error.ValueIncompatibleWithInterpreteType(null, null, null, "abc", "double", "100"), + } + }; + + Generic.Validate(check, data); + } + + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDefaultValueTag_NotYetSupportedTag() + { + // Create ErrorMessage + var message = Error.NotYetSupportedTag(null, null, null, "columnPid"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.68.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unsupported tag 'DefaultValue' in Column 'columnPid'.", + HowToFix = "", + ExampleCode = "", + Details = "Interprete/DefaultValue tag allows to give a default value to a parameter." + Environment.NewLine + "This is currently only supported on standalone read parameters and the given value should be compatible with the Inteprete/Type.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDefaultValueTag_UnsupportedTag() + { + // Create ErrorMessage + var message = Error.UnsupportedTag(null, null, null, "paramId"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.68.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unsupported tag 'DefaultValue' in Param 'paramId'.", + HowToFix = "", + ExampleCode = "", + Details = "Interprete/DefaultValue tag allows to give a default value to a parameter." + Environment.NewLine + "This is currently only supported on standalone read parameters and the given value should be compatible with the Inteprete/Type.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDefaultValueTag(); + + [TestMethod] + public void Param_CheckDefaultValueTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDefaultValueTag_CheckId() => Generic.CheckId(check, CheckId.CheckDefaultValueTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/NotYetSupportedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/NotYetSupportedTag.xml new file mode 100644 index 00000000..cbd0ad69 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/NotYetSupportedTag.xml @@ -0,0 +1,71 @@ + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2_String + read + + string + + abc + + + + TableSyntax1_Column3_Double + read + + double + + 1 + + + + + TableSyntax2 + array + + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2_String + read + + string + + abc + + + + TableSyntax2_Column3_Double + read + + double + + 1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/UnsupportedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/UnsupportedTag.xml new file mode 100644 index 00000000..c1267be5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/UnsupportedTag.xml @@ -0,0 +1,290 @@ + + + + + Standalone_Bus + bus + + string + + abc + + + + Standalone_CRC + crc + + double + + abc + + + + Standalone_DataminerInfo + dataminer info + + string + + abc + + + + Standalone_DiscreetInfo + discreet info + + string + + abc + + + + Standalone_Dummy + dummy + + string + + abc + + + + Standalone_ElementDmaId + elementdmaid + + string + + abc + + + + Standalone_ElementId + elementid + + string + + abc + + + + Standalone_ElementName + elementname + + string + + abc + + + + Standalone_Fixed + fixed + + string + + abc + + + + Standalone_Group + group + + string + + abc + + + + Standalone_Header + header + + string + + abc + + + + Standalone_IP + ip + + string + + abc + + + + Standalone_Length + length + + double + + abc + + + + Standalone_PollingIp + pollingip + + string + + abc + + + + Standalone_ReadBit + read bit + + double + + abc + + + + Standalone_Response + response + + string + + abc + + + + Standalone_Trailer + trailer + + string + + abc + + + + Standalone_WriteBit + write bit + + double + + abc + + + + + Standalone_String_ReadOnly + read + + string + abc + + + + Standalone_String_ReadWrite + read + + string + abc + + + + Standalone_String_ReadWrite + write + + string + + abc + + + + Standalone_String_WriteOnly + write + + string + + abc + + + + + Standalone_Double_ReadOnly + read + + double + 1 + + + + Standalone_Double_ReadWrite + read + + double + 1 + + + + Standalone_Double_ReadWrite + write + + double + + 1 + + + + Standalone_Double_WriteOnly + write + + double + + 1 + + + + + TableSyntax1 + array + + + 1 + + + + TableSyntax1_Instance + read + + string + + + + + TableSyntax2 + array + + + + + 1 + + + + TableSyntax2_Instance + read + + string + + + + + TableSyntax3 + array + + + + + 1 + + + + TableSyntax3_Instance + read + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml new file mode 100644 index 00000000..825b4a81 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml @@ -0,0 +1,18 @@ + + + + + + DoubleParam_StringValue + read + + double + abc + + + + + + + + diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..8d4eabe0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/DefaultValue/CheckDefaultValueTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,339 @@ + + + + + Standalone_Bus + bus + + string + + + + + + Standalone_CRC + crc + + double + + + + + + Standalone_DataminerInfo + dataminer info + + string + + + + + + Standalone_DiscreetInfo + discreet info + + string + + + + + + Standalone_Dummy + dummy + + string + + + + + + Standalone_ElementDmaId + elementdmaid + + string + + + + + + Standalone_ElementId + elementid + + string + + + + + + Standalone_ElementName + elementname + + string + + + + + + Standalone_Fixed + fixed + + string + + + + + + Standalone_Group + group + + string + + + + + + Standalone_Header + header + + string + + + + + + Standalone_IP + ip + + string + + + + + + Standalone_Length + length + + double + + + + + + Standalone_PollingIp + pollingip + + string + + + + + + Standalone_ReadBit + read bit + + double + + + + + + Standalone_Response + response + + string + + + + + + Standalone_Trailer + trailer + + string + + + + + + Standalone_WriteBit + write bit + + double + + + + + + + Standalone_String_ReadOnly + read + + string + abc + + + + Standalone_String_ReadWrite + read + + string + abc + + + + Standalone_String_ReadWrite + write + + string + + + + + + Standalone_String_WriteOnly + write + + string + + + + + + + Standalone_Double_ReadOnly + read + + double + 1 + + + + Standalone_Double_ReadWrite + read + + double + 1 + + + + Standalone_Double_ReadWrite + write + + double + + + + + + Standalone_Double_WriteOnly + write + + double + + + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + read + + string + + + + TableSyntax1_Column2_String + read + + string + + + + + + TableSyntax1_Column3_Double + read + + double + + + + + + + TableSyntax2 + array + + + + + + + + TableSyntax2_Instance + read + + string + + + + TableSyntax2_Column2_String + read + + string + + + + + + TableSyntax2_Column3_Double + read + + double + + + + + + + TableSyntax3 + array + + + + + + + + TableSyntax3_Instance + read + + string + + + + TableSyntax3_Column2_String + read + + string + + + + + + TableSyntax3_Column3_Double + read + + double + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/CheckExceptionsTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/CheckExceptionsTag.cs new file mode 100644 index 00000000..44a8d21b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/CheckExceptionsTag.cs @@ -0,0 +1,107 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Exceptions.CheckExceptionsTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Exceptions.CheckExceptionsTag; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckExceptionsTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckExceptionsTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckExceptionsTag_AddedException() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedException", + ExpectedResults = new List + { + ErrorCompare.AddedException(null, null, "1", "100"), + ErrorCompare.AddedException(null, null, "2", "101"), + + ErrorCompare.AddedException(null, null, "1", "200"), + ErrorCompare.AddedException(null, null, "2", "201"), + + ErrorCompare.AddedException(null, null, "1", "300"), + ErrorCompare.AddedException(null, null, "2", "301"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckExceptionsTag_RemovedException() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedException", + ExpectedResults = new List + { + ErrorCompare.RemovedException(null, null, "1", "100"), + ErrorCompare.RemovedException(null, null, "2", "101"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckExceptionsTag_UpdatedExceptionValueTag() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedExceptionValueTag", + ExpectedResults = new List + { + ErrorCompare.UpdatedExceptionValueTag(null, null, "1", "100", "1", "2"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckExceptionsTag(); + + [TestMethod] + public void Param_CheckExceptionsTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckExceptionsTag_CheckId() => Generic.CheckId(root, CheckId.CheckExceptionsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_New.xml new file mode 100644 index 00000000..e1c38fea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_New.xml @@ -0,0 +1,144 @@ + + + + + NoValueRestriciton_FromNoException + + + + NewException_1 + -1 + + + + + true + + + + NoValueRestriciton_FromOneException + + + + ExistingException_1 + -1 + + + NewException1 + -2 + + + + + true + + + + + WithinRange_FromNoException + + + + NewException_1 + 1 + + + + + true + + 2 + 100 + + + + true + + + + WithinRange_FromOneException + + + + ExistingException_1 + -1 + + + NewException1 + 2 + + + + + true + + 3 + 100 + + + + true + + + + + WithinDiscreetValues_FromNoException + + + + NewException_1 + 1 + + + + + true + + + discreet + + + + Discreet 2 + 2 + + + + + + WithinDiscreetValues_FromOneException + + + + ExistingException_1 + -1 + + + NewException_2 + 2 + + + + + true + + + discreet + + + Discreet 1 + 1 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_Old.xml new file mode 100644 index 00000000..529d1a59 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/AddedException_Old.xml @@ -0,0 +1,144 @@ + + + + + NoValueRestriciton_FromNoException + + + + + true + + + + NoValueRestriciton_FromOneException + + + + ExistingException_1 + -1 + + + + + + true + + + + + WithinRange_FromNoException + + + + + true + + 0 + 100 + + + + true + + + + WithinRange_FromOneException + + + + ExistingException_1 + -1 + + + + + + true + + 0 + 100 + + + + true + + + + + WithinDiscreetValues_FromNoException + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + WithinDiscreetValues_FromOneException + + + + ExistingException_1 + -1 + + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_New.xml new file mode 100644 index 00000000..fe70686b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_New.xml @@ -0,0 +1,38 @@ + + + + + FromOneToZero + + + true + + + + FromTwoToOne + + + + N/A + 1 + + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_Old.xml new file mode 100644 index 00000000..cb147a28 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/RemovedException_Old.xml @@ -0,0 +1,38 @@ + + + + + FromOneToZero + + + + N/A + 1 + + + + + true + + + + FromTwoToOne + + + + N/A + 1 + + + N/A + 2 + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_New.xml new file mode 100644 index 00000000..581d880a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_New.xml @@ -0,0 +1,20 @@ + + + + + UpdatedValueElement + + + + Exception_1 + 2 + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_Old.xml new file mode 100644 index 00000000..fc9f97b5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Invalid/UpdatedExceptionValueTag_Old.xml @@ -0,0 +1,20 @@ + + + + + UpdatedValueElement + + + + Exception_1 + 1 + + + + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..3dc051b7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,184 @@ + + + + + SameExceptions_NoException + + true + + + + SameExceptions_1Exception + + + + Exception_1 + 1 + + + + + true + + + + SameExceptions_2Exceptions + + + + Exception_1 + 1 + + + Exception_2 + 2 + + + + + true + + + + SameExceptions_TrimmedValues + + + + Number_TrimBefore + 1 + + + String_TrimBefore + TrimBefore + + + String_TrimAfter + Trim After + + + String_Trim + Trim + + + String_TrimEnters + TrimEnters + + + String_TrimEnters_Emtpy + + + + + + true + + + + + AddedException_OutOfRange_FromNoException + + + + Exception_1 + -1 + + + + + true + + 0 + 100 + + + + true + + + + AddedException_OutOfRange_FromOneException + + + + Exception_1 + -1 + + + Exception_2 + -2 + + + + + true + + 0 + 100 + + + + true + + + + + AddedException_OutOfDiscreetValues_FromNoException + + + + Exception_1 + -1 + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + AddedException_OutOfDiscreetValues_FromOneException + + + + Exception_1 + -1 + + + Exception_2 + -2 + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..522bcf77 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/CheckExceptionsTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,187 @@ + + + + + SameExceptions_NoException + + true + + + + SameExceptions_1Exception + + + + Exception_1 + 1 + + + + + true + + + + SameExceptions_2Exceptions + + + + Exception_1 + 1 + + + Exception_2 + 2 + + + + + true + + + + SameExceptions_TrimmedValues + + + + Number_TrimBefore + 1 + + + String_TrimBefore + TrimBefore + + + String_TrimAfter + Trim After + + + String_Trim + Trim + + + String_TrimEnters + + TrimEnters + + + + String_TrimEnters_Emtpy + + + + + + + true + + + + + AddedException_OutOfRange_FromNoException + + + + + true + + 0 + 100 + + + + true + + + + AddedException_OutOfRange_FromOneException + + + + Exception_1 + -1 + + + + + + true + + 0 + 100 + + + + true + + + + + AddedException_OutOfDiscreetValues_FromNoException + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + AddedException_OutOfDiscreetValues_FromOneException + + + + Exception_1 + -1 + + + + + + true + + + discreet + + + Discreet 1 + 1 + + + Discreet 2 + 2 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/CheckValueAttribute.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/CheckValueAttribute.cs new file mode 100644 index 00000000..5e7d71fa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/CheckValueAttribute.cs @@ -0,0 +1,121 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Exceptions.Exception.CheckValueAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Exceptions.Exception.CheckValueAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckValueAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckValueAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckValueAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + + Error.MissingAttribute(null, null, null, "2"), + Error.MissingAttribute(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckValueAttribute_ValueIncompatibleWithInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ValueIncompatibleWithInterpreteType", + ExpectedResults = new List + { + Error.ValueIncompatibleWithInterpreteType(null, null, null, "abc", "double", "100"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckValueAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "paramId"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.70.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'Exception@value' in Param 'paramId'.", + HowToFix = "", + ExampleCode = "", + Details = "For each exception, the Exception@value attribute is required in order to define the incoming value that should be interpreted as exceptional." + Environment.NewLine + "The value should be compliant with the defined Param/Interprete/Type.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckValueAttribute(); + + [TestMethod] + public void Param_CheckValueAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckValueAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckValueAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..6dff1256 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,26 @@ + + + + + 1Exception + + + + + + + + + 2Exceptions + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml new file mode 100644 index 00000000..e2d18b39 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml @@ -0,0 +1,17 @@ + + + + + DoubleParam_StringValue + + double + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3cfa578b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/CheckValueAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,53 @@ + + + + + StringParam + + string + + + + + + + + DoubleParam_Integer + + double + + + + + + + DoubleParam_IntegerNegative + + double + + + + + + + + DoubleParam_Double + + double + + + + + + + DoubleParam_DoubleNegative + + double + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/CheckDisplayTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/CheckDisplayTag.cs new file mode 100644 index 00000000..c6ee97dd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/CheckDisplayTag.cs @@ -0,0 +1,196 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Exceptions.Exception.Display.CheckDisplayTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Exceptions.Exception.Display.CheckDisplayTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "My Exception", "100").WithSubResults( + Error.DuplicatedValue(null, null, null, "My Exception", "100"), + Error.DuplicatedValue(null, null, null, "My Exception", "100")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), + Error.EmptyTag(null, null, null, "101"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_UnrecommendedNADisplayValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNADisplayValue", + ExpectedResults = new List + { + Error.UnrecommendedNADisplayValue(null, null, null, "not applicable", "10", "N/A"), + Error.UnrecommendedNADisplayValue(null, null, null, "NA", "10", "N/A"), + Error.UnrecommendedNADisplayValue(null, null, null, "n/a", "10", "N/A"), + Error.UnrecommendedNADisplayValue(null, null, null, "n_a", "10", "N/A"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", " Leading Space"), + Error.UntrimmedTag(null, null, null, "100", "Trailing Spaces "), + Error.UntrimmedTag(null, null, null, "100", " Leading and Trailing Spaces "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_WrongCasing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WrongCasing", + ExpectedResults = new List + { + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "wrong casing", "Wrong Casing", "100")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_UnrecommendedNADisplayValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNADisplayValue", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_WrongCasing() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "WrongCasing", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckDisplayTag_CheckId() => Generic.CheckId(root, CheckId.CheckDisplayTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UnrecommendedNADisplayValue.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UnrecommendedNADisplayValue.xml new file mode 100644 index 00000000..9d39213c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UnrecommendedNADisplayValue.xml @@ -0,0 +1,22 @@ + + + + + + + N/A + + + N/A + + + N/A + + + N/A + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..ef0d986f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,21 @@ + + + + + + + + Leading Space + + + Trailing Spaces + + + Leading and Trailing Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml new file mode 100644 index 00000000..48e4394b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml @@ -0,0 +1,17 @@ + + + + + + + + + + Wrong Casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..569e6330 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,18 @@ + + + + + + + + My Exception + + + My Exception + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..0d1934ed --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,26 @@ + + + + + Empty + + + + + + + + + + Spaces + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..2d45b829 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,15 @@ + + + + + NoExceptionDisplay + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UnrecommendedNADisplayValue.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UnrecommendedNADisplayValue.xml new file mode 100644 index 00000000..635a2512 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UnrecommendedNADisplayValue.xml @@ -0,0 +1,22 @@ + + + + + + + not applicable + + + NA + + + n/a + + + n_a + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..ff2daaad --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,21 @@ + + + + + + + + Leading Space + + + Trailing Spaces + + + Leading and Trailing Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml new file mode 100644 index 00000000..e67f35d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml @@ -0,0 +1,17 @@ + + + + + + + + + + wrong casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..afa7bbce --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,24 @@ + + + + + + + + N/A + + + Not Available + + + Some Random Value + + + Name Ending on A + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/CheckValueTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/CheckValueTag.cs new file mode 100644 index 00000000..d291eaff --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/CheckValueTag.cs @@ -0,0 +1,156 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Exceptions.Exception.Value.CheckValueTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Exceptions.Exception.Value.CheckValueTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckValueTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckValueTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckValueTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + + Error.MissingTag(null, null, null, "2"), + Error.MissingTag(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckValueTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + // TODO: double check if untrimmed value actually work or get trimmed. + Error.UntrimmedTag(null, null, null, "1", " abc "), + Error.UntrimmedTag(null, null, null, "100", " 123 "), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckValueTag_ValueIncompatibleWithInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ValueIncompatibleWithInterpreteType", + ExpectedResults = new List + { + Error.ValueIncompatibleWithInterpreteType(null, null, null, "abc", "double", "100"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckValueTag(); + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckValueTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "paramId"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.71.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Exception/Value' in Param 'paramId'.", + HowToFix = "", + ExampleCode = "", + Details = "For each exception, the Exception/Value tag is required in order to define the value that should be stored in memory and database." + Environment.NewLine + "The value should be compliant with the defined Param/Interprete/Type.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckValueTag(); + + [TestMethod] + public void Param_CheckValueTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckValueTag_CheckId() => Generic.CheckId(check, CheckId.CheckValueTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..8b05e65f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,29 @@ + + + + + StringParam + + string + + + abc + + + + + + + DoubleParam_Integer + + double + + + 123 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..5813fe6a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,26 @@ + + + + + 1Exception + + + + + + + + + 2Exceptions + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..5520d58e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,29 @@ + + + + + StringParam + + string + + + abc + + + + + + + DoubleParam_Integer + + double + + + 123 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml new file mode 100644 index 00000000..9ada22d0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Invalid/ValueIncompatibleWithInterpreteType.xml @@ -0,0 +1,19 @@ + + + + + DoubleParam_StringValue + + double + + + abc + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..877b0659 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Exceptions/Exception/Value/CheckValueTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,63 @@ + + + + + StringParam + + string + + + abc + + + + + + + DoubleParam_Integer + + double + + + 123 + + + + + + DoubleParam_IntegerNegative + + double + + + -123 + + + + + + + DoubleParam_Double + + double + + + 1.23 + + + + + + DoubleParam_DoubleNegative + + double + + + -1.23 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/CheckLengthTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/CheckLengthTag.cs new file mode 100644 index 00000000..d25d84f3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/CheckLengthTag.cs @@ -0,0 +1,173 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Length.CheckLengthTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Length.CheckLengthTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckLengthTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLengthTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLengthTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "300"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLengthTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, Severity.Major, "abcd", "300"), + Error.InvalidValue(null, null, null, Severity.Critical, "5", "6024"), + Error.InvalidValue(null, null, null, Severity.Critical, "8", "6025"), + Error.InvalidValue(null, null, null, Severity.Critical, "7", "6026"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLengthTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckLengthTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "6024"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Length' in Param '6024'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLengthTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, Severity.Major, "tagValue", "6024"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'tagValue' in tag 'Length'. Param ID '6024'.", + Details = "The 'Length' tag needs to be an unsigned integer." + Environment.NewLine + "When the parameter is of type 'length', the 'Length' tag can not be larger than 4.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLengthTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "6024"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Length' in Param '6024'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckLengthTag(); + + [TestMethod] + public void Param_CheckLengthTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckLengthTag_CheckId() => Generic.CheckId(check, CheckId.CheckLengthTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..60d50643 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,16 @@ + + + + Comparison Value For Power In dbW + Comparison Value For Power In dbW + fixed + + other + fixed + string + + AAAA + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..1437b59b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,42 @@ + + + + Comparison Value For Power In dbW + Comparison Value For Power In dbW + fixed + + other + fixed + string + abcd + AAAA + + + + length + + unsigned number + fixed + 5 + double + + + + + length + + signed number + fixed + 8 + double + + + + + length + + 7 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..bd749954 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,14 @@ + + + + testParam + fixed + + other + string + fixed + AAAA + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..61330221 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Length/CheckLengthTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,91 @@ + + + + TitleSoftwareManagement + TitleSoftwareManagement + fixed + + title + + + + Title_Begin_Identification + Identification + fixed + + true + + + title + + + + Title_End_Generic + fixed + + true + + + title + + + + testParm + fixed + + other + fixed + string + 4 + AAAA + + + + + RealStateV0 + Real State V0 + + Real State V0 + + read bit + + unsigned number + fixed + double + 7 + 1 + + + + + length + + unsigned number + fixed + 4 + double + + + + + length + + signed number + fixed + 4 + double + + + + + length + + signed number + fixed + 2 + double + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..f6b2ad23 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,261 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.LengthType.CheckIdAttribute +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.LengthType.CheckIdAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), // Empty + Error.EmptyAttribute(null, null, null, "2"), // Spaces + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "200"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1", "200"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_ReferencedParamWrongInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongInterpreteType", + ExpectedResults = new List + { + Error.ReferencedParamWrongInterpreteType(null, null, null, "string", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "200", " 1"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "paramId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Interprete/LengthType@id' in Param 'paramId'.", + Details = "When Interprete/LengthType tag is set to 'other param', the id attribute should be added to it and should refer to the id of an existing parameter of Interprete/Type double.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "paramId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing attribute 'Interprete/LengthType@id' due to 'LengthType' 'other param'. Param ID 'paramId'.", + Details = "When Interprete/LengthType tag is set to 'other param', the id attribute should be added to it and should refer to the id of an existing parameter of Interprete/Type double.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "nonExistingParamId", "paramId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Interprete/LengthType@id' references a non-existing 'Param' with ID 'nonExistingParamId'. Param ID 'paramId'.", + Details = "When Interprete/LengthType tag is set to 'other param', the id attribute should be added to it and should refer to the id of an existing parameter of Interprete/Type double.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "paramId", "untrimmedValue"); + + var expected = new ValidationResult + { + Severity = Severity.Warning, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'id' in Param 'paramId'. Current value 'untrimmedValue'.", + Details = "When Interprete/LengthType tag is set to 'other param', the id attribute should be added to it and should refer to the id of an existing parameter of Interprete/Type double.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_ReferencedParamWrongInterpreteType() + { + // Create ErrorMessage + var message = Error.ReferencedParamWrongInterpreteType(null, null, null, "interpreteType", "2"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid Interprete/Type 'interpreteType' on Param referenced by Interprete/LengthType@id. Expected value 'double'. Param ID '2'.", + Details = "When Interprete/LengthType tag is set to 'other param', the id attribute should be added to it and should refer to the id of an existing parameter of Interprete/Type double.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..e161bfec --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,19 @@ + + + + + ReferencedParam_OtherParam + + double + + + + + LengthTypeOtherParam + + next param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..e3b12644 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + Empty + + other param + + + + Spaces + + other param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..27466c69 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,12 @@ + + + + + LengthTypeOtherParam + + other param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..acea93b3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,12 @@ + + + + + LengthTypeOtherParam + + other param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongInterpreteType.xml new file mode 100644 index 00000000..f5357c19 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongInterpreteType.xml @@ -0,0 +1,19 @@ + + + + + ReferencedParam_OtherParam + + string + + + + + LengthTypeOtherParam + + next param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..7ad245ef --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,19 @@ + + + + + ReferencedParam_OtherParam + + double + + + + + LengthTypeOtherParam + + next param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..09639ed4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,38 @@ + + + + + ReferencedParam_OtherParam + + double + + + + + LengthTypeFixed + + fixed + + + + LengthTypeLastNextParam + + last next param + + + + LengthTypeNextParam + + next param + + + + + LengthTypeOtherParam + + other param + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/CheckLengthTypeTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/CheckLengthTypeTag.cs new file mode 100644 index 00000000..69d1ecb6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/CheckLengthTypeTag.cs @@ -0,0 +1,170 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.LengthType.CheckLengthTypeTag +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.LengthType.CheckLengthTypeTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckLengthTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLengthTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLengthTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "300"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLengthTypeTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "fiixed", "1"), + Error.InvalidValue(null, null, null, "next param", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckLengthTypeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckLengthTypeTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "6024"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'LengthType' in Param '6024'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLengthTypeTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "tagValue", "6024"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'tagValue' in tag 'LengthType'. Param ID '6024'.", + Details = "When 'Param/Type' is 'fixed', 'Interprete/LengthType' should also be 'fixed'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckLengthTypeTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "300"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'LengthType' in Param '300'.", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckLengthTypeTag(); + + [TestMethod] + public void Param_CheckLengthTypeTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckLengthTypeTag_CheckId() => Generic.CheckId(check, CheckId.CheckLengthTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..f6760bfc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,16 @@ + + + + Comparison Value For Power In dbW + Comparison Value For Power In dbW + fixed + + other + + string + 4 + AAAA + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..acb97b90 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,26 @@ + + + + testParam1 + fixed + + other + fiixed + string + 4 + AAAA + + + + testParam2 + fixed + + other + next param + string + 4 + AAAA + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..10127617 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,14 @@ + + + + testParam + fixed + + other + string + 4 + AAAA + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..45b9e526 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/LengthType/CheckLengthTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,55 @@ + + + + TitleSoftwareManagement + TitleSoftwareManagement + fixed + + title + + + + Title_Begin_Identification + Identification + fixed + + true + + + title + + + + Title_End_Generic + fixed + + true + + + title + + + + testParam + fixed + + other + fixed + string + 4 + AAAA + + + + ValidUnsignedParam + fixed + + unsigned number + fixed + double + 4 + 1234 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/CheckOthersTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/CheckOthersTag.cs new file mode 100644 index 00000000..52cdd652 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/CheckOthersTag.cs @@ -0,0 +1,116 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Others.CheckOthersTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Others.CheckOthersTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOthersTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOthersTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOthersTag_UpdateOtherId() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdateOtherId", + ExpectedResults = new List + { + ErrorCompare.UpdateOtherId(null, null, "10", "11", "1", "1"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOthersTag_UpdateOtherDisplay() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdateOtherDisplay", + ExpectedResults = new List + { + ErrorCompare.UpdateOtherDisplay(null, null, "Display1", "Display2", "1", "1"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOthersTag_DeletedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "DeletedValue", + ExpectedResults = new List + { + ErrorCompare.DeletedValue(null, null, "1", "1"), + ErrorCompare.DeletedValue(null, null, "1", "2"), + ErrorCompare.DeletedValue(null, null, "6", "101"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOthersTag_AddedOthers() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedOthers", + ExpectedResults = new List + { + ErrorCompare.AddedOthers(null, null, "1", "1"), + ErrorCompare.AddedOthers(null, null, "1", "2"), + ErrorCompare.AddedOthers(null, null, "6", "101"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOthersTag(); + + [TestMethod] + public void Param_CheckOthersTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOthersTag_CheckId() => Generic.CheckId(root, CheckId.CheckOthersTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_New.xml new file mode 100644 index 00000000..99175db0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_New.xml @@ -0,0 +1,51 @@ + + + + + + + + N/A + 1 + + + + + true + + + + + + + N/A + 1 + + + + + true + + + + + + WithinRange - AddingOthers + + + + N/A + 6 + + + + 5 + 10 + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_Old.xml new file mode 100644 index 00000000..2422a23f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/AddedOthers_Old.xml @@ -0,0 +1,35 @@ + + + + + NoRange - AddingOthers + + true + + + + NoRange - AddingOther + + + + + + true + + + + + + WithinRange - AddingOthers + + + 5 + 10 + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_New.xml new file mode 100644 index 00000000..905f5825 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_New.xml @@ -0,0 +1,34 @@ + + + + NoRange - RemoveOther + + + + + + true + + + + NoRange - RemoveOthers + + true + + + + + + WithinRange - RemovingOthers + + + 5 + 10 + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_Old.xml new file mode 100644 index 00000000..0fe7ac6b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/DeletedValue_Old.xml @@ -0,0 +1,53 @@ + + + + + NoRange - RemoveOther + + + + N/A + 1 + + + + + true + + + + NoRange - RemoveOthers + + + + N/A + 1 + + + + + true + + + + + + WithinRange - RemovingOthers + + + + N/A + 6 + + + + 5 + 10 + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_New.xml new file mode 100644 index 00000000..2fc30a55 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_New.xml @@ -0,0 +1,14 @@ + + + + + + + Display2 + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_Old.xml new file mode 100644 index 00000000..cf81dad0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherDisplay_Old.xml @@ -0,0 +1,14 @@ + + + + + + + Display1 + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_New.xml new file mode 100644 index 00000000..8c4adb64 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_New.xml @@ -0,0 +1,14 @@ + + + + + + + N/A + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_Old.xml new file mode 100644 index 00000000..c544f2dc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Invalid/UpdateOtherId_Old.xml @@ -0,0 +1,14 @@ + + + + + + + N/A + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..0de2c4f3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,128 @@ + + + + + No Others + + true + + + + + + Same Others 1 + + + + N/A + 1 + + + + + true + + + + Same Others 2 + + + + N/A + + + + + true + + + + + + Added Out of Range Other + + + + N/A + + 2 + + + + 5 + 10 + + + + true + + + + + + NonMonitored - AddedOther + + + + N/A + 2 + + + + 5 + 10 + + + + false + + + + NonMonitored - RemovedOther + + + 5 + 10 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..c0b85e52 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Others/CheckOthersTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,121 @@ + + + + + No Others + + true + + + + + + Same Others 1 + + + + N/A + 1 + + + + + true + + + + Same Others 1 + + + + N/A + + + + + true + + + + + + Added Out of Range Other + + + 5 + 10 + + + + true + + + + + + NonMonitored - AddedOther + + + 5 + 10 + + + + false + + + + NonMonitored - RemovedOther + + + + N/A + 2 + + + + 5 + 10 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..0d50a70c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,103 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Interprete.Type.CheckTypeTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Interprete.Type.CheckTypeTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTypeTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTypeTag_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "1", "double", "string"), + ErrorCompare.UpdatedValue(null, null, "2", "string", "high nibble"), + ErrorCompare.UpdatedValue(null, null, "3", "high nibble", "double"), + ErrorCompare.UpdatedValue(null, null, "4", "high nibble", "string"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckTypeTag_RemovedTag() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedTag", + ExpectedResults = new List + { + ErrorCompare.RemovedTag(null, null, "1"), + ErrorCompare.RemovedTag(null, null, "2"), + ErrorCompare.RemovedTag(null, null, "3"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckTypeTag_AddedTag() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedTag", + ExpectedResults = new List + { + ErrorCompare.AddedTag(null, null, "double", "1"), + ErrorCompare.AddedTag(null, null, "string", "2"), + ErrorCompare.AddedTag(null, null, "high nibble", "3"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckTypeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_New.xml new file mode 100644 index 00000000..20fec217 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_New.xml @@ -0,0 +1,19 @@ + + + + + double + + + + + string + + + + + high nibble + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_Old.xml new file mode 100644 index 00000000..c82a3e13 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/AddedTag_Old.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_New.xml new file mode 100644 index 00000000..5289f68b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_New.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_Old.xml new file mode 100644 index 00000000..b2eeab78 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/RemovedTag_Old.xml @@ -0,0 +1,24 @@ + + + + + double + + + + + string + + + + + high nibble + + + + + high nibble + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..93aeecfa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,24 @@ + + + + + string + + + + + high nibble + + + + + double + + + + + string + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..b2eeab78 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,24 @@ + + + + + double + + + + + string + + + + + high nibble + + + + + high nibble + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..be543862 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,116 @@ + + + + + + NoChange_Double + read + + double + + + + NoChange_Double + write + + double + + + + NoChange_String + read + + string + + + + NoChange_String + write + + string + + + + NoChange_HighNible + read + + high nibble + + + + NoChange_HighNible + write + + high nibble + + + + + + NewParam_Double + read + + double + + + + NewParam_Double + write + + double + + + + NewParam_String + read + + string + + + + NewParam_String + write + + string + + + + NewParam_HighNible + read + + high nibble + + + + NewParam_HighNible + write + + high nibble + + + + + + AllowedChange_Write_DoubleToString + write + + string + + + + AllowedChange_Write_StringToDouble + write + + double + + + + AllowedChange_Write_HighNibbleToString + write + + string + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..0394d396 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Interprete/Type/CheckTypeTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,116 @@ + + + + + + NoChange_Double + read + + double + + + + NoChange_Double + write + + double + + + + NoChange_String + read + + string + + + + NoChange_String + write + + string + + + + NoChange_HighNible + read + + high nibble + + + + NoChange_HighNible + write + + high nibble + + + + + + + + + AllowedChange_Write_DoubleToString + write + + double + + + + AllowedChange_Write_StringToDouble + write + + string + + + + AllowedChange_Write_HighNibbleToString + write + + high nibble + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/CheckDependencyId.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/CheckDependencyId.cs new file mode 100644 index 00000000..51e520cd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/CheckDependencyId.cs @@ -0,0 +1,356 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.CheckDependencyId +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.CheckDependencyId; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDependencyId(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDependencyId_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDependencyId_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1000"), + Error.EmptyAttribute(null, null, null, "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyId_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "1000"), + Error.InvalidValue(null, null, null, "-10", "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyId_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "100", "1000"), + Error.NonExistingId(null, null, null, "200", "2000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckDependencyId_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyId_ReferencedParamWrongType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongType", + ExpectedResults = new List + { + Error.ReferencedParamWrongType(null, null, null, "array", "100"), + Error.ReferencedParamWrongType(null, null, null, "bus", "101"), + Error.ReferencedParamWrongType(null, null, null, "crc", "102"), + Error.ReferencedParamWrongType(null, null, null, "dataminer info", "103"), + Error.ReferencedParamWrongType(null, null, null, "discreet info", "104"), + Error.ReferencedParamWrongType(null, null, null, "dummy", "105"), + Error.ReferencedParamWrongType(null, null, null, "elementdmaid", "106"), + Error.ReferencedParamWrongType(null, null, null, "elementid", "107"), + Error.ReferencedParamWrongType(null, null, null, "elementname", "108"), + Error.ReferencedParamWrongType(null, null, null, "fixed", "109"), + Error.ReferencedParamWrongType(null, null, null, "group", "110"), + Error.ReferencedParamWrongType(null, null, null, "header", "111"), + Error.ReferencedParamWrongType(null, null, null, "ip", "112"), + Error.ReferencedParamWrongType(null, null, null, "length", "113"), + Error.ReferencedParamWrongType(null, null, null, "pollingip", "114"), + //Error.ReferencedParamWrongType(null, null, null, "read", "115"), + //Error.ReferencedParamWrongType(null, null, null, "read bit", "116"), + Error.ReferencedParamWrongType(null, null, null, "response", "117"), + Error.ReferencedParamWrongType(null, null, null, "trailer", "118"), + Error.ReferencedParamWrongType(null, null, null, "write", "119"), + Error.ReferencedParamWrongType(null, null, null, "write bit", "120"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyId_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1000", " 100"), + Error.UntrimmedAttribute(null, null, null, "2000", "200 "), + Error.UntrimmedAttribute(null, null, null, "2001", " 200 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckDependencyId(); + + [TestMethod] + public void Param_CheckDependencyId_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDependencyId_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.54.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Discreets@dependencyId' in Param '100'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyId_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "aaa", "100"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.54.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value 'aaa' in attribute 'Discreets@dependencyId'. Param ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyId_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "100", "1000"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.54.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Discreets@dependencyId' references a non-existing 'Param' with ID '100'. Param ID '1000'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyId_ReferencedParamRTDisplayExpected() + { + // Create ErrorMessage + var message = Error.ReferencedParamRTDisplayExpected(null, null, null, "100", "1000"); + + var expected = new ValidationResult + { + ErrorId = 6, + FullId = "2.54.6", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param '100' referenced by a 'Discreets@dependencyId' attribute. Param ID '1000'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyId_ReferencedParamWrongType() + { + // Create ErrorMessage + var message = Error.ReferencedParamWrongType(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "2.54.5", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid Param Type '2' on Param referenced by a 'Discreets@dependencyId' attribute. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyId_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "100", " untrimmed "); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.54.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Discreets@dependencyId' in Param '100'. Current value ' untrimmed '.", + HowToFix = "", + ExampleCode = "", + Details = "Discreets@dependencyId attribute should contain the ID of a Param." + Environment.NewLine + "The referenced Param is expected to:" + Environment.NewLine + "- Be of type 'read' or 'read bit'." + Environment.NewLine + "- Have RTDisplay tag set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDependencyId(); + + [TestMethod] + public void Param_CheckDependencyId_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDependencyId_CheckId() => Generic.CheckId(check, CheckId.CheckDependencyId); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..e3b5130c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,39 @@ + + + + + ParamWithRTDisplay_Read + read + + true + + + + ParamWithRTDisplay_ReadBit + read bit + + true + + + + + LeadingSpaces + + + + + + TrailingSpaces + + + + + + LeadingAndTrailing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..c634b06e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + DependencyId_Empty + + + + + + DependencyId_Spaces + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..8692d569 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,18 @@ + + + + + DependencyId_String + + + + + + DependencyId_NegativeNumber + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..6dfd5efb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,33 @@ + + + + + + + DependencyId_ToRead + + + + + + DependencyId_ToReadBit + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..3239c574 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,61 @@ + + + + + Read_RTDisplayFalse + read + + false + + + + Read_NoRTDisplay + read + + + + + + Read_NoDisplay + read + + + + + ReadBit_RTDisplayFalse + read bit + + false + + + + + DependencyId_ToRead_RTDisplayFalse + + + + + + DependencyId_ToRead_NoRTDisplay + + + + + + DependencyId_ToRead_NoDisplay + + + + + + + DependencyId_ToReadBit_RTDisplayFalse + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamWrongType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamWrongType.xml new file mode 100644 index 00000000..3b8e7a6f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/ReferencedParamWrongType.xml @@ -0,0 +1,280 @@ + + + + + array + array + + true + + + + bus + bus + + true + + + + crc + crc + + true + + + + dataminer info + dataminer info + + true + + + + discreet info + discreet info + + true + + + + dummy + dummy + + true + + + + elementdmaid + elementdmaid + + true + + + + elementid + elementid + + true + + + + elementname + elementname + + true + + + + fixed + fixed + + true + + + + group + group + + true + + + + header + header + + true + + + + ip + ip + + true + + + + length + length + + true + + + + pollingip + pollingip + + true + + + + read + read + + true + + + + read bit + read bit + + true + + + + response + response + + true + + + + trailer + trailer + + true + + + + write + write + + true + + + + write bit + write bit + + true + + + + + DependencyId_ToArray + + + + + + DependencyId_ToBus + + + + + + DependencyId_ToCrc + + + + + + DependencyId_ToCataMinerInfo + + + + + + DependencyId_ToDiscreetInfo + + + + + + DependencyId_ToDummy + + + + + + DependencyId_ToElementDmaId + + + + + + DependencyId_ToElementId + + + + + + DependencyId_ToElementName + + + + + + DependencyId_ToFixed + + + + + + DependencyId_ToGroup + + + + + + DependencyId_ToHeader + + + + + + DependencyId_ToIP + + + + + + DependencyId_ToLength + + + + + + DependencyId_ToPollingIP + + + + + + DependencyId_ToRead + + + + + + DependencyId_ToReadBit + + + + + + DependencyId_ToResponse + + + + + + DependencyId_ToTrailer + + + + + + DependencyId_ToWrite + + + + + + DependencyId_ToWriteBit + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..65d7d154 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,39 @@ + + + + + ParamWithRTDisplay_Read + read + + true + + + + ParamWithRTDisplay_ReadBit + read bit + + true + + + + + LeadingSpaces + + + + + + TrailingSpaces + + + + + + LeadingAndTrailing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..2cf96b42 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDependencyId/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,33 @@ + + + + + ParamWithRTDisplay_Read + read + + true + + + + ParamWithRTDisplay_ReadBit + read bit + + true + + + + + DependencyId_ToRead + + + + + + DependencyId_ToReadBit + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/CheckDiscreetsTag.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/CheckDiscreetsTag.cs new file mode 100644 index 00000000..cf5966c3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/CheckDiscreetsTag.cs @@ -0,0 +1,82 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.CheckDiscreetsTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.CheckDiscreetsTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDiscreetsTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDiscreetsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDiscreetsTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "discreet", "1"), + Error.MissingTag(null, null, null, "button", "2"), + Error.MissingTag(null, null, null, "pagebutton", "3"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDiscreetsTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "button", "0"); + + string description = "Missing 'Measurement/Discreets' tag for 'button' Param with ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDiscreetsTag(); + + [TestMethod] + public void Param_CheckDiscreetsTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDiscreetsTag_CheckId() => Generic.CheckId(check, CheckId.CheckDiscreetsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..53ad1ef4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,19 @@ + + + + + discreet + + + + + button + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e86afe1d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckDiscreetsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,19 @@ + + + + + discreet + + + My Discreet 0 + 0 + + + My Discreet 1 + 1 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/CheckMatrixDiscreets.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/CheckMatrixDiscreets.cs new file mode 100644 index 00000000..76ee310b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/CheckMatrixDiscreets.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.CheckMatrixDiscreets +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.CheckMatrixDiscreets; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckMatrixDiscreets(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckMatrixDiscreets_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckMatrixDiscreets_InvalidDiscreetCount() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidDiscreetCount", + ExpectedResults = new List + { + Error.InvalidDiscreetCount(null, null, null, "49", "48", "3"), + Error.InvalidDiscreetCount(null, null, null, "49", "48", "4"), + Error.InvalidDiscreetCount(null, null, null, "0", "48", "5"), + Error.InvalidDiscreetCount(null, null, null, "0", "48", "6"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckMatrixDiscreets_MissingDiscreetValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingDiscreetValue", + ExpectedResults = new List + { + Error.MissingDiscreetValue(null, null, null, "48", "1"), + Error.MissingDiscreetValue(null, null, null, "16", "2"), + Error.MissingDiscreetValue(null, null, null, "6;7;13;31;32;45", "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckMatrixDiscreets_DiscreetsNotOneBased() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DiscreetsNotOneBased", + ExpectedResults = new List + { + Error.DiscreetsNotOneBased(null, null, null, "1"), + Error.DiscreetsNotOneBased(null, null, null, "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckMatrixDiscreets(); + + [TestMethod] + public void Param_CheckMatrixDiscreets_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckMatrixDiscreets_CheckId() => Generic.CheckId(root, CheckId.CheckMatrixDiscreets); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/DiscreetsNotOneBased.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/DiscreetsNotOneBased.xml new file mode 100644 index 00000000..eb9f1218 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/DiscreetsNotOneBased.xml @@ -0,0 +1,217 @@ + + + + AlmostCorrectButZeroBased + array + + matrix + + + Input 1 + 0 + + + Input 2 + 1 + + + Input 3 + 2 + + + Input 4 + 3 + + + Input 5 + 4 + + + Input 6 + 5 + + + Input 7 + 6 + + + Input 8 + 7 + + + Input 9 + 8 + + + Input 10 + 9 + + + Input 11 + 10 + + + Input 12 + 11 + + + Input 13 + 12 + + + Input 14 + 13 + + + Input 15 + 14 + + + Input 16 + 15 + + + Output 1 + 16 + + + Output 2 + 17 + + + Output 3 + 18 + + + Output 4 + 19 + + + Output 5 + 20 + + + Output 6 + 21 + + + Output 7 + 22 + + + Output 8 + 23 + + + Output 9 + 24 + + + Output 10 + 25 + + + Output 11 + 26 + + + Output 12 + 27 + + + Output 13 + 28 + + + Output 14 + 29 + + + Output 15 + 30 + + + Output 16 + 31 + + + Output 17 + 32 + + + Output 18 + 33 + + + Output 19 + 34 + + + Output 20 + 35 + + + Output 21 + 36 + + + Output 22 + 37 + + + Output 23 + 38 + + + Output 24 + 39 + + + Output 25 + 40 + + + Output 26 + 41 + + + Output 27 + 42 + + + Output 28 + 43 + + + Output 29 + 44 + + + Output 30 + 45 + + + Output 31 + 46 + + + Output 32 + 47 + + + + + + Only1Discreet + + matrix + + + BBLABLABLA + 0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/InvalidDiscreetCount.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/InvalidDiscreetCount.xml new file mode 100644 index 00000000..b1e2179c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/InvalidDiscreetCount.xml @@ -0,0 +1,433 @@ + + + + + + TooManyOutput + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + Output 33 + 49 + + + + + + TooManyInput + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Input 17 + 17 + + + Output 1 + 18 + + + Output 2 + 19 + + + Output 3 + 20 + + + Output 4 + 21 + + + Output 5 + 22 + + + Output 6 + 23 + + + Output 7 + 24 + + + Output 8 + 25 + + + Output 9 + 26 + + + Output 10 + 27 + + + Output 11 + 28 + + + Output 12 + 29 + + + Output 13 + 30 + + + Output 14 + 31 + + + Output 15 + 32 + + + Output 16 + 33 + + + Output 17 + 34 + + + Output 18 + 35 + + + Output 19 + 36 + + + Output 20 + 37 + + + Output 21 + 38 + + + Output 22 + 39 + + + Output 23 + 40 + + + Output 24 + 41 + + + Output 25 + 42 + + + Output 26 + 43 + + + Output 27 + 44 + + + Output 28 + 45 + + + Output 29 + 46 + + + Output 30 + 47 + + + Output 31 + 48 + + + Output 32 + 49 + + + + + + + No Discreets + array + + matrix + + + + + No Discreet + array + + matrix + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/MissingDiscreetValue.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/MissingDiscreetValue.xml new file mode 100644 index 00000000..c84dd183 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Invalid/MissingDiscreetValue.xml @@ -0,0 +1,600 @@ + + + + MissingLastOutput + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + + + + MissingLastInput + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + + MissingInput_6_7_13_Output_15_16_39 + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a54892f9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/CheckMatrixDiscreets/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,224 @@ + + + + + Matrix_Read_16x32 + array + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + Matrix_Write + write + + other + next param + string + + + matrix + + + + + + NonMatrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/CheckDependencyValuesAttribute.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/CheckDependencyValuesAttribute.cs new file mode 100644 index 00000000..6b9d26a8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/CheckDependencyValuesAttribute.cs @@ -0,0 +1,264 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckDependencyValuesAttribute +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckDependencyValuesAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDependencyValuesAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "100"), + Error.EmptyAttribute(null, null, null, "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1002", "999"), + Error.NonExistingId(null, null, null, "1003", "999"), + + Error.NonExistingId(null, null, null, "1002", "999"), + Error.NonExistingId(null, null, null, "1003", "999"), + Error.NonExistingId(null, null, null, "1004", "999"), + Error.NonExistingId(null, null, null, "1005", "999"), + Error.NonExistingId(null, null, null, "1006", "999"), + Error.NonExistingId(null, null, null, "AAA", "999"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckDependencyValuesAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1002", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1003", "999"), + + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1002", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1003", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1004", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1004", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1005", "999"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1005", "999"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "100", " Leading"), + Error.UntrimmedAttribute(null, null, null, "100", "Trailing "), + Error.UntrimmedAttribute(null, null, null, "100", " LeadingAndTrailing "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckDependencyValuesAttribute(); + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDependencyValuesAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.59.1", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Discreet@dependencyValues' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreet@dependencyValues attribute can be used in 2 scenarios:" + Environment.NewLine + "- In combination with Discreets@dependencyId attribute." + Environment.NewLine + "- On a table contextMenu Param." + Environment.NewLine + " - All referenced Params then require their RTDisplay tag to be set to true." + Environment.NewLine + "" + Environment.NewLine + "See the guides for more info.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.59.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Discreet@dependencyValues' references a non-existing 'Param' with ID '2'. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreet@dependencyValues attribute can be used in 2 scenarios:" + Environment.NewLine + "- In combination with Discreets@dependencyId attribute." + Environment.NewLine + "- On a table contextMenu Param." + Environment.NewLine + " - All referenced Params then require their RTDisplay tag to be set to true." + Environment.NewLine + "" + Environment.NewLine + "See the guides for more info.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_ReferencedParamExpectingRTDisplay() + { + // Create ErrorMessage + var message = Error.ReferencedParamExpectingRTDisplay(null, null, null, "1002", "999"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.59.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param '1002' referenced in 'Discreet@dependencyValues' attribute. Param ID '999'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreet@dependencyValues attribute can be used in 2 scenarios:" + Environment.NewLine + "- In combination with Discreets@dependencyId attribute." + Environment.NewLine + "- On a table contextMenu Param." + Environment.NewLine + " - All referenced Params then require their RTDisplay tag to be set to true." + Environment.NewLine + "" + Environment.NewLine + "See the guides for more info.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.59.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Discreet@dependencyValues' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Discreet@dependencyValues attribute can be used in 2 scenarios:" + Environment.NewLine + "- In combination with Discreets@dependencyId attribute." + Environment.NewLine + "- On a table contextMenu Param." + Environment.NewLine + " - All referenced Params then require their RTDisplay tag to be set to true." + Environment.NewLine + "" + Environment.NewLine + "See the guides for more info.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDependencyValuesAttribute(); + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDependencyValuesAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDependencyValuesAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..536c6fea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..0905be3e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..0ffacc36 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,27 @@ + + + + + + MyTable_ContextMenu + write + + true + + + discreet + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..ca5ec7f5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,76 @@ + + + + + + MyTable_ContextMenu + write + + true + + + discreet + + + + + + + + + + + + + + MyTable + array + + + + + + + + + true + + + + MyTable_Instance + read + + + + MyTable_Column2 + read + + + + MyTable_Column3 + read + + + + MyTable_Column4 + read + + + + MyTable_Column5 + read + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..6cada0de --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f5bc87c5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDependencyValuesAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,176 @@ + + + + + + DynamicDropDown_Box + + + + + + + + + + + + + + + DynamicDropDown_ListOfValues + + true + + + + + + MyTable_ContextMenu + write + + true + + + discreet + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyTable + array + + + + + + + + + + + + + + + + + + MyTable_Instance + read + + + + MyTable_Column1002 + read + + true + + + + MyTable_Column1003 + read + + true + + + + MyTable_Column1004 + read + + true + + + + MyTable_Column1005 + read + + true + + + + MyTable_Column1006 + read + + true + + + + MyTable_Column1007 + read + + true + + + + MyTable_Column2001 + read + + true + + + + MyTable_Column2002 + read + + true + + + + MyTable_Column2003 + read + + true + + + + MyTable_Column3001 + read + + true + + + + MyTable_Column4001 + read + + true + + + + MyTable_Column5001 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/CheckDiscreetTag.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/CheckDiscreetTag.cs new file mode 100644 index 00000000..f9615581 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/CheckDiscreetTag.cs @@ -0,0 +1,83 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckDiscreetTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckDiscreetTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDiscreetTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDiscreetTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDiscreetTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDiscreetTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "1"); + + string description = "Missing 'Discreet' tag(s) in 'Measurement/Discreets' tag. Param ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDiscreetTag(); + + [TestMethod] + public void Param_CheckDiscreetTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckDiscreetTag_CheckId() => Generic.CheckId(check, CheckId.CheckDiscreetTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..241b7432 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..ee1a6270 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckDiscreetTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,51 @@ + + + + Button + + button + + + BLA + 1 + + + + + + PageButton + + pagebutton + + + New Page... + New Page + + + + + + Discreet_HardCoded + + discreet + + + BLA + 1 + + + ABC + 2 + + + + + + Discreet_Dynamic + + discreet + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..761800d0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,141 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckOptionsAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.CheckOptionsAttribute; + using SLDisValidator2.Common.Extensions; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_EmptyConfirmOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyConfirmOption", + ExpectedResults = new List + { + Error.MisconfiguredConfirmOptions(null, null, null, "199").WithSubResults( + Error.EmptyConfirmOption(null, null, null, "Random", "199"), + Error.EmptyConfirmOption(null, null, null, "Delete all", "199")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MisconfiguredConfirmOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MisconfiguredConfirmOptions", + ExpectedResults = new List + { + Error.MisconfiguredConfirmOptions(null, null, null, "199").WithSubResults( + Error.MissingConfirmOption(null, null, null, "Delete", "199"), + Error.EmptyConfirmOption(null, null, null, "Delete selected item(s)", "199"), + Error.UntrimmedConfirmOption(null, null, null, "Delete all", "199", "All rows will be deleted permanently. ")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingConfirmOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingConfirmOption", + ExpectedResults = new List + { + Error.MisconfiguredConfirmOptions(null, null, null, "199").WithSubResults( + Error.MissingConfirmOption(null, null, null, "Delete all", "199")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UntrimmedConfirmOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedConfirmOption", + ExpectedResults = new List + { + Error.MisconfiguredConfirmOptions(null, null, null, "199").WithSubResults( + Error.UntrimmedConfirmOption(null, null, null, "Random", "199", " My untrimmed confirm message on normal action. "), + + Error.UntrimmedConfirmOption(null, null, null, "Delete all", "199", " My untrimmed confirm message on critical action "), + Error.UntrimmedConfirmOption(null, null, null, "Delete with options before", "199", " My untrimmed confirm message on critical action with other options before "), + Error.UntrimmedConfirmOption(null, null, null, "Delete with options after", "199", " My untrimmed confirm message on critical action with other options after ")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly IRoot codeFix = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckDisplayTag_InvalidPagebuttonCaption() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedConfirmOption", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Codefix/UntrimmedConfirmOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Codefix/UntrimmedConfirmOption.xml new file mode 100644 index 00000000..52bb40b9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Codefix/UntrimmedConfirmOption.xml @@ -0,0 +1,56 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + Random + 10 + + + + Delete all + 20 + + + Delete with options before + 21 + + + Delete with options after + 22 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyConfirmOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyConfirmOption.xml new file mode 100644 index 00000000..ff3d33bd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyConfirmOption.xml @@ -0,0 +1,47 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + Random + 10 + + + Delete all + 20 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MisconfiguredConfirmOptions.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MisconfiguredConfirmOptions.xml new file mode 100644 index 00000000..3c251d6f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MisconfiguredConfirmOptions.xml @@ -0,0 +1,51 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + Delete + 20 + + + Delete selected item(s) + 21 + + + Delete all + 22 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MissingConfirmOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MissingConfirmOption.xml new file mode 100644 index 00000000..86761538 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/MissingConfirmOption.xml @@ -0,0 +1,43 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + Delete all + 21 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedConfirmOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedConfirmOption.xml new file mode 100644 index 00000000..79ce9d1c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedConfirmOption.xml @@ -0,0 +1,56 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + Random + 10 + + + + Delete all + 20 + + + Delete with options before + 21 + + + Delete with options after + 22 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..afb4caf4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,80 @@ + + + + + Table1_ContextMenu + write + + true + + + discreet + + + + Add item... + 1 + + + Duplicate item... + 2 + + + Separator 1 + -1 + + + Edit item... + 10 + + + Separator 2 + -2 + + + Delete selected item(s) + 20 + + + Delete all + 21 + + + + + Depends on Level Access + 31 + + + + + Execute Script + 32 + + + + + + Table1 + Table 1 + array + + + + + true + + + table + + + + Table1_PK + PK (Table 1) + read + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/CheckDisplayTag.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/CheckDisplayTag.cs new file mode 100644 index 00000000..dfed08d1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/CheckDisplayTag.cs @@ -0,0 +1,302 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.Discreet.Display.CheckDisplayTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.Display.CheckDisplayTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "My Discreet", "100").WithSubResults( + Error.DuplicatedValue(null, null, null, "My Discreet", "100"), + Error.DuplicatedValue(null, null, null, "My Discreet", "100")), + + Error.DuplicatedValue(null, null, null, "My Discreet", "101").WithSubResults( + Error.DuplicatedValue(null, null, null, "My Discreet", "101"), + Error.DuplicatedValue(null, null, null, "My discreet", "101")), + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "My discreet", "My Discreet", "101")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), + Error.EmptyTag(null, null, null, "101"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_InvalidPagebuttonCaption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPagebuttonCaption", + ExpectedResults = new List + { + Error.InvalidPagebuttonCaption(null, null, null, "AA...A", "AAA...", "1"), + Error.InvalidPagebuttonCaption(null, null, null, "BBB ...", "BBB...", "2"), + Error.InvalidPagebuttonCaption(null, null, null, " CCC ... ", "CCC...", "3"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", "AAA... "), + Error.UntrimmedTag(null, null, null, "200", " BBB "), + Error.UntrimmedTag(null, null, null, "300", " CCC"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_WrongCasing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "WrongCasing", + ExpectedResults = new List + { + Error.WrongCasing(null, null, null).WithSubResults( + Error.WrongCasing_Sub(null, null, null, "wrong casing", "Wrong Casing", "100")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly IRoot codeFix = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_InvalidPagebuttonCaption() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidPagebuttonCaption", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckDisplayTag_WrongCasing() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "WrongCasing", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckDisplayTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckDisplayTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckDisplayTag_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "1", "100", "Updated", "New_Updated"), + ErrorCompare.UpdatedValue(null, null, "2", "100", "Updated_2", "New_Updated_2"), + ErrorCompare.UpdatedValue(null, null, "3", "100", "ToEmpty", ""), + + ErrorCompare.UpdatedValue(null, null, "aaa", "200", "Updated", "New_Updated"), + ErrorCompare.UpdatedValue(null, null, "bbb", "200", "Updated_2", "New_Updated_2"), + ErrorCompare.UpdatedValue(null, null, "ccc", "200", "ToEmpty", ""), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckDisplayTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'Discreet/Display' in Param '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckDisplayTag_InvalidPagebuttonCaption() + { + // Create ErrorMessage + var message = Error.InvalidPagebuttonCaption(null, null, null, "AAA", "AAA...", "2"); + + string description = "Invalid pagebutton caption format 'AAA'. Suggested fix 'AAA...'. Param ID '2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckDisplayTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "0"); + + string description = "Missing tag 'Discreet/Display' in Param '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckDisplayTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", "1"); + + string description = "Untrimmed tag 'Discreet/Display' in Param '0'. Current value '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDisplayTag(); + + [TestMethod] + public void Param_CheckDisplayTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckDisplayTag_CheckId() => Generic.CheckId(root, CheckId.CheckDisplayTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/InvalidPagebuttonCaption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/InvalidPagebuttonCaption.xml new file mode 100644 index 00000000..94ae4c73 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/InvalidPagebuttonCaption.xml @@ -0,0 +1,34 @@ + + + + + pagebutton + + + AAA... + + + + + + + pagebutton + + + BBB... + + + + + + + pagebutton + + + CCC... + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..68ea7f91 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,38 @@ + + + + + + pagebutton + + + AAA... + + + + + + + + button + + + BBB + + + + + + + + discreet + + + CCC + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml new file mode 100644 index 00000000..8a41bdd5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Codefix/WrongCasing.xml @@ -0,0 +1,17 @@ + + + + + + + + + + Wrong Casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..b083f626 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,44 @@ + + + + + Updated_NumericValues + + + + New_Updated + 1 + + + New_Updated_2 + 2 + + + + 3 + + + + + + Updated_StringValues + + + + New_Updated + aaa + + + New_Updated_2 + bbb + + + + ccc + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..d47a8750 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,44 @@ + + + + + Updated_NumericValues + + + + Updated + 1 + + + Updated_2 + 2 + + + ToEmpty + 3 + + + + + + Updated_StringValues + + + + Updated + aaa + + + Updated_2 + bbb + + + ToEmpty + ccc + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..ef76d321 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,145 @@ + + + + + Same_NoDiscreet + + + + + + + Same_NoDiscreets + + + + + Same_NoMeasurement + + + + Same_1Discreet + + + + Test + + + + + + Same_2Discreets + read + + + + Test2 + 2 + + + Test + 1 + + + + + + Same_From2To3 + + + + Test + 1 + + + Test2 + 2 + + + Test3 + 3 + + + + + + + Same_From2To1 + + + + Test2 + 2 + + + + + + + MeaninglessChanges_Spaces + + + + Trim Before + 1 + + + Trim After + 2 + + + Trim + 3 + + + RemovingSpacesInTheMiddle + 4 + + + Adding Spaces In The Middle + 5 + + + + + + MeaninglessChanges_Casing + + + + My First Test + 1 + + + My Second Test + 2 + + + My Third Test + 3 + + + + + + MeaninglessChanges_AddingPageButtonEllipsis + + + + My first pageButton... + 1 + + + My second pageButton... + 2 + + + My third pageButton... + 3 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..7c10669b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,145 @@ + + + + + Same_NoDiscreet + + + + + + + Same_NoDiscreets + + + + + Same_NoMeasurement + + + + Same_1Discreet + + + + Test + + + + + + Same_2Discreets + read + + + + Test + 1 + + + Test2 + 2 + + + + + + Same_From2To3 + + + + Test + 1 + + + Test2 + 2 + + + + + + + Same_From2To1 + + + + Test + 1 + + + Test2 + 2 + + + + + + + MeaninglessChanges_Spaces + + + + Trim Before + 1 + + + Trim After + 2 + + + Trim + 3 + + + Removing Spaces In The Middle + 4 + + + AddingSpacesInTheMiddle + 5 + + + + + + MeaninglessChanges_Casing + + + + My first test + 1 + + + my Second test + 2 + + + MY THIRD TEST + 3 + + + + + + MeaninglessChanges_AddingPageButtonEllipsis + + + + My first pageButton ... + 1 + + + My second pageButton.. + 2 + + + My third pageButton + 3 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..ededa4a9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,32 @@ + + + + + SameCasing + + + + My Discreet + + + My Discreet + + + + + + DifferentCasing + + + + My Discreet + + + My discreet + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..9c3ca57b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,28 @@ + + + + + Empty + + pagebutton + + + + + + + + + Spaces + + pagebutton + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/InvalidPagebuttonCaption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/InvalidPagebuttonCaption.xml new file mode 100644 index 00000000..355fa9ac --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/InvalidPagebuttonCaption.xml @@ -0,0 +1,34 @@ + + + + + pagebutton + + + AA...A + + + + + + + pagebutton + + + BBB ... + + + + + + + pagebutton + + + CCC ... + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..bce9bd14 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..55b45e1c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,38 @@ + + + + + + pagebutton + + + AAA... + + + + + + + + button + + + BBB + + + + + + + + discreet + + + CCC + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml new file mode 100644 index 00000000..551a7410 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Invalid/WrongCasing.xml @@ -0,0 +1,17 @@ + + + + + + + + + + wrong casing + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..498da035 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Display/CheckDisplayTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,129 @@ + + + + + pagebutton + + pagebutton + + + AAA... + AAA + + + + + + + button_double + + button + + + AAA + 0 + + + + + + button_string + + button + + + AAA + A + + + + + + + discreet_double + + discreet + + + AAA + 0 + + + + + + discreet_string + + discreet + + + AAA + A + + + + + + + string + + string + + + AAA + 0 + + + + + + number + + number + + + AAA + 0 + + + + + + + number + + number + + + Correct Casing + 0 + + + + + + NoTitleCasingNeededFor_ContextMenu + + write + + number + + + Add stream... + 0 + + + Separator 1 + 100 + + + Do something... + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/CheckValueTag.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/CheckValueTag.cs new file mode 100644 index 00000000..2b0a453c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/CheckValueTag.cs @@ -0,0 +1,90 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Discreets.Discreet.Value.CheckValueTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Discreets.Discreet.Value.CheckValueTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckValueTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckValueTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckValueTag_UpdatedValue() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedValue", + ExpectedResults = new List + { + ErrorCompare.UpdatedValue(null, null, "SomeDisplay2", "1", "SomeValue1", "SomeValue3"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay2", "2", "2", "3"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay1", "3", "1", "3"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay3", "3", "3", "1"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay2", "6", "1", "5"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay1", "7", "2", "7"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckValueTag_RemovedItem() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedItem", + ExpectedResults = new List + { + ErrorCompare.RemovedItem(null, null, "SomeValue2", "1"), + ErrorCompare.RemovedItem(null, null, "2", "2"), + ErrorCompare.RemovedItem(null, null, "1", "3"), + ErrorCompare.RemovedItem(null, null, "2", "4"), + ErrorCompare.RemovedItem(null, null, "3", "5"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay2", "5", "2", "4"), + ErrorCompare.UpdatedValue(null, null, "SomeDisplay1", "5", "1", "5"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckValueTag(); + + [TestMethod] + public void Param_CheckValueTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckValueTag_CheckId() => Generic.CheckId(root, CheckId.CheckValueTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_New.xml new file mode 100644 index 00000000..b695f53f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_New.xml @@ -0,0 +1,67 @@ + + + + + discreet + + + SomeDisplay1 + SomeValue1 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + + + + + discreet + + + + + + + discreet + + + SomeDisplay3 + 3 + + + SomeDisplay1 + 1 + + + + + + + discreet + + + NEWDisplay3 + 6 + + + SomeDisplay1 + 5 + + + SomeDisplay2 + 4 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_Old.xml new file mode 100644 index 00000000..198084ca --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/RemovedItem_Old.xml @@ -0,0 +1,94 @@ + + + + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue2 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + + + + + discreet + + + SomeDisplay3 + 3 + + + SomeDisplay2 + 2 + + + SomeDisplay1 + 1 + + + + + + + discreet + + + SomeDisplay3 + 3 + + + SomeDisplay2 + 2 + + + SomeDisplay1 + 1 + + + + + + + discreet + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_New.xml new file mode 100644 index 00000000..505e0623 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_New.xml @@ -0,0 +1,129 @@ + + + + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 3 + + + + + + + discreet + + + SomeDisplay1 + 3 + + + SomeDisplay2 + 2 + + + SomeDisplay3 + 1 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 1 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay1 + 2 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 5 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay1 + 7 + + + SomeDisplay3 + 3 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_Old.xml new file mode 100644 index 00000000..de94f8fd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Invalid/UpdatedValue_Old.xml @@ -0,0 +1,129 @@ + + + + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue1 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 1 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay1 + 2 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 1 + + + SomeDisplay3 + 3 + + + + + + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay1 + 2 + + + SomeDisplay3 + 3 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..530a1064 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,135 @@ + + + + + + Same_Strings + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue2 + + + + + + Same_Numbers + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + Same_NoMeasurement + + + Same_NoDiscreets + + + + + Same_NoDiscreet + + + + + + + + Adding_Strings + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue2 + + + SomeDisplay3 + SomeValue3 + + + + + + Adding_Numbers + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + SomeDisplay3 + 3 + + + + + + + + TypeChange_FromStringToDiscreet + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + + + MeaninglessChanges_Casing + + discreet + + + My First Test + My First Test + + + My Second Test + My Second Test + + + My Third Test + My Third Test + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..662d36a3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Discreets/Discreet/Value/CheckValueTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,125 @@ + + + + + + Same_Strings + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue2 + + + + + + Same_Numbers + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + Same_NoMeasurement + + + Same_NoDiscreets + + + + + Same_NoDiscreet + + + + + + + + Adding_Strings + + discreet + + + SomeDisplay1 + SomeValue1 + + + SomeDisplay2 + SomeValue2 + + + + + + + Adding_Numbers + + discreet + + + SomeDisplay1 + 1 + + + SomeDisplay2 + 2 + + + + + + + + + TypeChange_FromStringToDiscreet + + string + + + + + + MeaninglessChanges_Casing + + discreet + + + My first test + My first test + + + my Second test + my Second test + + + MY THIRD TEST + MY THIRD TEST + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/CheckLinkAttribute.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/CheckLinkAttribute.cs new file mode 100644 index 00000000..9d8bf7e3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/CheckLinkAttribute.cs @@ -0,0 +1,99 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Type.CheckLinkAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Type.CheckLinkAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckLinkAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckLinkAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion Valid Checks + + #region Invalid Checks + + [TestMethod] + public void Param_CheckLinkAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "10000"), + Error.InvalidAttribute(null, null, null, "10001"), + Error.InvalidAttribute(null, null, null, "10002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckLinkAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "10000"), + } + }; + + Generic.Validate(test, data); + } + + #endregion Invalid Checks + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckLinkAttribute(); + + [TestMethod] + public void Param_CheckLinkAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckLinkAttribute(); + + [TestMethod] + public void Param_CheckLinkAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckLinkAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckLinkAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..e73b0d86 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,10 @@ + + + + Matrix + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..777bb0fa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,22 @@ + + + + MatrixNoExtension + + matrix + + + + MatrixBadExtension + + matrix + + + + MatrixEmpty + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..f7107142 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,10 @@ + + + + Matrix + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0610dfe7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckLinkAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,32 @@ + + + + Matrix1 + array + + matrix + + + + Matrix2 + array + + matrix + + + + Matrix3 + array + + matrix + + + + Matrix3 + write + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..f9c4c569 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,350 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Type.CheckOptionsAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Type.CheckOptionsAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidMatrix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidMatrix", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ValidTableSorting() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidTableSorting", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnDimensionsToOutputCount() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnDimensionsToOutputCount", + ExpectedResults = new List + { + Error.InvalidColumnDimensionsToOutputCount(null, null, null, "10000", "31", "32"), + Error.InvalidColumnDimensionsToOutputCount(null, null, null, "10001", "33", "32"), + Error.InvalidColumnDimensionsToOutputCount(null, null, null, "10002", "16", "32"), + Error.InvalidColumnDimensionsToOutputCount(null, null, null, "10003", "31", "32"), + Error.InvalidMatrixDimensionsToInputCount(null, null, null, "10003", "15", "16"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidConnectedMatrixPoints() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidConnectedMatrixPoints", + ExpectedResults = new List + { + Error.InvalidConnectedMatrixPoints(null, null, null, "COMin 17", "minimum", "output", "10001"), + Error.InvalidConnectedMatrixPoints(null, null, null, "COMax 0", "maximum", "output", "10002"), + Error.InvalidConnectedMatrixPoints(null, null, null, "COMax 17", "maximum", "output", "10003"), + Error.InvalidConnectedMatrixPoints(null, null, null, "COMin 11 and COMax 10", "max smaller than min", "output", "10004"), + Error.InvalidConnectedMatrixPoints(null, null, null, "CIMin 33", "minimum", "input", "10011"), + Error.InvalidConnectedMatrixPoints(null, null, null, "CIMax 0", "maximum", "input", "10012"), + Error.InvalidConnectedMatrixPoints(null, null, null, "CIMax 33", "maximum", "input", "10013"), + Error.InvalidConnectedMatrixPoints(null, null, null, "CIMin 22 and CIMax 21", "max smaller than min", "input", "10014"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMatrixDimensionsToInputCount() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidMatrixDimensionsToInputCount", + ExpectedResults = new List + { + Error.InvalidMatrixDimensionsToInputCount(null, null, null, "10000", "15", "16"), + Error.InvalidMatrixDimensionsToInputCount(null, null, null, "10001", "17", "16"), + Error.InvalidMatrixDimensionsToInputCount(null, null, null, "10002", "32", "16"), + Error.InvalidMatrixDimensionsToInputCount(null, null, null, "10003", "15", "16"), + Error.InvalidColumnDimensionsToOutputCount(null, null, null, "10003", "31", "32"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMatrixOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidMatrixOption", + ExpectedResults = new List + { + Error.InvalidMatrixOption(null, null, null, "matrix", "10000"), + Error.InvalidMatrixOption(null, null, null, "matrix", "10001"), + Error.InvalidMatrixOption(null, null, null, "matrix", "10002"), + Error.InvalidMatrixOption(null, null, null, "matrix", "10003"), + Error.InvalidMatrixOption(null, null, null, "matrix", "10004"), + Error.InvalidMatrixOption(null, null, null, "matrix", "20000"), + Error.InvalidMatrixOption(null, null, null, "matrix", "20001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "10000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingMatrixOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingMatrixOption", + ExpectedResults = new List + { + Error.MissingMatrixOption(null, null, null, "matrix", "10000"), + Error.MissingMatrixOption(null, null, null, "matrix", "10001"), + Error.MissingMatrixOption(null, null, null, "matrix", "10002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingPriorityForSortedColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingPriorityForSortedColumns", + ExpectedResults = new List + { + Error.MissingPriorityForSortedColumns(null, null, null, "1000"), + Error.MissingPriorityForSortedColumns(null, null, null, "2000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingSortingOnDateTimeColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingSortingOnDateTimeColumn", + ExpectedResults = new List + { + Error.MissingSortingOnDateTimeColumn(null, null, null, "1000", "1002"), + + Error.MissingSortingOnDateTimeColumn(null, null, null, "1100", "1102, 1104").WithSubResults( + Error.MissingSortingOnDateTimeColumn(null, null, null, "1100", "1102"), + Error.MissingSortingOnDateTimeColumn(null, null, null, "1100", "1104")), + + Error.MissingSortingOnDateTimeColumn(null, null, null, "1200", "1202, 1204").WithSubResults( + Error.MissingSortingOnDateTimeColumn(null, null, null, "1200", "1202"), + Error.MissingSortingOnDateTimeColumn(null, null, null, "1200", "1204")), + + Error.MissingSortingOnDateTimeColumn(null, null, null, "10000", "10002"), + + Error.MissingSortingOnDateTimeColumn(null, null, null, "10100", "10102, 10104").WithSubResults( + Error.MissingSortingOnDateTimeColumn(null, null, null, "10100", "10102"), + Error.MissingSortingOnDateTimeColumn(null, null, null, "10100", "10104")), + + Error.MissingSortingOnDateTimeColumn(null, null, null, "10200", "10202, 10204").WithSubResults( + Error.MissingSortingOnDateTimeColumn(null, null, null, "10200", "10202"), + Error.MissingSortingOnDateTimeColumn(null, null, null, "10200", "10204")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckOptionsAttribute_ReferencedParamRTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamRTDisplayExpected", + ExpectedResults = new List + { + Error.ReferencedParamRTDisplayExpected(null, null, null, "1002", "1000"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMatrixDimensionsToInputCount() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidMatrixDimensionsToInputCount", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnDimensionsToOutputCount() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidColumnDimensionsToOutputCount", + }; + + Generic.Fix(codeFix, data); + } + + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_ColumnOrderChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "ColumnOrderChanged", + ExpectedResults = new List + { + ErrorCompare.ColumnOrderChanged(null, null, "1001-1002-1003", "1000", "1001-1003-1002"), + ErrorCompare.ColumnOrderChanged(null, null, "2001-2002-2003", "2000", "2001-2002"), + ErrorCompare.ColumnOrderChanged(null, null, "3001-3002-3003", "3000", ""), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidColumnDimensionsToOutputCount.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidColumnDimensionsToOutputCount.xml new file mode 100644 index 00000000..fc0b7b5e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidColumnDimensionsToOutputCount.xml @@ -0,0 +1,33 @@ + + + + OutputCountTooLow + array + + matrix + + + + OutputCountTooHigh + array + + matrix + + + + OutputCountTooLow (Mistaken with InputCount) + array + + matrix + + + + InputAndOutputCountTooLow + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidMatrixDimensionsToInputCount.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidMatrixDimensionsToInputCount.xml new file mode 100644 index 00000000..8036ccce --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/InvalidMatrixDimensionsToInputCount.xml @@ -0,0 +1,33 @@ + + + + InputCountTooLow + array + + matrix + + + + InputCountTooHigh + array + + matrix + + + + InputCountTooHigh (Mistaken with outputCount) + array + + matrix + + + + InputAndOutputCountTooLow + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..edf937e1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,10 @@ + + + + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_New.xml new file mode 100644 index 00000000..a8f49e40 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_New.xml @@ -0,0 +1,33 @@ + + + + + Moved last to second + + true + + + table + + + + Removed last column + + true + + + table + + + + Remove all columns + + true + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_Old.xml new file mode 100644 index 00000000..f89821d3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Invalid/ColumnOrderChanged_Old.xml @@ -0,0 +1,33 @@ + + + + + Moved last to second + + true + + + table + + + + Removed last column + + true + + + table + + + + Remove all columns + + true + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..5bd4467e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,77 @@ + + + + + + RTDisplay_NoChange + + true + + + table + + + + + RTDisplay_NoChange_FromImplicitIdxToExplicit + + true + + + table + + + + + RTDisplay_NoColumn + + true + + + + + RTDisplay_NoColumn_OtherOptions + + true + + + number + + + + + RTDisplay_AddingColumns + + true + + + table + + + + RTDisplay_ChangingIdxButSamePID + + + true + + + table + + + + + + NoRTDisplay_OrderChanges + + false + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..f8d75409 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,77 @@ + + + + + + RTDisplay_NoChange + + true + + + table + + + + + RTDisplay_NoChange_FromImplicitIdxToExplicit + + true + + + table + + + + + RTDisplay_NoColumn + + true + + + + + RTDisplay_NoColumn_OtherOptions + + true + + + number + + + + + RTDisplay_AddingColumns + + true + + + table + + + + RTDisplay_ChangingIdxButSamePID + + + true + + + table + + + + + + NoRTDisplay_OrderChanges + + false + + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnDimensionsToOutputCount.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnDimensionsToOutputCount.xml new file mode 100644 index 00000000..b0b1e7b0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnDimensionsToOutputCount.xml @@ -0,0 +1,36 @@ + + + + OutputCountTooLow + array + + + matrix + + + + OutputCountTooHigh + array + + + matrix + + + + OutputCountTooLow (Mistaken with InputCount) + array + + + matrix + + + + InputAndOutputCountTooLow + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidConnectedMatrixPoints.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidConnectedMatrixPoints.xml new file mode 100644 index 00000000..d10a69cb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidConnectedMatrixPoints.xml @@ -0,0 +1,71 @@ + + + + + MatrixCOMinHigherThanTotalRows + array + + + matrix + + + + MatrixCOMaxLowerThan1 + array + + + matrix + + + + MatrixCOMaxHigherThanTotalRows + array + + + matrix + + + + MatrixCOMinHigherThanCOMax + array + + + matrix + + + + + + MatrixCIMinHigherThanTotalColumns + array + + + matrix + + + + MatrixCIMaxLowerthan1 + array + + + matrix + + + + MatrixCIMaxHigherThanTotalColumns + array + + + matrix + + + + MatrixCIMinHigherThanCIMax + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixDimensionsToInputCount.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixDimensionsToInputCount.xml new file mode 100644 index 00000000..7634805c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixDimensionsToInputCount.xml @@ -0,0 +1,36 @@ + + + + InputCountTooLow + array + + + matrix + + + + InputCountTooHigh + array + + + matrix + + + + InputCountTooHigh (Mistaken with outputCount) + array + + + matrix + + + + InputAndOutputCountTooLow + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml new file mode 100644 index 00000000..275016f6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml @@ -0,0 +1,56 @@ + + + + Missing CIMax + + + matrix + + + + pages in wrong first position + + + matrix + + + + pages in wrong middle position + + + matrix + + + + noDisconnectsInBackup wrong position 6 + + + matrix + + + + Something except noDisconnectsInBackup in position 8 + + + matrix + + + + + MatrixCOMinLowerThan0 + array + + + matrix + + + + MatrixCIMinLowerThan0 + array + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..bc464d96 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOption.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOption.xml new file mode 100644 index 00000000..adef55a2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOption.xml @@ -0,0 +1,25 @@ + + + + Matrix_SomeRandomOtherOption + + + matrix + + + + Matrix_MisspelledMatrixOption + + + matrix + + + + Matrix_EmptyOptionAttribute + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingPriorityForSortedColumns.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingPriorityForSortedColumns.xml new file mode 100644 index 00000000..919d15cd --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingPriorityForSortedColumns.xml @@ -0,0 +1,141 @@ + + + + + 2Sorted0PrioTable + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + 2Sorted0PrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + 2Sorted0PrioColumn2 + read + + other + next param + string + + + true + + + string + + + + 2Sorted0PrioColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + + + 2Sorted1PrioTable + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + 2Sorted1PrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + 2Sorted1PrioColumn2 + read + + other + next param + string + + + true + + + string + + + + 2Sorted1PrioColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingSortingOnDateTimeColumn.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingSortingOnDateTimeColumn.xml new file mode 100644 index 00000000..c43f4174 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingSortingOnDateTimeColumn.xml @@ -0,0 +1,486 @@ + + + + + + 1DateTimeNoSorting + array + + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + 1DateTimeNoSortingPrimaryKey + read + + other + next param + string + + + true + + + string + + + + 1DateTimeNoSortingDateTime1 + read + + other + next param + double + + + true + + + number + + + + 1DateTimeNoSortingNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + DateTime1Prio1_NormalPrio0_DateTime2NoPrio + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + DateTime1Prio1_NormalPrio0_DateTime2NoPrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + DateTime1Prio1_NormalPrio0_DateTime2NoPrioDateTime1 + read + + other + next param + double + + + true + + + number + + + + DateTime1Prio1_NormalPrio0_DateTime2NoPrioNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + DateTime1Prio1_NormalPrio0_DateTime2NoPrioDateTime2 + read + + other + next param + double + + + true + + + number + + + + + + DateTime1Prio1_NormalPrio0_DateTime2Prio2 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + DateTime1Prio1_NormalPrio0_DateTime2Prio2PrimaryKey + read + + other + next param + string + + + true + + + string + + + + DateTime1Prio1_NormalPrio0_DateTime2Prio2DateTime1 + read + + other + next param + double + + + true + + + number + + + + DateTime1Prio1_NormalPrio0_DateTime2Prio2Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + DateTime1Prio1_NormalPrio0_DateTime2Prio2DateTime2 + read + + other + next param + double + + + true + + + number + + + + + 1DateNoSorting + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + 1DateNoSortingPrimaryKey + read + + other + next param + string + + + true + + + string + + + + 1DateNoSortingDate1 + read + + other + next param + double + + + true + + + number + + + + 1DateNoSortingNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + Date1Prio1_NormalPrio0_Date2NoPrio + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + Date1Prio1_NormalPrio0_Date2NoPrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + Date1Prio1_NormalPrio0_Date2NoPrioDate1 + read + + other + next param + double + + + true + + + number + + + + Date1Prio1_NormalPrio0_Date2NoPrioNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + Date1Prio1_NormalPrio0_Date2NoPrioDate2 + read + + other + next param + double + + + true + + + number + + + + Date1Prio1_NormalPrio0_Date2Prio2 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + Date1Prio1_NormalPrio0_Date2Prio2PrimaryKey + read + + other + next param + string + + + true + + + string + + + + Date1Prio1_NormalPrio0_Date2Prio2Date1 + read + + other + next param + double + + + true + + + number + + + + Date1Prio1_NormalPrio0_Date2Prio2Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + Date1Prio1_NormalPrio0_Date2Prio2Date2 + read + + other + next param + double + + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml new file mode 100644 index 00000000..86cbc9bf --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamRTDisplayExpected.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d0397610 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,1070 @@ + + + + + Matrix + Matrix + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + Matrix + Matrix + write + + + matrix + + + + + MatrixWithPages + MatrixWithPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithPages + MatrixWithPages + write + + + matrix + + + + + MatrixWithEvenSmallPages + MatrixWithEvenSmallPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithEvenSmallPages + MatrixWithEvenSmallPages + write + + + matrix + + + + + MatrixWithNoDisconnectsAndPages + MatrixWithNoDisconnectsAndPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithNoDisconnectsAndPages + MatrixWithNoDisconnectsAndPages + write + + + matrix + + + + + MatrixWithNoDisconnectsAndEvenSmallPages + MatrixWithNoDisconnectsAndEvenSmallPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithNoDisconnectsAndEvenSmallPages + MatrixWithNoDisconnectsAndEvenSmallPages + write + + + matrix + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml new file mode 100644 index 00000000..b26228a6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml @@ -0,0 +1,1070 @@ + + + + + Matrix + Matrix + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + Matrix + Matrix + write + + + matrix + + + + + MatrixWithPages + MatrixWithPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithPages + MatrixWithPages + write + + + matrix + + + + + MatrixWithEvenSmallPages + MatrixWithEvenSmallPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithEvenSmallPages + MatrixWithEvenSmallPages + write + + + matrix + + + + + MatrixWithNoDisconnectsAndPages + MatrixWithNoDisconnectsAndPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithNoDisconnectsAndPages + MatrixWithNoDisconnectsAndPages + write + + + matrix + + + + + MatrixWithNoDisconnectsAndEvenSmallPages + MatrixWithNoDisconnectsAndEvenSmallPages + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Input 3 + 3 + + + Input 4 + 4 + + + Input 5 + 5 + + + Input 6 + 6 + + + Input 7 + 7 + + + Input 8 + 8 + + + Input 9 + 9 + + + Input 10 + 10 + + + Input 11 + 11 + + + Input 12 + 12 + + + Input 13 + 13 + + + Input 14 + 14 + + + Input 15 + 15 + + + Input 16 + 16 + + + Output 1 + 17 + + + Output 2 + 18 + + + Output 3 + 19 + + + Output 4 + 20 + + + Output 5 + 21 + + + Output 6 + 22 + + + Output 7 + 23 + + + Output 8 + 24 + + + Output 9 + 25 + + + Output 10 + 26 + + + Output 11 + 27 + + + Output 12 + 28 + + + Output 13 + 29 + + + Output 14 + 30 + + + Output 15 + 31 + + + Output 16 + 32 + + + Output 17 + 33 + + + Output 18 + 34 + + + Output 19 + 35 + + + Output 20 + 36 + + + Output 21 + 37 + + + Output 22 + 38 + + + Output 23 + 39 + + + Output 24 + 40 + + + Output 25 + 41 + + + Output 26 + 42 + + + Output 27 + 43 + + + Output 28 + 44 + + + Output 29 + 45 + + + Output 30 + 46 + + + Output 31 + 47 + + + Output 32 + 48 + + + + + + MatrixWithNoDisconnectsAndEvenSmallPages + MatrixWithNoDisconnectsAndEvenSmallPages + write + + + matrix + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidTableSorting.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidTableSorting.xml new file mode 100644 index 00000000..a326b3c5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidTableSorting.xml @@ -0,0 +1,1058 @@ + + + + + + + NoSortedColumn + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + NoSortedColumnPrimaryKey + read + + other + next param + string + + + true + + + string + + + + NoSortedColumn2 + read + + other + next param + string + + + true + + + string + + + + NoSortedColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + + + OneSortedColumn + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneSortedColumnPrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneSortedColumn2 + read + + other + next param + string + + + true + + + string + + + + OneSortedColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + + + TwoSortedColumns + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + TwoSortedColumnsPrimaryKey + read + + other + next param + string + + + true + + + string + + + + TwoSortedColumn2 + read + + other + next param + string + + + true + + + string + + + + TwoSortedColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + + + ThreeSortedColumns + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + ThreeSortedColumnsPrimaryKey + read + + other + next param + string + + + true + + + string + + + + ThreeSortedColumn2 + read + + other + next param + string + + + true + + + string + + + + ThreeSortedColumn3 + read + + numeric text + next param + double + + + true + + + number + + + + + + + OneDateTimeSortedDefaultPrio + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateTimeSortedDefaultPrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateTimeSortedDefaultPrioDateTime1 + read + + other + next param + double + + + true + + + number + + + + OneDateTimeSortedDefaultPrioNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + OneDateTimeSortedPrio0 + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateTimeSortedPrio0PrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateTimeSortedPrio0DateTime1 + read + + other + next param + double + + + true + + + number + + + + OneDateTimeSortedPrio0Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + OneDateTimeSortedPrio0_NormalPrio1 + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateTimeSortedPrio0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateTimeSortedPrio0_NormalPrio1DateTime1 + read + + other + next param + double + + + true + + + number + + + + OneDateTimeSortedPrio0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + TwoDateTimeSortedPrio2_0_NormalPrio1 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + TwoDateTimeSortedPrio2_0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + TwoDateTimeSortedPrio2_0_NormalPrio1DateTime1 + read + + other + next param + double + + + true + + + number + + + + TwoDateTimeSortedPrio2_0_NormalPrio1DateTime2 + read + + other + next param + double + + + true + + + number + + + + TwoDateTimeSortedPrio2_0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + TwoDateTimeSortedPrio0_NormalPrio1 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + TwoDateTimeSortedPrio0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + TwoDateTimeSortedPrio0_NormalPrio1DateTime1 + read + + other + next param + double + + + true + + + number + + + + TwoDateTimeSortedPrio0_NormalPrio1DateTime2 + read + + other + next param + double + + + true + + + number + + + + TwoDateTimeSortedPrio0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + + OneDateSortedDefaultPrio + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateSortedDefaultPrioPrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateSortedDefaultPrioDate1 + read + + other + next param + double + + + true + + + number + + + + OneDateSortedDefaultPrioNormal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + OneDateSortedPrio0 + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateSortedPrio0PrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateSortedPrio0Date1 + read + + other + next param + double + + + true + + + number + + + + OneDateSortedPrio0Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + OneDateSortedPrio0_NormalPrio1 + array + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + OneDateSortedPrio0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + OneDateSortedPrio0_NormalPrio1Date1 + read + + other + next param + double + + + true + + + number + + + + OneDateSortedPrio0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + TwoDateSortedPrio2_0_NormalPrio1 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + TwoDateSortedPrio2_0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + TwoDateSortedPrio2_0_NormalPrio1Date1 + read + + other + next param + double + + + true + + + number + + + + TwoDateSortedPrio2_0_NormalPrio1Date2 + read + + other + next param + double + + + true + + + number + + + + TwoDateSortedPrio2_0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + + TwoDateSortedPrio0_NormalPrio1 + array + + + + + + + + true + + + General + 0 + 0 + + + + + table + + + + TwoDateSortedPrio0_NormalPrio1PrimaryKey + read + + other + next param + string + + + true + + + string + + + + TwoDateSortedPrio0_NormalPrio1Date1 + read + + other + next param + double + + + true + + + number + + + + TwoDateSortedPrio0_NormalPrio1Date2 + read + + other + next param + double + + + true + + + number + + + + TwoDateSortedPrio0_NormalPrio1Normal1 + read + + numeric text + next param + double + + + true + + + number + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..1044062d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,525 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Type.CheckTypeTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Type.CheckTypeTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion Valid Checks + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidParamType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidParamType", + ExpectedResults = new List + { + Error.InvalidParamType(null, null, null, "dummy", "button", "1"), + Error.InvalidParamType(null, null, null, "read", "button", "2"), + + Error.InvalidParamType(null, null, null, "dummy", "pagebutton", "51"), + Error.InvalidParamType(null, null, null, "read", "pagebutton", "52"), + + Error.InvalidParamType(null, null, null, "dummy", "togglebutton", "101"), + Error.InvalidParamType(null, null, null, "read", "togglebutton", "102"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, " ABC ", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixAlarmingDisabled() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixAlarmingDisabled", + ExpectedResults = new List + { + Error.MatrixAlarmingDisabled(null, null, null, "10000"), + Error.MatrixAlarmingDisabled(null, null, null, "10001"), + Error.MatrixAlarmingDisabled(null, null, null, "10002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterprete() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixInvalidInterprete", + ExpectedResults = new List + { + Error.MatrixInvalidInterprete(null, null, null, "100").WithSubResults( + Error.MatrixInvalidInterpreteRawType(null, null, null, "numeric text", "100", false), + Error.MatrixInvalidInterpreteType(null, null, null, "high nibble", "100", "double", false)), + Error.MatrixInvalidInterprete(null, null, null, "101").WithSubResults( + Error.MatrixInvalidInterpreteRawType(null, null, null, "", "101", false), + Error.MatrixInvalidInterpreteType(null, null, null, "", "101", "double", false), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "", "101", false)) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteLengthType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixInvalidInterpreteLengthType", + ExpectedResults = new List + { + Error.MatrixInvalidInterpreteLengthType(null, null, null, "", "9000", true), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "", "9001", true), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "fixed", "10000", true), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "fixed", "10001", true), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "other param", "10002", true), + Error.MatrixInvalidInterpreteLengthType(null, null, null, "other param", "10003", true), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteRawType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixInvalidInterpreteRawType", + ExpectedResults = new List + { + Error.MatrixInvalidInterpreteRawType(null, null, null, "", "9000", true), + Error.MatrixInvalidInterpreteRawType(null, null, null, "", "9001", true), + Error.MatrixInvalidInterpreteRawType(null, null, null, "numeric text", "10000", true), + Error.MatrixInvalidInterpreteRawType(null, null, null, "numeric text", "10001", true), + Error.MatrixInvalidInterpreteRawType(null, null, null, "text", "10002", true), + Error.MatrixInvalidInterpreteRawType(null, null, null, "text", "10003", true), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixInvalidInterpreteType", + ExpectedResults = new List + { + Error.MatrixInvalidInterpreteType(null, null, null, "", "9000", "double", true), + Error.MatrixInvalidInterpreteType(null, null, null, "", "9001", "string", true), + Error.MatrixInvalidInterpreteType(null, null, null, "string", "10000", "double", true), + Error.MatrixInvalidInterpreteType(null, null, null, "high nibble", "10002", "double", true), + Error.MatrixInvalidInterpreteType(null, null, null, "high nibble", "10003", "string", true), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixSetterOnWrite() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixSetterOnWrite", + ExpectedResults = new List + { + Error.MatrixSetterOnWrite(null, null, null, "10001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixTrendingEnabled() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MatrixTrendingEnabled", + ExpectedResults = new List + { + Error.MatrixTrendingEnabled(null, null, null, "10000"), + Error.MatrixTrendingEnabled(null, null, null, "10001"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_TogglebuttonRecommended() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "TogglebuttonRecommended", + ExpectedResults = new List + { + Error.TogglebuttonRecommended(null, null, null, "200"), // Write param + Error.TogglebuttonRecommended(null, null, null, "1011"), // WriteBit param + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " pagebutton "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_TogglebuttonRecommended() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "TogglebuttonRecommended", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixAlarmingDisabled() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixAlarmingDisabled", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterprete() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixInvalidInterprete", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteLengthType() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixInvalidInterpreteLengthType", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteRawType() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixInvalidInterpreteRawType", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteType() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixInvalidInterpreteType", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixSetterOnWrite() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixSetterOnWrite", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixTrendingEnabled() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MatrixTrendingEnabled", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckTypeTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'Measurement/Type' in Param '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidParamType() + { + // Create ErrorMessage + var message = Error.InvalidParamType(null, null, null, "read", "button", "2"); + + string description = "Invalid value 'read' in 'Param/Type' for 'button'. Param ID '2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "0", "1"); + + string description = "Invalid value '0' in tag 'Measurement/Type'. Param ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixAlarmingDisabled() + { + // Create ErrorMessage + var message = Error.MatrixAlarmingDisabled(null, null, null, "0"); + + string description = "Matrix Param '0' should be alarmed."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterprete() + { + // Create ErrorMessage + var message = Error.MatrixInvalidInterprete(null, null, null, "0"); + + string description = "Invalid Interprete for matrix Param '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteLengthType() + { + // Create ErrorMessage + var message = Error.MatrixInvalidInterpreteLengthType(null, null, null, "0", "1", false); + + string description = "Invalid LengthType '0' for matrix Param '1'. Expected LengthType 'next param'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteRawType() + { + // Create ErrorMessage + var message = Error.MatrixInvalidInterpreteRawType(null, null, null, "0", "1", false); + + string description = "Invalid RawType '0' for matrix Param '1'. Expected RawType 'other'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixInvalidInterpreteType() + { + // Create ErrorMessage + var message = Error.MatrixInvalidInterpreteType(null, null, null, "0", "1", "2", false); + + string description = "Invalid Interprete/Type '0' for matrix Param '1'. Expected Type '2'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixSetterOnWrite() + { + // Create ErrorMessage + var message = Error.MatrixSetterOnWrite(null, null, null, "0"); + + string description = "Unsupported attribute 'setter' in Matrix '0'. Current value 'true'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_MatrixTrendingEnabled() + { + // Create ErrorMessage + var message = Error.MatrixTrendingEnabled(null, null, null, "0"); + + string description = "Matrix Param '0' should not be trended."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_TogglebuttonRecommended() + { + // Create ErrorMessage + var message = Error.TogglebuttonRecommended(null, null, null, "1"); + + string description = "Measurement/Type 'togglebutton' is recommended for Param with ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", "1"); + + string description = "Untrimmed tag 'Measurement/Type' in Param '0'. Current value '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckTypeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixAlarmingDisabled.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixAlarmingDisabled.xml new file mode 100644 index 00000000..bdbe4a75 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixAlarmingDisabled.xml @@ -0,0 +1,52 @@ + + + + Matrix MonitoredFalse + Matrix MonitoredFalse + array + + other + next param + double + + + true + + + matrix + + + + Matrix NoAlarm + Matrix NoAlarm + array + + other + next param + double + + + true + + + matrix + + + + Matrix NoMonitored + Matrix NoMonitored + array + + other + next param + double + + + true + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterprete.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterprete.xml new file mode 100644 index 00000000..4e328114 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterprete.xml @@ -0,0 +1,36 @@ + + + + Matrix_Invalid_RawType_Type + Matrix Missing Type + array + + other + next param + double + + + true + + + matrix + + + + Matrix_MissingInterprete + Matrix Missing Interprete + array + + other + next param + double + + + true + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteLengthType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteLengthType.xml new file mode 100644 index 00000000..05bc6a87 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteLengthType.xml @@ -0,0 +1,121 @@ + + + + Matrix Missing LengthType + Matrix Missing LengthType + array + + other + next param + double + + + true + + + matrix + + + + Matrix Missing LengthType + Matrix Missing LengthType + write + + other + next param + string + + + matrix + + + + + Matrix LengthType Fixed + Matrix LengthType Fixed + array + + other + next param + double + + + true + + + matrix + + + + Matrix LengthType Fixed + Matrix LengthType Fixed + write + + other + next param + string + + + matrix + + + + + Matrix LengthType OtherParam + Matrix LengthType OtherParam + array + + other + next param + double + + + true + + + matrix + + + + Matrix LengthType OtherParam + Matrix LengthType OtherParam + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteRawType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteRawType.xml new file mode 100644 index 00000000..e05eb7a6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteRawType.xml @@ -0,0 +1,122 @@ + + + + Matrix Missing RawType + Matrix Missing RawType + array + + other + next param + double + + + true + + + matrix + + + + Matrix Missing RawType + Matrix Missing RawType + write + + other + next param + string + + + matrix + + + + + + Matrix RawType NumericText + Matrix RawType NumericText + array + + other + next param + double + + + true + + + matrix + + + + Matrix RawType NumericText + Matrix RawType NumericText + write + + other + next param + string + + + matrix + + + + + Matrix RawType Text + Matrix RawType Text + array + + other + next param + double + + + true + + + matrix + + + + Matrix RawType Text + Matrix RawType Text + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteType.xml new file mode 100644 index 00000000..7b76808f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixInvalidInterpreteType.xml @@ -0,0 +1,92 @@ + + + + Matrix Missing Type + Matrix Missing Type + array + + other + next param + double + + + true + + + matrix + + + + Matrix Missing Type + Matrix Missing Type + write + + other + next param + string + + + matrix + + + + + Matrix Type String + Matrix Type String + array + + other + next param + double + + + true + + + matrix + + + + Matrix Type String + Matrix Type String + write + + other + next param + string + + + matrix + + + + Matrix Type HighNibble + Matrix Type HighNibble + array + + other + next param + double + + + true + + + matrix + + + + Matrix Type HighNibble + Matrix Type HighNibble + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixSetterOnWrite.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixSetterOnWrite.xml new file mode 100644 index 00000000..efe7c584 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixSetterOnWrite.xml @@ -0,0 +1,33 @@ + + + + Matrix setter true + Matrix setter true + array + + other + next param + double + + + true + + + matrix + + + + Matrix setter true + Matrix setter true + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixTrendingEnabled.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixTrendingEnabled.xml new file mode 100644 index 00000000..2bcfd22f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/MatrixTrendingEnabled.xml @@ -0,0 +1,33 @@ + + + + Matrix trending true + Matrix trending true + array + + other + next param + double + + + true + + + matrix + + + + Matrix trending true + Matrix trending true + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/TogglebuttonRecommended.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/TogglebuttonRecommended.xml new file mode 100644 index 00000000..520e29fe --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/TogglebuttonRecommended.xml @@ -0,0 +1,85 @@ + + + + + ReadWrite_Discreet + read + + discreet + + + Off + 0 + + + On + 1 + + + + + + ReadWrite_Discreet + write + + togglebutton + + + Off + 0 + + + On + 1 + + + + + + + Group_Read + group + + + Group_Write + group + + + Group_ReadWriteBit + Group_ReadWriteBit + read bit + + discreet + + + Off + 0 + + + On + 1 + + + + + + Group_ReadWriteBit + Group_ReadWriteBit + write bit + + togglebutton + + + Off + 0 + + + On + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..f01e2595 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,10 @@ + + + + write + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..2cc932c9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidParamType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidParamType.xml new file mode 100644 index 00000000..93c5c4ca --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidParamType.xml @@ -0,0 +1,53 @@ + + + + + + + button_dummy + dummy + + button + + + + button_read + read + + button + + + + + + pagebutton_dummy + dummy + + pagebutton + + + + pagebutton_read + read + + pagebutton + + + + + + togglebutton_dummy + dummy + + togglebutton + + + + togglebutton_read + read + + togglebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..0b14cbbf --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,9 @@ + + + + + ABC + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixAlarmingDisabled.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixAlarmingDisabled.xml new file mode 100644 index 00000000..0d8d144d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixAlarmingDisabled.xml @@ -0,0 +1,47 @@ + + + + Matrix MonitoredFalse + Matrix MonitoredFalse + array + + other + next param + double + + + false + + + matrix + + + + Matrix NoAlarm + Matrix NoAlarm + array + + other + next param + double + + + matrix + + + + Matrix NoMonitored + Matrix NoMonitored + array + + other + next param + double + + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterprete.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterprete.xml new file mode 100644 index 00000000..27cc20b6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterprete.xml @@ -0,0 +1,31 @@ + + + + Matrix_Invalid_RawType_Type + Matrix Missing Type + array + + numeric text + high nibble + next param + + + true + + + matrix + + + + Matrix_MissingInterprete + Matrix Missing Interprete + array + + true + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteLengthType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteLengthType.xml new file mode 100644 index 00000000..a921a563 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteLengthType.xml @@ -0,0 +1,93 @@ + + + + Matrix Missing LengthType + Matrix Missing LengthType + array + + other + double + + + true + + + matrix + + + + Matrix Missing LengthType + Matrix Missing LengthType + write + + other + string + + + matrix + + + + + Matrix LengthType Fixed + Matrix LengthType Fixed + array + + other + fixed + 10 + double + + + true + + + matrix + + + + Matrix LengthType Fixed + Matrix LengthType Fixed + write + + other + fixed + 10 + string + + + matrix + + + + + Matrix LengthType OtherParam + Matrix LengthType OtherParam + array + + other + other param + double + + + true + + + matrix + + + + Matrix LengthType OtherParam + Matrix LengthType OtherParam + write + + other + other param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteRawType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteRawType.xml new file mode 100644 index 00000000..865cca7c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteRawType.xml @@ -0,0 +1,91 @@ + + + + Matrix Missing RawType + Matrix Missing RawType + array + + next param + double + + + true + + + matrix + + + + Matrix Missing RawType + Matrix Missing RawType + write + + next param + string + + + matrix + + + + + Matrix RawType NumericText + Matrix RawType NumericText + array + + numeric text + next param + double + + + true + + + matrix + + + + Matrix RawType NumericText + Matrix RawType NumericText + write + + numeric text + next param + string + + + matrix + + + + + Matrix RawType Text + Matrix RawType Text + array + + text + next param + double + + + true + + + matrix + + + + Matrix RawType Text + Matrix RawType Text + write + + text + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteType.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteType.xml new file mode 100644 index 00000000..ffe1e90b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixInvalidInterpreteType.xml @@ -0,0 +1,90 @@ + + + + Matrix Missing Type + Matrix Missing Type + array + + other + next param + + + true + + + matrix + + + + Matrix Missing Type + Matrix Missing Type + write + + other + next param + + + matrix + + + + + Matrix Type String + Matrix Type String + array + + other + next param + string + + + true + + + matrix + + + + Matrix Type String + Matrix Type String + write + + other + next param + string + + + matrix + + + + Matrix Type HighNibble + Matrix Type HighNibble + array + + other + next param + high nibble + + + true + + + matrix + + + + Matrix Type HighNibble + Matrix Type HighNibble + write + + other + next param + high nibble + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixSetterOnWrite.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixSetterOnWrite.xml new file mode 100644 index 00000000..d4848cb6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixSetterOnWrite.xml @@ -0,0 +1,33 @@ + + + + Matrix setter true + Matrix setter true + array + + other + next param + double + + + true + + + matrix + + + + Matrix setter true + Matrix setter true + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixTrendingEnabled.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixTrendingEnabled.xml new file mode 100644 index 00000000..8b044769 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/MatrixTrendingEnabled.xml @@ -0,0 +1,33 @@ + + + + Matrix trending true + Matrix trending true + array + + other + next param + double + + + true + + + matrix + + + + Matrix trending true + Matrix trending true + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/TogglebuttonRecommended.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/TogglebuttonRecommended.xml new file mode 100644 index 00000000..625908c6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/TogglebuttonRecommended.xml @@ -0,0 +1,85 @@ + + + + + ReadWrite_Discreet + read + + discreet + + + Off + 0 + + + On + 1 + + + + + + ReadWrite_Discreet + write + + discreet + + + Off + 0 + + + On + 1 + + + + + + + Group_Read + group + + + Group_Write + group + + + Group_ReadWriteBit + Group_ReadWriteBit + read bit + + discreet + + + Off + 0 + + + On + 1 + + + + + + Group_ReadWriteBit + Group_ReadWriteBit + write bit + + discreet + + + Off + 0 + + + On + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..23f033ae --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,10 @@ + + + + write + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f07146f3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,259 @@ + + + + + Standalone ReadOnly Discreet + read + + discreet + + + Off + 0 + + + On + 1 + + + + + + Standalone ReadOnly String + read + + string + + + + + + Standalone WriteOnly Button + write + + button + + + Off + 0 + + + On + 1 + + + + + + Standalone WriteOnly Discreet RandomValues + write + + discreet + + + RandomDisplayA + 0 + + + RandomDisplayB + 1 + + + + + + Standalone WriteOnly Discreet ToggleValues + write + + discreet + + + Disable + 0 + + + Enable + 1 + + + + + + + + Standalone ReadWrite ToggleButton + read + + discreet + + + Off + 0 + + + On + 1 + + + + + + Standalone ReadWrite ToggleButton + write + + togglebutton + + + Off + 0 + + + On + 1 + + + + + + Standalone ReadWrite Discreet + read + + discreet + + + RandomDisplayA + 0 + + + RandomDisplayB + 1 + + + + + + Standalone ReadWrite Discreet + write + + discreet + + + RandomDisplayA + 0 + + + RandomDisplayB + 1 + + + + + + + Group_Read + group + + + Group_Write + group + + + Group_ReadWriteBit + Group_ReadWriteBit + read bit + + discreet + + + Off + 0 + + + On + 1 + + + + + + Group_ReadWriteBit + Group_ReadWriteBit + write bit + + togglebutton + + + Off + 0 + + + On + 1 + + + + + + + + + Matrix NoTrending NoSetter + Matrix NoTrending NoSetter + array + + other + next param + double + + + true + + + matrix + + + + Matrix NoTrending NoSetter + Matrix NoTrending NoSetter + write + + other + next param + string + + + matrix + + + + + Matrix TrendingFalse SetterFalse + Matrix TrendingFalse SetterFalse + array + + other + next param + double + + + true + + + matrix + + + + Matrix TrendingFalse SetterFalse + Matrix TrendingFalse SetterFalse + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/CheckWidthAttribute.cs b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/CheckWidthAttribute.cs new file mode 100644 index 00000000..3ed8150f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/CheckWidthAttribute.cs @@ -0,0 +1,235 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Measurement.Type.CheckWidthAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Measurement.Type.CheckWidthAttribute; + using SLDisValidator2.Common.Extensions; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckWidthAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckWidthAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion Valid Checks + + #region Invalid Checks + + [TestMethod] + public void Param_CheckWidthAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_EmptyWidth() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyWidth", + ExpectedResults = new List + { + Error.EmptyWidth(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_UntrimmedWidth() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedWidth", + ExpectedResults = new List + { + Error.UntrimmedWidth(null, null, null, " 110 ", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_InvalidWidth() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidWidth", + ExpectedResults = new List + { + Error.InvalidWidth(null, null, null, "z", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_UnrecommendedWidth() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedWidth", + ExpectedResults = new List + { + Error.UnrecommendedWidth(null, null, null, "50", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_InconsistentWidth() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InconsistentWidth", + ExpectedResults = new List + { + Error.InconsistentWidth(null, null, null, "General", "1, 2", "110, 140", true).WithSubResults( + Error.InconsistentWidth(null, null, null, "General", "1", "110", false), + Error.InconsistentWidth(null, null, null, "General", "2", "140", false)) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_UnsupportedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedAttribute", + ExpectedResults = new List + { + Error.UnsupportedAttribute(null, null, null, "Discreet", "1"), + } + }; + + Generic.Validate(test, data); + } + + #endregion Invalid Checks + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckWidthAttribute(); + + [TestMethod] + public void Param_CheckWidthAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_EmptyWidth() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyWidth", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_UntrimmedWidth() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedWidth", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_InvalidWidth() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidWidth", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_UnrecommendedWidth() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedWidth", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckWidthAttribute_InconsistentWidth() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InconsistentWidth", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckWidthAttribute(); + + [TestMethod] + public void Param_CheckWidthAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckWidthAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckWidthAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/EmptyWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/EmptyWidth.xml new file mode 100644 index 00000000..f5dd82ee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/EmptyWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InconsistentWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InconsistentWidth.xml new file mode 100644 index 00000000..0b50237f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InconsistentWidth.xml @@ -0,0 +1,30 @@ + + + + + true + + + General + + + + + button + + + + + true + + + General + + + + + button + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InvalidWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InvalidWidth.xml new file mode 100644 index 00000000..f5dd82ee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/InvalidWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..eb649f85 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UnrecommendedWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UnrecommendedWidth.xml new file mode 100644 index 00000000..73b506f8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UnrecommendedWidth.xml @@ -0,0 +1,9 @@ + + + + + button + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UntrimmedWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UntrimmedWidth.xml new file mode 100644 index 00000000..a19546b3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Codefix/UntrimmedWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + Interface + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/EmptyWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/EmptyWidth.xml new file mode 100644 index 00000000..1ce28ce6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/EmptyWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InconsistentWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InconsistentWidth.xml new file mode 100644 index 00000000..376e699b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InconsistentWidth.xml @@ -0,0 +1,30 @@ + + + + + true + + + General + + + + + button + + + + + true + + + General + + + + + button + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InvalidWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InvalidWidth.xml new file mode 100644 index 00000000..9804022f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/InvalidWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..c4454d3b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnrecommendedWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnrecommendedWidth.xml new file mode 100644 index 00000000..9ece9958 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnrecommendedWidth.xml @@ -0,0 +1,9 @@ + + + + + button + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnsupportedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnsupportedAttribute.xml new file mode 100644 index 00000000..7c87291b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UnsupportedAttribute.xml @@ -0,0 +1,17 @@ + + + + + true + + + General + + + + + discreet + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UntrimmedWidth.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UntrimmedWidth.xml new file mode 100644 index 00000000..1a22c881 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Invalid/UntrimmedWidth.xml @@ -0,0 +1,17 @@ + + + + + true + + + Interface + + + + + pagebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..04733dac --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Measurement/Type/CheckWidthAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,114 @@ + + + + + + true + + + General + + + + + pagebutton + + + + + true + + + General + + + + + pagebutton + + + + + true + + + Interfaces + + + + + button + + + + + true + + + Cards + + + + + button + + + + + + + analog + + + + + chart + + + + + digital threshold + + + + + discreet + + + + + matrix + + + + + number + + + + + progress + + + + + string + + + + + table + + + + + title + + + + + togglebutton + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/CheckMessageTag.cs b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/CheckMessageTag.cs new file mode 100644 index 00000000..351e6862 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/CheckMessageTag.cs @@ -0,0 +1,83 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Message.CheckMessageTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Message.CheckMessageTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckMessageTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckMessageTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckMessageTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + // No Confirm Pop-up + Error.MissingTag(null, null, null, "100").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Reboot")), + Error.MissingTag(null, null, null, "101").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Shutdown")), + Error.MissingTag(null, null, null, "102").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Reboot"), + Error.MissingTag_Sub(null, null, null, "Shutdown")), + Error.MissingTag(null, null, null, "103").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Reboot")), + + // Confirm Pop-up != always + Error.MissingTag(null, null, null, "1000").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Reboot")), + Error.MissingTag(null, null, null, "1001").WithSubResults( + Error.MissingTag_Sub(null, null, null, "Reboot")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckMessageTag(); + + [TestMethod] + public void Param_CheckMessageTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckMessageTag_CheckId() => Generic.CheckId(check, CheckId.CheckMessageTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..de2b08df --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,88 @@ + + + + + MissingMessage_RebootButton + + button + + + Reboot + 1 + + + + + + MissingMessage_ShutdownButton + + button + + + Shutdown + 2 + + + + + + MissingMessage_RebootAndShutdownButtons + + button + + + Reboot + 1 + + + Shutdown + 2 + + + + + + MissingMessage_RebootAndRandomButtons + + button + + + Reboot + 1 + + + Random + 2 + + + + + + + + MissingMessage_ConfirmPopupNever + + button + + + Reboot + 1 + + + + + + MissingMessage_ConfirmPopupDM + + button + + + Reboot + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..de60d3d5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Message/CheckMessageTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,168 @@ + + + + + + Message_RebootButton + Are you sure you want to do this? + + button + + + Reboot + 1 + + + + + + Message_Shutdown_Button + Are you sure you want to do this? + + button + + + Shutdown + 2 + + + + + + Message_RebootAndShutdownButtons + Are you sure you want to do this? + + button + + + Reboot + 1 + + + Shutdown + 2 + + + + + + Message_RebootAndRandomButtons + Are you sure you want to do this? + + button + + + Reboot + 1 + + + Something + 2 + + + + + + Message_RebootSmthButton + Are you sure you want to do this? + + button + + + RebootSmth + 1 + + + + + + Message_SmthRebootButton + Are you sure you want to do this? + + button + + + SmthReboot + 1 + + + + + + + Message_RandomButton + Are you sure you want to do this? + + button + + + Something + 1 + + + + + + Message_RandomButtons + Are you sure you want to do this? + + button + + + Something + 1 + + + Something else + 2 + + + + + + + + NoMessage_RandomButton + + button + + + Something + 1 + + + + + + NoMessage_RandomButtons + + button + + + Something + 1 + + + Something else + 2 + + + + + + + + NoMessage_ButConfirmPopupAttribute + + button + + + Reboot + 1 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/CheckColumnNames.cs b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/CheckColumnNames.cs new file mode 100644 index 00000000..c725ea36 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/CheckColumnNames.cs @@ -0,0 +1,149 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Name.CheckColumnNames +{ + using System; + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Name.CheckColumnNames; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckColumnNames(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckColumnNames_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTableNameAsPrefix", + ExpectedResults = new List + { + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax1", "Instance1", "101").WithExtraData(ExtraData.TableName, "TableSyntax1"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax2", "Instance2", "201").WithExtraData(ExtraData.TableName, "TableSyntax2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefixes() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTableNameAsPrefixes", + ExpectedResults = new List + { + Error.MissingTableNameAsPrefixes(null, null, null, "TableSyntax1", "100").WithSubResults( + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax1", "Instance_1", "101").WithExtraData(ExtraData.TableName, "TableSyntax1"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax1", "Column2_1", "102").WithExtraData(ExtraData.TableName, "TableSyntax1"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax1", "Column3_1", "103").WithExtraData(ExtraData.TableName, "TableSyntax1"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax1", "Column3_1", "153").WithExtraData(ExtraData.TableName, "TableSyntax1")), + + Error.MissingTableNameAsPrefixes(null, null, null, "TableSyntax2", "200").WithSubResults( + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax2", "Instance_2", "201").WithExtraData(ExtraData.TableName, "TableSyntax2"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax2", "Column2_2", "202").WithExtraData(ExtraData.TableName, "TableSyntax3"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax2", "Column3_2", "203").WithExtraData(ExtraData.TableName, "TableSyntax3"), + Error.MissingTableNameAsPrefix(null, null, null, "TableSyntax2", "Column3_2", "253").WithExtraData(ExtraData.TableName, "TableSyntax3")), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckColumnNames(); + + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefix() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingTableNameAsPrefix", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefixes() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingTableNameAsPrefixes", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefix() + { + // Create ErrorMessage + var message = Error.MissingTableNameAsPrefix(null, null, null, "Inputs", "Instance", "102"); + + string description = "Missing table name 'Inputs' in front of column name 'Instance'. Column PID '102'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Param_CheckColumnNames_MissingTableNameAsPrefixes() + { + // Create ErrorMessage + var message = Error.MissingTableNameAsPrefixes(null, null, null, "Inputs", "100"); + + string description = "Missing table name 'Inputs' in front of column names. Table PID '100'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckColumnNames(); + + [TestMethod] + public void Param_CheckColumnNames_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckColumnNames_CheckId() => Generic.CheckId(check, CheckId.CheckColumnNames); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefix.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefix.xml new file mode 100644 index 00000000..19a2c94e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefix.xml @@ -0,0 +1,28 @@ + + + + + TableSyntax1 + array + + + + + TableSyntax1Instance1 + read + + + + TableSyntax2 + array + + + + + + TableSyntax2Instance2 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefixes.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefixes.xml new file mode 100644 index 00000000..13cae5ee --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Codefix/MissingTableNameAsPrefixes.xml @@ -0,0 +1,54 @@ + + + + + TableSyntax1 + array + + + + + TableSyntax1Instance_1 + read + + + TableSyntax1Column2_1 + read + + + TableSyntax1Column3_1 + read + + + TableSyntax1Column3_1 + write + + + + TableSyntax2 + array + + + + + + + + TableSyntax2Instance_2 + read + + + TableSyntax2Column2_2 + read + + + TableSyntax2Column3_2 + read + + + TableSyntax2Column3_2 + write + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefix.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefix.xml new file mode 100644 index 00000000..cd40bb0f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefix.xml @@ -0,0 +1,28 @@ + + + + + TableSyntax1 + array + + + + + Instance1 + read + + + + TableSyntax2 + array + + + + + + Instance2 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefixes.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefixes.xml new file mode 100644 index 00000000..169bd985 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Invalid/MissingTableNameAsPrefixes.xml @@ -0,0 +1,54 @@ + + + + + TableSyntax1 + array + + + + + Instance_1 + read + + + Column2_1 + read + + + Column3_1 + read + + + Column3_1 + write + + + + TableSyntax2 + array + + + + + + + + Instance_2 + read + + + Column2_2 + read + + + Column3_2 + read + + + Column3_2 + write + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e8b94cdb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckColumnNames/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,169 @@ + + + + + + MyTests + array + + + + + + + + + + MyTestsInstance + + + MyTests Column2 + + + MyTests_Column3 + + + MyTestsTable Column4 + + + MyTestsTable_Column5 + + + + + MyTestsTable + array + + + + + + + + + + MyTestsInstance + + + MyTests Column2 + + + MyTests_Column3 + + + MyTestsTable Column4 + + + MyTestsTable_Column5 + + + + MyTests Table + array + + + + + + + + + + MyTestsInstance + + + MyTests Column2 + + + MyTests_Column3 + + + MyTestsTable Column4 + + + MyTestsTable_Column5 + + + + My Tests Table + array + + + + + + + + + + + + My TestsInstance + + + My Tests Column2 + + + My Tests_Column3 + + + My TestsTable Column4 + + + My TestsTable_Column5 + + + My Tests Table Column6 + + + My Tests Table_Column7 + + + + TableSyntax1 + array + + + + + TableSyntax1_Instance + + + TableSyntax1_Column2 + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + + + TableSyntax2_Column2 + + + + + MyViewTable + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..d36b813a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,406 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Name.CheckNameTag +{ + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Name.CheckNameTag; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckNameTag(); + + #region Valid + + [TestMethod] + public void Param_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid + + [TestMethod] + public void Param_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "SameName", "100, 150, 101").WithSubResults( + Error.DuplicatedValue(null, null, null, "SameName", "100"), + Error.DuplicatedValue(null, null, null, "SameName", "150"), + Error.DuplicatedValue(null, null, null, "SameName", "101")), + Error.DuplicatedValue(null, null, null, "SameName3", "200, 201").WithSubResults( + Error.DuplicatedValue(null, null, null, "SameName3", "200"), + Error.DuplicatedValue(null, null, null, "SameName3", "201")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + // DuplicatedValue not really necessary here as EmptyTag is already a critical error + //Error.DuplicatedValue(null, null, null, "", "1, 2").WithSubResults(new List + //{ + // Error.DuplicatedValue(null, null, null, "", "1"), + // Error.DuplicatedValue(null, null, null, "", "2"), + //}), + + Error.EmptyTag(null, null, null, "10"), + Error.EmptyTag(null, null, null, "11"), + // DuplicatedValue not really necessary here as EmptyTag is already a critical error + //Error.DuplicatedValue(null, null, null, " ", "10, 11").WithSubResults(new List + //{ + // Error.DuplicatedValue(null, null, null, " ", "10"), + // Error.DuplicatedValue(null, null, null, " ", "11"), + //}), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Currently there aren't any invalid characters.")] + public void Param_CheckNameTag_InvalidChars() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidChars", + ExpectedResults = new List + { + // There are currently no invalid char + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + Error.MissingTag(null, null, null, "2"), + // DuplicatedValue not really necessary here as MissingTag is already a critical error + //Error.DuplicatedValue(null, null, null, "", "1, 2").WithSubResults(new List + //{ + // Error.DuplicatedValue(null, null, null, "", "1"), + // Error.DuplicatedValue(null, null, null, "", "2"), + //}), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_RestrictedName() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RestrictedName", + ExpectedResults = new List + { + Error.RestrictedName(null, null, null, "1", "__StartingWithTwoUnderscores"), + Error.RestrictedName(null, null, null, "2", "__StartingWithTwoUnderscores"), + // DuplicatedValue not really necessary here as MissingTag is already a critical error + //Error.DuplicatedValue(null, null, null, "__StartingWithTwoUnderscores", "1, 2").WithSubResults(new List + //{ + // Error.DuplicatedValue(null, null, null, "__StartingWithTwoUnderscores", "1"), + // Error.DuplicatedValue(null, null, null, "__StartingWithTwoUnderscores", "2"), + //}), + + Error.RestrictedName(null, null, null, "10", "TotalNbrOfActiveCriticalAlarms"), + Error.RestrictedName(null, null, null, "11", "TotalNbrOfActiveCriticalAlarms"), + // DuplicatedValue not really necessary here as MissingTag is already a critical error + //Error.DuplicatedValue(null, null, null, "TotalNbrOfActiveCriticalAlarms", "10, 11").WithSubResults(new List + //{ + // Error.DuplicatedValue(null, null, null, "TotalNbrOfActiveCriticalAlarms", "10"), + // Error.DuplicatedValue(null, null, null, "TotalNbrOfActiveCriticalAlarms", "11"), + //}), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckNameTag_RTDisplayExpectedOnContextMenu() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpectedOnContextMenu", + ExpectedResults = new List + { + //Error.RTDisplayExpectedOnContextMenu(null, null, null, ""), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckNameTag_RTDisplayExpectedOnQActionFeedback() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpectedOnQActionFeedback", + ExpectedResults = new List + { + //Error.RTDisplayExpectedOnQActionFeedback(null, null, null, ""), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_UnrecommendedChars() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedChars", + ExpectedResults = new List + { + Error.UnrecommendedChars(null, null, null, "Name", "AAA[AAA", "["), + Error.UnrecommendedChars(null, null, null, "Name", "AAA[AAA", "["), + Error.DuplicatedValue(null, null, null, "AAA[AAA", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "AAA[AAA", "1"), + Error.DuplicatedValue(null, null, null, "AAA[AAA", "2")), + + Error.UnrecommendedChars(null, null, null, "Name", "Poll_metaData_%[x]-_|_QATrigger", "% [ ] - |"), + + Error.UnrecommendedChars(null, null, null, "Name", "test with Spaces in The middle", "[Whitespace]"), + Error.UnrecommendedChars(null, null, null, "Name", " test With leading space", "[Whitespace]"), + Error.UnrecommendedChars(null, null, null, "Name", " test With leading spaces", "[Whitespace]"), + Error.UnrecommendedChars(null, null, null, "Name", "test With trailing space ", "[Whitespace]"), + Error.UnrecommendedChars(null, null, null, "Name", "test With trailing spaces ", "[Whitespace]"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_UnrecommendedStartChars() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedStartChars", + ExpectedResults = new List + { + Error.UnrecommendedStartChars(null, null, null, "Name", "1AAA", "1"), + + Error.UnrecommendedStartChars(null, null, null, "Name", "10AAA", "1, 0"), + Error.UnrecommendedStartChars(null, null, null, "Name", "10AAA", "1, 0"), + Error.DuplicatedValue(null, null, null, "10AAA", "10, 11").WithSubResults( + Error.DuplicatedValue(null, null, null, "10AAA", "10"), + Error.DuplicatedValue(null, null, null, "10AAA", "11")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckNameTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " ABC "), + + Error.UntrimmedTag(null, null, null, "10", " XYZ "), + Error.UntrimmedTag(null, null, null, "11", " XYZ "), + Error.DuplicatedValue(null, null, null, "XYZ", "10, 11").WithSubResults( + Error.DuplicatedValue(null, null, null, " XYZ ", "10"), + Error.DuplicatedValue(null, null, null, " XYZ ", "11")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckNameTag_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckNameTag_LoggerTableColumnNameChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "LoggerTableColumnNameChanged", + ExpectedResults = new List + { + ErrorCompare.LoggerTableColumnNameChanged(null, null, "oldNameOfColumn", "101", "100", "renamedOldNameOfColumn"), + ErrorCompare.LoggerTableColumnNameChanged(null, null, "oldName_ofLastColumn", "104", "100", "oldNameofLastColumn"), + ErrorCompare.LoggerTableColumnNameChanged(null, null, "oldName_ofLastColumn", "203", "200", "oldName_ofLastColumn11"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckNameTag(); + + [TestMethod] + [Ignore("Currently there aren't any invalid characters, and so also no code fix.")] + public void Param_CheckNameTag_InvalidChars() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidChars", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckNameTag_UnrecommendedChars() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedChars", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckNameTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckNameTag_UnrecommendedChars() + { + // Create ErrorMessage + var message = Error.UnrecommendedChars(null, null, null, "1", "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 7, + FullId = "2.2.7", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "Unrecommended chars in some parameter names.", + Description = "Unrecommended chars '3' in tag '1'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + AutoFixWarnings = new List<(string, bool)> + { + ("Double check the use of the Parameter class in QActions.", true), + ("Double check the use of the (Get/Set)ParameterByName methods in QActions.", false) + } + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Param_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/InvalidChars.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/InvalidChars.xml new file mode 100644 index 00000000..d1d2e5e6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/InvalidChars.xml @@ -0,0 +1,7 @@ + + + + AAA_AAA + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UnrecommendedChars.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UnrecommendedChars.xml new file mode 100644 index 00000000..22d9ff0b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UnrecommendedChars.xml @@ -0,0 +1,37 @@ + + + + + + + AAA_AAA + read + + + AAA_AAA + read + + + + Poll_metaData___X_____QATrigger + + + + testWithSpacesInTheMiddle + + + _TestWithLeadingSpace + + + _TestWithLeadingSpaces + + + testWithTrailingSpace + + + testWithTrailingSpaces + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..4ac6212d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + ABC + + + + + XYZ + + + XYZ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_New.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_New.xml new file mode 100644 index 00000000..24946c3d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_New.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + renamedOldNameOfColumn + + + oldNameofLastColumn + + + + + + + + + + + oldName_ofLastColumn11 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_Old.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_Old.xml new file mode 100644 index 00000000..bc1951d5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Invalid/LoggerTableColumnNameChanged_Old.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + oldNameOfColumn + + + oldName_ofLastColumn + + + + + + + + + + + oldName_ofLastColumn + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..d38ce65c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + oldNameOfColumn + + + oldName_ofLastColumn + + + + + + + + + + + oldName_ofLastColumn + + + + + notAColumnCHANGED + + + + + + + + + + + notAlLoggerColumnIndexCHANGED + + + notAlLoggerColumnValueCHANGED + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..2ea6fa9e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + oldNameOfColumn + + + oldName_ofLastColumn + + + + + + + + + + + oldName_ofLastColumn + + + + + notAColumn + + + + + + + + + + + notAlLoggerColumnIndex + + + notAlLoggerColumnValue + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..c1f092e6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,27 @@ + + + + + SameName + read + + + SameName + write + + + SameName + read + + + + SameName3 + read + + + SameName3 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..5b3741ed --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,25 @@ + + + + + + + read + + + + read + + + + + + read + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml new file mode 100644 index 00000000..a9bee3df --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/InvalidChars.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..ff9b7e2c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,13 @@ + + + + + + read + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnContextMenu.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnContextMenu.xml new file mode 100644 index 00000000..78513f0e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnContextMenu.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnQActionFeedback.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnQActionFeedback.xml new file mode 100644 index 00000000..78513f0e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RTDisplayExpectedOnQActionFeedback.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RestrictedName.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RestrictedName.xml new file mode 100644 index 00000000..c6ec4088 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/RestrictedName.xml @@ -0,0 +1,25 @@ + + + + + + __StartingWithTwoUnderscores + read + + + __StartingWithTwoUnderscores + read + + + + + TotalNbrOfActiveCriticalAlarms + read + + + TotalNbrOfActiveCriticalAlarms + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedChars.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedChars.xml new file mode 100644 index 00000000..1dd610de --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedChars.xml @@ -0,0 +1,39 @@ + + + + + + + + AAA[AAA + read + + + AAA[AAA + read + + + + Poll_metaData_%[x]-_|_QATrigger + + + + test with Spaces in The middle + + + test With leading space + + + test With leading spaces + + + test With trailing space + + + test With trailing spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedStartChars.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedStartChars.xml new file mode 100644 index 00000000..15b869b1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UnrecommendedStartChars.xml @@ -0,0 +1,20 @@ + + + + + 1AAA + read + + + + + 10AAA + read + + + 10AAA + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..6d72ae11 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,17 @@ + + + + + ABC + + + + + XYZ + + + XYZ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..aeeee6d2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,73 @@ + + + + + Read + read + + + Write + write + + + ReadWrite + read + + + ReadWrite + write + + + + + GroupRead + read + + + GroupWrite + write + + + ReadBit + read bit + + + WriteBit + write bit + + + ReadBitWrite + read bit + + + ReadBitWrite + write + + + ReadWriteBit + read + + + ReadWriteBit + write bit + + + ReadBitWriteBit + read bit + + + ReadBitWriteBit + write bit + + + + + ArrayWrite + array + + + ArrayWrite + write + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..58bc0d20 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,147 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.SNMP.OID.CheckIdAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.SNMP.OID.CheckIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "10"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_InvalidAttributeValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttributeValue", + ExpectedResults = new List + { + Error.InvalidAttributeValue(null, null, null, "10", " 011 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, " 11 ", "10"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_UnsupportedParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedParam", + ExpectedResults = new List + { + Error.UnsupportedParam(null, null, null, " 100 ", "10"), + Error.UnsupportedParam(null, null, null, " 101 ", "11"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "10", " 11 "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckIdAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..969d7b55 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,12 @@ + + + + + 1.3.6.1.2.* + + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..7b5c7f9b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,9 @@ + + + + + 1.3.6.1.2.* + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml new file mode 100644 index 00000000..639a2850 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/InvalidAttributeValue.xml @@ -0,0 +1,9 @@ + + + + + 1.3.6.1.2.* + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..6723f58c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,9 @@ + + + + + 1.3.6.1.2.* + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UnsupportedParam.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UnsupportedParam.xml new file mode 100644 index 00000000..e7e33958 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UnsupportedParam.xml @@ -0,0 +1,30 @@ + + + + + Refers to table + + 1.3.6.1.2.* + + + + Refers to column + + 1.3.6.1.2.* + + + + + + Table + array + + + + + + TableColumn + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..b1656c54 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,12 @@ + + + + + 1.3.6.1.2.* + + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..edfbaaaa --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,98 @@ + + + + + ReferencedParam_Read + read + + + ReferencedParam_Bus + bus + + + + + StandaloneWithDynamicOid_RefToRead + + 1.3.6.1.2.* + + + + StandaloneWithDynamicOid_RefToBus + + 1.3.6.1.2.* + + + + + + Standalone without dynamic OID + + 1.3.6.1.2 + + + + + + SubTable + array + + + true + 1.3.6.1.2 + + + + + + TableWithFilteredRows + array + + + + + + + + TableWithFilteredRowsInstance + read + + 1.3.6.1.1.* + + + + TableWithFilteredRowsColumn2 + read + + 1.3.6.1.2.* + + + + + + TableNormal + array + + + + + + 1.3.6 + + + + TableNormalInstance + read + + 1.3.6.1.1 + + + + TableNormalColumn2 + read + + 1.3.6.1.2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/CheckOidTagIdAttrCombo.cs b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/CheckOidTagIdAttrCombo.cs new file mode 100644 index 00000000..118c8b7c --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/CheckOidTagIdAttrCombo.cs @@ -0,0 +1,83 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.SNMP.OID.CheckOidTagIdAttrCombo +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.SNMP.OID.CheckOidTagIdAttrCombo; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOidTagIdAttrCombo(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOidTagIdAttrCombo_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOidTagIdAttrCombo_ExcessiveAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveAttribute", + ExpectedResults = new List + { + Error.ExcessiveAttribute(null, null, null, "1000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOidTagIdAttrCombo_InvalidCombo() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCombo", + ExpectedResults = new List + { + Error.InvalidCombo(null, null, null, "1.3.6.1.2", " 1 ", "10"), + Error.InvalidCombo(null, null, null, "1.3.6.1.2.*", "", "11"), + Error.InvalidCombo(null, null, null, "1.3.6.1.1", " 1 ", "2001"), + Error.InvalidCombo(null, null, null, "1.3.6.1.2.*", "", "2002"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOidTagIdAttrCombo(); + + [TestMethod] + public void Param_CheckOidTagIdAttrCombo_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOidTagIdAttrCombo_CheckId() => Generic.CheckId(root, CheckId.CheckOidTagIdAttrCombo); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/ExcessiveAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/ExcessiveAttribute.xml new file mode 100644 index 00000000..22239203 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/ExcessiveAttribute.xml @@ -0,0 +1,19 @@ + + + + Referenced param + read + + + + + NormalTable + array + + + 1.3.6.1.2.1.1.5.0 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/InvalidCombo.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/InvalidCombo.xml new file mode 100644 index 00000000..5af8f476 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Invalid/InvalidCombo.xml @@ -0,0 +1,47 @@ + + + + Referenced param + read + + + + + Standalone WithId WithoutWildcard + + 1.3.6.1.2 + + + + Standalone WithoutId WithWildcard + + 1.3.6.1.2.* + + + + + + TableWithFilteredRows + array + + + + + + + + TableWithFilteredRows WithId WithoutWildcard + read + + 1.3.6.1.1 + + + + TableWithFilteredRows WithoutId WithWildcard + read + + 1.3.6.1.2.* + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..100259bc --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/OID/CheckOidTagIdAttrCombo/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,88 @@ + + + + + Referenced param + read + + + + + Standalone with dynamic OID + + 1.3.6.1.2.* + + + + + + Standalone without dynamic OID + + 1.3.6.1.2 + + + + + + SubTable + array + + + true + 1.3.6.1.2 + + + + + + TableWithFilteredRows + array + + + + + + + + TableWithFilteredRowsInstance + read + + 1.3.6.1.1.* + + + + TableWithFilteredRowsColumn2 + read + + 1.3.6.1.2.* + + + + + + TableNormal + array + + + + + + 1.3.6 + + + + TableNormalInstance + read + + 1.3.6.1.1 + + + + TableNormalColumn2 + read + + 1.3.6.1.2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/CheckMapAlarmAttribute.cs b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/CheckMapAlarmAttribute.cs new file mode 100644 index 00000000..d1ebf1e0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/CheckMapAlarmAttribute.cs @@ -0,0 +1,202 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.SNMP.TrapOID.CheckMapAlarmAttribute +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.SNMP.TrapOID.CheckMapAlarmAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckMapAlarmAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckMapAlarmAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckMapAlarmAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckMapAlarmAttribute_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckMapAlarmAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "100", " TRUE|Severity:1:Information,*| "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckMapAlarmAttribute(); + + [TestMethod] + public void Param_CheckMapAlarmAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckMapAlarmAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.55.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'SNMP/TrapOID@mapAlarm' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckMapAlarmAttribute_RTDisplayExpected() + { + // Create ErrorMessage + var message = Error.RTDisplayExpected(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.55.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on Param '2' generating alarms based on traps.", + HowToFix = "", + ExampleCode = "", + Details = "'Param/SNMP/TrapOID@mapAlarm' attribute of a Param starts with 'TRUE' when the param is expected to generate alarm or information event on received traps." + Environment.NewLine + "Such feature requires the parameter RTDisplay tag set to 'true'.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckMapAlarmAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.55.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'SNMP/TrapOID@mapAlarm' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckMapAlarmAttribute(); + + [TestMethod] + public void Param_CheckMapAlarmAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckMapAlarmAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckMapAlarmAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..1f3c9a8a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..b7d52ba2 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + true + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..1f3c9a8a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..8b35b53b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..7bb8bc9a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/SNMP/TrapOID/CheckMapAlarmAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,28 @@ + + + + + TrapReceiver_SLProtocol + Trap Received Via SLProtocol + dummy + + true + + + true + * + + + + + TrapReceiver_SLScripting + Trap Received Via SLScripting + dummy + + true + * + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..20c2ee86 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,312 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Type.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Type.CheckIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + Error.EmptyAttribute(null, null, null, "2"), + Error.EmptyAttribute(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "read bit", "11"), + Error.MissingAttribute(null, null, null, "write bit", "21"), + Error.MissingAttribute(null, null, null, "response", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumn", + ExpectedResults = new List + { + Error.NonExistingColumn(null, null, null, "1002", "1000"), + Error.NonExistingColumn(null, null, null, "1004", "1000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, "10", "11"), + Error.NonExistingParam(null, null, null, "20", "21"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingResponse() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingResponse", + ExpectedResults = new List + { + Error.NonExistingResponse(null, null, null, "1", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "11", " 10"), + Error.UntrimmedAttribute(null, null, null, "21", "20 "), + Error.UntrimmedAttribute(null, null, null, "100", " 1 "), + Error.UntrimmedAttribute(null, null, null, "1000", " 1001;1002 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.62.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Type@id' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Param.Type tag value, this attribute should refer to an existing protocol items:" + Environment.NewLine + "- read bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- write bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- response: ID of the response responsible to further parse the value of this param (mandatory)." + Environment.NewLine + "- array: Semi-column list of column Param IDs (optional: depends on the type of table and the presence of ArrayOptions/ColumnOptions tags).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingColumn() + { + // Create ErrorMessage + var message = Error.NonExistingColumn(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 5, + FullId = "2.62.5", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Type@id' references a non-existing 'Column' with PID '2'. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Param.Type tag value, this attribute should refer to an existing protocol items:" + Environment.NewLine + "- read bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- write bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- response: ID of the response responsible to further parse the value of this param (mandatory)." + Environment.NewLine + "- array: Semi-column list of column Param IDs (optional: depends on the type of table and the presence of ArrayOptions/ColumnOptions tags).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.62.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Type@id' references a non-existing 'Param' with ID '2'. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Param.Type tag value, this attribute should refer to an existing protocol items:" + Environment.NewLine + "- read bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- write bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- response: ID of the response responsible to further parse the value of this param (mandatory)." + Environment.NewLine + "- array: Semi-column list of column Param IDs (optional: depends on the type of table and the presence of ArrayOptions/ColumnOptions tags).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_NonExistingResponse() + { + // Create ErrorMessage + var message = Error.NonExistingResponse(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.62.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Attribute 'Type@id' references a non-existing 'Response' with ID '2'. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Param.Type tag value, this attribute should refer to an existing protocol items:" + Environment.NewLine + "- read bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- write bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- response: ID of the response responsible to further parse the value of this param (mandatory)." + Environment.NewLine + "- array: Semi-column list of column Param IDs (optional: depends on the type of table and the presence of ArrayOptions/ColumnOptions tags).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.62.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Type@id' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "Depending on the Param.Type tag value, this attribute should refer to an existing protocol items:" + Environment.NewLine + "- read bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- write bit: ID of the corresponding group param (mandatory)." + Environment.NewLine + "- response: ID of the response responsible to further parse the value of this param (mandatory)." + Environment.NewLine + "- array: Semi-column list of column Param IDs (optional: depends on the type of table and the presence of ArrayOptions/ColumnOptions tags).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Param_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..f7ec12d3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,55 @@ + + + + + + GroupRead + group + + + GroupRead_ReadBit_1 + read bit + + + + + GroupWrite + group + + + GroupWrite_WriteBit_1 + write bit + + + + + ResponseParam + response + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + + string + + + + TableSyntax1_Column2 + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..2cbc3a3f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,19 @@ + + + + + Empty + read + + + Spaces + read + + + EmptyLines + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..e2a165ba --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,23 @@ + + + + + + ReadBit + read bit + + + + + WriteBit + write bit + + + + + ResponseParam + response + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingColumn.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingColumn.xml new file mode 100644 index 00000000..e7ee17d9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingColumn.xml @@ -0,0 +1,35 @@ + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + + string + + + + + TableSyntax1_Column3 + + string + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..a473ef44 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,25 @@ + + + + + + + GroupRead_ReadBit_1 + read bit + + + + + + GroupWrite_WriteBit_1 + write bit + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingResponse.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingResponse.xml new file mode 100644 index 00000000..8721fcf5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/NonExistingResponse.xml @@ -0,0 +1,15 @@ + + + + + ResponseParam + response + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..52e3f9f7 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,55 @@ + + + + + + GroupRead + group + + + GroupRead_ReadBit_1 + read bit + + + + + GroupWrite + group + + + GroupWrite_WriteBit_1 + write bit + + + + + ResponseParam + response + + + + + TableSyntax1 + array + + + + TableSyntax1_Instance + + string + + + + TableSyntax1_Column2 + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..cdd54c47 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,115 @@ + + + + + RegularParam + read + + + + + GroupRead + group + + + GroupRead_ReadBit_1 + read bit + + + + + GroupWrite + group + + + GroupWrite_WriteBit_1 + write bit + + + + + ResponseParam + response + + + + + TableSyntax1NoRTDisplay + array + + + + TableSyntax1NoRTDisplay_Instance + + string + + + + TableSyntax1NoRTDisplay_Column2 + + string + + + + + TableSyntax1RTDisplay + array + + + true + + + + TableSyntax1RTDisplay_Instance + + string + + + true + + + string + + + + TableSyntax1RTDisplay_Column2 + + string + + + true + + + string + + + + + + TableSyntax2 + array + + + + + + + TableSyntax2_Instance + + string + + + + TableSyntax2_Column2 + + string + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..a3dc8f92 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,544 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Type.CheckOptionsAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Type.CheckOptionsAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLinkSerial() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidHeaderTrailerLinkSerial.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLinkSmartSerial() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidHeaderTrailerLinkSmartSerial.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_Matrix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidMatrix.xml", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Duplicate() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateHeaderTrailerLinkOptions", + ExpectedResults = new List + { + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "1", "header", "1, 2").WithSubResults( + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "1", "header", "1"), + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "1", "header", "2")), + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "2", "trailer", "3, 4").WithSubResults( + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "2", "trailer", "3"), + Error.DuplicateHeaderTrailerLinkOptions(null, null, null, "2", "trailer", "4")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Excessive() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveHeaderTrailerLinkOptions.xml", + ExpectedResults = new List + { + Error.ExcessiveHeaderTrailerLinkOptions(null, null, null, "1") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Invalid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidHeaderTrailerLinkOptions.xml", + ExpectedResults = new List + { + Error.InvalidHeaderTrailerLinkOptions(null, null, null, "trailer", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Missing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingHeaderTrailerLinkOptions.xml", + ExpectedResults = new List + { + Error.MissingHeaderTrailerLinkOptions(null, null, null, "header", "1"), + Error.MissingHeaderTrailerLinkOptions(null, null, null, "trailer", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Missing_MultipleConnections() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HeaderTrailerLinkMissingMultipleConnections.xml", + ExpectedResults = new List + { + Error.MissingHeaderTrailerLinkOptions(null, null, null, "header", "1"), + Error.MissingHeaderTrailerLinkOptions(null, null, null, "trailer", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_HeaderTrailerLink_Missing_SmartSerialSingle() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HeaderTrailerLinkMissingSmartSerialSingle.xml", + ExpectedResults = new List + { + Error.MissingHeaderTrailerLinkOptions(null, null, null, "header", "1"), + Error.MissingHeaderTrailerLinkOptions(null, null, null, "trailer", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InconsistentColumnTypeDimensions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InconsistentColumnTypeDimensions.xml", + ExpectedResults = new List + { + Error.InconsistentColumnTypeDimensions(null, null, null, "columntypes=500:0-14", "dimensions=32,16", "1"), + Error.InconsistentColumnTypeDimensions(null, null, null, "columntypes=500:0-16", "dimensions=32,16", "3") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingMatrixOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingMatrixOptions.xml", + ExpectedResults = new List + { + Error.MissingMatrixOptions(null, null, null, "dimensions", "1"), + Error.MissingMatrixOptions(null, null, null, "columntypes", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingAttributeForMatrix() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttributeForMatrix", + ExpectedResults = new List + { + Error.MissingAttributeForMatrix(null, null, null, "1") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMatrixParamType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidMatrixParamType", + ExpectedResults = new List + { + Error.InvalidMatrixParamType(null, null, null, "bus", "1"), + Error.InvalidMatrixParamType(null, null, null, "read", "2"), + Error.InvalidMatrixParamType(null, null, null, "write bit", "3"), + Error.InvalidMatrixParamType(null, null, null, "", "4") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMatrixOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidMatrixOption", + ExpectedResults = new List + { + Error.InvalidMatrixOption(null, null, null, "columntypes=:100:0-", "1"), + Error.InvalidMatrixOption(null, null, null, "columntypes=100:-31", "2"), + Error.InvalidMatrixOption(null, null, null, "columntypes=100:0-15,16|17-31", "3"), + Error.InvalidMatrixOption(null, null, null, "columntypes=0-31", "4"), + Error.InvalidMatrixOption(null, null, null, "columntypes=100:0,31", "5"), + Error.InvalidMatrixOption(null, null, null, "dimensions=16-32", "50"), + Error.InvalidMatrixOption(null, null, null, "dimensions=16", "51"), + Error.InvalidMatrixOption(null, null, null, "dimensions=,32", "52"), + Error.InvalidMatrixOption(null, null, null, "dimensions=16,", "53"), + Error.InvalidMatrixOption(null, null, null, "dimensions=,", "54"), + Error.InvalidMatrixOption(null, null, null, "dimensions=-1,32", "55"), + Error.InvalidMatrixOption(null, null, null, "dimensions=16,-32", "56") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingColumnTypeParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingColumnTypeParam", + ExpectedResults = new List + { + Error.MissingColumnTypeParam(null, null, null, "100", "1"), + Error.MissingColumnTypeParam(null, null, null, "101", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingColumnTypeParamInterprete() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingColumnTypeParamInterprete", + ExpectedResults = new List + { + Error.MissingColumnTypeParamInterprete(null, null, null, "100", "1"), + Error.MissingColumnTypeParamInterprete(null, null, null, "101", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnTypeParamInterprete() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnTypeParamInterprete", + ExpectedResults = new List + { + Error.InvalidColumnTypeParamInterprete(null, null, null, "101", "1").WithSubResults( + Error.InvalidColumnTypeParamRawType(null, null, null, "other", "101", "1"), + Error.InvalidColumnTypeParamType(null, null, null, "string", "101", "1")), + Error.InvalidColumnTypeParamInterprete(null, null, null, "102", "2").WithSubResults( + Error.InvalidColumnTypeParamRawType(null, null, null, "other", "102", "2"), + Error.InvalidColumnTypeParamType(null, null, null, "string", "102", "2")) + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnTypeParamRawType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnTypeParamRawType", + ExpectedResults = new List + { + Error.InvalidColumnTypeParamRawType(null, null, null, "other", "100", "1"), + Error.InvalidColumnTypeParamRawType(null, null, null, "other", "101", "2") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnTypeParamType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnTypeParamType", + ExpectedResults = new List + { + Error.InvalidColumnTypeParamType(null, null, null, "high nibble", "101", "1"), + Error.InvalidColumnTypeParamType(null, null, null, "high nibble", "101", "2"), + Error.InvalidColumnTypeParamType(null, null, null, "string", "102", "3"), + Error.InvalidColumnTypeParamType(null, null, null, "string", "102", "4") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidColumnTypeParamLengthType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidColumnTypeParamLengthType", + ExpectedResults = new List + { + Error.InvalidColumnTypeParamLengthType(null, null, null, "last next param", "101", "1"), + Error.InvalidColumnTypeParamLengthType(null, null, null, "last next param", "101", "2"), + Error.InvalidColumnTypeParamLengthType(null, null, null, "other param", "102", "3"), + Error.InvalidColumnTypeParamLengthType(null, null, null, "other param", "102", "4") + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UnrecommendedSshOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSshOptions", + ExpectedResults = new List + { + Error.UnrecommendedSshOptions(null, null, null, "SSH Username", "101"), + Error.UnrecommendedSshOptions(null, null, null, "SSH PWD", "102"), + Error.UnrecommendedSshOptions(null, null, null, "SSH Options", "103"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_InvalidMixOfSshOptionsAndPortSettings() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidMixOfSshOptionsAndPortSettings", + ExpectedResults = new List + { + Error.UnrecommendedSshOptions(null, null, null, "SSH PWD", "12"), + Error.InvalidMixOfSshOptionsAndPortSettings(null, null, null, "SSH PWD", "12"), + } + }; + + Generic.Validate(test, data); + } + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingAttributeForMatrix() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttributeForMatrix", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingColumnTypeParam() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingColumnTypeParam", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MissingColumnTypeParamInterprete() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingColumnTypeParamInterprete", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_ExcessiveHeaderTrailerLinkOptions() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ExcessiveHeaderTrailerLinkOptions", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckOptionsAttribute_MatrixDimensionsChanged() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MatrixDimensionsChanged", + ExpectedResults = new List + { + ErrorCompare.MatrixDimensionsChanged(null, null, "1", "64,64", "128,128"), + ErrorCompare.MatrixDimensionsChanged(null, null, "2", "64,64", "64,128"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_MatrixDimensionsRemoved() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "MatrixDimensionsRemoved", + ExpectedResults = new List + { + ErrorCompare.MatrixDimensionsRemoved(null, null, "128,128", "1"), + ErrorCompare.MatrixDimensionsRemoved(null, null, "64,128", "2"), + ErrorCompare.MatrixDimensionsRemoved(null, null, "64,128", "3"), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Param); + + [TestMethod] + public void Param_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/ExcessiveHeaderTrailerLinkOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/ExcessiveHeaderTrailerLinkOptions.xml new file mode 100644 index 00000000..c1144bad --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/ExcessiveHeaderTrailerLinkOptions.xml @@ -0,0 +1,8 @@ + + smart-serial + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttributeForMatrix.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttributeForMatrix.xml new file mode 100644 index 00000000..a4635f07 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingAttributeForMatrix.xml @@ -0,0 +1,16 @@ + + + + Matrix_MissingOptions + array + + other + next param + double + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParam.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParam.xml new file mode 100644 index 00000000..db7b0c04 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParam.xml @@ -0,0 +1,47 @@ + + + + array + + other + next param + double + + + matrix + + + + InputsOutputs + write + + other + next param + string + + + matrix + + + + Matrix_ColumnType + Matrix_ColumnType + read + + numeric text + next param + double + + + + InputsOutputs_ColumnType + InputsOutputs_ColumnType + read + + numeric text + next param + double + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParamInterprete.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParamInterprete.xml new file mode 100644 index 00000000..3cd4afbe --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Codefix/MissingColumnTypeParamInterprete.xml @@ -0,0 +1,46 @@ + + + + Matrix + Matrix + array + + other + next param + double + + + matrix + + + + Matrix + Matrix + write + + other + next param + string + + + matrix + + + + read + + numeric text + next param + double + + + + read + + numeric text + next param + double + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_New.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_New.xml new file mode 100644 index 00000000..d34a4e86 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_New.xml @@ -0,0 +1,24 @@ + + + + array + + + + array + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_Old.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_Old.xml new file mode 100644 index 00000000..ca615f2a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsChanged_Old.xml @@ -0,0 +1,24 @@ + + + + array + + + + array + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_New.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_New.xml new file mode 100644 index 00000000..e9aed135 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_New.xml @@ -0,0 +1,34 @@ + + + + array + + + + array + + + + array + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_Old.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_Old.xml new file mode 100644 index 00000000..8f76b8c4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Invalid/MatrixDimensionsRemoved_Old.xml @@ -0,0 +1,34 @@ + + + + array + + + + array + + + + array + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..9e140f55 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,42 @@ + + + + array + + + + array + + + + array + + + + + + array + + + array + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..9e140f55 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,42 @@ + + + + array + + + + array + + + + array + + + + + + array + + + array + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateHeaderTrailerLinkOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateHeaderTrailerLinkOptions.xml new file mode 100644 index 00000000..739db5d5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateHeaderTrailerLinkOptions.xml @@ -0,0 +1,17 @@ + + smart-serial + + + header + + + header + + + trailer + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ExcessiveHeaderTrailerLinkOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ExcessiveHeaderTrailerLinkOptions.xml new file mode 100644 index 00000000..77b59e02 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ExcessiveHeaderTrailerLinkOptions.xml @@ -0,0 +1,8 @@ + + smart-serial + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingMultipleConnections.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingMultipleConnections.xml new file mode 100644 index 00000000..2003744a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingMultipleConnections.xml @@ -0,0 +1,11 @@ + + serial + + + header + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingSmartSerialSingle.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingSmartSerialSingle.xml new file mode 100644 index 00000000..36b5ff22 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/HeaderTrailerLinkMissingSmartSerialSingle.xml @@ -0,0 +1,11 @@ + + smart-serial single + + + header + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InconsistentColumnTypeDimensions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InconsistentColumnTypeDimensions.xml new file mode 100644 index 00000000..1583769e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InconsistentColumnTypeDimensions.xml @@ -0,0 +1,28 @@ + + + + MissingColumn15 + array + + other + next param + double + + + matrix + + + + OneTooMany + array + + other + next param + double + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamInterprete.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamInterprete.xml new file mode 100644 index 00000000..2d93f983 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamInterprete.xml @@ -0,0 +1,63 @@ + + + + Matrix_Invalid_RawType_Type + Matrix Invalid RawType Type + array + + other + next param + double + + + matrix + + + + Matrix_Invalid_RawType_Type + Matrix Invalid RawType Type + write + + other + next param + string + + + matrix + + + + + + ColumnTypes_ReadMatrix_Invalid_RawType_Type + read + + other + string + next param + + + true + + + number + + + + ColumnTypes_WriteMatrix_RawType_Type + read + + other + string + fixed + 1 + + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamLengthType.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamLengthType.xml new file mode 100644 index 00000000..6949aca4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamLengthType.xml @@ -0,0 +1,89 @@ + + + + + Matrix_LastNextParam + Matrix LastNextParam + array + + other + next param + double + + + matrix + + + + Matrix_LastNextParam + Matrix LastNextParam + write + + other + next param + string + + + matrix + + + + Matrix_OtherParam + Matrix OtherParam + array + + other + next param + double + + + matrix + + + + Matrix_OtherParam + Matrix OtherParam + write + + other + next param + string + + + matrix + + + + + + ColumnTypes_Matrix_LastNextParam + read + + numeric text + last next param + double + + + true + + + number + + + + ColumnTypes_Matrix_OtherParam + read + + numeric text + other param + double + + + true + + + number + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamRawType.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamRawType.xml new file mode 100644 index 00000000..a3bdcbbe --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamRawType.xml @@ -0,0 +1,52 @@ + + + + + Matrix_Other + Matrix Other + array + + other + next param + double + + + matrix + + + + Matrix_Other + Matrix Other + write + + other + next param + string + + + matrix + + + + + + ColumnTypes_ReadMatrix_Other + read + + other + next param + double + + + + ColumnTypes_WriteMatrix_Other + read + + other + fixed + 1 + double + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamType.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamType.xml new file mode 100644 index 00000000..2ec5dbf6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidColumnTypeParamType.xml @@ -0,0 +1,73 @@ + + + + + Matrix_HighNibble + array + + other + next param + double + + + matrix + + + + Matrix_HighNibble + write + + other + next param + string + + + matrix + + + + Matrix_String + array + + other + next param + double + + + matrix + + + + Matrix_String + write + + other + next param + string + + + matrix + + + + + + ColumnTypes_Matrix_HighNibble + read + + numeric text + next param + high nibble + + + + ColumnTypes_Matrix_String + read + + numeric text + next param + string + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidHeaderTrailerLinkOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidHeaderTrailerLinkOptions.xml new file mode 100644 index 00000000..38eda0a3 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidHeaderTrailerLinkOptions.xml @@ -0,0 +1,8 @@ + + smart-serial + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml new file mode 100644 index 00000000..bfe7a3a6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixOption.xml @@ -0,0 +1,148 @@ + + + + InvalidColumnType_MissingMaxColumnType + array + + other + next param + double + + + matrix + + + + InvalidColumnType_MissingMinColumnType + array + + other + next param + double + + + matrix + + + + InvalidColumnType_TooComplexColumnTypes + array + + other + next param + double + + + matrix + + + + InvalidColumnType_MissingPidColumnType + array + + other + next param + double + + + matrix + + + + InvalidColumnType_BadSeparator + array + + other + next param + double + + + matrix + + + + InvalidDimensions_BadSeparator + array + + other + next param + double + + + matrix + + + + InvalidDimensions_BadSeparator2 + array + + other + next param + double + + + matrix + + + + InvalidDimensions_MissingRows + array + + other + next param + double + + + matrix + + + + InvalidDimensions_MissingColumns + array + + other + next param + double + + + matrix + + + + InvalidDimensions_Value + array + + other + next param + double + + + matrix + + + + InvalidDimensions_NegativeRows + array + + other + next param + double + + + matrix + + + + InvalidDimensions_NegativeColumns + array + + other + next param + double + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixParamType.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixParamType.xml new file mode 100644 index 00000000..f450bb1a --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMatrixParamType.xml @@ -0,0 +1,52 @@ + + + + Invalid_busType + bus + + other + next param + double + + + matrix + + + + Invalid_ReadType + read + + other + next param + double + + + matrix + + + + Invalid_WriteBitType + write bit + + other + next param + double + + + matrix + + + + Invalid_Empty + + + other + next param + double + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMixOfSshOptionsAndPortSettings.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMixOfSshOptionsAndPortSettings.xml new file mode 100644 index 00000000..49f50139 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidMixOfSshOptionsAndPortSettings.xml @@ -0,0 +1,12 @@ + + + + read + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttributeForMatrix.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttributeForMatrix.xml new file mode 100644 index 00000000..7b7fe2f1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingAttributeForMatrix.xml @@ -0,0 +1,16 @@ + + + + Matrix_MissingOptions + array + + other + next param + double + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParam.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParam.xml new file mode 100644 index 00000000..9d6003e5 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParam.xml @@ -0,0 +1,27 @@ + + + + array + + other + next param + double + + + matrix + + + + InputsOutputs + write + + other + next param + string + + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParamInterprete.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParamInterprete.xml new file mode 100644 index 00000000..42214e2e --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingColumnTypeParamInterprete.xml @@ -0,0 +1,36 @@ + + + + Matrix + Matrix + array + + other + next param + double + + + matrix + + + + Matrix + Matrix + write + + other + next param + string + + + matrix + + + + read + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingHeaderTrailerLinkOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingHeaderTrailerLinkOptions.xml new file mode 100644 index 00000000..971c05eb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingHeaderTrailerLinkOptions.xml @@ -0,0 +1,11 @@ + + smart-serial + + + header + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOptions.xml new file mode 100644 index 00000000..e9a07c2b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/MissingMatrixOptions.xml @@ -0,0 +1,18 @@ + + + + MissingDimensions + array + + matrix + + + + MissingColumnTypes + array + + matrix + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UnrecommendedSshOptions.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UnrecommendedSshOptions.xml new file mode 100644 index 00000000..c123cd6b --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UnrecommendedSshOptions.xml @@ -0,0 +1,13 @@ + + + + read + + + read + + + read + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..58cb706f --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,8 @@ + + serial + + + header + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSerial.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSerial.xml new file mode 100644 index 00000000..d137a246 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSerial.xml @@ -0,0 +1,18 @@ + + serial + + + + header + + + trailer + + + header + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSmartSerial.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSmartSerial.xml new file mode 100644 index 00000000..bb5c9cc6 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidHeaderTrailerLinkSmartSerial.xml @@ -0,0 +1,34 @@ + + smart-serial + + + + header + + + trailer + + + header + + + trailer + + + + + header + + + header + + + + + trailer + + + trailer + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml new file mode 100644 index 00000000..3cbc4a60 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckOptionsAttribute/Samples/Validate/Valid/ValidMatrix.xml @@ -0,0 +1,49 @@ + + + + Matrix + Matrix + array + + other + double + next param + + + matrix + + + + Matrix + Matrix + write + + other + string + next param + + + matrix + + + + ColumnTypes for Read Matrix + read + + numeric text + double + next param + + + + ColumnTypes for Write Matrix + read + + unsigned number + double + fixed + 1 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..583234cb --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,251 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Type.CheckTypeTag +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Type.CheckTypeTag; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + Error.EmptyTag(null, null, null, "2"), + Error.EmptyTag(null, null, null, "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "InvalidType", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckTypeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " read"), + Error.UntrimmedTag(null, null, null, "2", "read "), + Error.UntrimmedTag(null, null, null, "3", " read "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckTypeTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.61.2", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Param/Type' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "All parameters must have a properly filled-in 'Param/Type' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckTypeTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 4, + FullId = "2.61.4", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Param/Type'. Param ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "All parameters must have a properly filled-in 'Param/Type' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckTypeTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.61.1", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Param/Type' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "All parameters must have a properly filled-in 'Param/Type' tag.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckTypeTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.61.3", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Param/Type' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "All parameters must have a properly filled-in 'Param/Type' tag.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTypeTag(); + + [TestMethod] + public void Param_CheckTypeTag_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckTypeTag_CheckId() => Generic.CheckId(check, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..50d19c94 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading Space + read + + + Trailing Space + read + + + Leading and Trailing + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..e9083024 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,20 @@ + + + + + Empty + + + + Spaces + + + + Empty Lines + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..b63bb5a9 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,9 @@ + + + + + InvalidType + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..c29ef4b1 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..69472220 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,18 @@ + + + + + Leading Space + read + + + Trailing Space + read + + + Leading and Trailing + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..2ac4d4e4 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,90 @@ + + + + + array + array + + + bus + bus + + + crc + crc + + + dataminer info + dataminer info + + + discreet info + discreet info + + + dummy + dummy + + + elementdmaid + elementdmaid + + + elementid + elementid + + + elementname + elementname + + + fixed + fixed + + + group + group + + + header + header + + + ip + ip + + + length + length + + + pollingip + pollingip + + + read + read + + + read bit + read bit + + + response + response + + + trailer + trailer + + + write + write + + + write bit + write bit + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/CheckVirtualAttribute.cs b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/CheckVirtualAttribute.cs new file mode 100644 index 00000000..240595f8 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/CheckVirtualAttribute.cs @@ -0,0 +1,216 @@ +namespace SLDisValidatorUnitTests.Protocol.Params.Param.Type.CheckVirtualAttribute +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Params.Param.Type.CheckVirtualAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckVirtualAttribute(); + + #region Valid Checks + + [TestMethod] + public void Param_CheckVirtualAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Param_CheckVirtualAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "900"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Param_CheckVirtualAttribute_RTDisplayExpected() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "RTDisplayExpected", + ExpectedResults = new List + { + Error.RTDisplayExpected(null, null, null, "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Param_CheckVirtualAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "200", " destination "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckVirtualAttribute(); + + [TestMethod] + public void Param_CheckVirtualAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void Param_CheckVirtualAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Param_CheckVirtualAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "2.58.1", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty attribute 'Type@virtual' in Param '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckVirtualAttribute_RTDisplayExpected() + { + // Create ErrorMessage + var message = Error.RTDisplayExpected(null, null, null, "2"); + + var expected = new ValidationResult + { + ErrorId = 3, + FullId = "2.58.3", + Category = Category.Param, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "RTDisplay(true) expected on parameters used as virtual source. Param ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Param_CheckVirtualAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "2.58.2", + Category = Category.Param, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Type@virtual' in Param '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckVirtualAttribute(); + + [TestMethod] + public void Param_CheckVirtualAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Param); + + [TestMethod] + public void Param_CheckVirtualAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckVirtualAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..c5ba64ea --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,9 @@ + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..05fb356d --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,10 @@ + + + + + Destination_NoFilter + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..7dd1da24 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,9 @@ + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml new file mode 100644 index 00000000..5285b1b0 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/RTDisplayExpected.xml @@ -0,0 +1,35 @@ + + + + + + Source_NoFilter + read + + false + + + + Source_ProtocolFilter + read + + + + + + Source_ProtocolFilter_ParamFilter + read + + + + Source_ParamFilter + read + + false + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..da5e1e97 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,10 @@ + + + + + Destination_NoFilter + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..26806561 --- /dev/null +++ b/ProtocolTests/Protocol/Params/Param/Type/CheckVirtualAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,59 @@ + + + + + + OtherParam + + + + + + Source_NoFilter + read + + true + + + + Source_ProtocolFilter + read + + true + + + + Source_ProtocolFilter_ParamFilter + read + + true + + + + Source_ParamFilter + read + + true + + + + + + Destination_NoFilter + read + + + Destination_ProtocolFilter + read + + + Destination_ProtocolFilter_ParamFilter + read + + + Destination_ParamFilter + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..146b9ce8 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,217 @@ +namespace SLDisValidatorUnitTests.Protocol.PortSettings.CheckNameAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.PortSettings.CheckNameAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void PortSettings_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_ValidVirtualNoName() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidVirtualNoName", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_ValidVirtualNoPortSettings() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidVirtualNoPortSettings", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void PortSettings_CheckNameAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "0"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "0"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_MissingPortSettings() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingPortSettings", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "0"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "0", " AAA "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckNameAttribute(); + + [TestMethod] + public void PortSettings_CheckNameAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(check, data); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void PortSettings_CheckNameAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'PortSettings@name' in Connection '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'PortSettings@name' in Connection '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void PortSettings_CheckNameAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " myConnection "); + + string description = "Untrimmed attribute 'PortSettings@name' in Connection '0'. Current value ' myConnection '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckNameAttribute(); + + [TestMethod] + public void PortSettings_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(check, Category.PortSettings); + + [TestMethod] + public void PortSettings_CheckNameAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..6b12fd98 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..6b12fd98 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..84b129e9 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..3ca93384 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..4857e895 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingPortSettings.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingPortSettings.xml new file mode 100644 index 00000000..d315ef69 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingPortSettings.xml @@ -0,0 +1,4 @@ + + snmp + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..131cec82 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6b12fd98 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoName.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoName.xml new file mode 100644 index 00000000..4aa95df6 --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoName.xml @@ -0,0 +1,7 @@ + + virtual + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoPortSettings.xml b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoPortSettings.xml new file mode 100644 index 00000000..4bbfbbab --- /dev/null +++ b/ProtocolTests/Protocol/PortSettings/CheckNameAttribute/Samples/Validate/Valid/ValidVirtualNoPortSettings.xml @@ -0,0 +1,4 @@ + + virtual + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..844edf53 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,175 @@ +namespace SLDisValidatorUnitTests.Protocol.Ports.PortSettings.CheckNameAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Ports.PortSettings.CheckNameAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Ports_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Ports_CheckNameAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Ports_CheckNameAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Ports_CheckNameAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " AAA "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly IRoot codeFix = new CheckNameAttribute(); + + [TestMethod] + public void Ports_CheckNameAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Ports_CheckNameAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Ports_CheckNameAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Ports_CheckNameAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "1"); + + string description = "Missing attribute 'Ports/PortSettings@name' in Connection '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Ports_CheckNameAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "1"); + + string description = "Empty attribute 'Ports/PortSettings@name' in Connection '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Ports_CheckNameAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "1", " myConnection "); + + string description = "Untrimmed attribute 'Ports/PortSettings@name' in Connection '1'. Current value ' myConnection '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameAttribute(); + + [TestMethod] + public void Ports_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Ports); + + [TestMethod] + public void Ports_CheckNameAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..d0ac13e1 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..b1ded0fc --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,10 @@ + + serial + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..011120d7 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..2a227973 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + snmp + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..527e80a0 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,10 @@ + + serial + + + + true + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..5e38ea6a --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..c851b7b5 --- /dev/null +++ b/ProtocolTests/Protocol/Ports/PortSettings/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/CheckProviderTag.cs b/ProtocolTests/Protocol/Provider/CheckProviderTag/CheckProviderTag.cs new file mode 100644 index 00000000..9d88f216 --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/CheckProviderTag.cs @@ -0,0 +1,135 @@ +namespace SLDisValidatorUnitTests.Protocol.Provider.CheckProviderTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Provider.CheckProviderTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckProviderTag(); + + [TestMethod] + public void Protocol_CheckProviderTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckProviderTag_ValidSkyline() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidSkyline", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckProviderTag_ValidNonSkyline() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNonSkyline", + ExpectedResults = new List(), + IsSkylineUser = false, + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckProviderTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckProviderTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckProviderTag_InvalidTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTag", + ExpectedResults = new List + { + Error.InvalidTag(null, null, null, "Other Provider", "Skyline Communications"), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckProviderTag(); + + [TestMethod] + public void Protocol_CheckProviderTag_MissingTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckProviderTag(); + + [TestMethod] + public void Protocol_CheckProviderTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckProviderTag_CheckId() => Generic.CheckId(root, CheckId.CheckProviderTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Codefix/MissingTag.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Codefix/MissingTag.xml new file mode 100644 index 00000000..018a0c5f --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Codefix/MissingTag.xml @@ -0,0 +1,3 @@ + + Skyline Communications + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..f82bb5ba --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/InvalidTag.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/InvalidTag.xml new file mode 100644 index 00000000..855fb6f1 --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/InvalidTag.xml @@ -0,0 +1,3 @@ + + Other Provider + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..00e499a9 --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + Skyline Communications + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidNonSkyline.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidNonSkyline.xml new file mode 100644 index 00000000..855fb6f1 --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidNonSkyline.xml @@ -0,0 +1,3 @@ + + Other Provider + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidSkyline.xml b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidSkyline.xml new file mode 100644 index 00000000..018a0c5f --- /dev/null +++ b/ProtocolTests/Protocol/Provider/CheckProviderTag/Samples/Validate/Valid/ValidSkyline.xml @@ -0,0 +1,3 @@ + + Skyline Communications + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/CSharpCheckEntryPoints.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/CSharpCheckEntryPoints.cs new file mode 100644 index 00000000..a3dff998 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/CSharpCheckEntryPoints.cs @@ -0,0 +1,234 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpCheckEntryPoints +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpCheckEntryPoints; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpCheckEntryPoints(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_MissingEntryPoint() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingEntryPoint", + ExpectedResults = new List + { + // DefaultClass_DefaultMethod + Error.MissingEntryPoint(null, null, null, "QAction", "Run", "10"), + Error.MissingEntryPoint(null, null, null, "QAction", "Run", "11"), + Error.MissingEntryPoint(null, null, null, "QAction", "Run", "12"), + + // DefaultClass_MyMethod + Error.MissingEntryPoint(null, null, null, "QAction", "MyMethod", "20"), + Error.MissingEntryPoint(null, null, null, "QAction", "MyMethod", "21"), + Error.MissingEntryPoint(null, null, null, "QAction", "MyMethod", "22"), + + // MyClass_MyMethod + Error.MissingEntryPoint(null, null, null, "MyClass", "MyMethod", "30"), + Error.MissingEntryPoint(null, null, null, "MyClass", "MyMethod", "31"), + Error.MissingEntryPoint(null, null, null, "MyClass", "MyMethod", "32"), + + // Combination + Error.MissingEntryPoint(null, null, null, "QAction", "MyMethodTypo", "100"), + Error.MissingEntryPoint(null, null, null, "MyClass1", "MyMethodTypo", "100"), + Error.MissingEntryPoint(null, null, null, "MyClass2Typo", "MyMethod", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointClass() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedAccessModifierForEntryPointClass", + ExpectedResults = new List + { + // DefaultClass_DefaultMethod + Error.UnexpectedAccessModifierForEntryPointClass(null, null, null, "QAction", "internal", "10"), + + // DefaultClass_MyMethod + Error.UnexpectedAccessModifierForEntryPointClass(null, null, null, "QAction", "internal", "20"), + + // MyClass_MyMethod + Error.UnexpectedAccessModifierForEntryPointClass(null, null, null, "MyClass", "internal", "30"), + + // MultipleEntryPoints + Error.UnexpectedAccessModifierForEntryPointClass(null, null, null, "QAction", "internal", "100"), + Error.UnexpectedAccessModifierForEntryPointClass(null, null, null, "MyClass", "internal", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointMethod() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedAccessModifierForEntryPointMethod", + ExpectedResults = new List + { + // DefaultClass_DefaultMethod + Error.UnexpectedAccessModifierForEntryPointMethod(null, null, null, "QAction", "Run", "internal", "10"), + + // DefaultClass_MyMethod + Error.UnexpectedAccessModifierForEntryPointMethod(null, null, null, "QAction", "MyMethod", "internal", "20"), + + // MyClass_MyMethod + Error.UnexpectedAccessModifierForEntryPointMethod(null, null, null, "MyClass", "MyMethod", "private", "30"), + + // MultipleEntryPoints + Error.UnexpectedAccessModifierForEntryPointMethod(null, null, null, "QAction", "MyMethod", "internal", "100"), + Error.UnexpectedAccessModifierForEntryPointMethod(null, null, null, "MyClass", "MyMethod", "private", "100"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_UnexpectedArg0TypeForEntryPointMethod() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedArg0TypeForEntryPointMethod", + ExpectedResults = new List + { + // DefaultClass_DefaultMethod + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "QAction", "Run", "int", "10"), + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "QAction", "Run", "", "11"), + + // DefaultClass_MyMethod + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "QAction", "MyMethod", "string", "20"), + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "QAction", "MyMethod", "", "21"), + + // MyClass_MyMethod + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "MyClass", "MyMethod", "object", "30"), + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "MyClass", "MyMethod", "", "31"), + + // Combinations + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "QAction", "MyMethod", "SLProtocol[]", "100"), + Error.UnexpectedArg0TypeForEntryPointMethod(null, null, null, "MyClass", "MyMethod", "", "100"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpCheckEntryPoints(); + + [TestMethod] + [Ignore("Waiting on feedback from TomW")] + public void QAction_CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointClass() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnexpectedAccessModifierForEntryPointClass", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("Waiting on feedback from TomW")] + public void QAction_CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointMethod() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnexpectedAccessModifierForEntryPointMethod", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpCheckEntryPoints_MissingEntryPoint() + { + // Create ErrorMessage + var message = Error.MissingEntryPoint(null, null, null, "1", "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.12.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Entry point '1.2' not found in QAction. QAction ID 3.", + HowToFix = "", + ExampleCode = "", + Details = "The QAction@entryPoint attribute can optionally be used to overwrite the default entry point of a QAction." + Environment.NewLine + "" + Environment.NewLine + "By default, the entry point will be the method 'Run' that can be found under the class 'QAction'." + Environment.NewLine + "Defining multiple entry points can be done by providing a semicolon list of entry points." + Environment.NewLine + "In that case, each entry point corresponds to a QAction trigger." + Environment.NewLine + "" + Environment.NewLine + "One of the two following format can be used in order to overwrite default entry points (curly braces are here used as place holder indicators in the below explanation so are not to be included when defining your entry points):" + Environment.NewLine + "- {entryPointMethod}: the given method name in the 'QAction' class will be the new entry point." + Environment.NewLine + "- {entryPointClass}.{entryPointMethod}: the given method name in the given class name will be the new entry point." + Environment.NewLine + "" + Environment.NewLine + "Note that both the entry point class and methods are expected to be public and the first argument of the entry point is expected to be of type SLProtocol or SLProtocolExt.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpCheckEntryPoints(); + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpCheckEntryPoints_CheckId() => Generic.CheckId(check, CheckId.CSharpCheckEntryPoints); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointClass.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointClass.xml new file mode 100644 index 00000000..d1884f3b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointClass.xml @@ -0,0 +1,61 @@ + + CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointClass + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointMethod.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointMethod.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Codefix/UnexpectedAccessModifierForEntryPointMethod.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/MissingEntryPoint.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/MissingEntryPoint.xml new file mode 100644 index 00000000..2b5e6ebb --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/MissingEntryPoint.xml @@ -0,0 +1,127 @@ + + CSharpCheckEntryPoints_MissingEntryPoints + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointClass.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointClass.xml new file mode 100644 index 00000000..31431660 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointClass.xml @@ -0,0 +1,61 @@ + + CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointClass + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointMethod.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointMethod.xml new file mode 100644 index 00000000..d708cb56 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedAccessModifierForEntryPointMethod.xml @@ -0,0 +1,61 @@ + + CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointMethod + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedArg0TypeForEntryPointMethod.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedArg0TypeForEntryPointMethod.xml new file mode 100644 index 00000000..2e96643a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Invalid/UnexpectedArg0TypeForEntryPointMethod.xml @@ -0,0 +1,96 @@ + + CSharpCheckEntryPoints_UnexpectedAccessModifierForEntryPointMethod + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..7a9d4f1c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckEntryPoints/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,151 @@ + + CSharpCheckEntryPoints_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/CSharpCheckPreprocessorDirective.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/CSharpCheckPreprocessorDirective.cs new file mode 100644 index 00000000..0c392a00 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/CSharpCheckPreprocessorDirective.cs @@ -0,0 +1,110 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpCheckPreprocessorDirective +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpCheckPreprocessorDirective; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpCheckPreprocessorDirective(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpCheckPreprocessorDirective_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpCheckPreprocessorDirective_ObsoleteDcfV1() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ObsoleteDcfV1", + ExpectedResults = new List + { + Error.ObsoleteDcfV1(null, null, null, "1"), + Error.ObsoleteDcfV1(null, null, null, "1"), + Error.ObsoleteDcfV1(null, null, null, "1"), + + Error.ObsoleteDcfV1(null, null, null, "100"), // Uncommented + Error.ObsoleteDcfV1(null, null, null, "101"), // Simple Comment + + Error.ObsoleteDcfV1(null, null, null, "102"), // MultiLine Comment + Error.ObsoleteDcfV1(null, null, null, "102"), // MultiLine Comment + Error.ObsoleteDcfV1(null, null, null, "102"), // MultiLine Comment + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpCheckPreprocessorDirective_ObsoleteDcfV1() + { + // Create ErrorMessage + var message = Error.ObsoleteDcfV1(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.13.1", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Obsolete preprocessor directive 'DCFv1' used in QAction. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "DCFv1 preprocessor directive was used in the past in order to support older DM versions that didn't support DCF yet." + Environment.NewLine + "However, by now, our minimum DM supported version already has DCF support so this DCFv1 preprocessor directive is of no use anymore." + Environment.NewLine + "Moreover, in some cases, such preprocessor directive makes it harder to pinpoint issues so we highly recommend to fully remove the now useless DCFv1 directives (even commented out ones) from all protocols.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpCheckPreprocessorDirective(); + + [TestMethod] + public void QAction_CSharpCheckPreprocessorDirective_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpCheckPreprocessorDirective_CheckId() => Generic.CheckId(check, CheckId.CSharpCheckPreprocessorDirective); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Invalid/ObsoleteDcfV1.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Invalid/ObsoleteDcfV1.xml new file mode 100644 index 00000000..c909b48e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Invalid/ObsoleteDcfV1.xml @@ -0,0 +1,103 @@ + + CSharpCheckPreprocessorDirective_ObsoleteDcfv1 + 0.0.0.0 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b4a1b5bc --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckPreprocessorDirective/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,105 @@ + + CSharpCheckPreprocessorDirective_Valid + 0.0.0.0 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/CSharpCheckUnrecommendedConstructor.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/CSharpCheckUnrecommendedConstructor.cs new file mode 100644 index 00000000..f444e095 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/CSharpCheckUnrecommendedConstructor.cs @@ -0,0 +1,102 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpCheckUnrecommendedConstructor +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpCheckUnrecommendedConstructor; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpCheckUnrecommendedConstructor(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedConstructor_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedConstructor_UnrecommendedXmlSerializerConstructor() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedXmlSerializerConstructor", + ExpectedResults = new List + { + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(XmlTypeMapping)", "2"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, Type[])", "3"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, XmlAttributeOverrides)", "4"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, XmlRootAttribute)", "5"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, XmlAttributeOverrides, Type[], XmlRootAttribute, String)", "6"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, XmlAttributeOverrides, Type[], XmlRootAttribute, String, String)", "7"), + Error.UnrecommendedXmlSerializerConstructor(null, null, null, "System.Xml.Serialization", "XmlSerializer(Type, XmlAttributeOverrides, Type[], XmlRootAttribute, String, String, Evidence)", "8"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpCheckUnrecommendedConstructor_UnrecommendedXmlSerializerConstructor() + { + // Create ErrorMessage + var message = Error.UnrecommendedXmlSerializerConstructor(null, null, null, "unrecommendedConstructor", "constructorNamespace", "qactionId"); + + var expected = new ValidationResult + { + Severity = Severity.Critical, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Constructor 'unrecommendedConstructor' ('constructorNamespace') is unrecommended. QAction ID 'qactionId'.", + Details = "As mentioned on Microsoft docs (https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializer):" + Environment.NewLine + "To increase performance, the XML serialization infrastructure dynamically generates assemblies to serialize and deserialize specified types. The infrastructure finds and reuses those assemblies. This behavior occurs only when using the following constructors:" + Environment.NewLine + "- XmlSerializer.XmlSerializer(Type)" + Environment.NewLine + "- XmlSerializer.XmlSerializer(Type, String)" + Environment.NewLine + "If you use any of the other constructors, multiple versions of the same assembly are generated and never unloaded, which results in a memory leak and poor performance. The easiest solution is to use one of the previously mentioned two constructors.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpCheckUnrecommendedConstructor(); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedConstructor_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedConstructor_CheckId() => Generic.CheckId(check, CheckId.CSharpCheckUnrecommendedConstructor); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Invalid/UnrecommendedXmlSerializerConstructor.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Invalid/UnrecommendedXmlSerializerConstructor.xml new file mode 100644 index 00000000..6cd5befd --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Invalid/UnrecommendedXmlSerializerConstructor.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..567ab275 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedConstructor/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/CSharpCheckUnrecommendedMethod.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/CSharpCheckUnrecommendedMethod.cs new file mode 100644 index 00000000..4c84b28c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/CSharpCheckUnrecommendedMethod.cs @@ -0,0 +1,894 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpCheckUnrecommendedMethod +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpCheckUnrecommendedMethod; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpCheckUnrecommendedMethod(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyDataMinerNTGetRemoteTrend() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyDataMinerNTGetRemoteTrend", + ExpectedResults = new List + { + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "101"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "101"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "101"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "101"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg", + ExpectedResults = new List + { + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "102"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "102"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "102"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "102"), + Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_CHECK_TRIGGER() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_CHECK_TRIGGER", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_CHECK_TRIGGER(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_CHECK_TRIGGER(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_DATA() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_DATA", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_DATA(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_DATA(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_DESCRIPTION() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_DESCRIPTION", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_DESCRIPTION(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_DESCRIPTION(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_ITEM_DATA() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_ITEM_DATA", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_ITEM_DATA(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_ITEM_DATA(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_KEY_POSITION() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_KEY_POSITION", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_KEY_POSITION(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_KEY_POSITION(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_PARAMETER", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_ROW() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_GET_ROW", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_GET_ROW(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_GET_ROW(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_DESCRIPTION() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_DESCRIPTION", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_DESCRIPTION(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_DESCRIPTION(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_ITEM_DATA() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_ITEM_DATA", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_ITEM_DATA(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_ITEM_DATA(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_ROW() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNT_SET_ROW", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNT_SET_ROW(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNT_SET_ROW(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNTAddRow() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNTAddRow", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNTAddRow(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNTAddRow(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNTDeleteRow() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedNotifyProtocolNTDeleteRow", + ExpectedResults = new List + { + Error.UnrecommendedNotifyProtocolNTDeleteRow(null, null, null, "101"), + Error.UnrecommendedNotifyProtocolNTDeleteRow(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolGetParameterIndex() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSlProtocolGetParameterIndex", + ExpectedResults = new List + { + Error.UnrecommendedSlProtocolGetParameterIndex(null, null, null, "103"), + Error.UnrecommendedSlProtocolGetParameterIndex(null, null, null, "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolSetParameterIndex() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSlProtocolSetParameterIndex", + ExpectedResults = new List + { + Error.UnrecommendedSlProtocolSetParameterIndex(null, null, null, "104"), + Error.UnrecommendedSlProtocolSetParameterIndex(null, null, null, "104"), + Error.UnrecommendedSlProtocolSetParameterIndex(null, null, null, "104"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolSetParametersIndex() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSlProtocolSetParametersIndex", + ExpectedResults = new List + { + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + + Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "105"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedThreadAbort() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedThreadAbort", + ExpectedResults = new List + { + Error.UnrecommendedThreadAbort(null, null, null, "106"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpCheckUnrecommendedMethod(); + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_CHECK_TRIGGER() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_CHECK_TRIGGER", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_DATA() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_DATA", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_DESCRIPTION() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_DESCRIPTION", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_ITEM_DATA() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_ITEM_DATA", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_PARAMETER", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_GET_ROW() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_GET_ROW", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_DESCRIPTION() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_DESCRIPTION", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_ITEM_DATA() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_ITEM_DATA", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNT_SET_ROW() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNT_SET_ROW", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNTAddRow() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNTAddRow", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + [Ignore("TODO")] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyProtocolNTDeleteRow() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UnrecommendedNotifyProtocolNTDeleteRow", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyDataMinerNTGetRemoteTrend() + { + // Create ErrorMessage + var message = Error.UnrecommendedNotifyDataMinerNTGetRemoteTrend(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "3.15.5", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.NotifyDataMiner(216/*NT_GET_REMOTE_TREND*/, ...)' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "'SLProtocol.NotifyDataMiner(216/*NT_GET_REMOTE_TREND*/, ...)' method is now considered obsolete." + Environment.NewLine + "" + Environment.NewLine + "Instead, the 'GetTrendDataMessage' SLNet message is recommended as it is more efficient and up to date.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg() + { + // Create ErrorMessage + var message = Error.UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 6, + FullId = "3.15.6", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.NotifyDataMiner(260/*NT_GET_REMOTE_TREND_AVG*/, ...)' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "'SLProtocol.NotifyDataMiner(260/*NT_GET_REMOTE_TREND_AVG*/, ...)' method is now considered obsolete." + Environment.NewLine + "" + Environment.NewLine + "Instead, the 'GetTrendDataMessage' SLNet message is recommended as it is more efficient and up to date.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolGetParameterIndex() + { + // Create ErrorMessage + var message = Error.UnrecommendedSlProtocolGetParameterIndex(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.15.2", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.GetParameterIndex' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "'SLProtocol.GetParameterIndex' method is used to get the value of a specific cell in a table." + Environment.NewLine + "The problem with this call is that it relies on an indexer to identify the row for which a cell value needs to be retrieved." + Environment.NewLine + "However, the order of rows in element tables is not guaranteed." + Environment.NewLine + "Meaning, using an index (row position) is not ideal." + Environment.NewLine + "" + Environment.NewLine + "Instead, it is recommended to use the 'SLProtocol.GetParameterIndexByKey' method which relies on the primary key of the rows.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolSetParameterIndex() + { + // Create ErrorMessage + var message = Error.UnrecommendedSlProtocolSetParameterIndex(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.15.3", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.SetParameterIndex' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "'SLProtocol.SetParameterIndex' method is used to set the value of a specific cell in a table." + Environment.NewLine + "The problem with this call is that it relies on an indexer to identify the row for which a cell value needs to be updated." + Environment.NewLine + "However, the order of rows in element tables is not guaranteed." + Environment.NewLine + "Meaning, using an index (row position) is not ideal." + Environment.NewLine + "" + Environment.NewLine + "Instead, it is recommended to use the 'SLProtocol.SetParameterIndexByKey' method which relies on the primary key of the rows.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedSlProtocolSetParametersIndex() + { + // Create ErrorMessage + var message = Error.UnrecommendedSlProtocolSetParametersIndex(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "3.15.4", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.SetParametersIndex' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "'SLProtocol.SetParametersIndex' method is used to set the value of a specific cells in a table." + Environment.NewLine + "The problem with this call is that it relies on an indexer to identify the rows for which a cells values need to be updated." + Environment.NewLine + "However, the order of rows in element tables is not guaranteed." + Environment.NewLine + "Meaning, using an index (row position) is not ideal." + Environment.NewLine + "" + Environment.NewLine + "Instead, it is recommended to use the 'SLProtocol.SetParametersIndexByKey' method which relies on the primary key of the rows.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_UnrecommendedThreadAbort() + { + // Create ErrorMessage + var message = Error.UnrecommendedThreadAbort(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.15.1", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'System.Threading.Thread.Abort' is unrecommended. QAction ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The Thread.Abort method should be used with caution." + Environment.NewLine + "Particularly when you call it to abort a thread other than the current thread, you do not know what code has executed or failed to execute when the ThreadAbortException is thrown." + Environment.NewLine + "You also cannot be certain of the state of your application or any application and user state that it's responsible for preserving." + Environment.NewLine + "For example, calling Thread.Abort may prevent the execution of static constructors or the release of unmanaged resources." + Environment.NewLine + "" + Environment.NewLine + "Instead, some logic to nicely end the thread should be implemented." + Environment.NewLine + "This is usually implemented according to the cooperative cancellation model.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpCheckUnrecommendedMethod(); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedMethod_CheckId() => Generic.CheckId(check, CheckId.CSharpCheckUnrecommendedMethod); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTAddRow.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTAddRow.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTAddRow.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTDeleteRow.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTDeleteRow.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNTDeleteRow.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DATA.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DATA.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ROW.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ROW.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_GET_ROW.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ROW.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ROW.xml new file mode 100644 index 00000000..ecc4abbf --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Codefix/UnrecommendedNotifyProtocolNT_SET_ROW.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrend.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrend.xml new file mode 100644 index 00000000..cff8a150 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrend.xml @@ -0,0 +1,65 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedGetRemoteTrend + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg.xml new file mode 100644 index 00000000..110742ae --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyDataMinerNTGetRemoteTrendAvg.xml @@ -0,0 +1,63 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedGetRemoteTrendAvg + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTAddRow.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTAddRow.xml new file mode 100644 index 00000000..2d88cc9c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTAddRow.xml @@ -0,0 +1,58 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtAddRow + 0.0.0.0 + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTDeleteRow.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTDeleteRow.xml new file mode 100644 index 00000000..bb50c652 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNTDeleteRow.xml @@ -0,0 +1,58 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtDeleteRow + 0.0.0.0 + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml new file mode 100644 index 00000000..b43b66a8 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_ARRAY_ROW_COUNT.xml @@ -0,0 +1,49 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtArrayRowCount + 0.0.0.0 + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml new file mode 100644 index 00000000..55316fe4 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_CHECK_TRIGGER.xml @@ -0,0 +1,30 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtCheckTrigger + 0.0.0.0 + + + + + + + + + + Get Status Button + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DATA.xml new file mode 100644 index 00000000..901e536a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DATA.xml @@ -0,0 +1,57 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetData + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml new file mode 100644 index 00000000..01f0080b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_DESCRIPTION.xml @@ -0,0 +1,56 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetDescription + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml new file mode 100644 index 00000000..dcae582a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ITEM_DATA.xml @@ -0,0 +1,56 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetItemData + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_KEY_POSITION.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_KEY_POSITION.xml new file mode 100644 index 00000000..ed4f7775 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_KEY_POSITION.xml @@ -0,0 +1,65 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetKeyPosition + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml new file mode 100644 index 00000000..36af2184 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER.xml @@ -0,0 +1,58 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetParameter + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml new file mode 100644 index 00000000..06c98f47 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_DATA.xml @@ -0,0 +1,56 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetParameterByData + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml new file mode 100644 index 00000000..429d40f5 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_BY_NAME.xml @@ -0,0 +1,56 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetParameterByName + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX.xml new file mode 100644 index 00000000..2a9e9cd0 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_PARAMETER_INDEX.xml @@ -0,0 +1,59 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetParameterIndex + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ROW.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ROW.xml new file mode 100644 index 00000000..e346a536 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_GET_ROW.xml @@ -0,0 +1,58 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetRow + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml new file mode 100644 index 00000000..87494f72 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_NOTIFY_DISPLAY.xml @@ -0,0 +1,54 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtGetRow + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml new file mode 100644 index 00000000..071f10a0 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_DESCRIPTION.xml @@ -0,0 +1,57 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetDescription + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml new file mode 100644 index 00000000..9e14645a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ITEM_DATA.xml @@ -0,0 +1,63 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetItemData + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml new file mode 100644 index 00000000..f91e1f05 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_DATA.xml @@ -0,0 +1,55 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetParameterByData + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml new file mode 100644 index 00000000..a32e98be --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_BY_NAME.xml @@ -0,0 +1,55 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetParameterByName + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml new file mode 100644 index 00000000..97e9f952 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_PARAMETER_WITH_HISTORY.xml @@ -0,0 +1,65 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetParameterWithHistory + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ROW.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ROW.xml new file mode 100644 index 00000000..3a2a321d --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedNotifyProtocolNT_SET_ROW.xml @@ -0,0 +1,59 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedNtSetRow + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolGetParameterIndex.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolGetParameterIndex.xml new file mode 100644 index 00000000..2d17cd56 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolGetParameterIndex.xml @@ -0,0 +1,65 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedGetParameterIndex + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParameterIndex.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParameterIndex.xml new file mode 100644 index 00000000..d40b1dec --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParameterIndex.xml @@ -0,0 +1,63 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedSetParameterIndex + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParametersIndex.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParametersIndex.xml new file mode 100644 index 00000000..44433434 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedSlProtocolSetParametersIndex.xml @@ -0,0 +1,69 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedSetParametersIndex + 0.0.0.0 + + + + MyStandalone + read + + number + + + + + MyTable + array + + + + + + + + MyTableInstance + read + + + MyTableColumn2 + read + + + MyTableColumn3 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedThreadAbort.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedThreadAbort.xml new file mode 100644 index 00000000..a33876f6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Invalid/UnrecommendedThreadAbort.xml @@ -0,0 +1,29 @@ + + CSharpCheckUnrecommendedMethod_UnrecommendedThreadAbort + 0.0.0.0 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e637cda5 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedMethod/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,150 @@ + + CSharpCheckUnrecommendedMethod_Valid + 0.0.0.0 + + + + Standalone_Read + read + + + + MyTable + array + + + + + + + + MyTable_Instance + read + + + MyTable_Column2 + read + + + MyTable_Column3 + read + + + + MyMatrix + array + + + matrix + + + Input 1 + 1 + + + Input 2 + 2 + + + Output 1 + 3 + + + Output 2 + 4 + + + + + + MyMatrix_ColumnType + read + + + + + + +/// DataMiner QAction Class: AllowedMethods. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + object currentValue = protocol.GetParameterIndexByKey(1000, "PK_1", 2); + protocol.SetParameterIndexByKey(1000, "PK_1", 2, "newValue"); + + protocol.NotifyDataMiner(262, "value1", "value2"); + protocol.NotifyDataMiner((int)NotifyType.NT_ACK_MERGE_REQUEST, "value1", "value2"); + } +}]]> + + + +/// DataMiner QAction Class: UnrecommendedMethod_AllowedOnMatrix. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime myDateTime = new DateTime(2000, 12, 31); + + protocol.GetParameterIndex(10000, 0, 1); + protocol.SetParameterIndex(10000, 1, 0, 1); + protocol.SetParameterIndex(10000, 1, 0, 1, myDateTime); + + int[] ids = { 10000, 10000 }; + int[] iXs = { 0, 0, 1, 1 }; + int[] iYs = { 0, 1, 0, 1 }; + object[] values = { 1, 0, 1, 0 }; + DateTime[] dateTimes = { myDateTime, myDateTime, myDateTime, myDateTime }; + protocol.SetParametersIndex(ids, iXs, iYs, values); + protocol.SetParametersIndex(ids, iXs, iYs, values, dateTimes); + } + + public static void WriteDataToTableUsingIndex(SLProtocol protocol) + { + List tableIdForIndex = new List(); + Dictionary> tableDataForIndex = new Dictionary>(); + + var ids2 = new int[1]; + var rows = new int[1]; + var columns = new int[1]; + var values = new object[1]; + + int currentIndex = 0; + + for (int i = 0; i < 1; i++) + { + ids2[currentIndex] = tableIdForIndex[i]; + rows[currentIndex] = Convert.ToInt32(tableDataForIndex[i][0]); + columns[currentIndex] = Convert.ToInt32(tableDataForIndex[i][1]); + values[currentIndex] = tableDataForIndex[i][2]; + + currentIndex++; + } + + protocol.SetParametersIndex(ids2, rows, columns, values); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/CSharpCheckUnrecommendedPropertySet.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/CSharpCheckUnrecommendedPropertySet.cs new file mode 100644 index 00000000..8330a013 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/CSharpCheckUnrecommendedPropertySet.cs @@ -0,0 +1,174 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpCheckUnrecommendedPropertySet +{ + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpCheckUnrecommendedPropertySet; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpCheckUnrecommendedPropertySet(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedCultureInfoDefaultThreadCurrentCulture() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedCultureInfoDefaultThreadCurrentCulture", + ExpectedResults = new List + { + Error.UnrecommendedCultureInfoDefaultThreadCurrentCulture(null, null, null, "10"), + Error.UnrecommendedCultureInfoDefaultThreadCurrentCulture(null, null, null, "20"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedThreadCurrentThreadCurrentCulture() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedThreadCurrentThreadCurrentCulture", + ExpectedResults = new List + { + Error.UnrecommendedThreadCurrentThreadCurrentCulture(null, null, null, "10"), + Error.UnrecommendedThreadCurrentThreadCurrentCulture(null, null, null, "20"), + Error.UnrecommendedThreadCurrentThreadCurrentCulture(null, null, null, "30"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedThreadCurrentThreadCurrentUICulture() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedThreadCurrentThreadCurrentUICulture", + ExpectedResults = new List + { + Error.UnrecommendedThreadCurrentThreadCurrentUICulture(null, null, null, "10"), + Error.UnrecommendedThreadCurrentThreadCurrentUICulture(null, null, null, "20"), + Error.UnrecommendedThreadCurrentThreadCurrentUICulture(null, null, null, "30"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedCultureInfoDefaultThreadCurrentCulture() + { + // Create ErrorMessage + var message = Error.UnrecommendedCultureInfoDefaultThreadCurrentCulture(null, null, null, "qactionId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Setting property 'CultureInfo.DefaultThreadCurrentCulture' is unrecommended. QAction ID 'qactionId'.", + Details = "Changing application domain settings should not be performed as QActions from other connectors might be impacted by this change.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedThreadCurrentThreadCurrentCulture() + { + // Create ErrorMessage + var message = Error.UnrecommendedThreadCurrentThreadCurrentCulture(null, null, null, "qactionId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Setting property 'Thread.CurrentThread.CurrentCulture' is unrecommended. QAction ID 'qactionId'.", + Details = "As the threads that execute QAction code are part of a thread pool, changing a setting on a thread in a QAction can affect other QActions of other connectors.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_UnrecommendedThreadCurrentThreadCurrentUICulture() + { + // Create ErrorMessage + var message = Error.UnrecommendedThreadCurrentThreadCurrentUICulture(null, null, null, "qactionId"); + + var expected = new ValidationResult + { + Severity = Severity.Major, + Certainty = Certainty.Certain, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Setting property 'Thread.CurrentThread.CurrentUICulture' is unrecommended. QAction ID 'qactionId'.", + Details = "As the threads that execute QAction code are part of a thread pool, changing a setting on a thread in a QAction can affect other QActions of other connectors.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpCheckUnrecommendedPropertySet(); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpCheckUnrecommendedPropertySet_CheckId() => Generic.CheckId(check, CheckId.CSharpCheckUnrecommendedPropertySet); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedCultureInfoDefaultThreadCurrentCulture.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedCultureInfoDefaultThreadCurrentCulture.xml new file mode 100644 index 00000000..d1a440ca --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedCultureInfoDefaultThreadCurrentCulture.xml @@ -0,0 +1,32 @@ + + CSharpCheckUnrecommendedPropertySet_UnrecommendedCultureInfoDefaultThreadCurrentCulture + 0.0.0.0 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentCulture.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentCulture.xml new file mode 100644 index 00000000..37598b58 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentCulture.xml @@ -0,0 +1,51 @@ + + UnrecommendedThreadCurrentThreadCurrentCulture + 0.0.0.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentUICulture.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentUICulture.xml new file mode 100644 index 00000000..483265ed --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Invalid/UnrecommendedThreadCurrentThreadCurrentUICulture.xml @@ -0,0 +1,48 @@ + + UnrecommendedThreadCurrentThreadCurrentUICulture + 0.0.0.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..7d65bd53 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpCheckUnrecommendedPropertySet/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,34 @@ + + Valid + 0.0.0.0 + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/CSharpNotifyDataMinerNTAssignAlarmTemplate.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/CSharpNotifyDataMinerNTAssignAlarmTemplate.cs new file mode 100644 index 00000000..5abcc1dd --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/CSharpNotifyDataMinerNTAssignAlarmTemplate.cs @@ -0,0 +1,136 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTAssignAlarmTemplate +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTAssignAlarmTemplate; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTAssignAlarmTemplate(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignAlarmTemplate_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignAlarmTemplate_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignAlarmTemplate_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.19.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(117/*NT_ASSIGN_ALARM_TEMPLATE*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = { agentId, elementId };" + Environment.NewLine + "string[] alarmTemplate = new string[] { \"Alarm Template 1\" };" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMiner(117/*NT_ASSIGN_ALARM_TEMPLATE*/, elementDetails, alarmTemplate);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTAssignAlarmTemplate(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignAlarmTemplate_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignAlarmTemplate_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTAssignAlarmTemplate); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..c44705d4 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,114 @@ + + CSharpNotifyDataMinerNTAssignAlarmTemplate_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + uintList = new List(); + uintList.Add(10); + uint[] elementDetails_ListToArray = uintList.ToArray(); + + string[] alarmTemplate = new string[] { "MyAlarmTemplateName" }; + + // Different ways to define element + protocol.NotifyDataMiner(117, 10 , alarmTemplate); + protocol.NotifyDataMiner(117, elementId, alarmTemplate); + protocol.NotifyDataMiner(117, elementId_int, alarmTemplate); + protocol.NotifyDataMiner(117, elementId_string, alarmTemplate); + + protocol.NotifyDataMiner(117, new [] { 10 }, alarmTemplate); + protocol.NotifyDataMiner(117, new uint[] { 10 }, alarmTemplate); + protocol.NotifyDataMiner(117, new [] { elementId }, alarmTemplate); + protocol.NotifyDataMiner(117, new uint[] { elementId }, alarmTemplate); + + protocol.NotifyDataMiner(117, elementDetails, alarmTemplate); + protocol.NotifyDataMiner(117, elementDetails_hardcoded, alarmTemplate); + protocol.NotifyDataMiner(117, elementDetails_uint, alarmTemplate); + //protocol.NotifyDataMiner(117, elementDetails_multiline, alarmTemplate); // Not yet covered + //protocol.NotifyDataMiner(117, elementDetails_ListToArray, alarmTemplate); // Not yet covered + + AssignAlarmTemplate(protocol, elementId, alarmTemplate); + } + + private static void AssignAlarmTemplate(SLProtocol protocol, uint elementId, string[] alarmTemplate) + { + //protocol.NotifyDataMiner(117/*NT_ASSIGN_ALARM_TEMPLATE*/, elementId, alarmTemplate); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..9fe00b7a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignAlarmTemplate/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,97 @@ + + CSharpNotifyDataMinerNTAssignAlarmTemplate_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/CSharpNotifyDataMinerNTAssignSimulation.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/CSharpNotifyDataMinerNTAssignSimulation.cs new file mode 100644 index 00000000..c5578ebd --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/CSharpNotifyDataMinerNTAssignSimulation.cs @@ -0,0 +1,134 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTAssignSimulation +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTAssignSimulation; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTAssignSimulation(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignSimulation_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignSimulation_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignSimulation_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.24.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(76/*NT_ASSIGN_SIMULATION*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = new uint[] { agentId, elementId };" + Environment.NewLine + "bool assignSimulation = false;" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMinerQueued(76 /*NT_ASSIGN_SIMULATION*/ , elementDetails, assignSimulation);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTAssignSimulation(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignSimulation_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTAssignSimulation_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTAssignSimulation); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..76a82ac9 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,101 @@ + + CSharpNotifyDataMinerNTAssignSimulation_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + uintList = new List(); + uintList.Add(10); + uint[] elementDetails_ListToArray = uintList.ToArray(); + + // Different ways to define element + protocol.NotifyDataMiner(76, 10 , null); + protocol.NotifyDataMiner(76, elementId, null); + protocol.NotifyDataMiner(76, elementId_int, null); + protocol.NotifyDataMiner(76, elementId_string, null); + + protocol.NotifyDataMiner(76, new[] { 10 }, null); + protocol.NotifyDataMiner(76, new uint[] { 10 }, null); + protocol.NotifyDataMiner(76, new [] { elementId }, null); + protocol.NotifyDataMiner(76, new uint[] { elementId }, null); + + protocol.NotifyDataMiner(76, elementDetails, null); + protocol.NotifyDataMiner(76, elementDetails_hardcoded, null); + protocol.NotifyDataMiner(76, elementDetails_uint, null); + //protocol.NotifyDataMiner(76, elementDetails_multiline, null); // Not yet covered + //protocol.NotifyDataMiner(76, elementDetails_ListToArray, null); // Not yet covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3255a42b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTAssignSimulation/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,84 @@ + + CSharpNotifyDataMinerNTAssignSimulation_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/CSharpNotifyDataMinerNTEditProperty.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/CSharpNotifyDataMinerNTEditProperty.cs new file mode 100644 index 00000000..b56a0f9f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/CSharpNotifyDataMinerNTEditProperty.cs @@ -0,0 +1,132 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTEditProperty +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTEditProperty; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTEditProperty(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTEditProperty_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTEditProperty_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Edit multiple properties + Error.DeltIncompatible(null, null, null, "102"), + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTEditProperty_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.21.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(62/*NT_EDIT_PROPERTY*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "string propertyLocation = \"element:\"+ elementId + \":\" + agentId;" + Environment.NewLine + "string[] propertyDetails = new string[3] {\"DeviceKey\", \"read-write\", \"2100\"};" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMinerQueued(62/*NT_EDIT_PROPERTY*/ , propertyLocation, propertyDetails);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTEditProperty(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTEditProperty_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTEditProperty_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTEditProperty); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..bcc7a86f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,169 @@ + + CSharpNotifyDataMinerNTEditProperty_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3b737911 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTEditProperty/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,480 @@ + + CSharpNotifyDataMinerNTEditProperty_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/CSharpNotifyDataMinerNTGetAlarmInfo.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/CSharpNotifyDataMinerNTGetAlarmInfo.cs new file mode 100644 index 00000000..cb9fcdd6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/CSharpNotifyDataMinerNTGetAlarmInfo.cs @@ -0,0 +1,135 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetAlarmInfo +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetAlarmInfo; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTGetAlarmInfo(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetAlarmInfo_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetAlarmInfo_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetAlarmInfo_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.26.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(48/*NT_GET_ALARM_INFO*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementInfo = new uint[] { dmaId, elementId };" + Environment.NewLine + "uint[] parameterIds = new uint[] { 100, 300 };" + Environment.NewLine + "" + Environment.NewLine + "object[] result = (object[]) protocol.NotifyDataMiner(48 /* NT_GET_ALARM_INFO */, elementInfo, parameterIds);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTGetAlarmInfo(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetAlarmInfo_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetAlarmInfo_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTGetAlarmInfo); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..b07243a8 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,115 @@ + + CSharpNotifyDataMinerNTGetAlarmInfo_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..c43c00aa --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetAlarmInfo/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,110 @@ + + CSharpNotifyDataMinerNTGetAlarmInfo_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/CSharpNotifyDataMinerNTGetElementName.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/CSharpNotifyDataMinerNTGetElementName.cs new file mode 100644 index 00000000..93d69833 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/CSharpNotifyDataMinerNTGetElementName.cs @@ -0,0 +1,135 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetElementName +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetElementName; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTGetElementName(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetElementName_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetElementName_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetElementName_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.27.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(144/*NT_GET_ELEMENT_NAME*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = new uint[] { agentId, elementId };" + Environment.NewLine + "string elementName = (string) protocol.NotifyDataMiner(144/*NT_GET_ELEMENT_NAME */, elementDetails, null);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTGetElementName(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetElementName_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetElementName_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTGetElementName); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..e6826d0d --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,107 @@ + + CSharpNotifyDataMinerNTGetElementName_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..fb76e1e3 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetElementName/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,103 @@ + + CSharpNotifyDataMinerNTGetElementName_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/CSharpNotifyDataMinerNTGetParameter.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/CSharpNotifyDataMinerNTGetParameter.cs new file mode 100644 index 00000000..7aa58aab --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/CSharpNotifyDataMinerNTGetParameter.cs @@ -0,0 +1,131 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetParameter +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetParameter; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTGetParameter(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetParameter_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetParameter_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetParameter_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.18.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(73/*NT_GET_PARAMETER*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] ids = new uint[] { dmaID, elementID, parameterID };" + Environment.NewLine + "object[] result = (object[])protocol.NotifyDataMiner(73/*NT_GET_PARAMETER*/, ids, null);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTGetParameter(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetParameter_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetParameter_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTGetParameter); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..9251a9f4 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,110 @@ + + CSharpNotifyDataMinerNTGetParameter_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + string paramValue = Convert.ToString(getParamResult[0]); + protocol.Log("QA" + protocol.QActionID + "|Run|paramValue '" + paramValue + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0be248a2 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetParameter/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,113 @@ + + CSharpNotifyDataMinerNTGetParameter_Valid + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + string paramValue = Convert.ToString(result[0]); + protocol.Log("QA" + protocol.QActionID + "|Run|paramValue '" + paramValue + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/CSharpNotifyDataMinerNTGetValue.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/CSharpNotifyDataMinerNTGetValue.cs new file mode 100644 index 00000000..fe7e6ed6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/CSharpNotifyDataMinerNTGetValue.cs @@ -0,0 +1,135 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetValue +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTGetValue; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTGetValue(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetValue_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetValue_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetValue_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.25.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(69/*NT_GET_VALUE*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = new uint[] { agentId, elementId };" + Environment.NewLine + "int parameterId = 120;" + Environment.NewLine + "" + Environment.NewLine + "object[] result = (object[]) protocol.NotifyDataMiner(69 /*NT_GET_VALUE*/, elementDetails, parameterId);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTGetValue(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetValue_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTGetValue_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTGetValue); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..603ef009 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,119 @@ + + CSharpNotifyDataMinerNTGetValue_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + object paramValue = result[4]; + protocol.Log("QA" + protocol.QActionID + "|Run|paramValue '" + paramValue + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0a1cfcf2 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTGetValue/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,124 @@ + + CSharpNotifyDataMinerNTGetValue_Valid + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + object paramValue = result[4]; + protocol.Log("QA" + protocol.QActionID + "|Run|paramValue '" + paramValue + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/CSharpNotifyDataMinerNTServiceSetVdx.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/CSharpNotifyDataMinerNTServiceSetVdx.cs new file mode 100644 index 00000000..60bfbf28 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/CSharpNotifyDataMinerNTServiceSetVdx.cs @@ -0,0 +1,137 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTServiceSetVdx +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTServiceSetVdx; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTServiceSetVdx(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTServiceSetVdx_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTServiceSetVdx_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + // Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTServiceSetVdx_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.28.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(232/*NT_SERVICE_SET_VDX*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "string serviceInfo = dmaId + \"/\" + serviceId;" + Environment.NewLine + "string serviceVdx = \"Visio|1\";" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMiner(232 /*NT_SERVICE_SET_VDX*/ , serviceInfo, serviceVdx);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTServiceSetVdx(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTServiceSetVdx_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTServiceSetVdx_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTServiceSetVdx); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..87472461 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,108 @@ + + CSharpNotifyDataMinerNTServiceSetVdx_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..21922b0a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTServiceSetVdx/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,108 @@ + + CSharpNotifyDataMinerNTServiceSetVdx_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/CSharpNotifyDataMinerNTSetAlarmState.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/CSharpNotifyDataMinerNTSetAlarmState.cs new file mode 100644 index 00000000..97847fe1 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/CSharpNotifyDataMinerNTSetAlarmState.cs @@ -0,0 +1,131 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTSetAlarmState +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTSetAlarmState; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTSetAlarmState(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetAlarmState_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetAlarmState_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetAlarmState_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.17.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(116/*NT_SET_ALARM_STATE*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "object elementDetails = new uint[] {elementID, state, dmaID};" + Environment.NewLine + "object maskDetails = new string[] {maskType, comment};" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMiner(116 /* NT_SET_ALARM_STATE */, elementDetails, maskDetails);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTSetAlarmState(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetAlarmState_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetAlarmState_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTSetAlarmState); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..e977edf6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,99 @@ + + CSharpNotifyDataMinerNTSetAlarmState_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..342c6f6b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetAlarmState/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,129 @@ + + CSharpNotifyDataMinerNTSetAlarmState_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/CSharpNotifyDataMinerNTSetElementState.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/CSharpNotifyDataMinerNTSetElementState.cs new file mode 100644 index 00000000..d8344fd1 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/CSharpNotifyDataMinerNTSetElementState.cs @@ -0,0 +1,128 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTSetElementState +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTSetElementState; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTSetElementState(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetElementState_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetElementState_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetElementState_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.16.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(115/*NT_SET_ELEMENT_STATE*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = new uint[] { elementId, state, deleteOptions, dmaID };" + Environment.NewLine + "protocol.NotifyDataMiner(115 /*NT_SET_ELEMENT_STATE*/ , elementDetails, null);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTSetElementState(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetElementState_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTSetElementState_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTSetElementState); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..746a271b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,90 @@ + + CSharpNotifyDataMinerNTSetElementState_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0a987d17 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTSetElementState/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,92 @@ + + CSharpNotifyDataMinerNTSetElementState_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/CSharpNotifyDataMinerNTTrendingAssignTemplate.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/CSharpNotifyDataMinerNTTrendingAssignTemplate.cs new file mode 100644 index 00000000..b6f6633f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/CSharpNotifyDataMinerNTTrendingAssignTemplate.cs @@ -0,0 +1,133 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTTrendingAssignTemplate +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTTrendingAssignTemplate; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTTrendingAssignTemplate(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTTrendingAssignTemplate_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTTrendingAssignTemplate_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTTrendingAssignTemplate_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.22.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(14/*NT_TRENDING_ASSIGN_TEMPLATE*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = { agentId, elementId };" + Environment.NewLine + "string[] trendTemplate = new string[] { \"Template 1\" };" + Environment.NewLine + "" + Environment.NewLine + "protocol.NotifyDataMiner(14 /*NT_TRENDING_ASSIGN_TEMPLATE*/, elementDetails, trendTemplate);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTTrendingAssignTemplate(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTTrendingAssignTemplate_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTTrendingAssignTemplate_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTTrendingAssignTemplate); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..3926f442 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,97 @@ + + CSharpNotifyDataMinerNTTrendingAssignTemplate_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d680e879 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTTrendingAssignTemplate/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,92 @@ + + CSharpNotifyDataMinerNTTrendingAssignTemplate_Valid + 1.0.0.1 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/CSharpNotifyDataMinerNTUpdateDescriptionXml.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/CSharpNotifyDataMinerNTUpdateDescriptionXml.cs new file mode 100644 index 00000000..32738217 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/CSharpNotifyDataMinerNTUpdateDescriptionXml.cs @@ -0,0 +1,135 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTUpdateDescriptionXml +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTUpdateDescriptionXml; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTUpdateDescriptionXml(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdateDescriptionXml_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdateDescriptionXml_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdateDescriptionXml_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.23.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(127/*NT_UPDATE_DESCRIPTION_XML*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "uint[] elementDetails = new uint[] { agentId, elementId };" + Environment.NewLine + "object[] updates = new object[] { update1, update2 };" + Environment.NewLine + "" + Environment.NewLine + "int result = (int) protocol.NotifyDataMinerQueued(127/*NT_UPDATE_DESCRIPTION_XML */ , elementDetails, updates);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTUpdateDescriptionXml(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdateDescriptionXml_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdateDescriptionXml_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTUpdateDescriptionXml); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..b51f3310 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,133 @@ + + CSharpNotifyDataMinerNTUpdateDescriptionXml_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a53dd22e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdateDescriptionXml/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,130 @@ + + CSharpNotifyDataMinerNTUpdateDescriptionXml_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/CSharpNotifyDataMinerNTUpdatePortsXml.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/CSharpNotifyDataMinerNTUpdatePortsXml.cs new file mode 100644 index 00000000..dc5e5077 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/CSharpNotifyDataMinerNTUpdatePortsXml.cs @@ -0,0 +1,134 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTUpdatePortsXml +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyDataMinerNTUpdatePortsXml; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyDataMinerNTUpdatePortsXml(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdatePortsXml_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdatePortsXml_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Processing response + Error.DeltIncompatible(null, null, null, "102"), + + // Bulk Call + //Error.DeltIncompatible(null, null, null, "103"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdatePortsXml_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.20.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyDataMiner(Queued)(128/*NT_UPDATE_PORTS_XML*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "string updateConfig = changeType + \";\" + elementId + \";\" + parameterId + \";\" + agentId;" + Environment.NewLine + "string updateValue = inputs + \";\" + outputs;" + Environment.NewLine + "" + Environment.NewLine + "int result = (int) protocol.NotifyDataMinerQueued(128/*NT_UPDATE_PORTS_XML*/, updateConfig, updateValue);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyDataMinerNTUpdatePortsXml(); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdatePortsXml_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyDataMinerNTUpdatePortsXml_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyDataMinerNTUpdatePortsXml); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..0f04d60f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,171 @@ + + CSharpNotifyDataMinerNTUpdatePortsXml_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..896cb126 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyDataMinerNTUpdatePortsXml/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,175 @@ + + CSharpNotifyDataMinerNTUpdatePortsXml_Valid + 1.0.0.1 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/CSharpNotifyProtocolNTSnmpGet.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/CSharpNotifyProtocolNTSnmpGet.cs new file mode 100644 index 00000000..e6689e99 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/CSharpNotifyProtocolNTSnmpGet.cs @@ -0,0 +1,131 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyProtocolNTSnmpGet +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyProtocolNTSnmpGet; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyProtocolNTSnmpGet(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpGet_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpGet_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + //Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + //Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpGet_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.30.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyProtocol(295/*NT_SNMP_GET*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "object[] elementInfo = new object[] { elementId, ipPort, multipleGet, instance, connectionId, getCommunityString, splitErrors, agentId };" + Environment.NewLine + "string[] oidInfo = new string[] { \"1.3.6.1.2.1.1.4.0\" };" + Environment.NewLine + "" + Environment.NewLine + "object[] result = (object[])protocol.NotifyProtocol(295/*NT_SNMP_GET*/, elementInfo, oidInfo);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyProtocolNTSnmpGet(); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpGet_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpGet_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyProtocolNTSnmpGet); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..332922bb --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,133 @@ + + CSharpNotifyProtocolNTSnmpGet_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + protocol.Log("result '" + String.Join(";", result) + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d0bfb158 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpGet/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,136 @@ + + CSharpNotifyProtocolNTSnmpGet_Valid + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + protocol.Log("result '" + String.Join(";", result) + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/CSharpNotifyProtocolNTSnmpSet.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/CSharpNotifyProtocolNTSnmpSet.cs new file mode 100644 index 00000000..43b4f9cb --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/CSharpNotifyProtocolNTSnmpSet.cs @@ -0,0 +1,131 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyProtocolNTSnmpSet +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyProtocolNTSnmpSet; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyProtocolNTSnmpSet(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpSet_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpSet_DeltIncompatible() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DeltIncompatible", + ExpectedResults = new List + { + // Different ways to define NT + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + //Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + Error.DeltIncompatible(null, null, null, "100"), + + //Error.DeltIncompatible(null, null, null, "100"), + + // Different ways to define element + //Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + //Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + + Error.DeltIncompatible(null, null, null, "101"), + Error.DeltIncompatible(null, null, null, "101"), + //Error.DeltIncompatible(null, null, null, "101"), + + // Process result + Error.DeltIncompatible(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpSet_DeltIncompatible() + { + // Create ErrorMessage + var message = Error.DeltIncompatible(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.29.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.NotifyProtocol(292/*NT_SNMP_SET*/, ...)' is not compatible with 'DELT'. QAction ID '1'.", + HowToFix = "", + ExampleCode = "object[] elementInfo = new object[] { elementId, ipPort, multipleSet, instance, connectionId, setCommunityString, enableRetries, agentId };" + Environment.NewLine + "object[] oidInfo = new object[] { new object[] { oid, newValue, snmpType } };" + Environment.NewLine + "" + Environment.NewLine + "object[] result = (object[])protocol.NotifyProtocol(292/*NT_SNMP_SET*/, elementInfo, oidInfo);", + Details = "To make this call DELT compatible, the DMA ID needs to be provided as argument." + Environment.NewLine + "See Example code." + Environment.NewLine + "" + Environment.NewLine + "More information about the syntax can be found in the DataMiner Development Library.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyProtocolNTSnmpSet(); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpSet_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNTSnmpSet_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyProtocolNTSnmpSet); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Invalid/DeltIncompatible.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Invalid/DeltIncompatible.xml new file mode 100644 index 00000000..4a74c510 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Invalid/DeltIncompatible.xml @@ -0,0 +1,133 @@ + + CSharpNotifyProtocolNTSnmpSet_DeltIncompatible + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + protocol.Log("result '" + String.Join(";", result) + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f70ee90a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNTSnmpSet/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,180 @@ + + CSharpNotifyProtocolNTSnmpSet_Valid + 1.0.0.1 + + + + + + + + + + + + + + 0) + { + protocol.Log("result '" + String.Join(";", result) + "'", LogType.DebugInfo, LogLevel.NoLogging); + } + } + + public static void Testing(SLProtocol protocol) + { + object[] oaParams = (object[])protocol.GetParameters( + new UInt32[] + { + 6281, + 15 + }); + double val = Convert.ToDouble(oaParams[0]); + + int iTable = 6000; + int size = protocol.RowCount(iTable); + + string ip = Convert.ToString(oaParams[1]); + //string ip1 = ip.Split(';')[1]; + + //string sPollingIp = Convert.ToString(protocol.GetParameter(3010)); + Object[] oElementInfoSet = new Object[5]; + oElementInfoSet[0] = protocol.ElementID; //integer containing the elementid + oElementInfoSet[1] = ip; //string containing the IP address (this could also be IP:Port) + oElementInfoSet[2] = 0; //integer containing if it should be multipleset or not (0 false, 1 true), do NOT assign a Boolean this won’t work + oElementInfoSet[3] = ""; //string containing the instance, when there is no instance then an empty string (“”) needs to be assigned leaving this null will give errors + oElementInfoSet[4] = 0; //integer containing the connection that should be used (normally 0) + + Object[] oOIDs = new Object[size]; + string[] PKs = protocol.GetKeys(iTable); + + + for (int i = 0; i < size; i++) + { + //object[] iAlarmid = (object[])protocol.GetRow(iTable,i); + string sInstance = PKs[i]; + string sOid = "1.3.6.1.4.1.318.1.1.12.3.3.1.1.4." + sInstance; + Object[] oOID1 = new Object[3]; + oOID1[0] = sOid; //string containing the oid that needs to be set + oOID1[1] = val; //string, double containing the value that needs to be set + oOID1[2] = 1; + oOIDs[i] = oOID1; + } + Object[] oResult = (Object[])protocol.NotifyProtocol(292/*NT_SNMP_SET*/, oElementInfoSet, oOIDs); + + protocol.CheckTrigger(6004); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/CSharpNotifyProtocolNtFillArrayWithColumn.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/CSharpNotifyProtocolNtFillArrayWithColumn.cs new file mode 100644 index 00000000..72396402 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/CSharpNotifyProtocolNtFillArrayWithColumn.cs @@ -0,0 +1,666 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpNotifyProtocolNtFillArrayWithColumn +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpNotifyProtocolNtFillArrayWithColumn; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpNotifyProtocolNtFillArrayWithColumn(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_ColumnManagedByDataMiner() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnManagedByDataMiner", + ExpectedResults = new List + { + // DVE Element + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + + Error.ColumnManagedByDataMiner(null, null, null, "10006", "ColumnOption@option", "severity"), + + // State + Error.ColumnManagedByDataMiner(null, null, null, "10004", "ColumnOption@type", "state"), + + // DisplayKey + Error.ColumnManagedByDataMiner(null, null, null, "9999", "ColumnOption@type", "displaykey"), + + // Concatenation + Error.ColumnManagedByDataMiner(null, null, null, "10007", "ColumnOption@type", "concatenation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_ColumnManagedByProtocolItem() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnManagedByProtocolItem", + ExpectedResults = new List + { + #region QAction 300 (SetOnSingleColumn) + // RTT + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + + // Timestamp + Error.ColumnManagedByProtocolItem(null, null, null, "11004", "Timer", "1", "Timer@options", "ping/timestampColumn"), + + // Jitter + Error.ColumnManagedByProtocolItem(null, null, null, "11005", "Timer", "1", "Timer@options", "ping/jitterColumn"), + + // Latency + Error.ColumnManagedByProtocolItem(null, null, null, "11006", "Timer", "1", "Timer@options", "ping/latencyColumn"), + + // PacketLossRateColumn + Error.ColumnManagedByProtocolItem(null, null, null, "11007", "Timer", "1", "Timer@options", "ping/packetLossRateColumn"), + #endregion + + #region QAction 301 (SetOnMultipleColumns) + // All columns + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11004", "Timer", "1", "Timer@options", "ping/timestampColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11005", "Timer", "1", "Timer@options", "ping/jitterColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11006", "Timer", "1", "Timer@options", "ping/latencyColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11007", "Timer", "1", "Timer@options", "ping/packetLossRateColumn"), + #endregion + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_ColumnMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnMissingHistorySet", + ExpectedResults = new List + { + #region QAction 103: History sets on method call level + + // NotifyProtocol + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { primaryKeys, columnValues, columnValues2 })", + "103").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1002"), + Error.ColumnMissingHistorySet(null, null, null, "1003")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { primaryKeys, columnValues, columnValues2 })", + "103").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1102"), + Error.ColumnMissingHistorySet(null, null, null, "1103")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, Parameter.Mytable.Pid.mytable_column3_historysetfalse, Parameter.Mytable.Pid.mytable_column4_nohistoryset, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { primaryKeys, columnValues, columnValues2, columnValues3 })", + "103").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "10003"), + Error.ColumnMissingHistorySet(null, null, null, "10004")), + + #endregion + + #region QAction 104: History sets on cell level + + // History sets on cell level - no optional field + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3 }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValues })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1002") + //Error.ColumnMissingHistorySet(null, null, null, "1003") // use columnValues (no dateTime) + ), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3 }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1102"), + Error.ColumnMissingHistorySet(null, null, null, "1103")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, Parameter.Mytable.Pid.mytable_column3_historysetfalse, Parameter.Mytable.Pid.mytable_column4_nohistoryset }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "10003"), + Error.ColumnMissingHistorySet(null, null, null, "10004")), + + // History sets on cell level - optional bool field + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3, useClearAndLeaveFalse }, new object[] { primaryKeys, columnValues, columnValuesAndDateTimes })", + "104").WithSubResults( + //Error.ColumnMissingHistorySet(null, null, null, "1002"), // use columnValues (no dateTime) + Error.ColumnMissingHistorySet(null, null, null, "1003")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, useClearAndLeaveFalse }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValues })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1102") + //Error.ColumnMissingHistorySet(null, null, null, "1103") // use columnValues (no dateTime) + ), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, Parameter.Mytable.Pid.mytable_column3_historysetfalse, Parameter.Mytable.Pid.mytable_column4_nohistoryset, useClearAndLeaveFalse }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValues, columnValuesAndDateTimes })", + "104").WithSubResults( + //Error.ColumnMissingHistorySet(null, null, null, "10002"), // Has HistorySet="true" + //Error.ColumnMissingHistorySet(null, null, null, "10003"), // use columnValues (no dateTime) + Error.ColumnMissingHistorySet(null, null, null, "10004")), + + // History sets on cell level - optional array field {bool} + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults(Error.ColumnMissingHistorySet(null, null, null, "1002"), Error.ColumnMissingHistorySet(null, null, null, "1003")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, columnValues, columnValuesAndDateTimes })", + "104").WithSubResults( + //Error.ColumnMissingHistorySet(null, null, null, "1102"), // use columnValues (no dateTime) + Error.ColumnMissingHistorySet(null, null, null, "1103")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, Parameter.Mytable.Pid.mytable_column3_historysetfalse, Parameter.Mytable.Pid.mytable_column4_nohistoryset, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes, columnValues })", + "104").WithSubResults( + //Error.ColumnMissingHistorySet(null, null, null, "10002"), // Has HistorySet="true" + Error.ColumnMissingHistorySet(null, null, null, "10003") + //Error.ColumnMissingHistorySet(null, null, null, "10004") // use columnValues (no dateTime) + ), + + // History sets on cell level - optional array field {bool, null} + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1002"), + Error.ColumnMissingHistorySet(null, null, null, "1003")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1102"), + Error.ColumnMissingHistorySet(null, null, null, "1103")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, Parameter.Mytable.Pid.mytable_column3_historysetfalse, Parameter.Mytable.Pid.mytable_column4_nohistoryset, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, columnValues, columnValuesAndDateTimes, columnValuesAndDateTimes })", + "104").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "10003"), + Error.ColumnMissingHistorySet(null, null, null, "10004")) + + #endregion + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_HardCodedColumnPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedColumnPid", + ExpectedResults = new List + { + // QAction 102 + Error.HardCodedColumnPid(null, null, null, "1002", "102"), + //Error.HardCodedColumnPid(null, null, null, "1002", "102"), // Wrappers not yet covered + + // QAction 103 + Error.HardCodedColumnPid(null, null, null, "2002", "103"), + //Error.HardCodedColumnPid(null, null, null, "2002", "103"), // Wrappers not yet covered + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_HardCodedTablePid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedTablePid", + ExpectedResults = new List + { + // QAction 102 + Error.HardCodedTablePid(null, null, null, "1000", "102"), + Error.HardCodedTablePid(null, null, null, "1100", "102"), + + // QAction 103 + Error.HardCodedTablePid(null, null, null, "2000", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_NonExistingColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumn", + ExpectedResults = new List + { + // QAction 102 + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, 1009, false }, new object[] { keys, values })", + "102").WithSubResults( + Error.NonExistingColumn(null, null, null, "1009", "102"), + Error.HardCodedColumnPid(null, null, null, "1009", "102")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, MyParams.NonExistingColumn_999, 1110, new object[] { true } }, new object[] { keys, values, values })", + "102").WithSubResults( + Error.NonExistingColumn(null, null, null, "999", "102"), + Error.HardCodedColumnPid(null, null, null, "999", "102"), + Error.NonExistingColumn(null, null, null, "1110", "102"), + Error.HardCodedColumnPid(null, null, null, "1110", "102")), + + // QAction 103 + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysettrue.tablePid, 2009, new object[] { false } }, new object[] { keys, values })", + "103").WithSubResults( + Error.NonExistingColumn(null, null, null, "2009", "103"), + Error.HardCodedColumnPid(null, null, null, "2009","103")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_NonExistingTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingTable", + ExpectedResults = new List + { + // QAction 102 + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { 999, Parameter.Nohistoryset.Pid.nohistoryset_column2, false }, new object[] { keys, values })", + "102").WithSubResults( + Error.NonExistingTable(null, null, null, "999", "102"), + Error.HardCodedTablePid(null, null, null, "999", "102")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { MyParams.NonExistingTable_900, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3_1103, new object[] { false } }, new object[] { keys, values, values })", + "102").WithSubResults( + Error.NonExistingTable(null, null, null, "900", "102"), + Error.HardCodedTablePid(null, null, null, "900", "102")), + + // QAction 103 + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { 1999, Parameter.Historysettrue.Pid.historysettrue_column2, false }, new object[] { keys, values })", + "103").WithSubResults( + Error.NonExistingTable(null, null, null, "1999", "103"), + Error.HardCodedTablePid(null, null, null, "1999", "103")), + + // QAction 104 + Error.NonExistingTable(null, null, null, "0", "104"), + + // Wrong error for now. + Error.ColumnManagedByDataMiner(null, null, null, "1", "ColumnOption@type", "") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_UnexpectedImplementation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedImplementation", + ExpectedResults = new List + { + // Several Errors in a Method + + // TableHistorySet_SeveralColumns + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, new object[] { false, date_dt } }, new object[] { keys, values, values })", + "102").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1102"), + Error.ColumnMissingHistorySet(null, null, null, "1103")), + + // CellHistorySet_SeveralColumns + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2 ,Parameter.Nohistoryset.Pid.nohistoryset_column3, new object[] { false } }, new object[] { keys, values2, values3 })", + "103").WithSubResults( + Error.ColumnMissingHistorySet(null, null, null, "1002"), + Error.ColumnMissingHistorySet(null, null, null, "1003")), + + // HardCodedColumnPid_SeveralColumns + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysettrue.tablePid, MyParams.MyColumn_2002, 2003, true }, new object[] { keys, values, values })", + "104").WithSubResults( + Error.HardCodedColumnPid(null, null, null, "2002", "104"), + Error.HardCodedColumnPid(null, null, null, "2003", "104")), + + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, 1102, 1103}, new object[] { keys, values, values })", + "104").WithSubResults( + Error.HardCodedColumnPid(null, null, null, "1102", "104"), + Error.HardCodedColumnPid(null, null, null, "1103", "104")), + + // HardCodedColumnPid_And_HistorySet + Error.UnexpectedImplementation(null, null, null, + "(220, new object[] { Parameter.Historysetfalse.tablePid, 1102, 1103, new object[] { true , date_dt }}, new object[] { keys, values, values })", + "105").WithSubResults( + Error.HardCodedColumnPid(null, null, null, "1102", "105"), + Error.HardCodedColumnPid(null, null, null, "1103", "105"), + Error.ColumnMissingHistorySet(null, null, null, "1102"), + Error.ColumnMissingHistorySet(null, null, null, "1103")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_UnrecommendedSetOnSnmpParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSetOnSnmpParam", + ExpectedResults = new List + { + // SNMP + Error.UnrecommendedSetOnSnmpParam(null, null, null, "102"), + + Error.UnrecommendedSetOnSnmpParam(null, null, null, "103"), + Error.UnrecommendedSetOnSnmpParam(null, null, null, "106"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpNotifyProtocolNtFillArrayWithColumn(); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_ColumnMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ColumnMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_ColumnMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ColumnMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "3.34.4", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) method with one or more DateTime(s) given to it requires 'Param@historySet=true' on column with PID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) with DateTime given on table or cell level requires related column parameter(s) to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_HardCodedColumnPid() + { + // Create ErrorMessage + var message = Error.HardCodedColumnPid(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 6, + FullId = "3.34.6", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '2', use 'Parameter' class instead. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) is used to update the values of column(s)." + Environment.NewLine + "Make sure to provide it with column parameter IDs that exists excluding the index (Primary Key) column." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_HardCodedTablePid() + { + // Create ErrorMessage + var message = Error.HardCodedTablePid(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "3.34.5", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '2', use 'Parameter' class instead. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) is used to update the values of column(s)." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_NonExistingColumn() + { + // Create ErrorMessage + var message = Error.NonExistingColumn(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.34.3", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...)' references a non-existing 'column' with PID '2'. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) is used to update the values of column(s)." + Environment.NewLine + "Make sure to provide it with column parameter IDs that exists excluding the index (Primary Key) column." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_NonExistingTable() + { + // Create ErrorMessage + var message = Error.NonExistingTable(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.34.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...)' references a non-existing 'table' with PID '2'. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) is used to update the values of column(s)." + Environment.NewLine + "Make sure to provide it with the ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_UnexpectedImplementation() + { + // Create ErrorMessage + var message = Error.UnexpectedImplementation(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.34.1", + Category = Category.QAction, + Severity = Severity.BubbleUp, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...)' with arguments '2' is not implemented as expected. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol(220/*NT_FILL_ARRAY_WITH_COLUMN*/, ...) is used to update the values of column(s)." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "Also note that using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_UnrecommendedSetOnSnmpParam() + { + // Create ErrorMessage + var message = Error.UnrecommendedSetOnSnmpParam(null, null, null, "1"); + + var expected = new ValidationResult + { + ErrorId = 9, + FullId = "3.34.9", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended set on column '1' with 'ColumnOption@type' containing 'snmp'.", + HowToFix = "", + ExampleCode = "", + Details = + $"It is typically unrecommended to update SNMP parameters from within a protocol.{Environment.NewLine}" + + $"Indeed, SNMP parameters should typically strictly be updated via polling.{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Exceptions can sometimes be made when we update SNMP parameters based on received traps which contains, without any possible doubt, the new value.{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Side note: There are alternatives to poll SNMP parameters in an efficient way when, for example, a cell or column or row needs to be updated but you don't want to poll the entire table:{Environment.NewLine}" + + $"- See various snmpSet options{Environment.NewLine}" + + $"- See dynamicSnmpGet feature.{Environment.NewLine}" + + "- ...", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpNotifyProtocolNtFillArrayWithColumn(); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpNotifyProtocolNtFillArrayWithColumn_CheckId() => Generic.CheckId(check, CheckId.CSharpNotifyProtocolNtFillArrayWithColumn); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Codefix/ColumnMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Codefix/ColumnMissingHistorySet.xml new file mode 100644 index 00000000..d93ce13d --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Codefix/ColumnMissingHistorySet.xml @@ -0,0 +1,192 @@ + + NtFillArrayWithColumn_ColumnMissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + MyTable + array + + + + + + + + + MyTable_Column1_Instance + read + + + MyTable_Column2_HistorySetTrue + read + + + MyTable_Column3_HistorySetFalse + read + + + MyTable_Column4_NoHistorySet + read + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml new file mode 100644 index 00000000..56b6fcf6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml @@ -0,0 +1,104 @@ + + NtFillArrayWithColumn_ColumnManagedByDataMiner + 1.0.0.1 + + + + DVEs_DisplayKey + read + + + DVEs + array + + + + + + + + + + + + + DVEs_Instance + read + + + DVEs_Column2 + read + + + DVEs_Column3_DveElement + read + + + DVEs_Column4_State + read + + + DVEs_Column5_DeleteButton + write + + button + + + + DVEs_Column6_DveSeverity + read + + + DVEs_Column7_Concatenation + read + + + + + + +/// DataMiner QAction Class: DVEs. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] ValuesAndDateTimes = new object[] { new object[] { "Column3_Row1", date_dt }, new object[] { "Column3_Row2", date_dt }, "Column3_Row3" }; + + // DVE Element (No History Sets) + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement_10003, useClearAndLeaveFalse }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement_10003, new object[] { } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement_10003, new object[] { useClearAndLeaveFalse } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement_10003, new object[] { useClearAndLeaveTrue, null } }, new object[] { keys, values }); + + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column6_dveseverity_10006 }, new object[] { keys, values }); + + // State (History sets on method call level) + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column4_state_10004, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { keys, values }); + + // DisplayKey (History sets on cell level) + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_displaykey_9999 }, new object[] { keys, ValuesAndDateTimes }); + + // Concatenation + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column7_concatenation_10007 }, new object[] { keys, values }); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml new file mode 100644 index 00000000..493993dc --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml @@ -0,0 +1,121 @@ + + NtFillArrayWithColumn_ColumnManagedByProtocolItem + 1.0.0.1 + + + + MultiThreading + array + + + + + + + + + + + + MultiThreading_Instance + read + + + MultiThreading_IpAddress + read + + + MultiThreading_RTT + read + + + MultiThreading_Timestamp + read + + + MultiThreading_Jitter + read + + + MultiThreading_Latency + read + + + MultiThreading_PacketLossRate + read + + + + + + +/// DataMiner QAction Class: MultiThreading_SingleColumn. +/// +public class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] ValuesAndDateTimes = new object[] { new object[] { "Column3_Row1", date_dt }, new object[] { "Column3_Row2", date_dt }, "Column3_Row3" }; + + // RTT (No History Sets) + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt_11003, useClearAndLeaveFalse }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt_11003, new object[] { } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt_11003, new object[] { useClearAndLeaveFalse } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt_11003, new object[] { useClearAndLeaveTrue, null } }, new object[] { keys, values }); + + // Timestamp (History sets on method call level) + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_timestamp_11004, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { keys, values }); + + // Jitter (History sets on cell level) + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_jitter_11005 }, new object[] { keys, ValuesAndDateTimes }); + + // Latency + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_latency_11006 }, new object[] { keys, values }); + + // PacketLossRateColumn + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_packetlossrate_11007 }, new object[] { keys, values }); + } +}]]> + + + +/// DataMiner QAction Class: MultiThreading_MultipleColumns. +/// +public class QAction +{ + public static void Run(SLProtocol protocol) + { + object[] keys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + + // All Columns + protocol.NotifyProtocol(220, + new object[7] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress_11002, Parameter.Multithreading.Pid.multithreading_rtt_11003, Parameter.Multithreading.Pid.multithreading_timestamp_11004, Parameter.Multithreading.Pid.multithreading_jitter_11005, Parameter.Multithreading.Pid.multithreading_latency_11006, Parameter.Multithreading.Pid.multithreading_packetlossrate_11007 }, + new object[7] { keys, values, values, values, values, values, values }); + } +}]]> + + + + + + MultiThreaded Timer + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnMissingHistorySet.xml new file mode 100644 index 00000000..bf2a6fca --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/ColumnMissingHistorySet.xml @@ -0,0 +1,192 @@ + + NtFillArrayWithColumn_ColumnMissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + MyTable + array + + + + + + + + + MyTable_Column1_Instance + read + + + MyTable_Column2_HistorySetTrue + read + + + MyTable_Column3_HistorySetFalse + read + + + MyTable_Column4_NoHistorySet + read + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml new file mode 100644 index 00000000..80ed21d7 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml @@ -0,0 +1,172 @@ + + NtFillArrayWithColumn__HardCodedColumnPid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + NoHistorySet_Column4 + read + + + + HistorySetFalse + array + + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + HistorySetFalse_Column4 + read + + + + HistorySetTrue + array + + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + HistorySetTrue_Column4 + read + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml new file mode 100644 index 00000000..1739d855 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml @@ -0,0 +1,150 @@ + + NtFillArrayWithColumn_HardCodedTablePid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml new file mode 100644 index 00000000..e7a1ae2a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml @@ -0,0 +1,146 @@ + + NtFillArrayWithColumn__NonExistingColumn + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml new file mode 100644 index 00000000..958fe3ba --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml @@ -0,0 +1,168 @@ + + NtFillArrayWithColumn_NonExistingTable + 1.0.0.1 + + + ParamNeededForQA104 + read + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnexpectedImplementation.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnexpectedImplementation.xml new file mode 100644 index 00000000..f5b10f90 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnexpectedImplementation.xml @@ -0,0 +1,183 @@ + + NtFillArrayWithColumn__UnexpectedImplementation + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml new file mode 100644 index 00000000..191fb97c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml @@ -0,0 +1,87 @@ + + NtFillArrayWithColumn_UnrecommendedSetOnSnmpParam + 1.0.0.1 + + + + SNMP + array + + + + + + + + + + + + + SNMP_Instance + read + + + SNMP_Column2_SNMP + read + + + SNMP_Column3_SNMP + read + + + SNMP_Column4_Custom + read + + + SNMP_Column5_Custom + read + + + SNMP_Column6_SNMP + read + + + SNMP_Column7_Retrieved + read + + + SNMP_Column8_Retrieved + read + + + + + + +/// DataMiner QAction Class: SNMP. +/// +public static class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] column3Values = { "Value_1", "Value_2", protocol.Clear, null, protocol.Leave }; + + protocol.NotifyProtocol(220, new object[] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column2_snmp }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, + new object[3] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column3_snmp_103, Parameter.Snmp.Pid.snmp_column6_snmp }, + new object[3] { primaryKeys, column2Values, column3Values }); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..fcad9459 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpNotifyProtocolNtFillArrayWithColumn/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,622 @@ + + NtFillArrayWithColumn_Valid + 1.0.0.1 + + + + SNMP + array + + + + + + + + + + + + + SNMP_Instance + read + + + SNMP_Column2_SNMP + read + + + SNMP_Column3_SNMP + read + + + SNMP_Column4_Custom + read + + + SNMP_Column5_Custom + read + + + SNMP_Column6_SNMP + read + + + SNMP_Column7_Retrieved + read + + + SNMP_Column8_Retrieved + read + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + MyTable + array + + + + + + + + + MyTable_Column1_Instance + read + + + MyTable_Column2_HistorySetTrue + read + + + MyTable_Column3_HistorySetFalse + read + + + MyTable_Column4_NoHistorySet + read + + + + DVEs_DisplayKey + read + + + DVEs + array + + + + + + + + + + + + DVEs_Instance + read + + + DVEs_Column2 + read + + + DVEs_Column3_DveElement + read + + + DVEs_Column4_State + read + + + DVEs_Column5_DeleteButton + write + + button + + + + DVEs_Column6_WithHistorySet + read + + + + MultiThreading + array + + + + + + + + + + + + + MultiThreading_Instance + read + + + MultiThreading_IpAddress + read + + + MultiThreading_RTT + read + + + MultiThreading_Timestamp + read + + + MultiThreading_Jitter + read + + + MultiThreading_Latency + read + + + MultiThreading_PacketLossRate + read + + + MultiThreading_ColumnWithHistorySet + read + + + + + + > setColumnsData, DateTime dateTime = default(DateTime)) + { + // Requires Main 10.0.0 [CU?] or Feature 9.6.6 [CU?] (see RN 23815) + int rowCount = setColumnsData.ElementAt(0).Value.Count; + if (rowCount <= 0) + { + // No rows to update + return; + } + + object[] setColumnPids = new object[setColumnsData.Count + 1]; + object[] setColumnOptions = dateTime == default(DateTime) ? new object[] { true } : new object[] { true, dateTime }; + + object[] setColumnValues = new object[setColumnsData.Count]; + for (int i = 0; i < setColumnValues.Length; i++) + { + // Sanity checks + if (setColumnsData.ElementAt(i).Value.Count != rowCount) + { + protocol.Log("QA" + protocol.QActionID + "|SetColumns|SetColumns on table '" + setColumnsData.Keys.ToArray()[0] + "' failed. " + + "Not all columns contain the same number of rows.", LogType.Error, LogLevel.NoLogging); + + return; + } + + // Build set columns objects + setColumnPids[i] = setColumnsData.ElementAt(i).Key; + setColumnValues[i] = setColumnsData.ElementAt(i).Value.ToArray(); + } + + setColumnPids[setColumnPids.Length - 1] = setColumnOptions; + protocol.NotifyProtocol(220, setColumnPids, setColumnValues); + } + + public static void ReceivedIssue(SLProtocolExt protocol, int tableId) + { + List keys = new List(); + List values = new List(); + protocol.NotifyProtocol( + (int)SLNetMessages.NotifyType.NT_FILL_ARRAY_WITH_COLUMN, + new object[] { tableId, tableId + 6 }, + new object[] { keys.ToArray(), values.ToArray() }); + } + } + } +}]]> + + + +/// DataMiner QAction Class: SNMP. +/// +public static class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] column3Values = { "Value_1", "Value_2", protocol.Clear, null, protocol.Leave }; + + // 1 column + protocol.NotifyProtocol(220, new object[] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column7_retrieved }, new object[] { primaryKeys, column2Values }); + + // No options + protocol.NotifyProtocol(220, new object[] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column8_retrieved }, new object[] { primaryKeys, column2Values }); + + // 2 columns + protocol.NotifyProtocol(220, + new object[3] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column8_retrieved_108, Parameter.Snmp.Pid.snmp_column7_retrieved }, + new object[3] { primaryKeys, column2Values, column3Values }); + + // Nice Wrapper + Dictionary> snmpSetColumns = new Dictionary> + { + {Parameter.Snmp.tablePid, new List(primaryKeys)}, + {Parameter.Snmp.Pid.snmp_column7_retrieved, new List(column2Values)}, + {Parameter.Snmp.Pid.snmp_column8_retrieved_108, new List(column3Values)}, + }; + + protocol.SetColumns(snmpSetColumns); + protocol.SetColumns(snmpSetColumns, date_dt); + } +}]]> + + + +/// DataMiner QAction Class: WithoutDateTimes. +/// +public class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] column3Values = { "Value_1", "Value_2", protocol.Clear, null, protocol.Leave }; + + // Random notify type + protocol.NotifyProtocol(139, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2 }, new object[] { primaryKeys, column2Values }); + + // Without optional field + protocol.NotifyProtocol(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2 }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3 }, new object[] { primaryKeys, column2Values, column3Values }); + + // With optional bool field + protocol.NotifyProtocol(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, useClearAndLeaveFalse }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, useClearAndLeaveTrue }, new object[] { primaryKeys, column2Values, column3Values }); + + // With optional array field {} + protocol.NotifyProtocol(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, new object[] { } }, new object[] { primaryKeys, column2Values }); + + // With optional array field {bool} + protocol.NotifyProtocol(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, Parameter.Nohistoryset.Pid.nohistoryset_column3, new object[] { useClearAndLeaveTrue } }, new object[] { primaryKeys, column2Values, column3Values }); + + // With optional array field {bool, null} + protocol.NotifyProtocol(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column2, Parameter.Historysetfalse.Pid.historysetfalse_column3, new object[] { useClearAndLeaveTrue, null } }, new object[] { primaryKeys, column2Values, column3Values }); + + // Wrappers + protocol.SetColumnsWrapper(new object[] { Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, false }, new object[] { primaryKeys, column2Values }); + } +}]]> + + + +/// DataMiner QAction Class: HistorySetOnMethodCallLevel. +/// +public class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3" }; + object[] column3Values = { "Value_1", "Value_2", "Value_3" }; + + // History sets on method call level + protocol.NotifyProtocol(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue, date_dt } }, new object[] { primaryKeys, column2Values, column3Values }); + + // Wrappers + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { primaryKeys, column2Values }); + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue, date_dt } }, new object[] { primaryKeys, column2Values, column3Values }); + } +}]]> + + + +/// DataMiner QAction Class: HistorySetOnCellLevel. +/// +public class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3" }; + object[] column3ValuesAndDateTimes = new object[] { new object[] { "Column3_Row1", date_dt }, new object[] { "Column3_Row2", date_dt }, "Column3_Row3" }; + + // History sets on cell level - no optional field + protocol.NotifyProtocol(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3 }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + protocol.SetColumnsWrapper(new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3 }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + // History sets on cell level - optional bool field + protocol.NotifyProtocol(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, useClearAndLeaveFalse }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, useClearAndLeaveTrue }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + protocol.SetColumnsWrapper(new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, useClearAndLeaveFalse }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, useClearAndLeaveTrue }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + // History sets on cell level - optional array field {bool} + protocol.NotifyProtocol(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue } }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + protocol.SetColumnsWrapper(new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, new object[] { useClearAndLeaveFalse } }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue } }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + // History sets on cell level - optional array field {bool, null} + protocol.NotifyProtocol(220, new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.NotifyProtocol(220, new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue, null } }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + + protocol.SetColumnsWrapper(new object[] { Parameter.Mytable.tablePid, Parameter.Mytable.Pid.mytable_column2_historysettrue, new object[] { useClearAndLeaveFalse, null } }, new object[] { primaryKeys, column3ValuesAndDateTimes }); + protocol.SetColumnsWrapper(new object[] { Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column2, Parameter.Historysettrue.Pid.historysettrue_column3, new object[] { useClearAndLeaveTrue, null } }, new object[] { primaryKeys, column2Values, column3ValuesAndDateTimes }); + } +}]]> + + + +/// DataMiner QAction Class: DVEs. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] ValuesAndDateTimes = new object[] { new object[] { "Column3_Row1", date_dt }, new object[] { "Column3_Row2", date_dt }, "Column3_Row3" }; + + // No History Sets + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2 }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2_10002, useClearAndLeaveFalse }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2_10002, new object[] { } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2_10002, new object[] { useClearAndLeaveFalse } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2_10002, new object[] { useClearAndLeaveTrue, null } }, new object[] { keys, values }); + + // History sets on method call level + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column6_withhistoryset_10006, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { keys, values }); + + // History sets on cell level + protocol.NotifyProtocol(220, new object[] { Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column6_withhistoryset_10006 }, new object[] { keys, ValuesAndDateTimes }); + } +}]]> + + + +/// DataMiner QAction Class: MultiThreading. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] ValuesAndDateTimes = new object[] { new object[] { "Column3_Row1", date_dt }, new object[] { "Column3_Row2", date_dt }, "Column3_Row3" }; + + // No History Sets + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress_11002, useClearAndLeaveFalse }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress_11002, new object[] { } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress_11002, new object[] { useClearAndLeaveFalse } }, new object[] { keys, values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress_11002, new object[] { useClearAndLeaveTrue, null } }, new object[] { keys, values }); + + // History sets on method call level + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_columnwithhistoryset_11008, new object[] { useClearAndLeaveFalse, date_dt } }, new object[] { keys, values }); + + // History sets on cell level + protocol.NotifyProtocol(220, new object[] { Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_columnwithhistoryset_11008 }, new object[] { keys, ValuesAndDateTimes }); + } +}]]> + + + +/// DataMiner QAction Class: ReceivedIssues. +/// +public static class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + var columnIdx = new uint[] + { + Parameter.Mytable.Idx.mytable_column1_instance_5001, + Parameter.Mytable.Idx.mytable_column2_historysettrue_5002 + }; + + var columns = (object[])protocol.NotifyProtocol((int)NotifyType.NT_GET_TABLE_COLUMNS, Parameter.Mytable.tablePid, columnIdx); + var grandMaster = Array.ConvertAll((object[])columns[1], x => Convert.ToString(x).Substring(7)); + int tableID = Parameter.Mytable.tablePid; + int columnID = Parameter.Mytable.Pid.mytable_column2_historysettrue_5002; + bool allowClearAndLeave = true; + DateTime timestamp = DateTime.Now; + object[] columnInfo = new object[] { tableID, columnID, new object[] { allowClearAndLeave, timestamp } }; + object[] primaryKeys = (object[])columns[0]; + object[] columnValues = grandMaster; + object[] values = new object[] { primaryKeys, columnValues }; + protocol.NotifyProtocol(220 /*NT_FILL_ARRAY_WITH_COLUMN*/, columnInfo, values); + } +}]]> + + + + + + MultiThreaded Timer + + + RegularTimerWithoutOptions + + 75 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/CSharpQActionCompilation.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/CSharpQActionCompilation.cs new file mode 100644 index 00000000..2a5f6581 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/CSharpQActionCompilation.cs @@ -0,0 +1,195 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpQActionCompilation +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpQActionCompilation; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpQActionCompilation(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpQActionCompilation_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpQActionCompilation_Valid_CSharp4() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_CSharp4", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpQActionCompilation_Valid_CSharp7_3() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_CSharp7_3", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpQActionCompilation_CompilationFailure() + { + // List of expected results + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "CompilationFailure", + ExpectedResults = new List + { + Error.CompilationFailure(null, null, null, "2").WithSubResults( + Error.CompilationFailure_Sub(null, null, null, "QAction_2.cs(9,19): error CS1001: Identifier expected"), + Error.CompilationFailure_Sub(null, null, null, "QAction_2.cs(9,19): error CS1002: ; expected")), + Error.CompilationFailure(null, null, null, "100").WithSubResults( + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(16,12): error CS1061: 'SLProtocol' does not contain a definition for 'MyMistypedMethod' and no accessible extension method 'MyMistypedMethod' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?)")), + Error.CompilationFailure(null, null, null, "201").WithSubResults( + Error.CompilationFailure_Sub(null, null, null, "QAction_201.cs(17,26): error CS0117: 'MyClass' does not contain a definition for 'MyMistypedMethod1'"), + Error.CompilationFailure_Sub(null, null, null, "QAction_201.cs(18,26): error CS0117: 'MyClass' does not contain a definition for 'MyMistypedMethod2'")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Not possible until we update Microsoft.CodeAnalysis")] + public void QAction_CSharpQActionCompilation_CompilationFailure_CSharp703() + { + // List of expected results + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "CompilationFailure_CSharp703", + ExpectedResults = new List + { + Error.CompilationFailure(null, null, null, "100").WithSubResults( + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(17,12): error CS1061: 'SLProtocol' does not contain a definition for 'MyMistypedMethod' and no accessible extension method 'MyMistypedMethod' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?)")/*, + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(33,15): error CS8025: Feature 'not pattern' is not available in C# 7.3. Please use language version 9.0 or greater."), + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(33,15): error CS8025: Feature 'type pattern' is not available in C# 7.3. Please use language version 9.0 or greater.") + */) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Not possible until we update Microsoft.CodeAnalysis")] + public void QAction_CSharpQActionCompilation_CompilationFailure_CSharp703_NoCompliancyTag() + { + // List of expected results + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "CompilationFailure_CSharp703_NoCompliancyTag", + ExpectedResults = new List + { + Error.CompilationFailure(null, null, null, "100").WithSubResults( + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(17,12): error CS1061: 'SLProtocol' does not contain a definition for 'MyMistypedMethod' and no accessible extension method 'MyMistypedMethod' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?)")/*, + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(33,15): error CS8025: Feature 'not pattern' is not available in C# 7.3. Please use language version 9.0 or greater."), + Error.CompilationFailure_Sub(null, null, null, "QAction_100.cs(33,15): error CS8025: Feature 'type pattern' is not available in C# 7.3. Please use language version 9.0 or greater.") + */) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Keeping the code in case we have the same situation again later")] + public void QAction_CSharpQActionCompilation_NoCSharpCodeAnalysisPerformed() + { + // QAction 100 + var result = Error.NoCSharpCodeAnalysisPerformed(null, null, null, "7.3", "< VS 2017"); + + // List of expected results + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NoCSharpCodeAnalysisPerformed", + ExpectedResults = new List + { + result + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpQActionCompilation_CompilationFailure() + { + // Create ErrorMessage + var message = Error.CompilationFailure(null, null, null, "1"); + + string description = "C# compilation errors. QAction ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CSharpQActionCompilation_CompilationFailure_Sub() + { + // Create ErrorMessage + var message = Error.CompilationFailure_Sub(null, null, null, "QAction_2.cs(9,19): error CS1002: ; expected"); + + string description = "QAction_2.cs(9,19): error CS1002: ; expected"; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpQActionCompilation(); + + [TestMethod] + public void QAction_CSharpQActionCompilation_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpQActionCompilation_CheckId() => Generic.CheckId(check, CheckId.CSharpQActionCompilation); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure.xml new file mode 100644 index 00000000..fd464537 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure.xml @@ -0,0 +1,85 @@ + + CSharpQActionCompilation_CompilationFailure + 0.0.0.0 + + + + + + + + + + +/// DataMiner QAction Class: Simple. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.MyMistypedMethod(); + } +}]]> + + + +/// DataMiner QAction Class: DllImport_PrecompiledQAction. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int goodTest1 = MyClass.MyMethod(5); + + int badTest1 = MyClass.MyMistypedMethod1(); + int badTest2 = MyClass.MyMistypedMethod2(); + + protocol.Log("goodTest1 '" + goodTest1 + "' - badTest1 '" + badTest1 + "' - badTest2 '" + badTest2 + "'", + LogType.DebugInfo, + LogLevel.NoLogging); + } +}]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703.xml new file mode 100644 index 00000000..a3b90e64 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703.xml @@ -0,0 +1,55 @@ + + CSharpQActionCompilation_CompilationFailure_CSharp703 + 0.0.0.0 + + + + + 10.0.0.0 + + + + + +/// DataMiner QAction Class: Simple_CSharp703. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // C#4 + protocol.MyMistypedMethod(); + + // C#6 + object test = ""; + if (string.IsNullOrEmpty(test?.ToString())) + { + protocol.Log("QA" + protocol.QActionID + "|Run|'test' is null or empty.", LogType.DebugInfo, LogLevel.NoLogging); + } + + // C#7.3 + if (test is string test2) + { + protocol.Log("QA" + protocol.QActionID + "|Run|" + test2, LogType.Error, LogLevel.NoLogging); + } + + // C#9 + if (test is not int) + { + protocol.Log("QA" + protocol.QActionID + "|Run|It is not int.", LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703_NoCompliancyTag.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703_NoCompliancyTag.xml new file mode 100644 index 00000000..28bd9887 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/CompilationFailure_CSharp703_NoCompliancyTag.xml @@ -0,0 +1,56 @@ + + CSharpQActionCompilation_CompilationFailure_CSharp703_NoCompliancyTag + 0.0.0.0 + + + + + + + + + +/// DataMiner QAction Class: Simple_CSharp703. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // C#4 + protocol.MyMistypedMethod(); + + // C#6 + object test = ""; + if (string.IsNullOrEmpty(test?.ToString())) + { + protocol.Log("QA" + protocol.QActionID + "|Run|'test' is null or empty.", LogType.DebugInfo, LogLevel.NoLogging); + } + + // C#7.3 + if (test is string test2) + { + protocol.Log("QA" + protocol.QActionID + "|Run|" + test2, LogType.Error, LogLevel.NoLogging); + } + + // C#9 + if (test is not int) + { + protocol.Log("QA" + protocol.QActionID + "|Run|It is not int.", LogType.Error, LogLevel.NoLogging); + } + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/NoCSharpCodeAnalysisPerformed.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/NoCSharpCodeAnalysisPerformed.xml new file mode 100644 index 00000000..c95c8a61 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Invalid/NoCSharpCodeAnalysisPerformed.xml @@ -0,0 +1,47 @@ + + CSharpQActionCompilation_NoCSharpCodeAnalysisPerformed + 0.0.0.0 + + + 9.6.11.0 + + + + + + + + + +/// DataMiner QAction Class: Simple. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..704b22fe --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,145 @@ + + CSharpQActionCompilation_Valid + 0.0.0.0 + + + + + + + + +/// DataMiner QAction Class: Simple. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + + +/// DataMiner QAction Class: DllImport_ExternalDll. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + BinaryConverter test = new BinaryConverter(); + protocol.Log(test.ToString(), LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + +/// DataMiner QAction Class: DllImport_PrecompiledQAction. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int test = MyClass.MyMethod(5); + protocol.Log("QA" + protocol.QActionID + "|Run|test '" + test + "'.", LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + +/// DataMiner QAction Class: DllImport_IgnoreEmpty1. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + +/// DataMiner QAction Class: DllImport_IgnoreEmpty1. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + } +}]]> + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp4.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp4.xml new file mode 100644 index 00000000..57a83ea9 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp4.xml @@ -0,0 +1,43 @@ + + CSharpQActionCompilation_Valid_CSharp4 + 0.0.0.0 + + + + + 8.5.0.0 + + + + + +/// DataMiner QAction Class: Simple_CSharp4. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // C#4 + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + + // C#6 + //object test = ""; + //if (string.IsNullOrEmpty(test?.ToString())) + //{ + // protocol.Log("QA" + protocol.QActionID + "|Run|'test' is null or empty.", LogType.DebugInfo, LogLevel.NoLogging); + //} + + // C#7.3 (not yet supported as it would require us to drop support of VS2015) + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp7_3.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp7_3.xml new file mode 100644 index 00000000..9918d5e9 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpQActionCompilation/Samples/Validate/Valid/Valid_CSharp7_3.xml @@ -0,0 +1,50 @@ + + CSharpQActionCompilation_Valid_CSharp7_3 + 0.0.0.0 + + + + + 9.6.11.0 + + + + + +/// DataMiner QAction Class: Simple_CSharp6. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // C#4 + protocol.Log("QA" + protocol.QActionID + "|Run|##### Start of QAction #####", LogType.DebugInfo, LogLevel.NoLogging); + + // C#6 + object test = ""; + if (string.IsNullOrEmpty(test?.ToString())) + { + protocol.Log("QA" + protocol.QActionID + "|Run|'test' is null or empty.", LogType.DebugInfo, LogLevel.NoLogging); + } + + if (test is string stringTest) + { + protocol.Log("QA" + protocol.QActionID + "|Run|'stringTest' is a string: " + stringTest, LogType.DebugInfo, LogLevel.NoLogging); + } + + // TODO: C#8 & higher syntax + // This one can't be unit tested + // because the unit test project refers to a too old version of Roslyn. + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/CSharpSLProtocolCheckTrigger.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/CSharpSLProtocolCheckTrigger.cs new file mode 100644 index 00000000..2cc68812 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/CSharpSLProtocolCheckTrigger.cs @@ -0,0 +1,88 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolCheckTrigger +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolCheckTrigger; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolCheckTrigger(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolCheckTrigger_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolCheckTrigger_NonExistingTrigger() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingTrigger", + ExpectedResults = new List + { + Error.NonExistingTrigger(null, null, null, "10", "100"), + Error.NonExistingTrigger(null, null, null, "10", "100"), + Error.NonExistingTrigger(null, null, null, "11", "100"), + Error.NonExistingTrigger(null, null, null, "15", "100"), + Error.NonExistingTrigger(null, null, null, "14", "100"), + Error.NonExistingTrigger(null, null, null, "10", "100"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolCheckTrigger_NonExistingTrigger() + { + // Create ErrorMessage + var message = Error.NonExistingTrigger(null, null, null, "10", "100"); + + string description = "Method 'SLProtocol.CheckTrigger' references a non-existing 'Trigger' with ID '10'. QAction ID '100'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolCheckTrigger(); + + [TestMethod] + public void QAction_CSharpSLProtocolCheckTrigger_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolCheckTrigger_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolCheckTrigger); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Invalid/NonExistingTrigger.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Invalid/NonExistingTrigger.xml new file mode 100644 index 00000000..ce6f5378 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Invalid/NonExistingTrigger.xml @@ -0,0 +1,64 @@ + + CSharpSLProtocolCheckTrigger_NonExistingTrigger + 1.0.0.1 + + + + + + + +/// DataMiner QAction Class: Simple_CheckTrigger_10. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int triggerId = 5 + 9; + + protocol.CheckTrigger(10); + protocol.CheckTrigger(10); + protocol.CheckTrigger(11); + + protocol.CheckTrigger(5 + 10); + protocol.CheckTrigger(triggerId); + protocol.CheckTrigger(Triggers.MyTrigger_10); + + protocol.CheckTriggerWrapper(12); // Not (yet) covered + protocol.CheckTriggerWrapper(5 + 15); // Not (yet) covered + protocol.CheckTriggerWrapper(triggerId); // Not (yet) covered + protocol.CheckTriggerWrapper(Triggers.MyTrigger_10); // Not (yet) covered + + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..496981de --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolCheckTrigger/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,91 @@ + + CSharpSLProtocolCheckTrigger_Valid + 0.0.0.0 + + + + + /// Performs a query using IMS Inventory Service + /// + /// Result Type + /// Query to perform + /// Action with extra processing + /// IMS Polling Task + /// IEnumerable<string> object with the ids of the objects to query + public void GetInventory( + Expression> query) + where TResult : class + { + Guid token = Guid.NewGuid(); + string channel = "channel"; + string id = "id"; + + var result = query.Compile()(token, channel, id); + } + } + } +}]]> + + + +/// DataMiner QAction Class: Simple_CheckTrigger_10. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int triggerId = 5 + 5; + + protocol.CheckTrigger(10); + protocol.CheckTrigger(5 + 5); + protocol.CheckTrigger(triggerId); + protocol.CheckTrigger(Triggers.MyTrigger_10); + + // Not yet covered + protocol.CheckTriggerWrapper(10); + protocol.CheckTriggerWrapper(5 + 5); + protocol.CheckTriggerWrapper(triggerId); + protocol.CheckTriggerWrapper(Triggers.MyTrigger_10); + } +}]]> + + + + + + CheckTrigger_10 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/CSharpSLProtocolFillArray.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/CSharpSLProtocolFillArray.cs new file mode 100644 index 00000000..2dc018c9 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/CSharpSLProtocolFillArray.cs @@ -0,0 +1,253 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolFillArray +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolFillArray; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolFillArray(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, "1000", "103"), + Error.NonExistingParam(null, null, null, "1100", "103"), + Error.NonExistingParam(null, null, null, "1200", "103"), + Error.HardCodedPid(null, null, null, "1000", "103"), + Error.HardCodedPid(null, null, null, "1100", "103"), + Error.HardCodedPid(null, null, null, "1200", "103"), + + Error.NonExistingParam(null, null, null, "2000", "103"), + Error.NonExistingParam(null, null, null, "2100", "103"), + Error.NonExistingParam(null, null, null, "2200", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2100", "103"), + Error.HardCodedPid(null, null, null, "2200", "103"), + + Error.NonExistingParam(null, null, null, "3000", "103"), + Error.NonExistingParam(null, null, null, "3100", "103"), + Error.NonExistingParam(null, null, null, "3200", "103"), + Error.HardCodedPid(null, null, null, "3000", "103"), + Error.HardCodedPid(null, null, null, "3100", "103"), + Error.HardCodedPid(null, null, null, "3200", "103"), + + // TODO: Not yet covered + //Error.NonExistingParam(null, null, null, "4000", "103"), + //Error.NonExistingParam(null, null, null, "4200", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_ParamMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ParamMissingHistorySet", + ExpectedResults = new List + { + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + + Error.ParamMissingHistorySet(null, null, null, "1102"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + + Error.ParamMissingHistorySet(null, null, null, "1102"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + // Not yet covered + //Error.ParamMissingHistorySet(null, null, null, "1002"), + //Error.ParamMissingHistorySet(null, null, null, "1003"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + //[TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpSLProtocolFillArray(); + + [TestMethod] + public void Protocol_CSharpSLProtocolFillArray_ParamMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ParamMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.9.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.FillArray' references a non-existing 'table' with PID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArray is used to update a table with new values." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_ParamMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ParamMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.9.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "SLProtocol.FillArray overload with 'DateTime? timeInfo' argument requires 'Param@historySet=true'. column PID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "Every overload of the 'SLProtocol.FillArray' method having the 'DateTime? timeInfo' argument is meant to execute a historySet." + Environment.NewLine + "Such method requires the columns of the table to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_HardCodedPid() + { + // Create ErrorMessage + var message = Error.HardCodedPid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.9.3", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArray is used to update a table with new values." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolFillArray(); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolFillArray); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Codefix/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Codefix/ParamMissingHistorySet.xml new file mode 100644 index 00000000..831617be --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Codefix/ParamMissingHistorySet.xml @@ -0,0 +1,127 @@ + + FillArray_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArray_HistorySets. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new[] { keys[i], values[i] }); + } + + protocol.FillArray(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + + protocol.FillArray(Parameter.Historysetfalse.tablePid, columnsList, date_dt); + + protocol.FillArray(Parameter.Nohistoryset.tablePid, rows, NotifyProtocol.SaveOption.Full, date_dt); + + protocol.FillArray(Parameter.Historysetfalse.tablePid, rows, NotifyProtocol.SaveOption.Partial, date_dt); + + protocol.FillArrayWrapper(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..5951be7e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,105 @@ + + FillArray_HardCodedPid + 1.0.0.1 + + + + FillArray + array + + + + + + + + FillArrayInstance + read + + + FillArrayColumn2 + read + + + FillArrayColumn3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArray. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new object[] { keys[i], values[i] }); + } + + protocol.FillArray(2000, columnsArray); + protocol.FillArray(2000, columnsArray, null); + protocol.FillArray(2000, columnsArray, date_dt); + + protocol.FillArray(2000, columnsList); + protocol.FillArray(2000, columnsList, null); + protocol.FillArray(2000, columnsList, date_dt); + + protocol.FillArray(2000, rows, NotifyProtocol.SaveOption.Full); + protocol.FillArray(2000, rows, NotifyProtocol.SaveOption.Partial, null); + protocol.FillArray(2000, rows, NotifyProtocol.SaveOption.Full, date_dt); + protocol.FillArray(2000, rows, NotifyProtocol.SaveOption.Partial, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..346bbc76 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,87 @@ + + FillArray_NonExistingParam + 1.0.0.1 + + + + + + + + +/// DataMiner QAction Class: FillArray. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid = 1000; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new object[] { keys[i], values[i] }); + } + + protocol.FillArray(1000, columnsArray); + protocol.FillArray(1100, columnsArray, null); + protocol.FillArray(1200, columnsArray, date_dt); + + protocol.FillArray(2000, columnsList); + protocol.FillArray(2100, columnsList, null); + protocol.FillArray(2200, columnsList, date_dt); + + protocol.FillArray(3000, rows, NotifyProtocol.SaveOption.Full); + protocol.FillArray(3100, rows, NotifyProtocol.SaveOption.Partial, null); + protocol.FillArray(3200, rows, NotifyProtocol.SaveOption.Partial, date_dt); + + // Not considered hard-coded for now even though it essentially is + protocol.FillArrayWrapper(4000, columnsArray); + protocol.FillArrayWrapper(4200, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/ParamMissingHistorySet.xml new file mode 100644 index 00000000..c406e005 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Invalid/ParamMissingHistorySet.xml @@ -0,0 +1,127 @@ + + FillArray_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArray_HistorySets. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new[] { keys[i], values[i] }); + } + + protocol.FillArray(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + + protocol.FillArray(Parameter.Historysetfalse.tablePid, columnsList, date_dt); + + protocol.FillArray(Parameter.Nohistoryset.tablePid, rows, NotifyProtocol.SaveOption.Full, date_dt); + + protocol.FillArray(Parameter.Historysetfalse.tablePid, rows, NotifyProtocol.SaveOption.Partial, date_dt); + + protocol.FillArrayWrapper(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..9cbc3d26 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArray/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,190 @@ + + FillArray_Valid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArray. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid1 = Parameter.Nohistoryset.tablePid; + int tablePid2 = Parameter.Historysetfalse.tablePid; + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new[] { keys[i], values[i] }); + } + + protocol.FillArray(tablePid1, columnsArray); + protocol.FillArray(tablePid2, columnsArray, null); + + protocol.FillArray(Parameter.Nohistoryset.tablePid, columnsList); + protocol.FillArray(Parameter.Historysetfalse.tablePid, columnsList, null); + + protocol.FillArray(tablePid1, rows, NotifyProtocol.SaveOption.Full); + protocol.FillArray(tablePid2, rows, NotifyProtocol.SaveOption.Partial, null); + + protocol.FillArrayWrapper(tablePid1, columnsArray); + } +}]]> + + + +/// DataMiner QAction Class: FillArray_historySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid = 2000; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + List rows = new List(); + for (int i = 0; i < keys.Length; i++) + { + rows.Add(new object[] { keys[i], values[i] }); + } + + //protocol.FillArray(tablePid, columnsArray, date_dt); + //protocol.FillArray(tablePid, columnsList, date_dt); + //protocol.FillArray(tablePid, rows, NotifyProtocol.SaveOption.Full, date_dt); + //protocol.FillArray(tablePid, rows, NotifyProtocol.SaveOption.Partial, date_dt); + //protocol.FillArrayWrapper(tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/CSharpSLProtocolFillArrayNoDelete.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/CSharpSLProtocolFillArrayNoDelete.cs new file mode 100644 index 00000000..7e9db5d7 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/CSharpSLProtocolFillArrayNoDelete.cs @@ -0,0 +1,235 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolFillArrayNoDelete +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolFillArrayNoDelete; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolFillArrayNoDelete(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, "1000", "103"), + Error.NonExistingParam(null, null, null, "1100", "103"), + Error.NonExistingParam(null, null, null, "1200", "103"), + Error.HardCodedPid(null, null, null, "1000", "103"), + Error.HardCodedPid(null, null, null, "1100", "103"), + Error.HardCodedPid(null, null, null, "1200", "103"), + + Error.NonExistingParam(null, null, null, "2000", "103"), + Error.NonExistingParam(null, null, null, "2100", "103"), + Error.NonExistingParam(null, null, null, "2200", "103"), + Error.HardCodedPid(null, null, null, "2000", "103"), + Error.HardCodedPid(null, null, null, "2100", "103"), + Error.HardCodedPid(null, null, null, "2200", "103"), + + // TODO: Not yet covered + //Error.NonExistingParam(null, null, null, "4000", "103"), + //Error.NonExistingParam(null, null, null, "4200", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_ParamMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ParamMissingHistorySet", + ExpectedResults = new List + { + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + + Error.ParamMissingHistorySet(null, null, null, "1102"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + // TODO: Not yet covered + //Error.ParamMissingHistorySet(null, null, null, "1002"), + //Error.ParamMissingHistorySet(null, null, null, "1003"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + //[TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpSLProtocolFillArrayNoDelete(); + + [TestMethod] + public void Protocol_CSharpSLProtocolFillArrayNoDelete_ParamMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ParamMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.10.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.FillArrayNoDelete' references a non-existing 'table' with PID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayNoDelete is used to update a table with new values." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_ParamMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ParamMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.10.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "SLProtocol.FillArrayNoDelete overload with 'DateTime? timeInfo' argument requires 'Param@historySet=true'. column PID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "Every overload of the 'SLProtocol.FillArrayNoDelete' method having the 'DateTime? timeInfo' argument is meant to execute a historySet." + Environment.NewLine + "Such method requires the columns of the table to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_HardCodedPid() + { + // Create ErrorMessage + var message = Error.HardCodedPid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.10.3", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayNoDelete is used to update a table with new values." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolFillArrayNoDelete(); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayNoDelete_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolFillArrayNoDelete); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Codefix/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Codefix/ParamMissingHistorySet.xml new file mode 100644 index 00000000..dee14e72 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Codefix/ParamMissingHistorySet.xml @@ -0,0 +1,117 @@ + + FillArrayNoDelete_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArrayNoDelete. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + protocol.FillArrayNoDelete(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + + protocol.FillArrayNoDelete(Parameter.Historysetfalse.tablePid, columnsList, date_dt); + + protocol.FillArrayNoDeleteWrapper(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..7f3d67db --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,96 @@ + + FillArrayNoDelete_HardCodedPid + 1.0.0.1 + + + + FillArrayNoDelete + array + + + + + + + + FillArrayInstance + read + + + FillArrayColumn2 + read + + + FillArrayColumn3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArrayNoDelete. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + protocol.FillArrayNoDelete(2000, columnsArray); + protocol.FillArrayNoDelete(2000, columnsArray, null); + protocol.FillArrayNoDelete(2000, columnsArray, date_dt); + + protocol.FillArrayNoDelete(2000, columnsList); + protocol.FillArrayNoDelete(2000, columnsList, null); + protocol.FillArrayNoDelete(2000, columnsList, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..1bfb0c11 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,109 @@ + + FillArrayNoDelete_NonExistingParam + 1.0.0.1 + + + + MyParam100 + read + + + + RetrievedTable + array + + + + + + + + Retrieved_Instance + read + + + Retrieved_Column2 + read + + + Retrieved_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArrayNoDelete. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid = 1000; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + protocol.FillArrayNoDelete(1000, columnsArray); + protocol.FillArrayNoDelete(1100, columnsArray, null); + protocol.FillArrayNoDelete(1200, columnsArray, date_dt); + + protocol.FillArrayNoDelete(2000, columnsList); + protocol.FillArrayNoDelete(2100, columnsList, null); + protocol.FillArrayNoDelete(2200, columnsList, date_dt); + + // Not considered hard-coded for now even though it essentially is + protocol.FillArrayNoDeleteWrapper(4000, columnsArray); + protocol.FillArrayNoDeleteWrapper(4200, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/ParamMissingHistorySet.xml new file mode 100644 index 00000000..703c3ef3 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Invalid/ParamMissingHistorySet.xml @@ -0,0 +1,117 @@ + + FillArrayNoDelete_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArrayNoDelete. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + protocol.FillArrayNoDelete(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + + protocol.FillArrayNoDelete(Parameter.Historysetfalse.tablePid, columnsList, date_dt); + + protocol.FillArrayNoDeleteWrapper(Parameter.Nohistoryset.tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0c277fe4 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayNoDelete/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,179 @@ + + FillArrayNoDelete_Valid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: FillArrayNoDelete. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid1 = Parameter.Nohistoryset.tablePid; + int tablePid2 = Parameter.Historysetfalse.tablePid; + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + + protocol.FillArrayNoDelete(tablePid1, columnsArray); + protocol.FillArrayNoDelete(tablePid2, columnsArray, null); + + protocol.FillArrayNoDelete(Parameter.Nohistoryset.tablePid, columnsList); + protocol.FillArrayNoDelete(Parameter.Historysetfalse.tablePid, columnsList, null); + + protocol.FillArrayNoDeleteWrapper(tablePid1, columnsArray); + } +}]]> + + + +/// DataMiner QAction Class: FillArrayNoDelete_historySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid = 2000; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + object[] columnsArray = new object[] { keys, values }; + List columnsList = new List { keys, values }; + + // TODO: Use Parameter class + + //protocol.FillArrayNoDelete(tablePid, columnsArray, date_dt); + //protocol.FillArrayNoDelete(tablePid, columnsList, date_dt); + //protocol.FillArrayNoDeleteWrapper(tablePid, columnsArray, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/CSharpSLProtocolFillArrayWithColumn.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/CSharpSLProtocolFillArrayWithColumn.cs new file mode 100644 index 00000000..f6ee7c4a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/CSharpSLProtocolFillArrayWithColumn.cs @@ -0,0 +1,458 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolFillArrayWithColumn +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolFillArrayWithColumn; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolFillArrayWithColumn(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_ColumnManagedByDataMiner() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnManagedByDataMiner", + ExpectedResults = new List + { + // DVE Element + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + Error.ColumnManagedByDataMiner(null, null, null, "10003", "ColumnOption@option", "element"), + + // State + Error.ColumnManagedByDataMiner(null, null, null, "10004", "ColumnOption@type", "state"), + + // DisplayKey + Error.ColumnManagedByDataMiner(null, null, null, "9999", "ColumnOption@type", "displaykey"), + + // Concatenation + Error.ColumnManagedByDataMiner(null, null, null, "10007", "ColumnOption@type", "concatenation") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_ColumnManagedByProtocolItem() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ColumnManagedByProtocolItem", + ExpectedResults = new List + { + // RTT + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + Error.ColumnManagedByProtocolItem(null, null, null, "11003", "Timer", "1", "Timer@options", "ping/rttColumn"), + + // Timestamp + Error.ColumnManagedByProtocolItem(null, null, null, "11004", "Timer", "1", "Timer@options", "ping/timestampColumn"), + + // Jitter + Error.ColumnManagedByProtocolItem(null, null, null, "11005", "Timer", "1", "Timer@options", "ping/jitterColumn"), + + // Latency + Error.ColumnManagedByProtocolItem(null, null, null, "11006", "Timer", "1", "Timer@options", "ping/latencyColumn"), + + // PacketLossRateColumn + Error.ColumnManagedByProtocolItem(null, null, null, "11007", "Timer", "1", "Timer@options", "ping/packetLossRateColumn"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_HardCodedColumnPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedColumnPid", + ExpectedResults = new List + { + Error.HardCodedColumnPid(null, null, null, "1002", "103"), + Error.HardCodedColumnPid(null, null, null, "1103", "103"), + Error.HardCodedColumnPid(null, null, null, "2002", "103"), + + // Wrapper: Not covered yet + //Error.HardCodedColumnPid(null, null, null, "1002", "103"), + //Error.HardCodedColumnPid(null, null, null, "2002", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_HardCodedTablePid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedTablePid", + ExpectedResults = new List + { + Error.HardCodedTablePid(null, null, null, "1000", "103"), + Error.HardCodedTablePid(null, null, null, "1100", "103"), + Error.HardCodedTablePid(null, null, null, "2000", "103"), + + // Wrapper: Not covered yet + //Error.HardCodedTablePid(null, null, null, "1000", "103"), + //Error.HardCodedTablePid(null, null, null, "2000", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_NonExistingColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumn", + ExpectedResults = new List + { + Error.NonExistingColumn(null, null, null, "1009", "103"), + Error.NonExistingColumn(null, null, null, "1109", "103"), + Error.NonExistingColumn(null, null, null, "2009", "103"), + + Error.HardCodedColumnPid(null, null, null, "1009", "103"), + Error.HardCodedColumnPid(null, null, null, "1109", "103"), + Error.HardCodedColumnPid(null, null, null, "2009", "103"), + + // Wrapper: Not covered yet + //Error.NonExistingColumn(null, null, null, "1009", "103"), + //Error.NonExistingColumn(null, null, null, "2009", "103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_NonExistingTable() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingTable", + ExpectedResults = new List + { + Error.NonExistingTable(null, null, null, "999", "103"), + Error.NonExistingTable(null, null, null, "1099", "103"), + Error.NonExistingTable(null, null, null, "1999", "103"), + + Error.HardCodedTablePid(null, null, null, "999", "103"), + Error.HardCodedTablePid(null, null, null, "1099", "103"), + Error.HardCodedTablePid(null, null, null, "1999", "103"), + + // Wrapper: Not covered yet + //Error.NonExistingTable(null, null, null, "999", "103"), + //Error.NonExistingTable(null, null, null, "1999", "103"), + + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_ParamMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ParamMissingHistorySet", + ExpectedResults = new List + { + // Hard-coded + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + Error.HardCodedColumnPid(null, null, null, "1002", "103"), + Error.HardCodedColumnPid(null, null, null, "1103", "103"), + + // Local Variable + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + // Generic Constant + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + // Parameter Class + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1103"), + + // Wrappers (Not yet covered) + //Error.ParamMissingHistorySet(null, null, null, "1002"), + //Error.ParamMissingHistorySet(null, null, null, "1103"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_UnrecommendedSetOnSnmpParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedSetOnSnmpParam", + ExpectedResults = new List + { + // SNMP + Error.UnrecommendedSetOnSnmpParam(null, null, null, "102"), + + Error.UnrecommendedSetOnSnmpParam(null, null, null, "103"), + Error.UnrecommendedSetOnSnmpParam(null, null, null, "106"), + + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpSLProtocolFillArrayWithColumn(); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_ParamMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ParamMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_HardCodedColumnPid() + { + // Create ErrorMessage + var message = Error.HardCodedColumnPid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "3.11.5", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayWithColumn is used to update the values of a column." + Environment.NewLine + "Make sure to provide it with an ID of a column parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_HardCodedTablePid() + { + // Create ErrorMessage + var message = Error.HardCodedTablePid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "3.11.4", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayWithColumn is used to update the values of a column." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_NonExistingColumn() + { + // Create ErrorMessage + var message = Error.NonExistingColumn(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.11.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.FillArrayWithColumn' references a non-existing 'column' with PID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayWithColumn is used to update the values of a column." + Environment.NewLine + "Make sure to provide it with an ID of a column parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_NonExistingTable() + { + // Create ErrorMessage + var message = Error.NonExistingTable(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.11.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.FillArrayWithColumn' references a non-existing 'table' with PID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.FillArrayWithColumn is used to update the values of a column." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_ParamMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ParamMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.11.3", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "SLProtocol.FillArrayWithColumn overload with 'DateTime? timeInfo' argument requires 'Param@historySet=true'. column PID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "Every overload of the 'SLProtocol.FillArrayWithColumn' method having the 'DateTime? timeInfo' argument is meant to execute a historySet." + Environment.NewLine + "Such method requires the column to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_UnrecommendedSetOnSnmpParam() + { + // Create ErrorMessage + var message = Error.UnrecommendedSetOnSnmpParam(null, null, null, "1"); + + var expected = new ValidationResult + { + ErrorId = 8, + FullId = "3.11.8", + Category = Category.QAction, + Severity = Severity.Minor, + Certainty = Certainty.Uncertain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended set on column '1' with 'ColumnOption@type' containing 'snmp'.", + HowToFix = "", + ExampleCode = "", + Details = + $"It is typically unrecommended to update SNMP parameters from within a protocol.{Environment.NewLine}" + + $"Indeed, SNMP parameters should typically strictly be updated via polling.{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Exceptions can sometimes be made when we update SNMP parameters based on received traps which contains, without any possible doubt, the new value.{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Side note: There are alternatives to poll SNMP parameters in an efficient way when, for example, a cell or column or row needs to be updated but you don't want to poll the entire table:{Environment.NewLine}" + + $"- See various snmpSet options{Environment.NewLine}" + + $"- See dynamicSnmpGet feature.{Environment.NewLine}" + + "- ...", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolFillArrayWithColumn(); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolFillArrayWithColumn_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolFillArrayWithColumn); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Codefix/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Codefix/ParamMissingHistorySet.xml new file mode 100644 index 00000000..2f11be95 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Codefix/ParamMissingHistorySet.xml @@ -0,0 +1,142 @@ + + FillArrayWithColumns_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayNoDelete_ParamMissingHistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int table1Pid = Parameter.Nohistoryset.tablePid; + int table1Column2Pid = Parameter.Nohistoryset.Pid.nohistoryset_column2_1002; + + int table2Pid = Parameter.Historysetfalse.tablePid; + int table2Column3Pid = Parameter.Historysetfalse.Pid.historysetfalse_column3_1103; + + //int table3Pid = Parameter.HistorySetTrue.tablePid; + //int table3Column1Pid = 2003; + + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + // Hard-coded + protocol.FillArrayWithColumn(table1Pid, 1002, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, 1103, keys, values, date_dt); + + // Local Variable + protocol.FillArrayWithColumn(table1Pid, table1Column2Pid, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, table2Column3Pid, keys, values, date_dt); + + // Generic Constant + protocol.FillArrayWithColumn(table1Pid, MyParams.Table1000_Column2, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, MyParams.Table1100_Column3, keys, values, date_dt); + + // Parameter class + protocol.FillArrayWithColumn(table1Pid, Parameter.Nohistoryset.Pid.nohistoryset_column2_1002, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, Parameter.Historysetfalse.Pid.historysetfalse_column3_1103, keys, values, date_dt); + + // Wrappers (Not yet covered) + protocol.FillArrayWithColumnWrapper(table1Pid, Parameter.Nohistoryset.Pid.nohistoryset_column2_1002, keys, values, date_dt); + protocol.FillArrayWithColumnWrapper(table2Pid, Parameter.Historysetfalse.Pid.historysetfalse_column3_1103, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml new file mode 100644 index 00000000..f0c3d20a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByDataMiner.xml @@ -0,0 +1,95 @@ + + FillArrayWithColumns_ColumnManagedByDataMiner + 1.0.0.1 + + + + DVEs_DisplayKey + read + + + DVEs + array + + + + + + + + + + + + + DVEs_Instance + read + + + DVEs_Column2 + read + + + DVEs_Column3_DveElement + read + + + DVEs_Column4_State + read + + + DVEs_Column5_DeleteButton + write + + button + + + + DVEs_Column6_DveSeverity + read + + + DVEs_Column7_Concatenation + read + + + + + + +/// DataMiner QAction Class: DVEs. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + // DVE Element + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement, keys, values); + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column3_dveelement_10003, keys, values, date_dt); + + // State + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column4_state_10004, keys, values); + + // DisplayKey + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_displaykey_9999, keys, values); + + // Concatenation + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column7_concatenation_10007, keys, values); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml new file mode 100644 index 00000000..089b3466 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ColumnManagedByProtocolItem.xml @@ -0,0 +1,96 @@ + + FillArrayWithColumns_ColumnManagedByProtocolItem + 1.0.0.1 + + + + MultiThreading + array + + + + + + + + + + + + MultiThreading_Instance + read + + + MultiThreading_IpAddress + read + + + MultiThreading_RTT + read + + + MultiThreading_Timestamp + read + + + MultiThreading_Jitter + read + + + MultiThreading_Latency + read + + + MultiThreading_PacketLossRate + read + + + + + + +/// DataMiner QAction Class: MultiThreading. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + // RTT + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt, keys, values); + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_rtt_11003, keys, values, date_dt); + + // Timestamp + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_timestamp_11004, keys, values); + + // Jitter + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_jitter_11005, keys, values); + + // Latency + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_latency_11006, keys, values); + + // PacketLossRateColumn + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_packetlossrate_11007, keys, values); + } +}]]> + + + + + + MultiThreaded Timer + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml new file mode 100644 index 00000000..15a44878 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedColumnPid.xml @@ -0,0 +1,137 @@ + + FillArrayWithColumns_HardCodedColumnPid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayWithColumn_HardCodedColumnPid. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(Parameter.Nohistoryset.tablePid, 1002, keys, values); + protocol.FillArrayWithColumn(Parameter.Historysetfalse.tablePid, 1103, keys, values, null); + protocol.FillArrayWithColumn(Parameter.Historysettrue.tablePid, 2002, keys, values, date_dt); + + protocol.FillArrayWithColumnsWrapper(Parameter.Nohistoryset.tablePid, 1002, keys, values); + protocol.FillArrayWithColumnsWrapper(Parameter.Historysettrue.tablePid, 2002, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml new file mode 100644 index 00000000..a4bcb4a7 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/HardCodedTablePid.xml @@ -0,0 +1,136 @@ + + FillArrayWithColumns_HardCodedTablePid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayNoDelete_HardCodedTablePid. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(1000, Parameter.Nohistoryset.Pid.nohistoryset_column2, keys, values); + protocol.FillArrayWithColumn(1100, Parameter.Historysetfalse.Pid.historysetfalse_column3, keys, values, null); + protocol.FillArrayWithColumn(2000, Parameter.Historysettrue.Pid.historysettrue_column2, keys, values, date_dt); + + protocol.FillArrayWithColumnsWrapper(1000, Parameter.Nohistoryset.Pid.nohistoryset_column2, keys, values); + protocol.FillArrayWithColumnsWrapper(2000, Parameter.Historysettrue.Pid.historysettrue_column2, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml new file mode 100644 index 00000000..243277b4 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingColumn.xml @@ -0,0 +1,144 @@ + + FillArrayWithColumns_NonExistingColumn + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayWithColumn_NonExistingColumn. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int table1Pid = Parameter.Nohistoryset.tablePid; + int table1WrongColumnPid = 1009; + + int table2Pid = Parameter.Historysetfalse.tablePid; + + int table3Pid = Parameter.Historysettrue.tablePid; + int table3WrongColumnPid = 2009; + + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(table1Pid, 1009, keys, values); + protocol.FillArrayWithColumn(table2Pid, 1109, keys, values, null); + protocol.FillArrayWithColumn(table3Pid, 2009, keys, values, date_dt); + + protocol.FillArrayWithColumnsWrapper(table1Pid, table1WrongColumnPid, keys, values); + protocol.FillArrayWithColumnsWrapper(table3Pid, table3WrongColumnPid, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml new file mode 100644 index 00000000..04a88d33 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/NonExistingTable.xml @@ -0,0 +1,143 @@ + + FillArrayWithColumns_NonExistingTable + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayNoDelete_NonExistingTable. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int table1Column2Pid = Parameter.Nohistoryset.Pid.nohistoryset_column2; + + int table2Column3Pid = Parameter.Historysetfalse.Pid.historysetfalse_column3; + + int table3Column2Pid = Parameter.Historysettrue.Pid.historysettrue_column2; + + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(1000 - 1, table1Column2Pid, keys, values); + protocol.FillArrayWithColumn(1100 - 1, table2Column3Pid, keys, values, null); + protocol.FillArrayWithColumn(2000 - 1, table3Column2Pid, keys, values, date_dt); + + protocol.FillArrayWithColumnsWrapper(1000 - 1, table1Column2Pid, keys, values); + protocol.FillArrayWithColumnsWrapper(2000 - 1, table3Column2Pid, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ParamMissingHistorySet.xml new file mode 100644 index 00000000..07d8c302 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/ParamMissingHistorySet.xml @@ -0,0 +1,142 @@ + + FillArrayWithColumns_MissingHistorySet + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_FillArrayNoDelete_ParamMissingHistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int table1Pid = Parameter.Nohistoryset.tablePid; + int table1Column2Pid = Parameter.Nohistoryset.Pid.nohistoryset_column2_1002; + + int table2Pid = Parameter.Historysetfalse.tablePid; + int table2Column3Pid = Parameter.Historysetfalse.Pid.historysetfalse_column3_1103; + + //int table3Pid = Parameter.HistorySetTrue.tablePid; + //int table3Column1Pid = 2003; + + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + // Hard-coded + protocol.FillArrayWithColumn(table1Pid, 1002, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, 1103, keys, values, date_dt); + + // Local Variable + protocol.FillArrayWithColumn(table1Pid, table1Column2Pid, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, table2Column3Pid, keys, values, date_dt); + + // Generic Constant + protocol.FillArrayWithColumn(table1Pid, MyParams.Table1000_Column2, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, MyParams.Table1100_Column3, keys, values, date_dt); + + // Parameter class + protocol.FillArrayWithColumn(table1Pid, Parameter.Nohistoryset.Pid.nohistoryset_column2_1002, keys, values, date_dt); + protocol.FillArrayWithColumn(table2Pid, Parameter.Historysetfalse.Pid.historysetfalse_column3_1103, keys, values, date_dt); + + // Wrappers (Not yet covered) + protocol.FillArrayWithColumnWrapper(table1Pid, Parameter.Nohistoryset.Pid.nohistoryset_column2_1002, keys, values, date_dt); + protocol.FillArrayWithColumnWrapper(table2Pid, Parameter.Historysetfalse.Pid.historysetfalse_column3_1103, keys, values, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml new file mode 100644 index 00000000..42b0a565 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Invalid/UnrecommendedSetOnSnmpParam.xml @@ -0,0 +1,83 @@ + + FillArrayWithColumns_UnrecommendedSetOnSnmpParam + 1.0.0.1 + + + + SNMP + array + + + + + + + + + + + + + SNMP_Instance + read + + + SNMP_Column2_SNMP + read + + + SNMP_Column3_SNMP + read + + + SNMP_Column4_Custom + read + + + SNMP_Column5_Custom + read + + + SNMP_Column6_SNMP + read + + + SNMP_Column7_Retrieved + read + + + SNMP_Column8_Retrieved + read + + + + + + +/// DataMiner QAction Class: SNMP. +/// +public static class QAction +{ + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + object[] column3Values = { "Value_1", "Value_2", protocol.Clear, null, protocol.Leave }; + + protocol.FillArrayWithColumn(Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column2_snmp, keys, values); + protocol.FillArrayWithColumn(Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column3_snmp_103, keys, values); + protocol.FillArrayWithColumn(Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column6_snmp, keys, column3Values); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d90be1cb --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolFillArrayWithColumn/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,434 @@ + + FillArrayWithColumns_Valid + 1.0.0.1 + + + + SNMP + array + + + + + + + + + + + + + SNMP_Instance + read + + + SNMP_Column2_SNMP + read + + + SNMP_Column3_SNMP + read + + + SNMP_Column4_Custom + read + + + SNMP_Column5_Custom + read + + + SNMP_Column6_SNMP + read + + + SNMP_Column7_Retrieved + read + + + SNMP_Column8_Retrieved + read + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + DVEs_DisplayKey + read + + + DVEs + array + + + + + + + + + + + + DVEs_Instance + read + + + DVEs_Column2 + read + + + DVEs_Column3_DveElement + read + + + DVEs_Column4_State + read + + + DVEs_Column5_DeleteButton + write + + button + + + + DVEs_Column6_WithHistorySet + read + + + + MultiThreading + array + + + + + + + + + + + + + MultiThreading_Instance + read + + + MultiThreading_IpAddress + read + + + MultiThreading_RTT + read + + + MultiThreading_Timestamp + read + + + MultiThreading_Jitter + read + + + MultiThreading_Latency + read + + + MultiThreading_PacketLossRate + read + + + MultiThreading_ColumnWithHistorySet + read + + + + + + + + + + +/// DataMiner QAction Class: SNMP. +/// +public static class QAction +{ + public static void Run(SLProtocol protocol) + { + bool useClearAndLeaveTrue = true; + bool useClearAndLeaveFalse = false; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + + object[] primaryKeys = { "PK_1", "PK_2", "PK_3", "PK_4", "PK_5" }; + object[] column2Values = { "Value_1", "Value_2", "Value_3", "Value_4", "Value_5" }; + object[] column3Values = { "Value_1", "Value_2", protocol.Clear, null, protocol.Leave }; + + protocol.NotifyProtocol(220, new object[] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column7_retrieved }, new object[] { primaryKeys, column2Values }); + protocol.NotifyProtocol(220, new object[] { Parameter.Snmp.tablePid, Parameter.Snmp.Pid.snmp_column8_retrieved_108, Parameter.Snmp.Pid.snmp_column7_retrieved }, new object[] { primaryKeys, column2Values, column3Values }); + } +}]]> + + + + +/// DataMiner QAction Class: NoHistorySets. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2, keys, values); + protocol.FillArrayWithColumn(Parameter.Historysetfalse.tablePid, Parameter.Historysetfalse.Pid.historysetfalse_column3, keys, values, null); + + // Not yet covered + protocol.FillArrayWithColumnsWrapper(Parameter.Nohistoryset.tablePid, Parameter.Nohistoryset.Pid.nohistoryset_column2_1002, keys, values); + } +}]]> + + + +/// DataMiner QAction Class: HistorySets. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column3, keys, values, date_dt); + + protocol.FillArrayWithColumnsWrapper(Parameter.Historysettrue.tablePid, Parameter.Historysettrue.Pid.historysettrue_column3, keys, values, date_dt); + } +}]]> + + + +/// DataMiner QAction Class: DVEs. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column2, keys, values); + protocol.FillArrayWithColumn(Parameter.Dves.tablePid, Parameter.Dves.Pid.dves_column6_withhistoryset_10006, keys, values, date_dt); + } +}]]> + + + +/// DataMiner QAction Class: MultiThreading. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] keys = { "PK_1", "PK_2", "PK_3" }; + object[] values = { "Value_1", "Value_2", "Value_3" }; + + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_ipaddress, keys, values); + protocol.FillArrayWithColumn(Parameter.Multithreading.tablePid, Parameter.Multithreading.Pid.multithreading_columnwithhistoryset_11008, keys, values, date_dt); + } +}]]> + + + + + + MultiThreaded Timer + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/CSharpSLProtocolGetParameter.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/CSharpSLProtocolGetParameter.cs new file mode 100644 index 00000000..dc928c6a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/CSharpSLProtocolGetParameter.cs @@ -0,0 +1,183 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolGetParameter +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolGetParameter; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolGetParameter(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + // Direct + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "200", "101"), + Error.HardCodedPid(null, null, null, "300", "101"), + Error.HardCodedPid(null, null, null, "350", "101"), + + // Simple Math + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + + // Advanced Math + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.HardCodedPid(null, null, null, "9", "101"), + Error.HardCodedPid(null, null, null, "19", "101"), + Error.HardCodedPid(null, null, null, "-29", "101"), + + Error.HardCodedPid(null, null, null, "99", "101"), + Error.HardCodedPid(null, null, null, "199", "101"), + + Error.NonExistingParam(null, null, null, "9", "101"), + Error.NonExistingParam(null, null, null, "19", "101"), + Error.NonExistingParam(null, null, null, "-29", "101"), + + Error.NonExistingParam(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "199", "101"), + + //Error.NonExistingParam(null, null, null, "999", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1099", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1199", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1299", "101"), // Not (yet) covered + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_NonExistingParam_NoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam_NoParamsTag", + ExpectedResults = new List + { + Error.HardCodedPid(null, null, null, "9", "101"), + Error.HardCodedPid(null, null, null, "-29", "101"), + Error.HardCodedPid(null, null, null, "19", "101"), + + Error.HardCodedPid(null, null, null, "99", "101"), + Error.HardCodedPid(null, null, null, "199", "101"), + + Error.NonExistingParam(null, null, null, "9", "101"), + Error.NonExistingParam(null, null, null, "19", "101"), + Error.NonExistingParam(null, null, null, "-29", "101"), + + Error.NonExistingParam(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "199", "101"), + + //Error.NonExistingParam(null, null, null, "999", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1099", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1199", "101"), // Not (yet) covered + //Error.NonExistingParam(null, null, null, "1299", "101"), // Not (yet) covered + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.6.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Method 'SLProtocol.GetParameter' references a non-existing 'Param' with ID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.GetParameter is used to get the current value of a standalone parameter." + Environment.NewLine + "Make sure to provide it with an ID of a standalone parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolGetParameter(); + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameter_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolGetParameter); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..78b0073c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,102 @@ + + GetParameter_HardCodedPid + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + + +/// DataMiner QAction Class: GetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int pid = 100; + + // Hard-coded + protocol.GetParameter(pid); + protocol.GetParameter(MyParams.MyReadParam_100); + protocol.GetParameter(100); + protocol.GetParameter(200); + protocol.GetParameter(300); + protocol.GetParameter(350); + + // Simple Math + protocol.GetParameter(50 + 50); + protocol.GetParameter(150 - 50); + protocol.GetParameter(2 * 50); + protocol.GetParameter(200 / 2); + + // Advanced Math + protocol.GetParameter(25 * 2 + 50); + protocol.GetParameter(((25 * 4) + 100) / 2); + + // Wrappers: Not yet covered + protocol.GetParameterWrapper(100); + protocol.GetParameterWrapper(50 + 50); + protocol.GetParameterWrapper(pid); + protocol.GetParameterWrapper(MyParams.MyReadParam_100); + + // Parameter helper class + protocol.GetParameter(Parameter.readparam_100); + protocol.GetParameterWrapper(Parameter.readparam_100); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..cde18f0e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,84 @@ + + GetParameter_NonExistingParam + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + + +/// DataMiner QAction Class: GetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.GetParameter(9); + protocol.GetParameter(20 - 1); + protocol.GetParameter(1 - 30); + + int pid_99 = 99; + protocol.GetParameter(pid_99); + protocol.GetParameter(MyParams.NonExisting_199); + + int pid_1199 = 1199; + protocol.GetParameterWrapper(999); // Not (yet) covered + protocol.GetParameterWrapper(1100 - 1); // Not (yet) covered + protocol.GetParameterWrapper(pid_1199); // Not (yet) covered + protocol.GetParameterWrapper(MyParams.NonExisting_1299); // Not (yet) covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml new file mode 100644 index 00000000..0c29f62a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml @@ -0,0 +1,63 @@ + + GetParameter_NonExistingParam_NoParams + 1.0.0.1 + + + + + + + + +/// DataMiner QAction Class: GetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + protocol.GetParameter(9); + protocol.GetParameter(20 - 1); + protocol.GetParameter(1 - 30); + + int pid_99 = 99; + protocol.GetParameter(pid_99); + protocol.GetParameter(MyParams.MyReadParam_199); + + int pid_1199 = 1199; + protocol.GetParameterWrapper(999); // Not (yet) covered + protocol.GetParameterWrapper(1100 - 1); // Not (yet) covered + protocol.GetParameterWrapper(pid_1199); // Not (yet) covered + protocol.GetParameterWrapper(MyParams.MyReadParam_1299); // Not (yet) covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..13297cbe --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameter/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,94 @@ + + GetParameter_Valid + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + +/// DataMiner QAction Class: GetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int pid = 100; + + // DM Params are ignored as the don't have to be present in the driver + the Parameter Helper class can't be used. + // DM Param range 1: [64 300 -> 69 999] + protocol.GetParameter(64300); // DM Param Range 1 Low + protocol.GetParameter(60000 + 9999); // DM Param Range 1 High + + // DM Param range 2: [100 000 -> 999 999] + protocol.GetParameter(100000); // DM Param Range 2 Low + protocol.GetParameter(900000 + 99999); // DM Param Range 2 High + + // Parameter helper class + protocol.GetParameter(Parameter.readparam_100); + protocol.GetParameter(Parameter.Write.writeparam_200); + protocol.GetParameter(Parameter.readwriteparam_300_350); + protocol.GetParameter(Parameter.Write.readwriteparam_300_350); + + // Wrappers + protocol.GetParameterWrapper(Parameter.readparam_100); + protocol.GetParameterWrapper(Parameter.Write.writeparam_200); + protocol.GetParameterWrapper(Parameter.readwriteparam_300_350); + protocol.GetParameterWrapper(Parameter.Write.readwriteparam_300_350); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/CSharpSLProtocolGetParameters.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/CSharpSLProtocolGetParameters.cs new file mode 100644 index 00000000..8fe79d32 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/CSharpSLProtocolGetParameters.cs @@ -0,0 +1,390 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolGetParameters +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolGetParameters; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolGetParameters(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + // protocol.GetParameters() + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "200", "101"), + Error.HardCodedPid(null, null, null, "300", "101"), + //Error.HardCodedPid(null, null, null, "350", "101"), // Not yet supported + + //// Wrappers (Not yet supported) + //Error.HardCodedPid(null, null, null, "100", "102"), + //Error.HardCodedPid(null, null, null, "200", "102"), + //Error.HardCodedPid(null, null, null, "300", "102"), + //Error.HardCodedPid(null, null, null, "350", "102"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + #region QAction 101: protocol.GetParameters + + Error.UnexpectedImplementation(null, null, null, + "(new uint[] { 9, Parameter.Write.writeparam_200 })", + "101").WithSubResults( + Error.HardCodedPid(null, null, null, "9", "101"), + Error.NonExistingParam(null, null, null, "9", "101")), + + Error.UnexpectedImplementation(null, null, null, + "(new uint[] { Parameter.Write.writeparam_200, nonExisting_99, Parameter.readwriteparam_300_350 })", + "101").WithSubResults( + Error.HardCodedPid(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "99", "101")), + + Error.UnexpectedImplementation(null, null, null, + "(pidsToGet)", + "101").WithSubResults( + Error.HardCodedPid(null, null, null, "199", "101"), + Error.NonExistingParam(null, null, null, "199", "101")), + + //Error.UnexpectedImplementation(null, null, null, + // "(pidsToGetAsList.ToArray())", + // "101", + // new List + // { + // Error.HardCodedPid(null, null, null, "1099", "102"), + // Error.NonExistingParam(null, null, null, "1099", "102"), + // }), // Not yet supported + + #endregion + + #region QAction 102: Wrappers (Not yet supported) + + //Error.UnexpectedImplementation(null, null, null, + // "(new uint[] { 9, Parameter.Write.writeparam_200 })", + // "101", + // new List + // { + // Error.HardCodedPid(null, null, null, "9", "102"), + // Error.NonExistingParam(null, null, null, "9", "102"), + // }), + + //Error.UnexpectedImplementation(null, null, null, + // "(new uint[] { Parameter.Write.writeparam_200, nonExisting_99, Parameter.readwriteparam_300_350 })", + // "101", + // new List + // { + // Error.HardCodedPid(null, null, null, "99", "102"), + // Error.NonExistingParam(null, null, null, "99", "102"), + // }), + + //Error.UnexpectedImplementation(null, null, null, + // "(pidsToGet)", + // "101", + // new List + // { + // Error.HardCodedPid(null, null, null, "199", "102"), + // Error.NonExistingParam(null, null, null, "199", "102"), + // }), + + //Error.UnexpectedImplementation(null, null, null, + // "(pidsToGetAsList.ToArray())", + // "101", + // new List + // { + // Error.HardCodedPid(null, null, null, "1099", "102"), + // Error.NonExistingParam(null, null, null, "1099", "102"), + // }), + + #endregion + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_UnexpectedImplementation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnexpectedImplementation", + ExpectedResults = new List + { + Error.UnsupportedArgumentTypeForIds(null, null, null, "object", "1"), + + #region QAction 101: protocol.GetParameters + + Error.UnexpectedImplementation(null, null, null, + "(new uint[] { pids, Parameter.readparam_100, MyParams.NonExisting_199 })", + "101").WithSubResults( + Error.HardCodedPid(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "99", "101"), + Error.HardCodedPid(null, null, null, "199", "101"), + Error.NonExistingParam(null, null, null, "199", "101")), + + Error.UnexpectedImplementation(null, null, null, "(pidsToGet)", "101").WithSubResults( + Error.HardCodedPid(null, null, null, "1999", "101"), + Error.NonExistingParam(null, null, null, "1999", "101"), + Error.HardCodedPid(null, null, null, "1299", "101"), + Error.NonExistingParam(null, null, null, "1299", "101")), + + #endregion + + #region QAction 102: Wrappers (Not yet supported) + + //Error.UnexpectedImplementation(null, null, null, + // "(new int[] { pids, Parameter.readparam_100, MyParams.NonExisting_199 })", + // "102").WithSubResults( + // new List{ + // Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "102"), + // Error.HardCodedPid(null, null, null, "99", "102"), + // Error.NonExistingParam(null, null, null, "99", "102"), + // Error.HardCodedPid(null, null, null, "199", "102"), + // Error.NonExistingParam(null, null, null, "199", "102"), + // }), + + //Error.UnexpectedImplementation(null, null, null, "(pidsToGet)", "102").WithSubResults( + // new List{ + // Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "102"), + // Error.HardCodedPid(null, null, null, "1999", "102"), + // Error.NonExistingParam(null, null, null, "1999", "102"), + // Error.HardCodedPid(null, null, null, "1299", "102"), + // Error.NonExistingParam(null, null, null, "1299", "102"), + // }), + + #endregion + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_UnsupportedArgumentTypeForIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnsupportedArgumentTypeForIds", + ExpectedResults = new List + { + Error.UnsupportedArgumentTypeForIds(null, null, null, "object", "1"), + + // protocol.GetParameters() + Error.UnsupportedArgumentTypeForIds(null, null, null, "string", "100"), + Error.UnsupportedArgumentTypeForIds(null, null, null, "double", "100"), + Error.UnsupportedArgumentTypeForIds(null, null, null, "int", "100"), + Error.UnsupportedArgumentTypeForIds(null, null, null, "uint", "100"), + Error.UnsupportedArgumentTypeForIds(null, null, null, "uint", "100"), + + Error.UnsupportedArgumentTypeForIds(null, null, null, "string[]", "101"), // string[] to string[] + Error.UnsupportedArgumentTypeForIds(null, null, null, "double[]", "101"), // double[] to object + Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "101"), // double[] to object + + Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "102"), // int[] to var + Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "102"), // Implicit array type + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "103"), // List.ToArray // Not yet supported + //Error.UnsupportedArgumentTypeForIds(null, null, null, "List", "103"), // List // Not yet supported + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "IEnumerable", "104"), // Not yet supported + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "MyClass", "200"), // Not yet supported + + //// Wrappers (Not yet supported) + //Error.UnsupportedArgumentTypeForIds(null, null, null, "string", "1000"), + //Error.UnsupportedArgumentTypeForIds(null, null, null, "double", "1000"), + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int", "1000"), + //Error.UnsupportedArgumentTypeForIds(null, null, null, "uint", "1000"), + //Error.UnsupportedArgumentTypeForIds(null, null, null, "uint", "1000"), + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "string[]", "1001"), // string[] to string[] + //Error.UnsupportedArgumentTypeForIds(null, null, null, "double[]", "1001"), // double[] to object + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "1001"), // double[] to object + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "1002"), // int[] to var + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "1002"), // Implicit array type + + //Error.UnsupportedArgumentTypeForIds(null, null, null, "int[]", "1003"), // List.ToArray // Not yet supported + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_HardCodedPid() + { + // Create ErrorMessage + var message = Error.HardCodedPid(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.33.3", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '2', use 'Parameter' class instead. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.GetParameters is used to get current values of standalone parameters." + Environment.NewLine + "Make sure to provide it with a uint array of existing standalone parameter IDs." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.33.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.GetParameters' references a non-existing 'Param' with ID '2'. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.GetParameters is used to get current values of standalone parameters." + Environment.NewLine + "Make sure to provide it with a uint array of existing standalone parameter IDs." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_UnexpectedImplementation() + { + // Create ErrorMessage + var message = Error.UnexpectedImplementation(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.33.1", + Category = Category.QAction, + Severity = Severity.BubbleUp, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.GetParameters' with arguments '2' is not implemented as expected. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.GetParameters is used to get current values of standalone parameters." + Environment.NewLine + "Make sure to provide it with a uint array of existing standalone parameter IDs." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_UnsupportedArgumentTypeForIds() + { + // Create ErrorMessage + var message = Error.UnsupportedArgumentTypeForIds(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "3.33.4", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invocation of method 'SLProtocol.GetParameters' has an invalid type '2' for the argument 'ids'. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.GetParameters is used to get current values of standalone parameters." + Environment.NewLine + "Make sure to provide it with a uint array of existing standalone parameter IDs." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolGetParameters(); + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolGetParameters_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolGetParameters); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..8e6154cd --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,114 @@ + + GetParameters_HardCodedPid + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + to array (not yet supported) + List pidsToGetAsList = new List { Parameter.readparam_100, 350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGetAsList.ToArray()); + } +}]]> + + + to array (not yet supported) + List pidsToGetAsList = new List { Parameter.readparam_100, 350 }; + returnedValues = (object[])protocol.GetParametersWrapper(pidsToGetAsList.ToArray()); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..ab5e478b --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,109 @@ + + GetParameters_NonExistingParam + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + + to array (not yet supported) + List pidsToGetAsList = new List { Parameter.readparam_100, nonExisting_99 + 1000 }; + protocol.GetParameters(pidsToGetAsList.ToArray()); + } +}]]> + + + to array (not yet supported) + List pidsToGetAsList = new List { Parameter.readparam_100, nonExisting_99 + 1000 }; + protocol.GetParametersWrapper(pidsToGetAsList.ToArray()); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnexpectedImplementation.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnexpectedImplementation.xml new file mode 100644 index 00000000..69f9e099 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnexpectedImplementation.xml @@ -0,0 +1,87 @@ + + GetParameters_UnexpectedImplementation + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnsupportedArgumentTypeForIds.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnsupportedArgumentTypeForIds.xml new file mode 100644 index 00000000..77d724a7 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Invalid/UnsupportedArgumentTypeForIds.xml @@ -0,0 +1,276 @@ + + GetParameters_HardCodedPid + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + + + + + + + + + + + to array + List intList = new List { Parameter.readparam_100, Parameter.readwriteparam_300_350 }; + protocol.GetParameters(intList.ToArray()); + protocol.GetParameters(intList); + } +}]]> + + + to array + IEnumerable intEnumerable = GetPids(); + protocol.GetParameters(intEnumerable); + } + + public static IEnumerable GetPids() + { + yield return Parameter.readparam_100; + yield return Parameter.readwriteparam_300_350; + } +}]]> + + + + + + + + + + + + + + + + to array + List intList = new List { Parameter.readparam_100, Parameter.readwriteparam_300_350 }; + protocol.GetParametersWrapper(intList.ToArray()); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..f42c93d7 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolGetParameters/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,145 @@ + + GetParameters_Valid + 1.0.0.1 + + + + ReadParam_100 + read + + + + WriteParam_200 + write + + + + ReadWriteParam_300_350 + read + + + ReadWriteParam_300_350 + write + + + + + + + + + 69 999] + returnedValues = (object[])protocol.GetParameters(new uint[] { 64300, 69999 }); + + // DM Param range 2: [100 000 -> 999 999] + returnedValues = (object[])protocol.GetParameters(new uint[] { 100000, 999999 }); + + // Parameter helper class + returnedValues = (object[])protocol.GetParameters(new uint[] { Parameter.readparam_100, Parameter.Write.writeparam_200 }); + + // variable: uint[] + uint[] pidsToGet = new uint[] { Parameter.readwriteparam_300_350, Parameter.Write.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGet); + + // variable: uint[] as object + object pidsToGetAsObject = new uint[] { Parameter.readwriteparam_300_350, Parameter.Write.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGetAsObject); + + // variable: uint[] as var + var pidsToGetAsVar = new uint[] { Parameter.readwriteparam_300_350, Parameter.Write.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGetAsVar); + + // variable: implicit uint[] as var + var pidsToGetAsImplicitArrayTypeVar = new[] { (uint)Parameter.readwriteparam_300_350, (uint)Parameter.Write.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGetAsImplicitArrayTypeVar); + + // variable: List to array + List pidsToGetAsList = new List { Parameter.readparam_100, Parameter.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParameters(pidsToGetAsList.ToArray()); + + // variable: IEnumerable to array + IEnumerable pidsToGetAsIEnumerable = GetPids(); + returnedValues = (object[])protocol.GetParameters(pidsToGetAsIEnumerable.ToArray()); + } + + public static IEnumerable GetPids() + { + yield return Parameter.readparam_100; + yield return Parameter.readwriteparam_300_350; + } +}]]> + + + 69 999] + returnedValues = (object[])protocol.GetParametersWrapper(new uint[] { 64300, 69999 }); + + // DM Param range 2: [100 000 -> 999 999] + returnedValues = (object[])protocol.GetParametersWrapper(new uint[] { 100000, 999999 }); + + // Parameter helper class + returnedValues = (object[])protocol.GetParametersWrapper(new uint[] { Parameter.readparam_100, Parameter.Write.writeparam_200 }); + + // var: uint[] + uint[] pidsToGet = new uint[] { Parameter.readwriteparam_300_350, Parameter.Write.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParametersWrapper(pidsToGet); + + //// var: uint[] as object + //object pidsToGetAsObject = new uint[] { Parameter.readwriteparam_300_350, Parameter.Write.readwriteparam_300_350 }; + //returnedValues = (object[])protocol.GetParametersWrapper(pidsToGetAsObject); + + // var: List to array + List pidsToGetAsList = new List { Parameter.readparam_100, Parameter.readwriteparam_300_350 }; + returnedValues = (object[])protocol.GetParametersWrapper(pidsToGetAsList.ToArray()); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/CSharpSLProtocolSetParameter.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/CSharpSLProtocolSetParameter.cs new file mode 100644 index 00000000..bdcdda7d --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/CSharpSLProtocolSetParameter.cs @@ -0,0 +1,350 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolSetParameter +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolSetParameter; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolSetParameter(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + // QAction 100: SetParameter + Error.HardCodedPid(null, null, null, "100", "100"), + Error.HardCodedPid(null, null, null, "100", "100"), + Error.HardCodedPid(null, null, null, "200", "100"), + Error.HardCodedPid(null, null, null, "201", "100"), + + Error.HardCodedPid(null, null, null, "100", "100"), + + Error.HardCodedPid(null, null, null, "100", "100"), + + // QAction 101: SetParameter_HistorySet + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + + Error.HardCodedPid(null, null, null, "100", "101"), + Error.HardCodedPid(null, null, null, "100", "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + // QAction 100: SetParameter + // Hard-coded + Error.HardCodedPid(null, null, null, "9", "100"), + Error.NonExistingParam(null, null, null, "9", "100"), + Error.HardCodedPid(null, null, null, "19", "100"), + Error.NonExistingParam(null, null, null, "19", "100"), + Error.HardCodedPid(null, null, null, "-29", "100"), + Error.NonExistingParam(null, null, null, "-29", "100"), + + // Variables + Error.HardCodedPid(null, null, null, "99", "100"), + Error.HardCodedPid(null, null, null, "199", "100"), + Error.NonExistingParam(null, null, null, "99", "100"), + Error.NonExistingParam(null, null, null, "199", "100"), + + // Wrappers (not yet covered) + //Error.NonExistingParam(null, null, null, "999", "100"), + //Error.NonExistingParam(null, null, null, "1099", "100"), + //Error.NonExistingParam(null, null, null, "1199", "100"), + //Error.NonExistingParam(null, null, null, "1299", "100"), + + + // QAction 101: SetParameter_HistorySet + // Hard-coded + Error.HardCodedPid(null, null, null, "9", "101"), + Error.NonExistingParam(null, null, null, "9", "101"), + Error.HardCodedPid(null, null, null, "19", "101"), + Error.NonExistingParam(null, null, null, "19", "101"), + Error.HardCodedPid(null, null, null, "-29", "101"), + Error.NonExistingParam(null, null, null, "-29", "101"), + + // Variables + Error.HardCodedPid(null, null, null, "99", "101"), + Error.HardCodedPid(null, null, null, "199", "101"), + Error.NonExistingParam(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "199", "101"), + + // Wrappers (not yet covered) + //Error.NonExistingParam(null, null, null, "999", "101"), + //Error.NonExistingParam(null, null, null, "1099", "101"), + //Error.NonExistingParam(null, null, null, "1199", "101"), + //Error.NonExistingParam(null, null, null, "1299", "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_NonExistingParam_NoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam_NoParamsTag", + ExpectedResults = new List + { + // QAction 100: SetParameter + // Hard-coded + Error.HardCodedPid(null, null, null, "9", "100"), + Error.HardCodedPid(null, null, null, "19", "100"), + Error.HardCodedPid(null, null, null, "-29", "100"), + Error.NonExistingParam(null, null, null, "9", "100"), + Error.NonExistingParam(null, null, null, "19", "100"), + Error.NonExistingParam(null, null, null, "-29", "100"), + + // Variables + Error.HardCodedPid(null, null, null, "99", "100"), + Error.HardCodedPid(null, null, null, "199", "100"), + Error.NonExistingParam(null, null, null, "99", "100"), + Error.NonExistingParam(null, null, null, "199", "100"), + + // Wrappers (not yet covered) + //Error.NonExistingParam(null, null, null, "999", "100"), + //Error.NonExistingParam(null, null, null, "1099", "100"), + //Error.NonExistingParam(null, null, null, "1199", "100"), + //Error.NonExistingParam(null, null, null, "1299", "100"), + + + // QAction 101: SetParameter_HistorySet + // Hard-coded + Error.HardCodedPid(null, null, null, "9", "101"), + Error.HardCodedPid(null, null, null, "19", "101"), + Error.HardCodedPid(null, null, null, "-29", "101"), + Error.NonExistingParam(null, null, null, "9", "101"), + Error.NonExistingParam(null, null, null, "19", "101"), + Error.NonExistingParam(null, null, null, "-29", "101"), + + // Variables + Error.HardCodedPid(null, null, null, "99", "101"), + Error.HardCodedPid(null, null, null, "199", "101"), + Error.NonExistingParam(null, null, null, "99", "101"), + Error.NonExistingParam(null, null, null, "199", "101"), + + // Wrappers (not yet covered) + //Error.NonExistingParam(null, null, null, "999", "101"), + //Error.NonExistingParam(null, null, null, "1099", "101"), + //Error.NonExistingParam(null, null, null, "1199", "101"), + //Error.NonExistingParam(null, null, null, "1299", "101"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_ParamMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ParamMissingHistorySet", + ExpectedResults = new List + { + // Hard-coded + Error.HardCodedPid(null, null, null, "200", "101"), + Error.HardCodedPid(null, null, null, "201", "101"), + Error.ParamMissingHistorySet(null, null, null, "200"), + Error.ParamMissingHistorySet(null, null, null, "201"), + + // Variables + Error.HardCodedPid(null, null, null, "200", "101"), + Error.HardCodedPid(null, null, null, "201", "101"), + Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + Error.HardCodedPid(null, null, null, "200", "101"), + Error.HardCodedPid(null, null, null, "201", "101"), + Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + + // Parameter helper class + Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + + // Wrappers: Not (yet) covered) + //Error.HardCodedPid(null, null, null, "200", "101"), + //Error.HardCodedPid(null, null, null, "201", "101"), + //Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + //Error.HardCodedPid(null, null, null, "200", "101"), + //Error.HardCodedPid(null, null, null, "201", "101"), + //Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + //Error.ParamMissingHistorySet(null, null, null, "200"), + //Error.ParamMissingHistorySet(null, null, null, "201"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + //[TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpSLProtocolSetParameter(); + + [TestMethod] + public void Protocol_CSharpSLProtocolSetParameter_ParamMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ParamMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.7.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.SetParameter' references a non-existing 'Param' with ID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.SetParameter is used to update the value of a standalone parameter." + Environment.NewLine + "Make sure to provide it with an ID of a standalone parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_HardCodedPid() + { + // Create ErrorMessage + var message = Error.HardCodedPid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.7.2", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.SetParameter is used to update the value of a standalone parameter." + Environment.NewLine + "Make sure to provide it with an ID of a standalone parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_ParamMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ParamMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.7.3", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "SLProtocol.SetParameter overload with 'ValueType timeInfo' argument requires 'Param@historySet=true'. Param ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "Every overload of the 'SLProtocol.SetParameter' method having the 'ValueType timeInfo' argument is meant to execute a historySet on a standlone parameter." + Environment.NewLine + "Such method requires the standalone parameter to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolSetParameter(); + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolSetParameter_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolSetParameter); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Codefix/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Codefix/ParamMissingHistorySet.xml new file mode 100644 index 00000000..6654ae60 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Codefix/ParamMissingHistorySet.xml @@ -0,0 +1,112 @@ + + SetParameter_MissingHistorySet + 1.0.0.1 + + + + HistorySet_True + read + + string + + + + + HistorySet_False + read + + string + + + + HistorySet_NotPresent + read + + string + + + + + + + + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int historySetFalsePid = 100 + 100; + int historySetNotPresentPid = 201; + DateTime date_dt = new DateTime(2018, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + // Hard-coded + protocol.SetParameter(200, "value", date_dt); + protocol.SetParameter(200 + 1, "value", date_dt); + + // Variables + protocol.SetParameter(historySetFalsePid, "value", date_dt); + protocol.SetParameter(historySetNotPresentPid, "value", date_vt); // Not covered yet + protocol.SetParameter(MyParams.HistorySet_False_200, "value", date_dt); + protocol.SetParameter(MyParams.HistorySet_NotPresent_201, "value", date_vt); // Not covered yet + + // Parameter helper class + protocol.SetParameter(Parameter.historyset_false, "value", date_dt); + protocol.SetParameter(Parameter.historyset_notpresent, "value", date_vt); // Not covered yet + protocol.SetParameter(Parameter.historyset_false_200, "value", date_dt); + protocol.SetParameter(Parameter.historyset_notpresent_201, "value", date_vt); // Not covered yet + + // Wrappers: Not (yet) covered + protocol.SetParameterWrapper(200, "value", date_dt); + protocol.SetParameterWrapper(200 + 1, "value", date_vt); + protocol.SetParameterWrapper(historySetFalsePid, "value", date_dt); + protocol.SetParameterWrapper(historySetNotPresentPid, "value", date_vt); + protocol.SetParameterWrapper(MyParams.HistorySet_False_200, "value", date_dt); + protocol.SetParameterWrapper(MyParams.HistorySet_NotPresent_201, "value", date_vt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..e1e49b38 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,144 @@ + + SetParameter_HarCodedPid + 1.0.0.1 + + + + HistorySet_True + read + + string + + + + + HistorySet_False + read + + string + + + + HistorySet_NotPresent + read + + string + + + + + + + + + + + +/// DataMiner QAction Class: SetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int pid = 50 + 50; + + // Hard-coded + protocol.SetParameter(100, "value"); + protocol.SetParameter(100, "value"); + protocol.SetParameter(200, "value"); + protocol.SetParameter(201, "value"); + + // Hard-coded from another class + protocol.SetParameter(MyParams.HistorySet_True_100, "value"); + + protocol.SetParameter(pid, "value"); + protocol.SetParameterWrapper(100, "value"); // Not covered yet + protocol.SetParameterWrapper(50 + 50, "value"); // Not covered yet + protocol.SetParameterWrapper(pid, "value"); // Not covered yet + protocol.SetParameterWrapper(MyParams.HistorySet_True_100, "value"); // Not covered yet + + // Definitely allowed + protocol.SetParameter(Parameter.historyset_true_100, "value"); + protocol.SetParameterWrapper(Parameter.historyset_true_100, "value"); + } +} +]]> + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int pid = 50 + 50; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + // Hard-coded + protocol.SetParameter(100, "value", date_dt); + protocol.SetParameter(100, "value", date_vt); + + protocol.SetParameter(50 + 50, "value", date_dt); + protocol.SetParameter(pid, "value", date_vt); + protocol.SetParameterWrapper(100, "value", date_dt); // Not yet covered + protocol.SetParameterWrapper(50 + 50, "value", date_vt); // Not yet covered + protocol.SetParameterWrapper(pid, "value", date_dt); // Not yet covered + protocol.SetParameterWrapper(MyParams.HistorySet_True_100, "value", date_vt); // Not yet covered + + // Definitely allowed + protocol.SetParameter(Parameter.historyset_true_100, "value", date_dt); + protocol.SetParameter(Parameter.historyset_true_100, "value", date_vt); + protocol.SetParameterWrapper(Parameter.historyset_true_100, "value", date_dt); + protocol.SetParameterWrapper(Parameter.historyset_true_100, "value", date_vt); + } +} +]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..465425bd --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,110 @@ + + SetParameter_NonExistingparam + 1.0.0.1 + + + + + + + +/// DataMiner QAction Class: SetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // Hard-coded + protocol.SetParameter(9, "value"); + protocol.SetParameter(20 - 1, "value"); + protocol.SetParameter(1 - 30, "value"); + + // Variables + int pid_99 = 99; + protocol.SetParameter(pid_99, "value"); + protocol.SetParameter(MyParams.NonExisting_199, "value"); + + // Wrappers: Not (yet) covered + int pid_1199 = 1199; + protocol.SetParameterWrapper(999, "value"); + protocol.SetParameterWrapper(1100 - 1, "value"); + protocol.SetParameterWrapper(pid_1199, "value"); + protocol.SetParameterWrapper(MyParams.NonExisting_1299, "value"); + } +} +]]> + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + protocol.SetParameter(9, "value", date_dt); + protocol.SetParameter(20 - 1, "value", date_vt); + protocol.SetParameter(1 - 30, "value", date_dt); + + int pid_99 = 99; + protocol.SetParameter(pid_99, "value", date_dt); + protocol.SetParameter(MyParams.NonExisting_199, "value", date_vt); + + int pid_1199 = 1199; + protocol.SetParameterWrapper(999, "value", date_dt); // Not (yet) covered + protocol.SetParameterWrapper(1100 - 1, "value", date_vt); // Not (yet) covered + protocol.SetParameterWrapper(pid_1199, "value", date_dt); // Not (yet) covered + protocol.SetParameterWrapper(MyParams.NonExisting_1299, "value", date_vt); // Not (yet) covered + } +} +]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml new file mode 100644 index 00000000..81781f7c --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/NonExistingParam_NoParamsTag.xml @@ -0,0 +1,110 @@ + + SetParameter_NonExistingparam_NoParams + 1.0.0.1 + + + + + + + +/// DataMiner QAction Class: SetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // Hard-coded + protocol.SetParameter(9, "value"); + protocol.SetParameter(20 - 1, "value"); + protocol.SetParameter(1 - 30, "value"); + + // Variables + int pid_99 = 99; + protocol.SetParameter(pid_99, "value"); + protocol.SetParameter(MyParams.NonExisting_199, "value"); + + // Wrappers: Not (yet) covered + int pid_1199 = 1199; + protocol.SetParameterWrapper(999, "value"); + protocol.SetParameterWrapper(1100 - 1, "value"); + protocol.SetParameterWrapper(pid_1199, "value"); + protocol.SetParameterWrapper(MyParams.NonExisting_1299, "value"); + } +} +]]> + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + protocol.SetParameter(9, "value", date_dt); + protocol.SetParameter(20 - 1, "value", date_vt); + protocol.SetParameter(1 - 30, "value", date_dt); + + int pid_99 = 99; + protocol.SetParameter(pid_99, "value", date_dt); + protocol.SetParameter(MyParams.NonExisting_199, "value", date_vt); + + int pid_1199 = 1199; + protocol.SetParameterWrapper(999, "value", date_dt); // Not (yet) covered + protocol.SetParameterWrapper(1100 - 1, "value", date_vt); // Not covered yet + protocol.SetParameterWrapper(pid_1199, "value", date_dt); // Not (yet) covered + protocol.SetParameterWrapper(MyParams.NonExisting_1299, "value", date_vt); // Not covered yet + } +} +]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/ParamMissingHistorySet.xml new file mode 100644 index 00000000..20dd8fc8 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Invalid/ParamMissingHistorySet.xml @@ -0,0 +1,112 @@ + + SetParameter_MissingHistorySet + 1.0.0.1 + + + + HistorySet_True + read + + string + + + + + HistorySet_False + read + + string + + + + HistorySet_NotPresent + read + + string + + + + + + + + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int historySetFalsePid = 100 + 100; + int historySetNotPresentPid = 201; + DateTime date_dt = new DateTime(2018, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + // Hard-coded + protocol.SetParameter(200, "value", date_dt); + protocol.SetParameter(200 + 1, "value", date_dt); + + // Variables + protocol.SetParameter(historySetFalsePid, "value", date_dt); + protocol.SetParameter(historySetNotPresentPid, "value", date_vt); // Not covered yet + protocol.SetParameter(MyParams.HistorySet_False_200, "value", date_dt); + protocol.SetParameter(MyParams.HistorySet_NotPresent_201, "value", date_vt); // Not covered yet + + // Parameter helper class + protocol.SetParameter(Parameter.historyset_false, "value", date_dt); + protocol.SetParameter(Parameter.historyset_notpresent, "value", date_vt); // Not covered yet + protocol.SetParameter(Parameter.historyset_false_200, "value", date_dt); + protocol.SetParameter(Parameter.historyset_notpresent_201, "value", date_vt); // Not covered yet + + // Wrappers: Not (yet) covered + protocol.SetParameterWrapper(200, "value", date_dt); + protocol.SetParameterWrapper(200 + 1, "value", date_vt); + protocol.SetParameterWrapper(historySetFalsePid, "value", date_dt); + protocol.SetParameterWrapper(historySetNotPresentPid, "value", date_vt); + protocol.SetParameterWrapper(MyParams.HistorySet_False_200, "value", date_dt); + protocol.SetParameterWrapper(MyParams.HistorySet_NotPresent_201, "value", date_vt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..2aa0714e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetParameter/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,147 @@ + + SetParameter_Valid + 1.0.0.1 + + + + HistorySet_True + read + + string + + + + + HistorySet_False + read + + string + + + + HistorySet_NotPresent + read + + string + + + + + + + + + + + +/// DataMiner QAction Class: SetParameter. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + // DM Params are ignored as the don't have to be present in the driver + the Parameter Helper class can't be used. + // DM Param range 1: [64 300 -> 69 999] + protocol.SetParameter(64300, "value"); // DM Param Range 1 Low + protocol.SetParameter(60000 + 9999, "value"); // DM Param Range 1 High + + // DM Param range 2: [100 000 -> 999 999] + protocol.SetParameter(100000, "value"); // DM Param Range 2 Low + protocol.SetParameter(900000 + 99999, "value"); // DM Param Range 2 High + + // Parameter helper class + protocol.SetParameter(Parameter.historyset_true_100, "value"); + protocol.SetParameter(Parameter.historyset_false_200, "value"); + protocol.SetParameter(Parameter.historyset_notpresent_201, "value"); + + // Wrappers + protocol.SetParameterWrapper(Parameter.historyset_true_100, "value"); + protocol.SetParameterWrapper(Parameter.historyset_false_200, "value"); + protocol.SetParameterWrapper(Parameter.historyset_notpresent_201, "value"); + } + + public static void Run2(SLProtocol protocol) + { + int iTriggerParam = protocol.GetTriggerParameter(); + + string sValue = Convert.ToString(protocol.GetParameter(iTriggerParam)); + + string splitter = ":"; + if (iTriggerParam == 5119) + splitter = "/"; + + string sResult = sValue.Substring(0, 2) + splitter + sValue.Substring(2, 2) + splitter + sValue.Substring(4, 2); + + protocol.SetParameter(iTriggerParam - 5000, sResult); + } +}]]> + + + +/// DataMiner QAction Class: SetParameter_HistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + // Parameter helper class + protocol.SetParameter(Parameter.historyset_true, "value", date_dt); + protocol.SetParameter(Parameter.historyset_true, "value", date_vt); + + // Wrappers + protocol.SetParameterWrapper(Parameter.historyset_true, "value", date_dt); + protocol.SetParameterWrapper(Parameter.historyset_true, "value", date_vt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/CSharpSLProtocolSetRow.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/CSharpSLProtocolSetRow.cs new file mode 100644 index 00000000..b4565e17 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/CSharpSLProtocolSetRow.cs @@ -0,0 +1,264 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolSetRow +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolSetRow; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolSetRow(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_HardCodedPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "HardCodedPid", + ExpectedResults = new List + { + // By Key + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + + // By RowPosition + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), + + // Constant in a different location + Error.HardCodedPid(null, null, null, "1000", "102"), + + // Constant in the same method + Error.HardCodedPid(null, null, null, "1000", "102"), + + // Constant as global property + Error.HardCodedPid(null, null, null, "1000", "102"), + + // Unchanged variable inside the same method + Error.HardCodedPid(null, null, null, "1000", "102"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + // Doesn't cover the standalone param message yet + + Error.NonExistingParam(null, null, null, "2000", "102"), + Error.NonExistingParam(null, null, null, "2100", "102"), + Error.NonExistingParam(null, null, null, "2200", "102"), + + Error.NonExistingParam(null, null, null, "3000", "102"), + Error.NonExistingParam(null, null, null, "3100", "102"), + Error.NonExistingParam(null, null, null, "3200", "102"), + Error.NonExistingParam(null, null, null, "3300", "102"), + Error.NonExistingParam(null, null, null, "3400", "102"), + + // Cause all tests are using hard-coded PIDs + Error.HardCodedPid(null, null, null, "100", "102"), + Error.HardCodedPid(null, null, null, "2000", "102"), + Error.HardCodedPid(null, null, null, "2100", "102"), + Error.HardCodedPid(null, null, null, "2200", "102"), + + Error.HardCodedPid(null, null, null, "3000", "102"), + Error.HardCodedPid(null, null, null, "3100", "102"), + Error.HardCodedPid(null, null, null, "3200", "102"), + Error.HardCodedPid(null, null, null, "3300", "102"), + Error.HardCodedPid(null, null, null, "3400", "102"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_ParamMissingHistorySet() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ParamMissingHistorySet", + ExpectedResults = new List + { + Error.HardCodedPid(null, null, null, "1000", "102"), + Error.HardCodedPid(null, null, null, "1000", "102"), // Calculated one + Error.HardCodedPid(null, null, null, "1000", "102"), // Constant from another class + + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + + // ValueType isn't covered yet + //Error.ParamMissingHistorySet(null, null, null, "1002"), // Not yet covered + //Error.ParamMissingHistorySet(null, null, null, "1003"), // Not yet covered + + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + + Error.ParamMissingHistorySet(null, null, null, "1002"), + Error.ParamMissingHistorySet(null, null, null, "1003"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + //[TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CSharpSLProtocolSetRow(); + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_ParamMissingHistorySet() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ParamMissingHistorySet", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.8.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Method 'SLProtocol.SetRow' references a non-existing 'table' with PID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.SetRow is used to update the values of a table row." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolFillArray_HardCodedPid() + { + // Create ErrorMessage + var message = Error.HardCodedPid(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.8.2", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended use of magic number '1', use 'Parameter' class instead. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "SLProtocol.SetRow is used to update the values of a table row." + Environment.NewLine + "Make sure to provide it with an ID of a table parameter that exists." + Environment.NewLine + "Using Parameter class is recommended.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_ParamMissingHistorySet() + { + // Create ErrorMessage + var message = Error.ParamMissingHistorySet(null, null, null, "1"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.8.3", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "SLProtocol.SetRow overload with 'ValueType timeInfo' argument requires 'Param@historySet=true'. column PID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "Every overload of the 'SLProtocol.SetRow' method having the 'ValueType timeInfo' argument is meant to execute a historySet." + Environment.NewLine + "Such method requires the columns of table to be set to have the 'Param@historySet' attribute set to 'true'.", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolSetRow(); + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolSetRow_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolSetRow); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Codefix/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Codefix/ParamMissingHistorySet.xml new file mode 100644 index 00000000..efad24a6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Codefix/ParamMissingHistorySet.xml @@ -0,0 +1,88 @@ + + SetRow_MissingHistorySet + 1.0.0.1 + + + + SetRow + array + + + + + + + + SetRow_Instance + read + + + SetRow_Column2_HistorySetFalse + read + + + SetRow_Column3_NoHistorySetAttribute + read + + + + + + + + + +/// DataMiner QAction Class: Simple_SetRow_MissingHistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] rowValues = { null, "Column2_Value", "Column3_Value" }; + bool overRideBehaviour = true; + + protocol.SetRow(1000, "PK_1", rowValues, date_dt); + protocol.SetRow(900 + 100, "PK_1", rowValues, date_vt); // ValueType isn't covered + protocol.SetRow(MyParams.MyTable_1000, "PK_1", rowValues, date_dt, overRideBehaviour); + protocol.SetRow(Parameter.Setrow.tablePid, "PK_1", rowValues, date_dt, overRideBehaviour); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/HardCodedPid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/HardCodedPid.xml new file mode 100644 index 00000000..d116339a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/HardCodedPid.xml @@ -0,0 +1,106 @@ + + SetRow_HardCodedPid + 1.0.0.1 + + + + SetRow + array + + + + + + + + SetRow_Instance + read + + + SetRow_Column2 + read + + + SetRow_Column3 + read + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..cc4b3d61 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,102 @@ + + SetRow_NonExistingParam + 1.0.0.1 + + + + MyParam_100 + read + + + + SetRow + array + + + + + + + + SetRow_Instance + read + + + SetRow_Column2 + read + + + SetRow_Column3 + read + + + + + + + + + + +/// DataMiner QAction Class: Simple_SetRow_NonExistingParam. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] rowValues = { null, "Column2_Value", "Column3_Value" }; + bool overRideBehaviour = true; + + protocol.SetRow(100, "PK_1", rowValues); + protocol.SetRow(2000, "PK_1", rowValues); + protocol.SetRow(2000 + 100, "PK_1", rowValues); + protocol.SetRow(2300 - 100, "PK_1", rowValues); + + protocol.SetRow(3000, "PK_1", rowValues, overRideBehaviour); + protocol.SetRow(3100, "PK_1", rowValues, null); + protocol.SetRow(3200, "PK_1", rowValues, date_dt); + protocol.SetRow(3300, "PK_1", rowValues, date_vt); + protocol.SetRow(3400, "PK_1", rowValues, date_dt, overRideBehaviour); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/ParamMissingHistorySet.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/ParamMissingHistorySet.xml new file mode 100644 index 00000000..1b1988b5 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Invalid/ParamMissingHistorySet.xml @@ -0,0 +1,88 @@ + + SetRow_MissingHistorySet + 1.0.0.1 + + + + SetRow + array + + + + + + + + SetRow_Instance + read + + + SetRow_Column2_HistorySetFalse + read + + + SetRow_Column3_NoHistorySetAttribute + read + + + + + + + + + +/// DataMiner QAction Class: Simple_SetRow_MissingHistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + object[] rowValues = { null, "Column2_Value", "Column3_Value" }; + bool overRideBehaviour = true; + + protocol.SetRow(1000, "PK_1", rowValues, date_dt); + protocol.SetRow(900 + 100, "PK_1", rowValues, date_vt); // ValueType isn't covered + protocol.SetRow(MyParams.MyTable_1000, "PK_1", rowValues, date_dt, overRideBehaviour); + protocol.SetRow(Parameter.Setrow.tablePid, "PK_1", rowValues, date_dt, overRideBehaviour); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..dd6b3eb2 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolSetRow/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,184 @@ + + SetRow_Valid + 1.0.0.1 + + + + NoHistorySet + array + + + + + + + + NoHistorySet_Instance + read + + + NoHistorySet_Column2 + read + + + NoHistorySet_Column3 + read + + + + HistorySetFalse + array + + + + + + + + HistorySetFalse_Instance + read + + + HistorySetFalse_Column2 + read + + + HistorySetFalse_Column3 + read + + + + HistorySetTrue + array + + + + + + + + HistorySetTrue_Instance + read + + + HistorySetTrue_Column2 + read + + + HistorySetTrue_Column3 + read + + + + + + + + + + + + + +/// DataMiner QAction Class: Simple_SetRow_MissingHistorySet. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int tablePid = Parameter.Historysettrue.tablePid; + object[] rowValues = { null, "Column2_Value", "Column3_Value" }; + bool overRideBehaviour = true; + DateTime date_dt = new DateTime(2008, 8, 29, 19, 27, 15); + ValueType date_vt = new DateTime(2008, 8, 29, 19, 27, 15); + + // Variables + protocol.SetRow(tablePid, "PK_1", rowValues, date_dt); + protocol.SetRow(tablePid, "PK_1", rowValues, date_vt); // Not covered yet + protocol.SetRow(tablePid, "PK_1", rowValues, date_dt, overRideBehaviour); + protocol.SetRow(tablePid, "PK_1", rowValues, date_vt, overRideBehaviour); // Not covered yet + + // Parameter helper class + protocol.SetRow(Parameter.Historysettrue.tablePid, "PK_1", rowValues, date_dt); + protocol.SetRow(Parameter.Historysettrue.tablePid, "PK_1", rowValues, date_vt); + protocol.SetRow(Parameter.Historysettrue.tablePid, "PK_1", rowValues, date_dt, overRideBehaviour); + protocol.SetRow(Parameter.Historysettrue.tablePid, "PK_1", rowValues, date_vt, overRideBehaviour); + + // Wrappers: Not covered yet + protocol.SetRowWrapper(tablePid, "PK_1", rowValues, date_dt); + protocol.SetRowWrapper(Parameter.Historysettrue.tablePid, "PK_1", rowValues, date_dt); + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/CSharpSLProtocolTriggerAction.cs b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/CSharpSLProtocolTriggerAction.cs new file mode 100644 index 00000000..d5fcf14a --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/CSharpSLProtocolTriggerAction.cs @@ -0,0 +1,193 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CSharpSLProtocolTriggerAction +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CSharpSLProtocolTriggerAction; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CSharpSLProtocolTriggerAction(); + + #region Valid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_NonExistingActionId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingActionId", + ExpectedResults = new List + { + // Hard-coded (1x) + Error.NonExistingActionId(null, null, null, "10", "101"), + Error.NonExistingActionId(null, null, null, "11", "101"), + Error.NonExistingActionId(null, null, null, "12", "101"), + + // Hard-coded Subtractions (2x) + Error.NonExistingActionId(null, null, null, "20", "101"), + Error.NonExistingActionId(null, null, null, "21", "101"), + Error.NonExistingActionId(null, null, null, "22", "101"), + + // Hard-coded additions (3x) + Error.NonExistingActionId(null, null, null, "30", "101"), + Error.NonExistingActionId(null, null, null, "31", "101"), + Error.NonExistingActionId(null, null, null, "32", "101"), + + // Local variable (4x) + Error.NonExistingActionId(null, null, null, "40", "101"), + Error.NonExistingActionId(null, null, null, "41", "101"), + Error.NonExistingActionId(null, null, null, "42", "101"), + + // Distant variable (5x) + Error.NonExistingActionId(null, null, null, "50", "101"), + Error.NonExistingActionId(null, null, null, "51", "101"), + Error.NonExistingActionId(null, null, null, "52", "101"), + + // Method wrapper (6x) + //Error.NonExistingActionId(null, null, null, "60", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "61", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "62", "101"), // Not yet covered + + // Method wrapper (7x) + //Error.NonExistingActionId(null, null, null, "70", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "71", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "72", "101"), // Not yet covered + + // Method wrapper (8x) + //Error.NonExistingActionId(null, null, null, "80", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "81", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "82", "101"), // Not yet covered + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_NonExistingActionIdNoAction() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingActionId_NoAction", + ExpectedResults = new List + { + // Hard-coded (1x) + Error.NonExistingActionId(null, null, null, "10", "101"), + Error.NonExistingActionId(null, null, null, "11", "101"), + Error.NonExistingActionId(null, null, null, "12", "101"), + + // Hard-coded Subtractions (2x) + Error.NonExistingActionId(null, null, null, "20", "101"), + Error.NonExistingActionId(null, null, null, "21", "101"), + Error.NonExistingActionId(null, null, null, "22", "101"), + + // Hard-coded additions (3x) + Error.NonExistingActionId(null, null, null, "30", "101"), + Error.NonExistingActionId(null, null, null, "31", "101"), + Error.NonExistingActionId(null, null, null, "32", "101"), + + // Local variable (4x) + Error.NonExistingActionId(null, null, null, "40", "101"), + Error.NonExistingActionId(null, null, null, "41", "101"), + Error.NonExistingActionId(null, null, null, "42", "101"), + + // Distant variable (5x) + Error.NonExistingActionId(null, null, null, "50", "101"), + Error.NonExistingActionId(null, null, null, "51", "101"), + Error.NonExistingActionId(null, null, null, "52", "101"), + + // Method wrapper (6x) + //Error.NonExistingActionId(null, null, null, "60", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "61", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "62", "101"), // Not yet covered + + // Method wrapper (7x) + //Error.NonExistingActionId(null, null, null, "70", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "71", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "72", "101"), // Not yet covered + + // Method wrapper (8x) + //Error.NonExistingActionId(null, null, null, "80", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "81", "101"), // Not yet covered + //Error.NonExistingActionId(null, null, null, "82", "101"), // Not yet covered + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_NonExistingActionId() + { + // Create ErrorMessage + var message = Error.NonExistingActionId(null, null, null, "1", "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.5.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + Description = "Method 'NotifyProtocol(221/*NT_RUN_ACTION*/, ...)' references a non-existing 'Action' with ID '1'. QAction ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "NotifyProtocol 221 is used to trigger an action to go off." + Environment.NewLine + "Make sure to provide it with an ID of an action that exists.", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CSharpSLProtocolTriggerAction(); + + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CSharpSLProtocolTriggerAction_CheckId() => Generic.CheckId(check, CheckId.CSharpSLProtocolTriggerAction); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId.xml new file mode 100644 index 00000000..6e08438e --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId.xml @@ -0,0 +1,110 @@ + + CSharpSLProtocolTriggerAction_NonExistingActionId + 1.0.0.1 + + + + ActionId_1 + + + ActionId_2 + + + ActionId_3 + + + + + + + + + +/// DataMiner QAction Class: Simple_NotifyProtocol_10. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int actionId = 20 + 20; + + // Hard-coded (1x) + protocol.NotifyProtocol(221, 10, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 11, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 12, null); + + // Hard-coded Subtractions (2x) + protocol.NotifyProtocol(221, 22 - 2, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 23 - 2, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 24 - 2, null); + + // Hard-coded additions (3x) + protocol.NotifyProtocol((int)myEnums.NT_221, 25 + 5, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 25 + 6, null); + protocol.NotifyProtocol(221, 25 + 7, null); + + // Local variable (4x) + protocol.NotifyProtocol(221, actionId, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, actionId + 1, null); + protocol.NotifyProtocol((int)myEnums.NT_221, actionId + 2, null); + + // Distant variable (5x) + protocol.NotifyProtocol(221, MyActions.MyAction_50, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 1, null); + protocol.NotifyProtocol((int)myEnums.NT_221, MyActions.MyAction_50 + 2, null); + + // Method wrapper (6x) + protocol.NotifyProtocolWrapper(221, 60); // Not yet covered + protocol.NotifyProtocolWrapper(221, 60 + 1); // Not yet covered + protocol.NotifyProtocolWrapper(221, actionId + 22); // Not yet covered + protocol.NotifyProtocolWrapper(221, MyActions.MyAction_50 + 13); // Not yet covered + + // Method wrapper (7x) + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, actionId + 32); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 23); // Not yet covered + + // Method wrapper (8x) + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, actionId + 42); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, MyActions.MyAction_50 + 33); // Not yet covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId_NoAction.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId_NoAction.xml new file mode 100644 index 00000000..fa288984 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Invalid/NonExistingActionId_NoAction.xml @@ -0,0 +1,98 @@ + + CSharpSLProtocolTriggerAction_NonExistingActionId + 1.0.0.1 + + + + + + + +/// DataMiner QAction Class: Simple_NotifyProtocol_10. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int actionId = 20 + 20; + + // Hard-coded (1x) + protocol.NotifyProtocol(221, 10, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 11, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 12, null); + + // Hard-coded Subtractions (2x) + protocol.NotifyProtocol(221, 22 - 2, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 23 - 2, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 24 - 2, null); + + // Hard-coded additions (3x) + protocol.NotifyProtocol((int)myEnums.NT_221, 25 + 5, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 25 + 6, null); + protocol.NotifyProtocol(221, 25 + 7, null); + + // Local variable (4x) + protocol.NotifyProtocol(221, actionId, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, actionId + 1, null); // Not yet covered + protocol.NotifyProtocol((int)myEnums.NT_221, actionId + 2, null); // Not yet covered + + // Distant variable (5x) + protocol.NotifyProtocol(221, MyActions.MyAction_50, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 1, null); // Not yet covered + protocol.NotifyProtocol((int)myEnums.NT_221, MyActions.MyAction_50 + 2, null); // Not yet covered + + // Method rapper (6x) + protocol.NotifyProtocolWrapper(221, 60); // Not yet covered + protocol.NotifyProtocolWrapper(221, 60 + 1); // Not yet covered + protocol.NotifyProtocolWrapper(221, actionId + 22); // Not yet covered + protocol.NotifyProtocolWrapper(221, MyActions.MyAction_50 + 13); // Not yet covered + + // Method rapper (7x) + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, actionId + 32); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 23); // Not yet covered + + // Method rapper (8x) + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, actionId + 42); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, MyActions.MyAction_50 + 33); // Not yet covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..89b51616 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CSharpSLProtocolTriggerAction/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,188 @@ + + CSharpSLProtocolTriggerAction_Valid + 0.0.0.0 + + + + ActionId_10 + + + ActionId_11 + + + ActionId_12 + + + + ActionId_20 + + + ActionId_21 + + + ActionId_22 + + + + ActionId_30 + + + ActionId_31 + + + ActionId_32 + + + + ActionId_40 + + + ActionId_41 + + + ActionId_42 + + + + ActionId_50 + + + ActionId_51 + + + ActionId_52 + + + + ActionId_60 + + + ActionId_61 + + + ActionId_62 + + + ActionId_63 + + + + ActionId_70 + + + ActionId_71 + + + ActionId_72 + + + ActionId_73 + + + + ActionId_80 + + + ActionId_81 + + + ActionId_82 + + + ActionId_83 + + + + + + + + + +/// DataMiner QAction Class: Simple_NotifyProtocol_10. +/// +public class QAction +{ + /// + /// The QAction entry point. + /// + /// Link with SLProtocol process. + public static void Run(SLProtocol protocol) + { + int actionId = 20 + 20; + + // Hard-coded (1x) + protocol.NotifyProtocol(221, 10, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 11, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 12, null); + + // Hard-coded Subtractions (2x) + protocol.NotifyProtocol(221, 22 - 2, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 23 - 2, null); + protocol.NotifyProtocol((int)myEnums.NT_221, 24 - 2, null); + + // Hard-coded additions (3x) + protocol.NotifyProtocol((int)myEnums.NT_221, 25 + 5, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, 25 + 6, null); + protocol.NotifyProtocol(221, 25 + 7, null); + + // Local variable (4x) + protocol.NotifyProtocol(221, actionId, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, actionId + 1, null); // Not yet covered + protocol.NotifyProtocol((int)myEnums.NT_221, actionId + 2, null); // Not yet covered + + // Distant variable (5x) + protocol.NotifyProtocol(221, MyActions.MyAction_50, null); + protocol.NotifyProtocol((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 1, null); // Not yet covered + protocol.NotifyProtocol((int)myEnums.NT_221, MyActions.MyAction_50 + 2, null); // Not yet covered + + // Method wrapper (6x) + protocol.NotifyProtocolWrapper(221, 60); // Not yet covered + protocol.NotifyProtocolWrapper(221, 60 + 1); // Not yet covered + protocol.NotifyProtocolWrapper(221, actionId + 22); // Not yet covered + protocol.NotifyProtocolWrapper(221, MyActions.MyAction_50 + 13); // Not yet covered + + // Method wrapper (7x) + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, 70 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, actionId + 32); // Not yet covered + protocol.NotifyProtocolWrapper((int)NotifyType.NT_RUN_ACTION, MyActions.MyAction_50 + 23); // Not yet covered + + // Method wrapper (8x) + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, 80 + 1); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, actionId + 42); // Not yet covered + protocol.NotifyProtocolWrapper((int)myEnums.NT_221, MyActions.MyAction_50 + 33); // Not yet covered + } +}]]> + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..052eb4f8 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,306 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CheckIdAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void QAction_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void QAction_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "3.31.5", + Category = Category.QAction, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one QAction with same ID '2'. QAction Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each qaction." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each qaction should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "3.31.2", + Category = Category.QAction, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'QAction@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each qaction." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each qaction should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "3.31.4", + Category = Category.QAction, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'QAction@id'. QAction name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each qaction." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each qaction should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "3.31.1", + Category = Category.QAction, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'QAction@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each qaction." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each qaction should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "3.31.3", + Category = Category.QAction, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'QAction@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each qaction." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each qaction should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void QAction_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..62d05848 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..107d4a42 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..5b9a70c1 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..4fc365e2 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..00b1e773 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..9fd03015 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..61ba5c68 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..fb5edcc3 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,67 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CheckNameAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CheckNameAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void QAction_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CheckNameAttribute_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameAttribute(); + + [TestMethod] + public void QAction_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(root, Category.QAction); + + [TestMethod] + public void QAction_CheckNameAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..5d92341f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,8 @@ + + CheckNameAttribute_DuplicatedValue + 0.0.0.0 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..50a79a11 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,13 @@ + + CheckNameAttribute_Valid + 0.0.0.0 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/CheckTriggersAttribute.cs b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/CheckTriggersAttribute.cs new file mode 100644 index 00000000..5c7333df --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/CheckTriggersAttribute.cs @@ -0,0 +1,234 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.CheckTriggersAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.CheckTriggersAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTriggersAttribute(); + + #region Valid Checks + + [TestMethod] + public void QAction_CheckTriggersAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CheckTriggersAttribute_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "aaa", "1"), + Error.InvalidAttribute(null, null, null, "1;bbb", "2").WithSubResults( + Error.InvalidAttribute(null, null, null, "bbb", "2")), + Error.InvalidAttribute(null, null, null, "ccc;1", "3").WithSubResults( + Error.InvalidAttribute(null, null, null, "ccc", "3")), + Error.InvalidAttribute(null, null, null, "1;aaa;bbb;ccc;2", "4").WithSubResults( + Error.InvalidAttribute(null, null, null, "aaa", "4"), + Error.InvalidAttribute(null, null, null, "bbb", "4"), + Error.InvalidAttribute(null, null, null, "ccc", "4")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + Error.MissingAttribute(null, null, null, "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_NonExistingGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingGroup", + ExpectedResults = new List + { + Error.NonExistingGroup(null, null, null, "11", "1"), + Error.NonExistingGroup(null, null, null, "21", "2"), + Error.NonExistingGroup(null, null, null, "23", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_NonExistingParam() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingParam", + ExpectedResults = new List + { + Error.NonExistingParam(null, null, null, "1", "1"), + Error.NonExistingParam(null, null, null, "1", "2"), + Error.NonExistingParam(null, null, null, "3", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CheckTriggersAttribute_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "0", "1"); + + string description = "Duplicate value '0' in attribute 'QAction@triggers'. QAction ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'triggers' in QAction '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_InvalidAttribute() + { + // Create ErrorMessage + var message = Error.InvalidAttribute(null, null, null, "0", "1"); + + string description = "Invalid value '0' in attribute 'triggers'. QAction ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'triggers' in QAction '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_NonExistingGroup() + { + // Create ErrorMessage + var message = Error.NonExistingGroup(null, null, null, "0", "1"); + + string description = "Attribute 'triggers' references a non-existing 'Group' with ID '0'. QAction ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void QAction_CheckTriggersAttribute_NonExistingParam() + { + // Create ErrorMessage + var message = Error.NonExistingParam(null, null, null, "0", "1"); + + string description = "Attribute 'triggers' references a non-existing 'Param' with ID '0'. QAction ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTriggersAttribute(); + + [TestMethod] + public void QAction_CheckTriggersAttribute_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CheckTriggersAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckTriggersAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..755e6491 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,16 @@ + + CheckTriggersAttribute_DuplicatedId + 0.0.0.0 + + + + MyParam + read + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..9efa9989 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,9 @@ + + CheckTriggersAttribute_EmptyAttribute + 0.0.0.0 + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..52ccb86f --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,27 @@ + + CheckTriggersAttribute_InvalidAttribute + 0.0.0.0 + + + + MyParam + read + + + MyParam2 + read + + + MyParam3 + read + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..1ee9af15 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,10 @@ + + CheckTriggersAttribute_MissingAttribute + 0.0.0.0 + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingGroup.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingGroup.xml new file mode 100644 index 00000000..b55cdee1 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingGroup.xml @@ -0,0 +1,21 @@ + + CheckTriggersAttribute_NonExistingGroup + 0.0.0.0 + + + + MyParam + read + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingParam.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingParam.xml new file mode 100644 index 00000000..d2cfffe9 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Invalid/NonExistingParam.xml @@ -0,0 +1,21 @@ + + CheckTriggersAttribute_NonExistingParam + 0.0.0.0 + + + + MyParam + read + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6080c5b6 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/CheckTriggersAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,87 @@ + + CheckTriggersAttribute_Valid + 0.0.0.0 + + + + MyParam + read + + + MyParam2 + read + + + MyParam3 + read + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + + + + + 101 + + + + + 102 + + + + + + + 100 + + + + + 101 + + + + + 102 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..d92c4e10 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,158 @@ +namespace SLDisValidatorUnitTests.Protocol.QActions.QAction.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.QActions.QAction.Condition.CheckConditionTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void QAction_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void QAction_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void QAction_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void QAction_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "currentCondition", "reason", "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "3.35.1", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition 'currentCondition'. Reason 'reason'. QAction ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'QAction/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void QAction_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "3.35.2", + Category = Category.QAction, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'QAction/Condition' references a non-existing 'Param' with PID '2'. QAction ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'QAction/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parentheses is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void QAction_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.QAction); + + [TestMethod] + public void QAction_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..18d69ce8 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..71508dbb --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,18 @@ + + + + + + string + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..b8d28072 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,8 @@ + + + + + 20]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..07562e58 --- /dev/null +++ b/ProtocolTests/Protocol/QActions/QAction/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..c75ac706 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Relations.Relation.CheckNameAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Relations.Relation.CheckNameAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Relation_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Relation_CheckNameAttribute_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1"), + Error.DuplicatedValue(null, null, null, "Name1")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameAttribute(); + + [TestMethod] + public void Relation_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Relation); + + [TestMethod] + public void Relation_CheckNameAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..e2454b84 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..97a5cd27 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/CheckPathAttribute.cs b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/CheckPathAttribute.cs new file mode 100644 index 00000000..2bdf064f --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/CheckPathAttribute.cs @@ -0,0 +1,438 @@ +namespace SLDisValidatorUnitTests.Protocol.Relations.Relation.CheckPathAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Relations.Relation.CheckPathAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPathAttribute(); + + #region Valid Checks + + [TestMethod] + public void Relation_CheckPathAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_Valid_ChildrenToParent() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_ChildrenToParent", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_Valid_NToMRelation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_NToMRelation", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Relation_CheckPathAttribute_DuplicateValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateValue", + ExpectedResults = new List + { + Error.DuplicateValue(null, null, null, "1000;1100").WithSubResults( + Error.DuplicateValue(null, null, null, "1000;1100"), + Error.DuplicateValue(null, null, null, "1000;1100")), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "test1"), + Error.InvalidValue(null, null, null, "test2"), + + Error.InvalidValue(null, null, null, "100;test3;200").WithSubResults( + Error.InvalidValue(null, null, null, "test3")), + + Error.InvalidValue(null, null, null, "100;test4;200;test5").WithSubResults( + Error.InvalidValue(null, null, null, "test4"), + Error.InvalidValue(null, null, null, "test5")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyForRelation() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingForeignKeyForRelation", + ExpectedResults = new List + { + // missing foreignKey in options' column - 2 levels + Error.MissingForeignKeyForRelation(null, null, null, "1000;2000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "1000", "2000")), + + // missing foreignKey in options' column - 3 levels + Error.MissingForeignKeyForRelation(null, null, null, "1000;2000;3000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "1000", "2000")), + + // missing column with fk in table - 3 levels + Error.MissingForeignKeyForRelation(null, null, null, "3000;4000;5000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "4000", "5000")), + + // missing column with fk in table and missing foreignKey in options' column - 3 levels + Error.MissingForeignKeyForRelation(null, null, null, "4000;5000;6000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "4000", "5000"), + Error.MissingForeignKeyInTable_Sub(null, null, null, "5000", "6000")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyForRelation_ChildrenToParent() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingForeignKeyForRelation_ChildrenToParent", + ExpectedResults = new List + { + // 2 Levels - Missing 1 FK + Error.MissingForeignKeyForRelation(null, null, null, "2000;1000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "2000", "1000")), + + // 3 Levels - Missing 1 FK Option + Error.MissingForeignKeyForRelation(null, null, null, "3000;2000;1000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "2000", "1000")), + + // 3 Levels - Missing 1 FK Column + Error.MissingForeignKeyForRelation(null, null, null, "5000;4000;3000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "5000", "4000")), + + // 3 levels - Missing 2 FKs + Error.MissingForeignKeyForRelation(null, null, null, "6000;5000;4000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "6000", "5000"), + Error.MissingForeignKeyInTable_Sub(null, null, null, "5000", "4000")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyForRelation_NToM() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingForeignKeyForRelation_NToM", + ExpectedResults = new List + { + // N to M Relation with missing foreignKey in options' column + Error.MissingForeignKeyForRelation(null, null, null, "10000;10100;10200").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "10100", "10200")), + + // N to M Relation with two missing foreignKey in options' column + Error.MissingForeignKeyForRelation(null, null, null, "10000;10150;10200").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "10000", "10150"), + Error.MissingForeignKeyInTable_Sub(null, null, null, "10150", "10200")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyForRelation_WithInvalidPathIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingForeignKeyForRelation_WithInvalidPathIds", + ExpectedResults = new List + { + // 1 missing foreignKey in options' column and 1 invalid path id - 4 levels + Error.MissingForeignKeyForRelation(null, null, null, "1000;test;3000;4000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "3000", "4000")), + + Error.InvalidValue(null, null, null, "1000;test;3000;4000").WithSubResults( + Error.InvalidValue(null, null, null, "test")), + + // 2 missing foreignKeys in options' column and 1 invalid path id - 4 levels + Error.MissingForeignKeyForRelation(null, null, null, "test2;3000;4000;5000").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "3000", "4000"), + Error.MissingForeignKeyInTable_Sub(null, null, null, "4000", "5000")), + + Error.InvalidValue(null, null, null, "test2;3000;4000;5000").WithSubResults( + Error.InvalidValue(null, null, null, "test2")), + + // 1 missing foreignKeys in options' column and 2 invalid path id - 4 levels + Error.MissingForeignKeyForRelation(null, null, null, "test3;3000;4000;test4").WithSubResults( + Error.MissingForeignKeyInTable_Sub(null, null, null, "3000", "4000")), + + Error.InvalidValue(null, null, null, "test3;3000;4000;test4").WithSubResults( + Error.InvalidValue(null, null, null, "test3"), + Error.InvalidValue(null, null, null, "test4")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "1001;1002").WithSubResults( + Error.NonExistingId(null, null, null, "1001"), + Error.NonExistingId(null, null, null, "1002")), + + Error.InvalidValue(null, null, null, "1;1003;2;1004").WithSubResults( + Error.NonExistingId(null, null, null, "1003"), + Error.NonExistingId(null, null, null, "1004")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "1001;1002").WithSubResults( + Error.NonExistingId(null, null, null, "1001"), + Error.NonExistingId(null, null, null, "1002")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Relation_CheckPathAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + //Error.ReferencedParamExpectingRTDisplay(null, null, null, "") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Relation_CheckPathAttribute_ReferencedParamWrongType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongType", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "1;2;3").WithSubResults( + Error.ReferencedParamWrongType(null, null, null, "bus", "1"), + Error.ReferencedParamWrongType(null, null, null, "read", "2"), + Error.ReferencedParamWrongType(null, null, null, "write", "3")), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Relation_CheckPathAttribute_DuplicateValue() + { + // Create ErrorMessage + var message = Error.DuplicateValue(null, null, null, "1000;1100"); + + string description = "Duplicated Relation path '1000;1100'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + string description = "Empty attribute 'Relation@path'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "0"); + + string description = "Invalid value '0' in attribute 'Relation@path'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + string description = "Missing attribute 'Relation@path'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyForRelation() + { + // Create ErrorMessage + var message = Error.MissingForeignKeyForRelation(null, null, null, "myRelation"); + + string description = "Missing foreignKey(s) detected for relation 'myRelation'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_MissingForeignKeyInTable() + { + // Create ErrorMessage + var message = Error.MissingForeignKeyInTable_Sub(null, null, null, "1000", "2000"); + + string description = "Missing foreignKey between table '1000' and table '2000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Relation_CheckPathAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = "Attribute 'Relation@path' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPathAttribute(); + + [TestMethod] + public void Relation_CheckPathAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Relation); + + [TestMethod] + public void Relation_CheckPathAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPathAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/DuplicateValue.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/DuplicateValue.xml new file mode 100644 index 00000000..ba282357 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/DuplicateValue.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + table + + + + + + + + table + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..9878d51d --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..3c1c93ad --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,27 @@ + + + + + array + + + true + + + + array + + + true + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..d1a58d9c --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation.xml new file mode 100644 index 00000000..be067a6d --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation.xml @@ -0,0 +1,106 @@ + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + + + TableLevel2_FkMissing_Options + array + + + + + + + TableLevel2_FkMissing_Options_Instance + read + + + TableLevel2_FkMissing_Options_FkTo1000 + read + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + + TableLevel4 + array + + + + + + + TableLevel4_Instance + read + + + TableLevel4_FkTo3000 + read + + + + TableLevel5_FkMissing_Column + array + + + + + + TableLevel5_FkMissing_Column_Instance + read + + + + TableLevel6_FkMissing_Options + array + + + + + + + TableLevel6_FkMissing_Options_Instance + read + + + TableLevel6_FkMissing_Options_FkTo5000 + read + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_ChildrenToParent.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_ChildrenToParent.xml new file mode 100644 index 00000000..ab765bb3 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_ChildrenToParent.xml @@ -0,0 +1,106 @@ + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + + + TableLevel2_FkMissing_Options + array + + + + + + + TableLevel2_FkMissing_Options_Instance + read + + + TableLevel2_FkMissing_Options_FkTo1000 + read + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + + TableLevel4 + array + + + + + + + TableLevel4_Instance + read + + + TableLevel4_FkTo3000 + read + + + + TableLevel5_FkMissing_Column + array + + + + + + TableLevel5_FkMissing_Column_Instance + read + + + + TableLevel6_FkMissing_Options + array + + + + + + + TableLevel6_FkMissing_Options_Instance + read + + + TableLevel6_FkMissing_Options_FkTo5000 + read + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_NToM.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_NToM.xml new file mode 100644 index 00000000..c6644db8 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_NToM.xml @@ -0,0 +1,83 @@ + + + + + NToMParentTable + array + + + + + + NToMParentTable_Instance + read + + + + + NToMIntermediateTable1_FkMissing_Options + + array + + + + + + + + NToMIntermediateTable1_FkMissing_Options_Instance + read + + + NToMIntermediateTable1_FkMissing_Options_FkTo10000 + read + + + NToMIntermediateTable1_FkMissing_Options_FkTo10200 + read + + + + + NToMIntermediateTable2_FkMissing_Options + + array + + + + + + + + NToMIntermediateTable2_FkMissing_Options_Instance + read + + + NToMIntermediateTable2_FkMissing_Options_FkTo10000 + read + + + NToMIntermediateTable2_FkMissing_Options_FkTo10200 + read + + + + NToMChildrenTable + array + + + + + + NToMChildrenTable_Instance + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_WithInvalidPathIds.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_WithInvalidPathIds.xml new file mode 100644 index 00000000..e86bf14c --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/MissingForeignKeyForRelation_WithInvalidPathIds.xml @@ -0,0 +1,86 @@ + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + + TableLevel2_FkTo1000 + read + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + + TableLevel4_FkMissing_Options + array + + + + + + + TableLevel4_FkMissing_Options_Instance + read + + + TableLevel4_FkMissing_Options_FkTo3000 + read + + + TableLevel5_FkMissing_Column + array + + + + + + TableLevel5_FkMissing_Column_Instance + read + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..df069988 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,32 @@ + + + + + array + + + true + + + + array + + + true + + + + array + + + true + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..2b7fa27f --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..dbb1152a --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + TableLevel1_RTDisplayFalse + array + + + + + false + + + + TableLevel1_Instance + read + + + + TableLevel2_NoRTDisplay + array + + + + + + + + + + TableLevel2_Instance + read + + + TableLevel2_FkTo1000 + read + + + + TableLevel3_NoDisplay + array + + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml new file mode 100644 index 00000000..e85538b0 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml @@ -0,0 +1,22 @@ + + + + + + + + + Bus + bus + + + Read + read + + + Write + write + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b4b01986 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + TableLevel1 + array + + + + + true + + + + TableLevel1_Instance + read + + true + + + + + TableLevel2 + array + + + + + + true + + + + TableLevel2_Instance + read + + true + + + + TableLevel2_FkTo1000 + read + + true + + + + + TableLevel3 + array + + + + + + true + + + + TableLevel3_Instance + read + + true + + + + TableLevel3_FkTo2000 + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_ChildrenToParent.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_ChildrenToParent.xml new file mode 100644 index 00000000..65577da7 --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_ChildrenToParent.xml @@ -0,0 +1,63 @@ + + + + + + + TableLevel1 + array + + + + + + TableLevel1_Instance + read + + + + TableLevel2 + array + + + + + + + TableLevel2_Instance + read + + + TableLevel2_FkTo1000 + read + + + + TableLevel3 + array + + + + + + + TableLevel3_Instance + read + + + TableLevel3_FkTo2000 + read + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_NToMRelation.xml b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_NToMRelation.xml new file mode 100644 index 00000000..5fe4818e --- /dev/null +++ b/ProtocolTests/Protocol/Relations/Relation/CheckPathAttribute/Samples/Validate/Valid/Valid_NToMRelation.xml @@ -0,0 +1,62 @@ + + + + + + + NToMParentTable + array + + + + + + NToMParentTable_Instance + read + + + + NToMIntermediateTable + array + + + + + + + + NToMIntermediateTable_Instance + read + + + NToMIntermediateTable_FkTo10000 + read + + + NToMIntermediateTable_FkTo10200 + read + + + + NToMChildrenTable + array + + + + + + NToMChildrenTable_Instance + read + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..c3d999d7 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.Responses.Response.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Responses.Response.CheckIdAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Response_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Response_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Response_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Response_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "11.4.5", + Category = Category.Response, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Response with same ID '2'. Response Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each response." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each response should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Response_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "11.4.2", + Category = Category.Response, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Response@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each response." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each response should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Response_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "11.4.4", + Category = Category.Response, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Response@id'. Response name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each response." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each response should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Response_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "11.4.1", + Category = Category.Response, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Response@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each response." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each response should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Response_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "11.4.3", + Category = Category.Response, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Response@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each response." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each response should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Response_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Response); + + [TestMethod] + public void Response_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..7af6c6b8 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..25f9d851 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..34cf14aa --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..0dc72e11 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..b4080ece --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..ab219601 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6eb0e132 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/CheckResponseLogic.cs b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/CheckResponseLogic.cs new file mode 100644 index 00000000..c1ab852a --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/CheckResponseLogic.cs @@ -0,0 +1,99 @@ +namespace SLDisValidatorUnitTests.Protocol.Responses.Response.CheckResponseLogic +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Responses.Response.CheckResponseLogic; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckResponseLogic(); + + #region Valid Checks + + [TestMethod] + public void Response_CheckResponseLogic_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Response_CheckResponseLogic_ValidOnEach() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidOnEach", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Response_CheckResponseLogic_MissingCrcResponseAction() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingCrcResponseAction", + ExpectedResults = new List + { + Error.MissingCrcResponseAction(null, null, null, "1", "2"), + Error.MissingCrcResponseAction(null, null, null, "2", "2"), + Error.MissingCrcResponseAction(null, null, null, "3", "2"), + Error.MissingCrcResponseAction(null, null, null, "4", "2"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Response_CheckResponseLogic_MissingCrcResponseActionEachOvewrite() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingCrcResponseActionEachOvewrite", + ExpectedResults = new List + { + Error.MissingCrcResponseAction(null, null, null, "2", "2"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckResponseLogic(); + + [TestMethod] + public void Response_CheckResponseLogic_CheckCategory() => Generic.CheckCategory(root, Category.Response); + + [TestMethod] + public void Response_CheckResponseLogic_CheckId() => Generic.CheckId(root, CheckId.CheckResponseLogic); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseAction.xml b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseAction.xml new file mode 100644 index 00000000..5de0b47e --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseAction.xml @@ -0,0 +1,110 @@ + + + + + CrcParam + crc + + + + + + NoTrigger + + 2 + + + + NoAction + + 2 + + + + NoCrcAction + + 2 + + + + TriggerInsteadOfAction + + 2 + + + + + + + DummyTrigger + action + + + + + BeforeResponse2 + response + + action + + + + + BeforeResponse3 + response + + action + + 3 + 4 + + + + BeforeResponse4 + response + + trigger + + 1 + + + + + BeforeCommandEach + command + + action + + 1 + + + + BeforeCommand2 + command + + action + + 1 + + + + + + + CalculateCrcResponse + response + crc + + + CalculateResponseLength + response + length + + + CalculateCrcCommand + command + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseActionEachOvewrite.xml b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseActionEachOvewrite.xml new file mode 100644 index 00000000..d835d723 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Invalid/MissingCrcResponseActionEachOvewrite.xml @@ -0,0 +1,56 @@ + + + + + CrcParam + crc + + + + + + CrcResponse + + 2 + + + + + + + BeforeResponseEach + response + + action + + 1 + + + + BeforeResponse2 + response + + action + + + + + BeforeResponseEach2 + response + + action + + 1 + + + + + + + CalculateCrcResponse + response + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3604bf54 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,64 @@ + + + + + CrcParam + crc + + + FixedParamAAA + fixed + + other + string + fixed + 3 + AAA + + + + + + + CrcResponse + + 2 + + + + NoCrcResponse + + 3 + + + + + + + BeforeCommandEach + response + + action + + + + + BeforeResponse2 + response + + action + + 1 + + + + + + + CrcResponse + response + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/ValidOnEach.xml b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/ValidOnEach.xml new file mode 100644 index 00000000..f7f430d6 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/CheckResponseLogic/Samples/Validate/Valid/ValidOnEach.xml @@ -0,0 +1,64 @@ + + + + + CrcParam + crc + + + FixedParamAAA + fixed + + other + string + fixed + 3 + AAA + + + + + + + CrcResponse + + 2 + + + + NoCrcResponse + + 3 + + + + + + + beforeResponseEach + response + + action + + + + + beforeResponseEach2 + response + + action + + 1 + + + + + + + CalculateCrcResponse + response + crc + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/CheckParamTag.cs b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/CheckParamTag.cs new file mode 100644 index 00000000..45126a54 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/CheckParamTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Responses.Response.Content.Param.CheckParamTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Responses.Response.Content.Param.CheckParamTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParamTag(); + + #region Valid Checks + + [TestMethod] + public void Response_CheckParamTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Response_CheckParamTag_EmptyParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyParamTag", + ExpectedResults = new List + { + Error.EmptyParamTag(null, null, null, "1"), + Error.EmptyParamTag(null, null, null, "2"), + Error.EmptyParamTag(null, null, null, "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckParamTag_InvalidParamTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidParamTag", + ExpectedResults = new List + { + Error.InvalidParamTag(null, null, null, "test1", "1"), + Error.InvalidParamTag(null, null, null, "test2", "2"), + Error.InvalidParamTag(null, null, null, "test3", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckParamTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2"), + Error.NonExistingId(null, null, null, "1003", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Response_CheckParamTag_NonExistingIdNoParamsTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoParamsTag", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1001", "1"), + Error.NonExistingId(null, null, null, "1001", "2"), + Error.NonExistingId(null, null, null, "1002", "2") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Response_CheckParamTag_EmptyParamTag() + { + // Create ErrorMessage + var message = Error.EmptyParamTag(null, null, null, "0"); + + string description = "Empty tag 'Content/Param' in Response '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Response_CheckParamTag_InvalidParamTag() + { + // Create ErrorMessage + var message = Error.InvalidParamTag(null, null, null, "test", "1"); + + string description = "Invalid value 'test' in tag 'Content/Param'. Response ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Response_CheckParamTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0", "1"); + + string description = "Tag 'Content/Param' references a non-existing 'Param' with ID '0'. Response ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParamTag(); + + [TestMethod] + public void Response_CheckParamTag_CheckCategory() => Generic.CheckCategory(check, Category.Response); + + [TestMethod] + public void Response_CheckParamTag_CheckId() => Generic.CheckId(check, CheckId.CheckParamTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml new file mode 100644 index 00000000..1ff8720b --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/EmptyParamTag.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + 1 + + + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml new file mode 100644 index 00000000..72e83b74 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/InvalidParamTag.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + test1 + + + + + 1 + 1 + test2 + test3 + 2 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..8a0345ad --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + 1001 + + + + + 1001 + 1002 + + + + + 1 + 1003 + 3 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml new file mode 100644 index 00000000..fb323124 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Invalid/NonExistingIdNoParamsTag.xml @@ -0,0 +1,17 @@ + + + + + + 1001 + + + + + 1001 + 1002 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..71966819 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Content/Param/CheckParamTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + 1001 + + + + + 1001 + 1002 + 1003 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..a2d14420 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Responses.Response.Name.CheckNameTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Responses.Response.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Response_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Response_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Response_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Response); + + [TestMethod] + public void Response_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..000595c1 --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..96e64c5e --- /dev/null +++ b/ProtocolTests/Protocol/Responses/Response/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/CheckIncludepagesAttribute.cs b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/CheckIncludepagesAttribute.cs new file mode 100644 index 00000000..e9544be2 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/CheckIncludepagesAttribute.cs @@ -0,0 +1,157 @@ +namespace SLDisValidatorUnitTests.Protocol.SNMP.CheckIncludepagesAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.SNMP.CheckIncludepagesAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIncludepagesAttribute(); + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "abc", "true; false"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_InvalidAttributeCasing() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttributeCasing", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "True", "true; false"), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIncludepagesAttribute(); + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_MissingAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_InvalidAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_InvalidAttributeCasing() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidAttributeCasing", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIncludepagesAttribute(); + + [TestMethod] + public void Protocol_CheckIncludepagesAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckIncludepagesAttriubte_CheckId() => Generic.CheckId(root, CheckId.CheckIncludepagesAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttribute.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttributeCasing.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttributeCasing.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/InvalidAttributeCasing.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/MissingAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/MissingAttribute.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Codefix/MissingAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..aca3f601 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..c88e5e58 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttributeCasing.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttributeCasing.xml new file mode 100644 index 00000000..a4a6d7e5 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/InvalidAttributeCasing.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..0e87781b --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckIncludepagesAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/CheckSnmpTag.cs b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/CheckSnmpTag.cs new file mode 100644 index 00000000..92e59a0d --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/CheckSnmpTag.cs @@ -0,0 +1,157 @@ +namespace SLDisValidatorUnitTests.Protocol.SNMP.CheckSnmpTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.SNMP.CheckSnmpTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckSnmpTag(); + + [TestMethod] + public void Protocol_CheckSnmpTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "abas", "auto, false"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_InvalidTrueValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTrueValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "true", "auto, false"), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckSnmpTag(); + + [TestMethod] + public void Protocol_CheckSnmpTag_MissingTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_EmptyTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_InvalidValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidValue", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckSnmpTag_InvalidTrueValue() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "InvalidTrueValue", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckSnmpTag(); + + [TestMethod] + public void Protocol_CheckSnmpTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckSnmpTag_CheckId() => Generic.CheckId(root, CheckId.CheckSnmpTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/EmptyTag.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/EmptyTag.xml new file mode 100644 index 00000000..0e87781b --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/EmptyTag.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidTrueValue.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidTrueValue.xml new file mode 100644 index 00000000..ca17b8f8 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidTrueValue.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidValue.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidValue.xml new file mode 100644 index 00000000..ca17b8f8 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/InvalidValue.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/MissingTag.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/MissingTag.xml new file mode 100644 index 00000000..cac48465 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Codefix/MissingTag.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..1dc27ef6 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidTrueValue.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidTrueValue.xml new file mode 100644 index 00000000..0ed7d0fd --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidTrueValue.xml @@ -0,0 +1,3 @@ + + true + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..b8278943 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,3 @@ + + abas + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0e87781b --- /dev/null +++ b/ProtocolTests/Protocol/SNMP/CheckSnmpTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + auto + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..8131aac4 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Timer_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Timer_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Timer_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "7.6.5", + Category = Category.Timer, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Timer with same ID '2'. Timer Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each timer." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each timer should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "7.6.2", + Category = Category.Timer, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Timer@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each timer." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each timer should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "7.6.4", + Category = Category.Timer, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Timer@id'. Timer name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each timer." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each timer should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "7.6.1", + Category = Category.Timer, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Timer@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each timer." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each timer should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "7.6.3", + Category = Category.Timer, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Timer@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each timer." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each timer should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Timer_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Timer); + + [TestMethod] + public void Timer_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..c3b39fcc --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..b1b78622 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..54ce43c1 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..4d07538b --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..dd637e36 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..b836e1ca --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..89251f9e --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..636895d9 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,747 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.CheckOptionsAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.CheckOptionsAttribute; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Timer_CheckOptionsAttribute_DuplicateOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;each:200").WithSubResults( + Error.DuplicateOption(null, null, null, "each")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_DuplicateOptionInPingOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateOptionInPingOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;ping:rttColumn=4,rttColumn=5").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:rttColumn=4,rttColumn=5").WithSubResults( + Error.DuplicateOptionInPingOption(null, null, null, "rttColumn"))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAttribute", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "3", "ip:2000,1;each:100;threadPool:aaa;qaction;qactionBefore:20;qactionAfter:bbb;randomOption").WithSubResults( + Error.InvalidThreadPoolOption(null, null, null, "threadPool:aaa").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "aaa")), + Error.UseOfObsoleteQActionOption(null, null, null), + Error.InvalidQActionOption(null, null, null, "qaction"), + Error.NonExistingIdInOption(null, null, null, "qactionBefore", "QAction", "20"), + Error.InvalidQActionAfterOption(null, null, null, "qactionAfter:bbb"), + Error.UnknownOption(null, null, null, "randomOption")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidDynamicThreadPoolOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidDynamicThreadPoolOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;dynamicThreadPool").WithSubResults( + Error.InvalidDynamicThreadPoolOption(null, null, null, "dynamicThreadPool")), + Error.InvalidAttribute(null, null, null, "2", "threadPool:10;ip:2000,1;each:100;dynamicThreadPool:").WithSubResults( + Error.InvalidDynamicThreadPoolOption(null, null, null, "dynamicThreadPool:")), + Error.InvalidAttribute(null, null, null, "3", "threadPool:10;ip:2000,1;each:100;dynamicThreadPool:abc").WithSubResults( + Error.InvalidDynamicThreadPoolOption(null, null, null, "dynamicThreadPool:abc")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidEachOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidEachOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each").WithSubResults( + Error.InvalidEachOption(null, null, null, "each")), + Error.InvalidAttribute(null, null, null, "2", "threadPool:10;ip:2000,1;each:").WithSubResults( + Error.InvalidEachOption(null, null, null, "each:")), + Error.InvalidAttribute(null, null, null, "3", "threadPool:10;ip:2000,1;each:abc").WithSubResults( + Error.InvalidEachOption(null, null, null, "each:abc")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidIgnoreIfOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidIgnoreIfOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;ignoreIf").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;ignoreIf:").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:")), + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;ignoreIf:abc,2").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:abc,2").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "abc"))), + Error.InvalidAttribute(null, null, null, "11", "ip:2000,1;each:1000;threadPool:10;ignoreIf:8,abc").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:8,abc").WithSubResults( + Error.NonExistingColumnIdxInOption(null, null, null, "", "8", "2000"))), + Error.InvalidAttribute(null, null, null, "20", "ip:2000,1;each:1000;threadPool:10;ignoreIf:2").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:2").WithSubResults( + Error.MissingValueInOption(null, null, null, ""))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidInstanceOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidInstanceOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;instance").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;instance:").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:")), + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;instance:aaa,0").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:aaa,0").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "aaa"))), + Error.InvalidAttribute(null, null, null, "11", "ip:2000,1;each:1000;threadPool:10;instance:2000,bbb").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:2000,bbb").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "bbb"))), + Error.InvalidAttribute(null, null, null, "12", "ip:2000,1;each:1000;threadPool:10;instance:ccc,ddd").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:ccc,ddd").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "ccc"), + Error.InvalidValueInOption(null, null, null, "", "ddd"))), + Error.InvalidAttribute(null, null, null, "20", "ip:2000,1;each:1000;threadPool:10;instance:2000").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:2000").WithSubResults( + Error.MissingValueInOption(null, null, null, ""))), + Error.InvalidAttribute(null, null, null, "30", "ip:2000,1;each:1000;threadPool:10;instance:1000,1").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:1000,1").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "", "Param", "1000"))), + Error.InvalidAttribute(null, null, null, "31", "ip:2000,1;each:1000;threadPool:10;instance:2000,2").WithSubResults( + Error.InvalidInstanceOption(null, null, null, "instance:2000,2").WithSubResults( + Error.NonExistingColumnIdxInOption(null, null, null, "", "2", "2000"))), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidIpOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidIpOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;each:100;ip").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip")), + Error.InvalidAttribute(null, null, null, "2", "threadPool:10;each:100;ip:").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:")), + + Error.InvalidAttribute(null, null, null, "10", "threadPool:10;each:100;ip:aaa,1").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:aaa,1").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "aaa"))), + Error.InvalidAttribute(null, null, null, "11", "threadPool:10;each:100;ip:2000,bbb").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:2000,bbb").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "bbb"))), + Error.InvalidAttribute(null, null, null, "12", "threadPool:10;each:100;ip:ccc,ddd").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:ccc,ddd").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "ccc"), + Error.InvalidValueInOption(null, null, null, "", "ddd"))), + + Error.InvalidAttribute(null, null, null, "20", "threadPool:10;each:100;ip:1000,0").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:1000,0").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "", "Param", "1000"))), + Error.InvalidAttribute(null, null, null, "21", "threadPool:10;each:100;ip:2000,1").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:2000,1").WithSubResults( + Error.NonExistingColumnIdxInOption(null, null, null, "", "1", "2000"))), + + Error.InvalidAttribute(null, null, null, "30", "threadPool:10;each:100;ip:2000").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:2000").WithSubResults( + Error.MissingValueInOption(null, null, null, ""))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidPingOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPingOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;ping").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;ping:").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:")), + + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;ping:rttColumn=10").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:rttColumn=10").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "rttColumn", "10", "2000"))), + Error.InvalidAttribute(null, null, null, "11", "ip:2000,1;each:1000;threadPool:10;ping:timeoutPid=abc").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:timeoutPid=abc").WithSubResults( + Error.InvalidValueInOption(null, null, null, "timeoutPid", "abc"), + Error.UseOfObsoleteTimeoutPidOptionInPingOption(null, null, null))), + Error.InvalidAttribute(null, null, null, "12", "ip:2000,1;each:1000;threadPool:10;ping:ttl=-1").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:ttl=-1").WithSubResults( + Error.InvalidValueInOption(null, null, null, "ttl", "-1"))), + Error.InvalidAttribute(null, null, null, "13", "ip:2000,1;each:1000;threadPool:10;ping:timeout=-1").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:timeout=-1").WithSubResults( + Error.InvalidValueInOption(null, null, null, "timeout", "-1"))), + Error.InvalidAttribute(null, null, null, "14", "ip:2000,1;each:1000;threadPool:10;ping:timestampcolumn=-1").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:timestampcolumn=-1").WithSubResults( + Error.InvalidValueInOption(null, null, null, "timestampColumn", "-1"))), + Error.InvalidAttribute(null, null, null, "15", "ip:2000,1;each:1000;threadPool:10;ping:type=abc").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:type=abc").WithSubResults( + Error.InvalidValueInOption(null, null, null, "type", "abc"))), + Error.InvalidAttribute(null, null, null, "16", "ip:2000,1;each:1000;threadPool:10;ping:size=-1").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:size=-1").WithSubResults( + Error.InvalidValueInOption(null, null, null, "size", "-1"))), + Error.InvalidAttribute(null, null, null, "17", "ip:2000,1;each:1000;threadPool:10;ping:continueSNMPOnTimeout=no").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:continueSNMPOnTimeout=no").WithSubResults( + Error.InvalidValueInOption(null, null, null, "continueSnmpOnTimeout", "no"))), + Error.InvalidAttribute(null, null, null, "18", "ip:2000,1;each:1000;threadPool:10;ping:jitterColumn=20").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:jitterColumn=20").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "jitterColumn", "20", "2000"))), + Error.InvalidAttribute(null, null, null, "19", "ip:2000,1;each:1000;threadPool:10;ping:latencyColumn=21").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:latencyColumn=21").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "latencyColumn", "21", "2000"))), + Error.InvalidAttribute(null, null, null, "20", "ip:2000,1;each:1000;threadPool:10;ping:packetLossRateColumn=22").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:packetLossRateColumn=22").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "packetLossRateColumn", "22", "2000"))), + Error.InvalidAttribute(null, null, null, "21", "ip:2000,1;each:1000;threadPool:10;ping:amountPacketsMeasurements=abc").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:amountPacketsMeasurements=abc").WithSubResults( + Error.InvalidValueInOption(null, null, null, "amountPacketsMeasurements", "abc"))), + Error.InvalidAttribute(null, null, null, "22", "ip:2000,1;each:1000;threadPool:10;ping:amountPacketsMeasurementsPid=10").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:amountPacketsMeasurementsPid=10").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "amountPacketsMeasurementsPid", "Param", "10"))), + Error.InvalidAttribute(null, null, null, "23", "ip:2000,1;each:1000;threadPool:10;ping:amountPackets=abc").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:amountPackets=abc").WithSubResults( + Error.InvalidValueInOption(null, null, null, "amountPackets", "abc"))), + Error.InvalidAttribute(null, null, null, "24", "ip:2000,1;each:1000;threadPool:10;ping:amountPacketsPid=10").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:amountPacketsPid=10").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "amountPacketsPid", "Param", "10"))), + Error.InvalidAttribute(null, null, null, "25", "ip:2000,1;each:1000;threadPool:10;ping:excludeWorstResults=110").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:excludeWorstResults=110").WithSubResults( + Error.InvalidValueInOption(null, null, null, "excludeWorstResults", "110"))), + Error.InvalidAttribute(null, null, null, "26", "ip:2000,1;each:1000;threadPool:10;ping:excludeWorstResultsPid=11").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:excludeWorstResultsPid=11").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "excludeWorstResultsPid", "Param", "11"))), + + Error.InvalidAttribute(null, null, null, "100", "ip:2000,1;each:1000;threadPool:10;ping:rttColumn=10,timeoutPid=abc,ttl=-1").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:rttColumn=10,timeoutPid=abc,ttl=-1").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "rttColumn", "10", "2000"), + Error.InvalidValueInOption(null, null, null, "timeoutPid", "abc"), + Error.UseOfObsoleteTimeoutPidOptionInPingOption(null, null, null), + Error.InvalidValueInOption(null, null, null, "ttl", "-1"))), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidPollingRateOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidPollingRateOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;pollingRate").WithSubResults( + Error.InvalidPollingRateOption(null, null, null, "pollingRate")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;pollingRate:").WithSubResults( + Error.InvalidPollingRateOption(null, null, null, "pollingRate:")), + + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;pollingRate:abc,def,ghi").WithSubResults( + Error.InvalidPollingRateOption(null, null, null, "pollingRate:abc,def,ghi").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "abc"), + Error.InvalidValueInOption(null, null, null, "", "def"), + Error.InvalidValueInOption(null, null, null, "", "ghi"))), + Error.InvalidAttribute(null, null, null, "100", "ip:2000,1;each:1000;threadPool:10;pollingRate:15").WithSubResults( + Error.InvalidPollingRateOption(null, null, null, "pollingRate:15").WithSubResults( + Error.MissingValueInOption(null, null, null, ""), + Error.MissingValueInOption(null, null, null, ""))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidQActionAfterOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidQActionAfterOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;qactionAfter").WithSubResults( + Error.InvalidQActionAfterOption(null, null, null, "qactionAfter")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;qactionAfter:").WithSubResults( + Error.InvalidQActionAfterOption(null, null, null, "qactionAfter:")), + + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;qactionAfter:abc").WithSubResults( + Error.InvalidQActionAfterOption(null, null, null, "qactionAfter:abc")), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidQActionBeforeOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidQActionBeforeOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;qactionBefore").WithSubResults( + Error.InvalidQActionBeforeOption(null, null, null, "qactionBefore")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;qactionBefore:").WithSubResults( + Error.InvalidQActionBeforeOption(null, null, null, "qactionBefore:")), + + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;qactionBefore:abc").WithSubResults( + Error.InvalidQActionBeforeOption(null, null, null, "qactionBefore:abc")), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidQActionOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidQActionOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;qaction").WithSubResults( + Error.InvalidQActionOption(null, null, null, "qaction"), + Error.UseOfObsoleteQActionOption(null, null, null)), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;qaction:").WithSubResults( + Error.InvalidQActionOption(null, null, null, "qaction:"), + Error.UseOfObsoleteQActionOption(null, null, null)), + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:10;qaction:abc").WithSubResults( + Error.InvalidQActionOption(null, null, null, "qaction:abc"), + Error.UseOfObsoleteQActionOption(null, null, null)) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidThreadPoolOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidThreadPoolOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool").WithSubResults( + Error.InvalidThreadPoolOption(null, null, null, "threadPool")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:").WithSubResults( + Error.InvalidThreadPoolOption(null, null, null, "threadPool:")), + + Error.InvalidAttribute(null, null, null, "10", "ip:2000,1;each:1000;threadPool:abc").WithSubResults( + Error.InvalidThreadPoolOption(null, null, null, "threadPool:abc").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "abc"))), + Error.InvalidAttribute(null, null, null, "11", "ip:2000,1;each:1000;threadPool:10,5,-1,-1,-1,-1,abc,def").WithSubResults( + Error.InvalidThreadPoolOption(null, null, null, "threadPool:10,5,-1,-1,-1,-1,abc,def").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "abc"), + Error.InvalidValueInOption(null, null, null, "", "def"))), + + Error.ThreadPoolCalculationIntervalDefined(null, null, null, "11") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_InvalidValueInOptions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValueInOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;ignoreIf:abc,2").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:abc,2").WithSubResults( + Error.InvalidValueInOption(null, null, null, "", "abc"))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_MissingEachOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingEachOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1").WithSubResults( + Error.MissingEachOption(null, null, null, "ip', 'threadPool", "1")), + Error.InvalidAttribute(null, null, null, "2", "threadPool:10").WithSubResults( + Error.MissingEachOption(null, null, null, "threadPool", "2"), + Error.MissingIpOption(null, null, null, "threadPool", "2")), + Error.InvalidAttribute(null, null, null, "3", "ip:2000,1").WithSubResults( + Error.MissingEachOption(null, null, null, "ip", "3"), + Error.MissingThreadPoolOption(null, null, null, "ip", "3")), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_MissingIpOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingIpOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;each:10").WithSubResults( + Error.MissingIpOption(null, null, null, "each', 'threadPool", "1")), + Error.InvalidAttribute(null, null, null, "2", "threadPool:10").WithSubResults( + Error.MissingIpOption(null, null, null, "threadPool", "2"), + Error.MissingEachOption(null, null, null, "threadPool", "2")), + Error.InvalidAttribute(null, null, null, "3", "each:10").WithSubResults( + Error.MissingIpOption(null, null, null, "each", "3"), + Error.MissingThreadPoolOption(null, null, null, "each", "3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_MissingThreadPoolOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingThreadPoolOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:10").WithSubResults( + Error.MissingThreadPoolOption(null, null, null, "each', 'ip", "1")), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1").WithSubResults( + Error.MissingThreadPoolOption(null, null, null, "ip", "2"), + Error.MissingEachOption(null, null, null, "ip", "2")), + Error.InvalidAttribute(null, null, null, "3", "each:10").WithSubResults( + Error.MissingThreadPoolOption(null, null, null, "each", "3"), + Error.MissingIpOption(null, null, null, "each", "3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_MissingValueInOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingValueInOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;ignoreIf:2").WithSubResults( + Error.InvalidIgnoreIfOption(null, null, null, "ignoreIf:2").WithSubResults( + Error.MissingValueInOption(null, null, null, ""))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_NonExistingIdInDynamicThreadPoolOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdInDynamicThreadPoolOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;dynamicThreadPool:100").WithSubResults( + Error.NonExistingIdInDynamicThreadPoolOption(null, null, null, "100")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_NonExistingIdInOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdInOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;qaction:11").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "qaction", "QAction", "11"), + Error.UseOfObsoleteQActionOption(null, null, null)), + Error.InvalidAttribute(null, null, null, "2", "ip:2000,1;each:1000;threadPool:10;qactionBefore:12").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "qactionBefore", "QAction", "12")), + Error.InvalidAttribute(null, null, null, "3", "ip:2000,1;each:1000;threadPool:10;qactionAfter:13").WithSubResults( + Error.NonExistingIdInOption(null, null, null, "qactionAfter", "QAction", "13")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_ThreadPoolCalculationIntervalDefined() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ThreadPoolCalculationIntervalDefined", + ExpectedResults = new List + { + Error.ThreadPoolCalculationIntervalDefined(null, null, null, "1"), + Error.ThreadPoolCalculationIntervalDefined(null, null, null, "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_UnknownOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnknownOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;typo:icmp").WithSubResults( + Error.UnknownOption(null, null, null, "typo:icmp")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_UnknownOptionInPingOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnknownOptionInPingOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "threadPool:10;ip:2000,1;each:100;ping:aech=200").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:aech=200").WithSubResults( + Error.UnknownOptionInPingOption(null, null, null, "aech=200"))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_UseOfObsoleteQActionOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UseOfObsoleteQActionOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;qaction:20").WithSubResults( + Error.UseOfObsoleteQActionOption(null, null, null)) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_UseOfObsoleteTimeoutPidOptionInPingOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UseOfObsoleteTimeoutPidOptionInPingOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "1", "ip:2000,1;each:1000;threadPool:10;ping:timeoutPid=10").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:timeoutPid=10").WithSubResults( + Error.UseOfObsoleteTimeoutPidOptionInPingOption(null, null, null))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_NonExistingColumnIdxInOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumnIdxInOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "21", "threadPool:10;each:100;ip:2000,1").WithSubResults( + Error.InvalidIpOption(null, null, null, "ip:2000,1").WithSubResults( + Error.NonExistingColumnIdxInOption(null, null, null, "", "1", "2000"))) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckOptionsAttribute_NonExistingColumnPositionInOption() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingColumnPositionInOption", + ExpectedResults = new List + { + Error.InvalidAttribute(null, null, null, "18", "ip:2000,1;each:1000;threadPool:10;ping:jitterColumn=20").WithSubResults( + Error.InvalidPingOption(null, null, null, "ping:jitterColumn=20").WithSubResults( + Error.NonExistingColumnPositionInOption(null, null, null, "jitterColumn", "20", "2000"))) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOptionsAttribute(); + + [TestMethod] + public void Timer_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Timer); + + [TestMethod] + public void Timer_CheckOptionsAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckOptionsAttribute); + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Timer_CheckOptionsAttribute_NonExistingIdInDynamicThreadPoolOption() + { + // Create ErrorMessage + var message = Error.NonExistingIdInDynamicThreadPoolOption(null, null, null, "1"); + + string description = "Option 'dynamicThreadPool' references a non-existing 'Param' with ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOption.xml new file mode 100644 index 00000000..cf5ec10a --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOption.xml @@ -0,0 +1,27 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOptionInPingOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOptionInPingOption.xml new file mode 100644 index 00000000..aebb433c --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/DuplicateOptionInPingOption.xml @@ -0,0 +1,27 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidAttribute.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidAttribute.xml new file mode 100644 index 00000000..62068b37 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidAttribute.xml @@ -0,0 +1,24 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidDynamicThreadPoolOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidDynamicThreadPoolOption.xml new file mode 100644 index 00000000..02a68bbf --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidDynamicThreadPoolOption.xml @@ -0,0 +1,26 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidEachOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidEachOption.xml new file mode 100644 index 00000000..1f71b4ff --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidEachOption.xml @@ -0,0 +1,26 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIgnoreIfOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIgnoreIfOption.xml new file mode 100644 index 00000000..b00aaada --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIgnoreIfOption.xml @@ -0,0 +1,45 @@ + + + + + MultiThreadTable + array + + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + MultiThreadTable_IgnoreIf + + + + + + EmptyIgnoreIf_1 + + + EmptyIgnoreIf_2 + + + + WrongPidRef_NonNumericPid + + + + WrongPidRef_UnexistingPID + + + + WrongConditionalValue_Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidInstanceOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidInstanceOption.xml new file mode 100644 index 00000000..815c4e4b --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidInstanceOption.xml @@ -0,0 +1,54 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + Instance_Empty1 + + + Instance_Empty2 + + + + + Instance_InvalidTablePid + + + Instance_InvalidColumnIdx + + + Instance_InvalidTablePid_InvalidColumnIdx + + + + + Instance_MissingColumnIdx + + + + + Instance_NonExistingTablePid + + + Instance_NonExistingColumnIdx + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIpOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIpOption.xml new file mode 100644 index 00000000..f725f1c2 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidIpOption.xml @@ -0,0 +1,54 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + + + + + + Ip_Empty1 + + + Ip_Empty2 + + + + + Ip_InvalidTablePid + + + Ip_InvalidColumnIdx + + + Ip_InvalidTablePid_InvalidColumnIdx + + + + + Ip_UnexistingTablePid + + + Ip_UnexistingColumnIdx + + + + + Ip_MissingColumnIdx + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPingOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPingOption.xml new file mode 100644 index 00000000..fff9bfbe --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPingOption.xml @@ -0,0 +1,48 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPollingRateOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPollingRateOption.xml new file mode 100644 index 00000000..452c2c01 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidPollingRateOption.xml @@ -0,0 +1,32 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionAfterOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionAfterOption.xml new file mode 100644 index 00000000..c4982504 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionAfterOption.xml @@ -0,0 +1,37 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + Empty 1 + + + Empty 2 + + + + + NonNumeric + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionBeforeOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionBeforeOption.xml new file mode 100644 index 00000000..deed67d8 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionBeforeOption.xml @@ -0,0 +1,36 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + Empty 1 + + + Empty 2 + + + + + NonNumeric + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionOption.xml new file mode 100644 index 00000000..e1672f34 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidQActionOption.xml @@ -0,0 +1,37 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + Emtpy 1 + + + Emtpy 2 + + + + + NonNumeric + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidThreadPoolOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidThreadPoolOption.xml new file mode 100644 index 00000000..9d38eead --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidThreadPoolOption.xml @@ -0,0 +1,53 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + Empty 1 + + + Empty 2 + + + + + Invalid_Size + + + Invalid_counterPid_queueSize__Useless_CalculationInterval + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidValueInOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidValueInOption.xml new file mode 100644 index 00000000..77fad4dc --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/InvalidValueInOption.xml @@ -0,0 +1,26 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + ignoreIf_columnIdx + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingEachOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingEachOption.xml new file mode 100644 index 00000000..05e15224 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingEachOption.xml @@ -0,0 +1,40 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + + DueTo_threadPool_ip + + + DueTo_threadPool + + + DueTo_ip + + col:1:10 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingIpOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingIpOption.xml new file mode 100644 index 00000000..cf803bb9 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingIpOption.xml @@ -0,0 +1,32 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + DueTo_threadPool_each + + + DueTo_threadPool + + + DueTo_each + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingThreadPoolOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingThreadPoolOption.xml new file mode 100644 index 00000000..3046053d --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingThreadPoolOption.xml @@ -0,0 +1,32 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + DueTo_ip_each + + + DueTo_ip + + + DueTo_each + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingValueInOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingValueInOption.xml new file mode 100644 index 00000000..3f7a8b8e --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/MissingValueInOption.xml @@ -0,0 +1,30 @@ + + + + + MultiThreadTable + array + + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + MultiThreadTable_IgnoreIf + + + + + + ignoreIf_MissingConditionalValue + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnIdxInOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnIdxInOption.xml new file mode 100644 index 00000000..c9974442 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnIdxInOption.xml @@ -0,0 +1,24 @@ + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + + + + + Ip_UnexistingColumnIdx + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnPositionInOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnPositionInOption.xml new file mode 100644 index 00000000..13fd892f --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingColumnPositionInOption.xml @@ -0,0 +1,24 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInDynamicThreadPoolOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInDynamicThreadPoolOption.xml new file mode 100644 index 00000000..8d05a87d --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInDynamicThreadPoolOption.xml @@ -0,0 +1,29 @@ + + + + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInOption.xml new file mode 100644 index 00000000..291753ce --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingIdInOption.xml @@ -0,0 +1,32 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + Qaction + + + QactionBefore + + + QactionAfter + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/ThreadPoolCalculationIntervalDefined.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/ThreadPoolCalculationIntervalDefined.xml new file mode 100644 index 00000000..1c022e52 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/ThreadPoolCalculationIntervalDefined.xml @@ -0,0 +1,41 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOption.xml new file mode 100644 index 00000000..a982358b --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOption.xml @@ -0,0 +1,25 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOptionInPingOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOptionInPingOption.xml new file mode 100644 index 00000000..8947989e --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UnknownOptionInPingOption.xml @@ -0,0 +1,25 @@ + + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteQActionOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteQActionOption.xml new file mode 100644 index 00000000..f9f274bd --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteQActionOption.xml @@ -0,0 +1,32 @@ + + CheckOptionsAttribute_UseOfObsoleteQActionOption + 0.0.0.0 + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + read + + + MultiThreadTable_Ip + read + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteTimeoutPidOptionInPingOption.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteTimeoutPidOptionInPingOption.xml new file mode 100644 index 00000000..25b5d4ee --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Invalid/UseOfObsoleteTimeoutPidOptionInPingOption.xml @@ -0,0 +1,29 @@ + + + + + MultiThread_Ping_Timeout + + + + MultiThreadTable + array + + + + + + + MultiThreadTable_PK + + + MultiThreadTable_Ip + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..8ca209e9 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,205 @@ + + CheckOptionsAttriubte_Valid + 0.0.0.0 + + + + threadPool_Usage + read + + + threadPool_Waiting + read + + + threadPool_MaxDuration + read + + + threadPool_AvgDuration + read + + + threadPool_Counter + read + + + + dynamicThreadPool_NbOfUsedThreads + read + + + + OtherTable + array + + + + + + + + OtherTable_PK + read + + + OtherTable_Column2 + read + + + OtherTable_Column3 + read + + + + MultiThreadTable + array + + + + + + + + + + MultiThreadTable_PK + read + + + MultiThreadTable_Ip + read + + + MultiThreadTable_IgnoreIf + read + + + MultiThreadTable_Ping_RTT + read + + + MultiThreadTable_Ping_TimeStamp + read + + + + + + + + + + + Normal Group + + + + MultiThread Group + + + + + + Normal Timer + + 1 + + + + + + MultiThread Timer: threadPool Size + + 100 + + + + MultiThread Timer: threadPool Size, StackSize) + + 100 + + + + + + + + + MultiThread Timer: dynamicThreadPool + + 100 + + + + + MultiThread Timer: ignoreIf + + 100 + + + + + MultiThread Timer: instance (on same table) + + 100 + + + + MultiThread Timer: instance (on different table) + + 100 + + + + + MultiThread Timer: ping icmp true + + 100 + + + + MultiThread Timer: ping winSock false + + 100 + + + + + MultiThread Timer: pollingRate + + 100 + + + + + MultiThread Timer: qactionAfter + + 100 + + + + MultiThread Timer: qactionBefore + + 100 + + + + MultiThread Timer: qactionBefore and qactionAfter + + 100 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..36e699a3 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,214 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.Condition.CheckConditionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List + { + Error.UnrecommendedCondition(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + [TestMethod] + public void Timer_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.UnrecommendedCondition(null, null, null, "1"), + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.UnrecommendedCondition(null, null, null, "2"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.UnrecommendedCondition(null, null, null, "1"), + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckConditionTag_UnrecommendedCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnrecommendedCondition", + ExpectedResults = new List + { + Error.UnrecommendedCondition(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.UnrecommendedCondition(null, null, null, "1"), + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Timer_CheckConditionTag_UnrecommendedCondition() + { + // Create ErrorMessage + var message = Error.UnrecommendedCondition(null, null, null, "1"); + + var expected = new ValidationResult + { + CheckId = 4, + ErrorId = 3, + FullId = "7.4.3", + Category = Category.Timer, + Severity = Severity.Minor, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Unrecommended condition on Timer. Timer ID '1'.", + HowToFix = "", + ExampleCode = "", + Details = "The usage of a Condition within a Timer is unrecommended for performance reasons. See DDL for more information.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1", "2"); + + var expected = new ValidationResult + { + CheckId = 4, + ErrorId = 2, + FullId = "7.4.2", + Category = Category.Timer, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Timer/Condition' references a non-existing 'Param' with PID '1'. Timer ID '2'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Timer/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Timer_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "1", "2", "3"); + + var expected = new ValidationResult + { + CheckId = 4, + ErrorId = 1, + FullId = "7.4.1", + Category = Category.Timer, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition '1'. Reason '2'. Timer ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Timer/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void Timer_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.Timer); + + [TestMethod] + public void Timer_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..644f18e5 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..1815ef8e --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,18 @@ + + + + + + string + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..395e69b1 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,8 @@ + + + + + 20]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/UnrecommendedCondition.xml b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/UnrecommendedCondition.xml new file mode 100644 index 00000000..eb7c6329 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Invalid/UnrecommendedCondition.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..eb7c6329 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/CheckGroupTag.cs b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/CheckGroupTag.cs new file mode 100644 index 00000000..9f753669 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/CheckGroupTag.cs @@ -0,0 +1,123 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.Content.Group.CheckGroupTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.Content.Group.CheckGroupTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckGroupTag(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckGroupTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + [TestMethod] + public void Timer_CheckGroupTag_NonExistingIdInGroup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdInGroup", + ExpectedResults = new List + { + Error.NonExistingIdInGroup(null, null, null, "Group", "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckGroupTag_EmptyGroupTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyGroupTag", + ExpectedResults = new List + { + Error.EmptyGroupTag(null, null, null, "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckGroupTag_InvalidTableIdInGroupTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTableIdInGroupTag", + ExpectedResults = new List + { + Error.InvalidGroupTag(null, null, null, "col:10:12", "1"), + Error.InvalidGroupTag(null, null, null, "col:10:12", "2"), + Error.InvalidGroupTag(null, null, null, "col:3:4", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Timer_CheckGroupTag_InvalidGroupTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidGroupTag", + ExpectedResults = new List + { + Error.InvalidGroupTag(null, null, null, "col10:20", "1"), + Error.InvalidGroupTag(null, null, null, "col:5:20", "2").WithSubResults( + Error.NonExistingIdInGroup(null, null, null, "Column index Table '2000' (0-based)", "5", "2" ), + Error.NonExistingIdInGroup(null, null, null, "Group", "20", "2")), + Error.InvalidGroupTag(null, null, null, "col:5:20", "3"), + Error.InvalidGroupTag(null, null, null, "abc", "4") + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + [TestCategory("Attribute")] + public class Attribute + { + private readonly IRoot check = new CheckGroupTag(); + + [TestMethod] + public void Timer_CheckGroupTag_CheckCategory() => Generic.CheckCategory(check, Category.Timer); + + [TestMethod] + public void Timer_CheckGroupTag_CheckId() => Generic.CheckId(check, CheckId.CheckGroupTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/EmptyGroupTag.xml b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/EmptyGroupTag.xml new file mode 100644 index 00000000..6f4babb7 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/EmptyGroupTag.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidGroupTag.xml b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidGroupTag.xml new file mode 100644 index 00000000..2a05e6f3 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidGroupTag.xml @@ -0,0 +1,46 @@ + + + + + array + + + + + + + + + + + + + + + + + + col10:20 + + + + + + col:5:20 + + + + + + col:5:20 + + + + + + abc + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidTableIdInGroupTag.xml b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidTableIdInGroupTag.xml new file mode 100644 index 00000000..2228f4dd --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/InvalidTableIdInGroupTag.xml @@ -0,0 +1,36 @@ + + + + + array + + + + + + + + + + + + + + col:10:12 + + + + + + col:10:12 + + + + + + col:3:4 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/NonExistingIdInGroup.xml b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/NonExistingIdInGroup.xml new file mode 100644 index 00000000..ca20be62 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Invalid/NonExistingIdInGroup.xml @@ -0,0 +1,17 @@ + + + + + 10 + 11 + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..35a74a76 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Content/Group/CheckGroupTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,32 @@ + + + + + array + + + + + + + + + + + + + + + + + 10 + + + + + col:3:10 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..f160fcef --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,67 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.Name.CheckNameTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.Name.CheckNameTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Timer_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Timer_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Timer); + + [TestMethod] + public void Timer_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..7a127e61 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..a20eeacd --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/CheckTimeTag.cs b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/CheckTimeTag.cs new file mode 100644 index 00000000..a8652495 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/CheckTimeTag.cs @@ -0,0 +1,241 @@ +namespace SLDisValidatorUnitTests.Protocol.Timers.Timer.Time.CheckTimeTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Timers.Timer.Time.CheckTimeTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckTimeTag(); + + #region Valid Checks + + [TestMethod] + public void Timer_CheckTimeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Timer_CheckTimeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_UntrimmedAndInvalid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAndInvalid", + ExpectedResults = new List + { + Error.InvalidTagValue(null, null, null, " 0 ", "loop, 1-2073600000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_InvalidTagValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidTagValue", + ExpectedResults = new List + { + Error.InvalidTagValue(null, null, null, "lalala", "loop, 1-2073600000"), + Error.InvalidTagValue(null, null, null, "0", "loop, 1-2073600000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_TimerTimeCannotBeLargerThan24Days() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "TimerTimeCannotBeLargerThan24Days", + ExpectedResults = new List + { + Error.TimerTimeCannotBeLargerThan24Days(null, null, null, "2073600001", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_DuplicateTimer() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateTimer", + ExpectedResults = new List + { + Error.DuplicateTimer(null, null, null, "loop", "1001, 1002").WithSubResults( + Error.DuplicateTimer(null, null, null, "loop", "1001"), + Error.DuplicateTimer(null, null, null, "loop", "1002")), + Error.DuplicateTimer(null, null, null, "60000", "1, 2").WithSubResults( + Error.DuplicateTimer(null, null, null, "60000", "1"), + Error.DuplicateTimer(null, null, null, "60000", "2")), + Error.DuplicateTimer(null, null, null, "300000", "11, 12, 13").WithSubResults( + Error.DuplicateTimer(null, null, null, "300000", "11"), + Error.DuplicateTimer(null, null, null, "300000", "12"), + Error.DuplicateTimer(null, null, null, "300000", "13")), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_TooFastTimer() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "TooFastTimer", + ExpectedResults = new List + { + Error.TooFastTimer(null, null, null, "500", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_TooSimilarTimers() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "TooSimilarTimers", + ExpectedResults = new List + { + Error.TooSimilarTimers(null, null, null, "1, 2, 3", "1000, 1001, 2000").WithSubResults( + Error.TooSimilarTimers(null, null, null, "1", "1000"), + Error.TooSimilarTimers(null, null, null, "2", "1001"), + Error.TooSimilarTimers(null, null, null, "3", "2000")), + Error.TooSimilarTimers(null, null, null, "11, 12, 13", "5000, 5099, 6050").WithSubResults( + Error.TooSimilarTimers(null, null, null, "11", "5000"), + Error.TooSimilarTimers(null, null, null, "12", "5099"), + Error.TooSimilarTimers(null, null, null, "13", "6050")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckTimeTag(); + + [TestMethod] + public void Timer_CheckTimeTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Timer_CheckTimeTag_TimerTimeCannotBeLargerThan24Days() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "TimerTimeCannotBeLargerThan24Days", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTimeTag(); + + [TestMethod] + public void Timer_CheckTimeTag_CheckCategory() => Generic.CheckCategory(root, Category.Timer); + + [TestMethod] + public void Timer_CheckTimeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTimeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/TimerTimeCannotBeLargerThan24Days.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/TimerTimeCannotBeLargerThan24Days.xml new file mode 100644 index 00000000..ee2a2b18 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/TimerTimeCannotBeLargerThan24Days.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..a760e412 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/DuplicateTimer.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/DuplicateTimer.xml new file mode 100644 index 00000000..1ae56d09 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/DuplicateTimer.xml @@ -0,0 +1,36 @@ + + + + + 1m Timer 1 + + + + 1m Timer 2 + + + + + 5m Timer 1 + + + + 5m Timer 2 + + + + 5m Timer 3 + + + + + + Loop Timer 1 + + + + Loop Timer 2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..0a93223d --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/InvalidTagValue.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/InvalidTagValue.xml new file mode 100644 index 00000000..fc085664 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/InvalidTagValue.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..6df59757 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TimerTimeCannotBeLargerThan24Days.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TimerTimeCannotBeLargerThan24Days.xml new file mode 100644 index 00000000..6a0518e9 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TimerTimeCannotBeLargerThan24Days.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooFastTimer.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooFastTimer.xml new file mode 100644 index 00000000..f8ee6ed8 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooFastTimer.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooSimilarTimers.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooSimilarTimers.xml new file mode 100644 index 00000000..341870a1 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/TooSimilarTimers.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedAndInvalid.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedAndInvalid.xml new file mode 100644 index 00000000..6145cfc9 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedAndInvalid.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..70a3cde1 --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..973e008e --- /dev/null +++ b/ProtocolTests/Protocol/Timers/Timer/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,53 @@ + + + + + Very Fast Timer (1s) + + 75 + + + + + Fast Timer (10s) + + 75 + + + + + Medium Timer (1m) + + 75 + + + + + Slow Timer (1h) + + 75 + + + + + Slowest timer (max value = 24 days) + + + + + + Loop Timer 11 + + + + + + Multi-threaded 21 + + + + Multi-threaded 22 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/CheckNameAttribute.cs b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/CheckNameAttribute.cs new file mode 100644 index 00000000..cf8b953e --- /dev/null +++ b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/CheckNameAttribute.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Topologies.Topology.CheckNameAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Topologies.Topology.CheckNameAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameAttribute(); + + #region Valid Checks + + [TestMethod] + public void Topology_CheckNameAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Topology_CheckNameAttribute_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1"), + Error.DuplicatedValue(null, null, null, "Name1")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameAttribute(); + + [TestMethod] + public void Topology_CheckNameAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Topology); + + [TestMethod] + public void Topology_CheckNameAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckNameAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..833d2a9e --- /dev/null +++ b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e69d1184 --- /dev/null +++ b/ProtocolTests/Protocol/Topologies/Topology/CheckNameAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/CheckParameterIdAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/CheckParameterIdAttribute.cs new file mode 100644 index 00000000..11ad4bf1 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/CheckParameterIdAttribute.cs @@ -0,0 +1,252 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.CheckParameterIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.CheckParameterIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParameterIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A"), + + Error.InvalidValue(null, null, null, "01"), + Error.InvalidValue(null, null, null, "-2"), + Error.InvalidValue(null, null, null, "1.5"), + Error.InvalidValue(null, null, null, "2,6"), + Error.InvalidValue(null, null, null, "+4"), + Error.InvalidValue(null, null, null, "5x10^1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckParameterIdAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_ReferencedParamWrongType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongType", + ExpectedResults = new List + { + Error.ReferencedParamWrongType(null, null, null, "write", "1"), + Error.ReferencedParamWrongType(null, null, null, "read bit", "2"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 1 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckParameterIdAttribute(); + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + string description = "Empty attribute 'TreeControl@parameterId'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "aaa"); + + string description = "Invalid value 'aaa' in attribute 'TreeControl@parameterId'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + string description = "Missing attribute 'TreeControl@parameterId'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1"); + + string description = "Attribute 'TreeControl@parameterId' references a non-existing 'Param' with ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, " 1 "); + + string description = "Untrimmed attribute 'TreeControl@parameterId'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParameterIdAttribute(); + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckParameterIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckParameterIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..7c247419 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..258be96d --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..64b53506 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..da98ba2b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..46d17f86 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..da98ba2b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml new file mode 100644 index 00000000..1e36e3e8 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml @@ -0,0 +1,21 @@ + + + + + Write_Param + write + + + ReadBit_Param + read bit + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..84483e33 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,14 @@ + + + + + + + + + + read + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0c1ea2a5 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/CheckParameterIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,21 @@ + + + + + TreeControlParam_Dummy + dummy + + + TreeControlParam_Read + read + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/CheckDetailsTableIdAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/CheckDetailsTableIdAttribute.cs new file mode 100644 index 00000000..bf594b3e --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/CheckDetailsTableIdAttribute.cs @@ -0,0 +1,233 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDetailsTableIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDetailsTableIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDetailsTableIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckDetailsTableIdAttribute_ReferencedTableExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedTableExpectingRTDisplay", + ExpectedResults = new List + { + // Direct Reference to table PID + Error.ReferencedTableExpectingRTDisplay(null, null, null, "1000"), + + // Reference to FK column leading to its table + Error.ReferencedTableExpectingRTDisplay(null, null, null, "2000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDetailsTableIdAttribute(); + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'LinkedDetails@detailsTableId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "aaa", "1"); + + string description = "Invalid value 'aaa' in attribute 'LinkedDetails@detailsTableId'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'LinkedDetails@detailsTableId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = @"Attribute 'ExtraDetails/LinkedDetails@detailsTableId' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 "); + + string description = "Untrimmed attribute 'LinkedDetails@detailsTableId' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDetailsTableIdAttribute(); + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckDetailsTableIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDetailsTableIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..045bd5b3 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + array + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..cd1c1174 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..dcdf1e2b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..a76a71b5 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..de0fd034 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/ReferencedTableExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/ReferencedTableExpectingRTDisplay.xml new file mode 100644 index 00000000..e34466b6 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/ReferencedTableExpectingRTDisplay.xml @@ -0,0 +1,96 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Table1 + array + + + + + + + + Table1_Instance + read + + true + + + + Table1_Column2 + read + + true + + + + + Table2 + array + + + + + + + + Table2_Instance + read + + true + + + + Table2_Column2_FkTo1000 + read + + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..9ddb63c2 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + array + + table + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..095096ca --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDetailsTableIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,154 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Level1 + array + + + + + + true + + + + Level1_Instance + read + + true + + + + Level1_Column2 + read + + true + + + discreet + + + + + Level1_ExtraDetails + array + + + + + + true + + + + Level1_ExtraDetails_Instance + read + + true + + + + Level1_ExtraDetails_Column2 + read + + true + + + + + Level2 + array + + + + + + true + + + + Level2_Instance + read + + true + + + + Level2_Column2_FkTo1000 + read + + true + + + discreet + + + + + Level2_ExtraDetails + array + + + + + + true + + + + Level2_ExtraDetails_Instance + read + + true + + + + Level2_ExtraDetails_Column2_FkTo1000 + read + + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/CheckDiscreetColumnIdAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/CheckDiscreetColumnIdAttribute.cs new file mode 100644 index 00000000..c04a5751 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/CheckDiscreetColumnIdAttribute.cs @@ -0,0 +1,229 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDiscreetColumnIdAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraDetails.LinkedDetails.CheckDiscreetColumnIdAttribute; + + + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckDiscreetColumnIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, " A", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1003"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckDiscreetColumnIdAttribute_ReferencedColumnExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedColumnExpectingRTDisplay", + ExpectedResults = new List + { + Error.ReferencedColumnExpectingRTDisplay(null, null, null, "1002"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1002 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckDiscreetColumnIdAttribute(); + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'LinkedDetails@discreetColumnId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'LinkedDetails@discreetColumnId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 "); + + string description = "Untrimmed attribute 'LinkedDetails@discreetColumnId' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "aaa", "1"); + + string description = "Invalid value 'aaa' in attribute 'LinkedDetails@discreetColumnId'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1005"); + + string description = @"Attribute 'ExtraDetails/LinkedDetails@discreetColumnId' references a non-existing 'Column' with PID '1005'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckDiscreetColumnIdAttribute(); + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_CheckCategory() => Generic.CheckCategory(check, Skyline.DataMiner.CICD.Validators.Common.Model.Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckDiscreetColumnIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckDiscreetColumnIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..f46351c4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,31 @@ + + + + + + array + + + + + + table + + + + + + discreet + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..22ab5b4b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..79deaa49 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..f560c8ac --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..15d44ccb --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,32 @@ + + + + + + + array + + + + + + table + + + + + + discreet + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml new file mode 100644 index 00000000..bc507ad4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml @@ -0,0 +1,72 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Table1 + array + + + + + + true + + + + Table1_Instance + read + + true + + + + Table1_Column2 + read + + + discreet + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..85b8587f --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,31 @@ + + + + + + array + + + + + + table + + + + + + discreet + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..2a80fcfc --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraDetails/LinkedDetails/CheckDiscreetColumnIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,72 @@ + + + + + TreeControlParam1 + dummy + + true + + + + TreeControlParam2 + dummy + + true + + + + TreeControlParam3 + dummy + + true + + + + + Table1 + array + + + + + + true + + + + Table1_Instance + read + + true + + + + Table1_Column2 + read + + true + + + discreet + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/CheckParameterAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/CheckParameterAttribute.cs new file mode 100644 index 00000000..905c245a --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/CheckParameterAttribute.cs @@ -0,0 +1,257 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.ExtraTab.Tab.CheckParameterAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraTab.Tab.CheckParameterAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParameterAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckParameterAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckParameterAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + // Type="parameters" cases + Error.InvalidValue(null, null, null, "1002,aaa,1003,1009,bbb", "1").WithSubResults( + Error.InvalidValue(null, null, null, "aaa", "1"), + Error.NonExistingId(null, null, null, "1009"), + Error.InvalidValue(null, null, null, "bbb", "1")), + Error.InvalidValue(null, null, null, "aaa", "1"), + Error.InvalidValue(null, null, null, "1009,1010", "1").WithSubResults( + Error.NonExistingId(null, null, null, "1009"), + Error.NonExistingId(null, null, null, "1010")), + + // Type="relation" cases + Error.InvalidValue(null, null, null, "10001,10002", "1"), + Error.InvalidValue(null, null, null, "aaa", "1"), + + // Type="summary" cases + Error.InvalidValue(null, null, null, "3000,4000", "1"), + Error.InvalidValue(null, null, null, "aaa", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + Error.MissingAttribute(null, null, null, "1"), + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + // type="parameters" cases + Error.InvalidValue(null, null, null, "1010,1002,1003,1009", "1").WithSubResults( + Error.NonExistingId(null, null, null, "1010"), + Error.NonExistingId(null, null, null, "1009")), + Error.NonExistingId(null, null, null, "1009"), + + // type="relation" cases + Error.NonExistingId(null, null, null, "10009"), + + // type="summary" cases + Error.NonExistingId(null, null, null, "9000"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckParameterAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckParameterAttribute(); + + [TestMethod] + public void TreeControl_CheckParameterAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckParameterAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Tab@parameter' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A", "1"); + + string description = "Invalid value 'A' in attribute 'Tab@parameter'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'Tab@parameter' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "0"); + + string description = @"Attribute 'ExtraTabs/Tab@parameter' references a non-existing 'Column' with PID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParameterAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 "); + + string description = "Untrimmed attribute 'Tab@parameter' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParameterAttribute(); + + [TestMethod] + public void TreeControl_CheckParameterAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckParameterAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckParameterAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..6d466589 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..1ba1661b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..dc41791a --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,93 @@ + + + + + TreeControl1 + + + TreeControl2 + + + TreeControl3 + + + + Table1 + + + Table1 Column1 + + + Table1 Column2 + + + Table1 Column3 + + + + Table2 + + + Table2 Column1 (FK to 1000) + + + Table2 Column2 + + + Table2 Column3 + + + + Table3 + + + Table3 Column1 (FK to 2000) + + + Table3 Column2 + + + Table3 Column3 + + + + Table10 + + + Table10 Column1 (FK to 1000) + + + Table10 Column2 + + + Table10 Column3 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..f8dd977e --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..2f7274eb --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,90 @@ + + + + + TreeControl1 + + + TreeControl2 + + + TreeControl3 + + + + Table1 + + + Table1 Column1 + + + Table1 Column2 + + + Table1 Column3 + + + + Table2 + + + Table2 Column1 (FK to 1000) + + + Table2 Column2 + + + Table2 Column3 + + + + Table3 + + + Table3 Column1 (FK to 2000) + + + Table3 Column2 + + + Table3 Column3 + + + + Table10 + + + Table10 Column1 (FK to 1000) + + + Table10 Column2 + + + Table10 Column3 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..27f529d2 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..93bc8e9c --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e271c11d --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckParameterAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,104 @@ + + + + + + + + + + TreeControl1 + + + TreeControl2 + + + TreeControl3 + + + + Table1 + + + Table1 Column1 + + + Table1 Column2 + + + Table1 Column3 + + + + Table2 + + + Table2 Column1 (FK to 1000) + + + Table2 Column2 + + + Table2 Column3 + + + + Table3 + + + Table3 Column1 (FK to 2000) + + + Table3 Column2 + + + Table3 Column3 + + + + Table10 + + + Table10 Column1 (FK to 1000) + + + Table10 Column2 + + + Table10 Column3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/CheckTableIdAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/CheckTableIdAttribute.cs new file mode 100644 index 00000000..38616436 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/CheckTableIdAttribute.cs @@ -0,0 +1,212 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.ExtraTab.Tab.CheckTableIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ExtraTab.Tab.CheckTableIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckTableIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "999"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckTableIdAttribute(); + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckTableIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Tab@tableId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A", "1"); + + string description = "Invalid value 'A' in attribute 'Tab@tableId'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'Tab@tableId' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = @"Attribute 'ExtraTabs/Tab@tableId' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 "); + + string description = "Untrimmed attribute 'Tab@tableId' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckTableIdAttribute(); + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckTableIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckTableIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..35463614 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..6a775998 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..5b9c3159 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..59e7b95f --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..3711cea4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..20a26a2d --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d6b0b9ac --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ExtraTab/Tab/CheckTableIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/CheckHiddenColumnsTag.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/CheckHiddenColumnsTag.cs new file mode 100644 index 00000000..044a9308 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/CheckHiddenColumnsTag.cs @@ -0,0 +1,283 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.HiddenColumns.CheckHiddenColumnsTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.HiddenColumns.CheckHiddenColumnsTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckHiddenColumnsTag(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1002", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A", "1").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "A")), + Error.InvalidValue(null, null, null, "A,B,C", "2").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "A"), + Error.InvalidValueInTag_Sub(null, null, null, "B"), + Error.InvalidValueInTag_Sub(null, null, null, "C")), + Error.InvalidValue(null, null, null, "1001;1002", "3").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "1001;1002")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_IrrelevantColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IrrelevantColumn", + ExpectedResults = new List + { + Error.IrrelevantColumn(null, null, null, "5001", "1"), + Error.IrrelevantColumn(null, null, null, "5002", "1"), + + Error.IrrelevantColumn(null, null, null, "5001", "3"), + Error.IrrelevantColumn(null, null, null, "5002", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_NonExistingIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIds", + ExpectedResults = new List + { + Error.NonExistingIds(null, null, null, "1").WithSubResults( + Error.NonExistingIds_Sub(null, null, null, "1003", "1"), + Error.NonExistingIds_Sub(null, null, null, "2005", "1")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1002 ").WithSubResults( + Error.UntrimmedInTag_Sub(null, null, null, " 1002 ")), + Error.UntrimmedTag(null, null, null, "2", " 1001, 1002 , 2001 ").WithSubResults( + Error.UntrimmedInTag_Sub(null, null, null, " 1001"), + Error.UntrimmedInTag_Sub(null, null, null, " 1002 "), + Error.UntrimmedInTag_Sub(null, null, null, " 2001 ")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckHiddenColumnsTag(); + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "0", "1"); + + string description = "Duplicate value '0' in tag 'HiddenColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'HiddenColumns' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A", "1"); + + string description = "Invalid value 'A' in tag 'HiddenColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_InvalidValueInTag() + { + // Create ErrorMessage + var message = Error.InvalidValueInTag_Sub(null, null, null, "A"); + + string description = "Invalid value 'A' in tag 'HiddenColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_NonExistingIds() + { + // Create ErrorMessage + var message = Error.NonExistingIds(null, null, null, "0"); + + string description = "Tag 'HiddenColumns' references non-existing IDs. TreeControl ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_NonExistingIdsSub() + { + // Create ErrorMessage + var message = Error.NonExistingIds_Sub(null, null, null, "0", "1"); + + string description = "Tag 'HiddenColumns' references a non-existing 'Column' with PID '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_UntrimmedInTag() + { + // Create ErrorMessage + var message = Error.UntrimmedInTag_Sub(null, null, null, " 0 "); + + string description = "Untrimmed value ' 0 ' in tag 'HiddenColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", " 1 "); + + string description = "Untrimmed tag 'HiddenColumns' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckHiddenColumnsTag(); + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckHiddenColumnsTag_CheckId() => Generic.CheckId(check, CheckId.CheckHiddenColumnsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..c32beffb --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,66 @@ + + + + + + 1002 + + + + 1001,1002,2001 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..f41426b7 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,62 @@ + + + + + + 1001,1002,1002 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..e2e7be01 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..cc0b677c --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,33 @@ + + + + + + A + + + + + A,B,C + + + + + + 1001;1002 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml new file mode 100644 index 00000000..4afc5348 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml @@ -0,0 +1,90 @@ + + + + + + + 1001,1002,2001,5001,5002 + + + + + +
+
+ + 1001,1002,2001,5001,5002 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml new file mode 100644 index 00000000..6e148e33 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml @@ -0,0 +1,61 @@ + + + + + + 1001,1003,2005 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..11c1742e --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,66 @@ + + + + + + 1002 + + + + 1001, 1002 , 2001 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..131aef0b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/HiddenColumns/CheckHiddenColumnsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,276 @@ + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + read + + + Table1_Column2 + read + + + Table1_Column3 + read + + + + Table2 + array + + + + + + table + + + + Table2_Instance + read + + + Table2_Column2 + read + + + + + ViewTables_Base1 + array + + + + + + table + + + + ViewTables_Base1_Instance + read + + + ViewTables_Base1_Column2 + read + + + + ViewTables_Base2 + array + + + + + + table + + + + ViewTables_Base2_Instance + read + + + ViewTables_Base2_Column2 + read + + + + ViewTable1 + array + + + + + + + + + + ViewTable2 + array + + + + + + + + ExtraDetails1 + array + + + + + + + table + + + + ExtraDetails1_Instance + read + + + ExtraDetails1_Column2 + read + + + ExtraDetails1_Column3 + read + + + + ExtraDetails2 + array + + + + + + + + table + + + + ExtraDetails2_Instance + read + + + ExtraDetails2_Column2 + read + + + ExtraDetails2_Column3 + read + + + ExtraDetails2_FkTo2000 + read + + + + ExtraTabRelation + array + + + + + + + table + + + + ExtraTabRelation_Instance + read + + + ExtraTabRelation_Column2 + read + + + ExtraTabRelation_Column3 + read + + + + ExtraTabSummary + array + + + + + + + table + + + + ExtraTabSummary_Instance + read + + + ExtraTabSummary_Column2 + read + + + ExtraTabSummary_Column3 + read + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + read + + + IrrelevantTable1_Column2 + read + + + + + + + + 1001,1002,2001,20002,20152 + + + + + + + + +
+
+
+
+ + 1001,1002,2001,20002,20152,30002,30102,31001,31002,31102 + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/CheckPathAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/CheckPathAttribute.cs new file mode 100644 index 00000000..4d1d1cf4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/CheckPathAttribute.cs @@ -0,0 +1,273 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.Hierarchy.CheckPathAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.CheckPathAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckPathAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckPathAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckPathAttribute_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1000", "1"), + Error.DuplicateId(null, null, null, "2000", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A,B,C", "1").WithSubResults( + Error.InvalidValueInAttribute_Sub(null, null, null, "A"), + Error.InvalidValueInAttribute_Sub(null, null, null, "B"), + Error.InvalidValueInAttribute_Sub(null, null, null, "C")), + Error.InvalidValue(null, null, null, "1000;2000", "2").WithSubResults( + Error.InvalidValueInAttribute_Sub(null, null, null, "1000;2000")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_NonExistingIdsInAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdsInAttribute", + ExpectedResults = new List + { + Error.NonExistingIdsInAttribute(null, null, null, "1").WithSubResults( + Error.NonExistingIdsInAttribute_Sub(null, null, null, "99", "1"), + Error.NonExistingIdsInAttribute_Sub(null, null, null, "999", "1")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckPathAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000, 2000 , 3000 ").WithSubResults( + Error.UntrimmedValueInAttribute_Sub(null, null, null, " 1000"), + Error.UntrimmedValueInAttribute_Sub(null, null, null, " 2000 "), + Error.UntrimmedValueInAttribute_Sub(null, null, null, " 3000 ")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckPathAttribute(); + + [TestMethod] + public void TreeControl_CheckPathAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckPathAttribute_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "0", "1"); + + string description = "Duplicate value '0' in attribute 'Hierarchy@path'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Hierarchy@path' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A,B,C", "1"); + + string description = "Invalid value 'A,B,C' in attribute 'Hierarchy@path'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_InvalidValueInAttribute() + { + // Create ErrorMessage + var message = Error.InvalidValueInAttribute_Sub(null, null, null, "A"); + + string description = "Invalid value 'A' in attribute 'Hierarchy@path'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_NonExistingIdsInAttribute() + { + // Create ErrorMessage + var message = Error.NonExistingIdsInAttribute(null, null, null, "0"); + + string description = "Attribute 'Hierarchy@path' references non-existing IDs. TreeControl ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_NonExistingIdsInAttributeSub() + { + // Create ErrorMessage + var message = Error.NonExistingIdsInAttribute_Sub(null, null, null, "0", "1"); + + string description = "Attribute 'Hierarchy@path' references a non-existing 'Table' with PID '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 , 2 "); + + string description = "Untrimmed attribute 'Hierarchy@path' in TreeControl '0'. Current value ' 1 , 2 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckPathAttribute_UntrimmedValueInAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInAttribute_Sub(null, null, null, " 1 "); + + string description = "Untrimmed value ' 1 ' in attribute 'Hierarchy@path'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckPathAttribute(); + + [TestMethod] + public void TreeControl_CheckPathAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckPathAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckPathAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..f0298e89 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..2ea3a7b2 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..6cf42959 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..71d3446e --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdsInAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdsInAttribute.xml new file mode 100644 index 00000000..db7bc2d3 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/NonExistingIdsInAttribute.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..d4d3fcf1 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..f98cce8f --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..6ea2ee3c --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/CheckPathAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,30 @@ + + + + + TreeControl Param + + + + TreeControl Level 1 + array + + true + + + + TreeControl Level 2 + array + + true + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/CheckConditionAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/CheckConditionAttribute.cs new file mode 100644 index 00000000..9921b08a --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/CheckConditionAttribute.cs @@ -0,0 +1,228 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckConditionAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckConditionAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckConditionAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckConditionAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "AAA:BBB", "1").WithSubResults( + Error.InvalidValueInAttribute_Sub(null, null, null, "", "1", "AAA")), + Error.InvalidValue(null, null, null, "1001", "1").WithSubResults( + Error.MissingValueInAttribute_Sub(null, null, null, "", "1")), + Error.InvalidValue(null, null, null, "CCC", "1").WithSubResults( + Error.InvalidValueInAttribute_Sub(null, null, null, "", "1", "CCC"), + Error.MissingValueInAttribute_Sub(null, null, null, "", "1")), + Error.InvalidValue(null, null, null, "filter:fk=", "2").WithSubResults( + Error.MissingValueInAttribute_Sub(null, null, null, "", "2")), + Error.InvalidValue(null, null, null, "filter:fk=AAA", "2").WithSubResults( + Error.InvalidValueInAttribute_Sub(null, null, null, "", "2", "AAA")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1003"), + Error.NonExistingId(null, null, null, "1004"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void TreeControl_CheckConditionAttribute_ReferencedColumnExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedColumnExpectingRTDisplay", + ExpectedResults = new List + { + Error.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "1"), + Error.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "1"), + + Error.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "1"), + Error.ReferencedColumnExpectingRTDisplay(null, null, null, "1002", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_UntrimmedColumnPid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedColumnPid", + ExpectedResults = new List + { + Error.UntrimmedColumnPid(null, null, null, " 1002 ", "1"), + Error.UntrimmedColumnPid(null, null, null, " 1002", "1"), + Error.UntrimmedColumnPid(null, null, null, "1002 ", "1"), + + Error.UntrimmedColumnPid(null, null, null, " 1003 ", "2"), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckConditionAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Table@condition' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "0", "1"); + + string description = "Invalid value '0' in attribute 'Table@condition'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_InvalidValueInAttribute_Sub() + { + // Create ErrorMessage + var message = Error.InvalidValueInAttribute_Sub(null, null, null, "", "1", "A"); + + string description = "Invalid option '' in attribute 'Table@condition'. TreeControl ID '1'. Current Value 'A'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_MissingValueInAttribute_Sub() + { + // Create ErrorMessage + var message = Error.MissingValueInAttribute_Sub(null, null, null, "", "1"); + + string description = "Missing value '' in attribute 'Table@condition'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1005"); + + string description = @"Attribute 'Hierarchy/Table@condition' references a non-existing 'Column' with PID '1005'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckConditionAttribute_UntrimmedColumnPid() + { + // Create ErrorMessage + var message = Error.UntrimmedColumnPid(null, null, null, "0", "1"); + + string description = "Untrimmed value '0' in attribute 'Table@condition' in TreeControl '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionAttribute(); + + [TestMethod] + public void TreeControl_CheckConditionAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckConditionAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckConditionAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..6e82228b --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..05810e76 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + +
+
+
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..ef5f41f8 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml new file mode 100644 index 00000000..b55b4ac8 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/ReferencedColumnExpectingRTDisplay.xml @@ -0,0 +1,54 @@ + + + + + TreeControlParam1 + dummy + + true + + + + + Table1 + array + + + + + + true + + + + Table1_Instance + read + + true + + + + Table1_Column2_Filter + read + + + + + + + +
+
+ + +
+
+ +
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/UntrimmedColumnPid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/UntrimmedColumnPid.xml new file mode 100644 index 00000000..b112dc1c --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Invalid/UntrimmedColumnPid.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + +
+
+
+
+ + + + +
+
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..7df30483 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckConditionAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,54 @@ + + + + + TreeControlParam1 + dummy + + true + + + + + Table1 + array + + + + + + true + + + + Table1_Instance + read + + true + + + + Table1_Column2_Filter + read + + true + + + + + + + +
+
+ + +
+
+ +
+ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..0fe61cd7 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,229 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "99"), + Error.NonExistingId(null, null, null, "999"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay check")] + public void TreeControl_CheckIdAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIdAttribute(); + + [TestMethod] + public void TreeControl_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Table@id' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A", "1"); + + string description = "Invalid value 'A' in attribute 'Table@id'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'Table@id' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = @"Attribute 'Hierarchy/Table@id' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", " 1 "); + + string description = "Untrimmed attribute 'Table@id' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void TreeControl_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..094797a9 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..8a631610 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,21 @@ + + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..faba27ad --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,21 @@ + + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..902215bc --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,21 @@ + + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..6104e288 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..3da73bd9 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,10 @@ + + + + +
+
+ + + +
\ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..204b172a --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..18b062c6 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/CheckParentAttribute.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/CheckParentAttribute.cs new file mode 100644 index 00000000..403f1e37 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/CheckParentAttribute.cs @@ -0,0 +1,237 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckParentAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.Hierarchy.Table.CheckParentAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckParentAttribute(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckParentAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckParentAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_ExcessiveAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveAttribute", + ExpectedResults = new List + { + Error.ExcessiveAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "99"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, "1", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckParentAttribute(); + + [TestMethod] + public void TreeControl_CheckParentAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckParentAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null, "0"); + + string description = "Empty attribute 'Table@parent' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_ExcessiveAttribute() + { + // Create ErrorMessage + var message = Error.ExcessiveAttribute(null, null, null, "0"); + + string description = "Unsupported attribute 'Table@parent' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "0", "1"); + + string description = "Invalid value '0' in attribute 'Table@parent'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null, "0"); + + string description = "Missing attribute 'Table@parent' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "1000"); + + string description = @"Attribute 'Hierarchy/Table@parent' references a non-existing 'Table' with PID '1000'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckParentAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "0", "1"); + + string description = "Untrimmed attribute 'Table@parent' in TreeControl '0'. Current value '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckParentAttribute(); + + [TestMethod] + public void TreeControl_CheckParentAttribute_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckParentAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckParentAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..19429af2 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..635caadb --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml new file mode 100644 index 00000000..41b1b005 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..3ed166a1 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..2465c6f9 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..546bcee4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..0f7bde30 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..18b062c6 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/Hierarchy/Table/CheckParentAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,22 @@ + + + + + +
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/CheckOverrideDisplayColumnsTag.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/CheckOverrideDisplayColumnsTag.cs new file mode 100644 index 00000000..dfca117c --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/CheckOverrideDisplayColumnsTag.cs @@ -0,0 +1,322 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.OverrideDisplayColumns.CheckOverrideDisplayColumnsTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.OverrideDisplayColumns.CheckOverrideDisplayColumnsTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOverrideDisplayColumnsTag(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1002", "1"), + Error.DuplicateId(null, null, null, "2002", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_DuplicateOverrideDisplayColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateOverrideDisplayColumn", + ExpectedResults = new List + { + Error.DuplicateOverrideDisplayColumn(null, null, null, "1000", "1").WithSubResults( + Error.DuplicateOverrideDisplayColumns_Sub(null, null, null, "1002"), + Error.DuplicateOverrideDisplayColumns_Sub(null, null, null, "1003")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A|C,B", "1").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "A"), + Error.InvalidValueInTag_Sub(null, null, null, "C"), + Error.InvalidValueInTag_Sub(null, null, null, "B")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_IrrelevantColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IrrelevantColumn", + ExpectedResults = new List + { + Error.IrrelevantColumn(null, null, null, "5002", "1"), + + Error.IrrelevantColumn(null, null, null, "5002", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_NonExistingIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIds", + ExpectedResults = new List + { + Error.NonExistingIds(null, null, null, "1").WithSubResults( + Error.NonExistingIds_Sub(null, null, null, "1004", "1"), + Error.NonExistingIds_Sub(null, null, null, "1005", "1"), + Error.NonExistingIds_Sub(null, null, null, "2003", "1")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1002 | 1003 ,2002 ").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, " 1002 "), + Error.UntrimmedValueInTag_Sub(null, null, null, " 1003 "), + Error.UntrimmedValueInTag_Sub(null, null, null, "2002 ")), + Error.UntrimmedTag(null, null, null, "2", "1002 | 1003 ,2002").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, "1002 "), + Error.UntrimmedValueInTag_Sub(null, null, null, " 1003 ")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckOverrideDisplayColumnsTag(); + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "1001", "1"); + + string description = "Duplicate value '1001' in tag 'OverrideDisplayColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_DuplicateOverrideDisplayColumn() + { + // Create ErrorMessage + var message = Error.DuplicateOverrideDisplayColumn(null, null, null, "0", "1"); + + string description = "Duplicate OverrideDisplayColumns IDs for Table '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_DuplicateOverrideDisplayColumn_Subs() + { + // Create ErrorMessage + var message = Error.DuplicateOverrideDisplayColumns_Sub(null, null, null, "0"); + + string description = "Duplicate OverrideDisplayColumns ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'OverrideDisplayColumns' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A|B,C", "1"); + + string description = "Invalid value 'A|B,C' in tag 'OverrideDisplayColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_InvalidValueInTag() + { + // Create ErrorMessage + var message = Error.InvalidValueInTag_Sub(null, null, null, "A"); + + string description = "Invalid value 'A' in tag 'OverrideDisplayColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_NonExistingIds() + { + // Create ErrorMessage + var message = Error.NonExistingIds(null, null, null, "0"); + + string description = "Tag 'OverrideDisplayColumns' references non-existing IDs. TreeControl ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_NonExistingIdsSub() + { + // Create ErrorMessage + var message = Error.NonExistingIds_Sub(null, null, null, "0", "1"); + + string description = "Tag 'OverrideDisplayColumns' references a non-existing 'Column' with PID '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", " 1 |2, 3 "); + + string description = "Untrimmed tag 'OverrideDisplayColumns' in TreeControl '0'. Current value ' 1 |2, 3 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_UntrimmedValueInTag() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInTag_Sub(null, null, null, " 1 "); + + string description = "Untrimmed value ' 1 ' in tag 'OverrideDisplayColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOverrideDisplayColumnsTag(); + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckOverrideDisplayColumnsTag_CheckId() => Generic.CheckId(check, CheckId.CheckOverrideDisplayColumnsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..41187207 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,53 @@ + + + + + +
+
+ + 1002|1003,2002 + + + +
+
+ + 1002|1003,2002 + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..159b9152 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,2002,2002,1002 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateOverrideDisplayColumn.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateOverrideDisplayColumn.xml new file mode 100644 index 00000000..a25cd0a4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/DuplicateOverrideDisplayColumn.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,1003,2002 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..563db114 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..fd160efc --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + A|C,B + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml new file mode 100644 index 00000000..f048badd --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml @@ -0,0 +1,89 @@ + + + + + + + 1002|1003,2002,5002 + + + + + +
+
+ + 1002|1003,2002,5002 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml new file mode 100644 index 00000000..1980b2f5 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1004|1005,2003 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..dc3a5ffb --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,53 @@ + + + + + +
+
+ + 1002 | 1003 ,2002 + + + +
+
+ + 1002 | 1003 ,2002 + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..86879a2f --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideDisplayColumns/CheckOverrideDisplayColumnsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,151 @@ + + + + + + + 1002|1003,2002,20002,20152 + + + + + + + + +
+
+
+
+ + 1002|1003,2002,20002,20152 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + + ViewTables_Base1 + array + + + + + + table + + + + ViewTables_Base1_Instance + + + ViewTables_Base1_Column2 + + + + ViewTables_Base2 + array + + + + + + table + + + + ViewTables_Base2_Instance + + + ViewTables_Base2_Column2 + + + + ViewTable1 + array + + + + + + + + + + ViewTable2 + array + + + + + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/CheckOverrideIconColumnsTag.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/CheckOverrideIconColumnsTag.cs new file mode 100644 index 00000000..4a0f6f90 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/CheckOverrideIconColumnsTag.cs @@ -0,0 +1,318 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.OverrideIconColumns.CheckOverrideIconColumnsTag +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.OverrideIconColumns.CheckOverrideIconColumnsTag; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + using SLDisValidator2.Common.Extensions; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckOverrideIconColumnsTag(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1002", "1"), + Error.DuplicateId(null, null, null, "2002", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_DuplicateOverrideIconColumns() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateOverrideIconColumns", + ExpectedResults = new List + { + Error.DuplicateOverrideIconColumns(null, null, null, "1000", "1").WithSubResults( + Error.DuplicateOverrideIconColumns_Sub(null, null, null, "1002"), + Error.DuplicateOverrideIconColumns_Sub(null, null, null, "1003")), + Error.DuplicateOverrideIconColumns(null, null, null, "2000", "1").WithSubResults( + Error.DuplicateOverrideIconColumns_Sub(null, null, null, "2002"), + Error.DuplicateOverrideIconColumns_Sub(null, null, null, "2003")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A,B", "1").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "A"), + Error.InvalidValueInTag_Sub(null, null, null, "B")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_IrrelevantColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IrrelevantColumn", + ExpectedResults = new List + { + Error.IrrelevantColumn(null, null, null, "5002", "1"), + + Error.IrrelevantColumn(null, null, null, "5002", "3") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_NonExistingIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIds", + ExpectedResults = new List + { + Error.NonExistingIds(null, null, null, "1").WithSubResults( + Error.NonExistingIds_Sub(null, null, null, "1099", "1"), + Error.NonExistingIds_Sub(null, null, null, "2099", "1")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1002, 2002 ").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, " 1002"), + Error.UntrimmedValueInTag_Sub(null, null, null, " 2002 ")), + Error.UntrimmedTag(null, null, null, "2", "1002, 2002").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, " 2002")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckOverrideIconColumnsTag(); + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "0", "1"); + + string description = "Duplicate value '0' in tag 'OverrideIconColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_DuplicateOverrideIconColumns() + { + // Create ErrorMessage + var message = Error.DuplicateOverrideIconColumns(null, null, null, "0", "1"); + + string description = "Duplicate OverrideIconColumns IDs for Table '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_DuplicateOverrideIconColumns_Subs() + { + // Create ErrorMessage + var message = Error.DuplicateOverrideIconColumns_Sub(null, null, null, "0"); + + string description = "Duplicate OverrideIconColumns ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'OverrideIconColumns' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A,B", "1"); + + string description = "Invalid value 'A,B' in tag 'OverrideIconColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_InvalidValueInTag() + { + // Create ErrorMessage + var message = Error.InvalidValueInTag_Sub(null, null, null, "A"); + + string description = "Invalid value 'A' in tag 'OverrideIconColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_NonExistingIds() + { + // Create ErrorMessage + var message = Error.NonExistingIds(null, null, null, "0"); + + string description = "Tag 'OverrideIconColumns' references non-existing IDs. TreeControl ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_NonExistingIdsSub() + { + // Create ErrorMessage + var message = Error.NonExistingIds_Sub(null, null, null, "0", "1"); + + string description = "Tag 'OverrideIconColumns' references a non-existing 'Column' with PID '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", " 1 "); + + string description = "Untrimmed tag 'OverrideIconColumns' in TreeControl '0'. Current value ' 1 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_UntrimmedValueInTag() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInTag_Sub(null, null, null, " 0 "); + + string description = "Untrimmed value ' 0 ' in tag 'OverrideIconColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckOverrideIconColumnsTag(); + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckOverrideIconColumnsTag_CheckId() => Generic.CheckId(check, CheckId.CheckOverrideIconColumnsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..56fd8839 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,69 @@ + + + + + +
+
+ + 1002,2002 + + + +
+
+ + 1002,2002 + + + + + + TreeControl1_Param + + + TreeControl2_Param + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..875b0a1d --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,2002,2002,1002 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateOverrideIconColumns.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateOverrideIconColumns.xml new file mode 100644 index 00000000..52e91421 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/DuplicateOverrideIconColumns.xml @@ -0,0 +1,47 @@ + + + + + +
+
+ + 1002,2003,1003,2002 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + + table + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..04f8aa88 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..d538dae5 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,40 @@ + + + + +
+
+ + A,B + + + + + + array + + + + + + + table + + + + + + + array + + + + + + table + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml new file mode 100644 index 00000000..4dc182ba --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml @@ -0,0 +1,90 @@ + + + + + + + 1002,2002,5002 + + + + + +
+
+ + 1002,2002,5002 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml new file mode 100644 index 00000000..d29cb7f4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,1099,2099 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..e0c497ea --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,69 @@ + + + + + +
+
+ + 1002, 2002 + + + +
+
+ + 1002, 2002 + + + + + + TreeControl1_Param + + + TreeControl2_Param + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..36726c34 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/OverrideIconColumns/CheckOverrideIconColumnsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,152 @@ + + + + + + + 1001,2001,20002,20152 + + + + + + + + +
+
+
+
+ + 1001,2001,20002,20152 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + + ViewTables_Base1 + array + + + + + + table + + + + ViewTables_Base1_Instance + + + ViewTables_Base1_Column2 + + + + ViewTables_Base2 + array + + + + + + table + + + + ViewTables_Base2_Instance + + + ViewTables_Base2_Column2 + + + + ViewTable1 + array + + + + + + + + + + ViewTable2 + array + + + + + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/CheckReadonlyColumnsTag.cs b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/CheckReadonlyColumnsTag.cs new file mode 100644 index 00000000..dc521b46 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/CheckReadonlyColumnsTag.cs @@ -0,0 +1,278 @@ +namespace SLDisValidatorUnitTests.Protocol.TreeControls.TreeControl.ReadonlyColumns.CheckReadonlyColumnsTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.TreeControls.TreeControl.ReadonlyColumns.CheckReadonlyColumnsTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckReadonlyColumnsTag(); + + #region Valid Checks + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_DuplicateId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateId", + ExpectedResults = new List + { + Error.DuplicateId(null, null, null, "1002", "1"), + Error.DuplicateId(null, null, null, "2002", "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "1"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "A,B", "1").WithSubResults( + Error.InvalidValueInTag_Sub(null, null, null, "A"), + Error.InvalidValueInTag_Sub(null, null, null, "B")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_IrrelevantColumn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "IrrelevantColumn", + ExpectedResults = new List + { + Error.IrrelevantColumn(null, null, null, "5001", "1"), + Error.IrrelevantColumn(null, null, null, "5002", "1"), + + Error.IrrelevantColumn(null, null, null, "5001", "3"), + Error.IrrelevantColumn(null, null, null, "5002", "3"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_NonExistingIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIds", + ExpectedResults = new List + { + Error.NonExistingIds(null, null, null, "1").WithSubResults( + Error.NonExistingIds_Sub(null, null, null, "1099", "1"), + Error.NonExistingIds_Sub(null, null, null, "2099", "1")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "1", " 1002, 2002 ").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, " 1002"), + Error.UntrimmedValueInTag_Sub(null, null, null, " 2002 ")), + Error.UntrimmedTag(null, null, null, "2", "1002, 2002").WithSubResults( + Error.UntrimmedValueInTag_Sub(null, null, null, " 2002")) + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckReadonlyColumnsTag(); + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_DuplicateId() + { + // Create ErrorMessage + var message = Error.DuplicateId(null, null, null, "0", "1"); + + string description = "Duplicate value '0' in tag 'ReadonlyColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "0"); + + string description = "Empty tag 'ReadonlyColumns' in TreeControl '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "A,B", "1"); + + string description = "Invalid value 'A,B' in tag 'ReadonlyColumns'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_InvalidValueInTag() + { + // Create ErrorMessage + var message = Error.InvalidValueInTag_Sub(null, null, null, "A"); + + string description = "Invalid value 'A' in tag 'ReadonlyColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_NonExistingIds() + { + // Create ErrorMessage + var message = Error.NonExistingIds(null, null, null, "0"); + + string description = "Tag 'ReadonlyColumns' references non-existing IDs. TreeControl ID '0'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_NonExistingIdsSub() + { + // Create ErrorMessage + var message = Error.NonExistingIds_Sub(null, null, null, "0", "1"); + + string description = "Tag 'ReadonlyColumns' references a non-existing 'Column' with PID '0'. TreeControl ID '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "0", " 1 , 2 "); + + string description = "Untrimmed tag 'ReadonlyColumns' in TreeControl '0'. Current value ' 1 , 2 '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_UntrimmedValueInTag() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInTag_Sub(null, null, null, " 1 "); + + string description = "Untrimmed value ' 1 ' in tag 'ReadonlyColumns'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckReadonlyColumnsTag(); + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_CheckCategory() => Generic.CheckCategory(check, Category.TreeControl); + + [TestMethod] + public void TreeControl_CheckReadonlyColumnsTag_CheckId() => Generic.CheckId(check, CheckId.CheckReadonlyColumnsTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..9a22a5d2 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,53 @@ + + + + + +
+
+ + 1002,2002 + + + +
+
+ + 1002,2002 + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/DuplicateId.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/DuplicateId.xml new file mode 100644 index 00000000..0cfa1cb8 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/DuplicateId.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,2002,2002,1002 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..d1a0be4d --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..c746c9c8 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + A,B + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml new file mode 100644 index 00000000..6321c234 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/IrrelevantColumn.xml @@ -0,0 +1,90 @@ + + + + + + + 1001,1002,2001,5001,5002 + + + + + +
+
+ + 1001,1002,2001,5001,5002 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml new file mode 100644 index 00000000..0c0a50ac --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/NonExistingIds.xml @@ -0,0 +1,45 @@ + + + + + +
+
+ + 1002,1099,2002,2099 + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..058616f4 --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,53 @@ + + + + + +
+
+ + 1002, 2002 + + + +
+
+ + 1002, 2002 + + + + + + + + + array + + + + + + + table + + + + + + + + array + + + + + + table + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..e414c2bc --- /dev/null +++ b/ProtocolTests/Protocol/TreeControls/TreeControl/ReadonlyColumns/CheckReadonlyColumnsTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,152 @@ + + + + + + + 1002,2002,20002,20152 + + + + + + + + +
+
+
+
+ + 1002,2002,20002,20152 + + + + + + TreeControl_Param_1 + + + TreeControl_Param_2 + + + TreeControl_Param_3 + + + + Table1 + array + + + + + + + table + + + + Table1_Instance + + + Table1_Column2 + + + Table1_Column2 + + + + Table2 + array + + + + + + table + + + + Table2_Instance + + + Table2_Column2 + + + + + ViewTables_Base1 + array + + + + + + table + + + + ViewTables_Base1_Instance + + + ViewTables_Base1_Column2 + + + + ViewTables_Base2 + array + + + + + + table + + + + ViewTables_Base2_Instance + + + ViewTables_Base2_Column2 + + + + ViewTable1 + array + + + + + + + + + + ViewTable2 + array + + + + + + + + IrrelevantTable1 + array + + + + + + table + + + + IrrelevantTable1_Instance + + + IrrelevantTable1_Column2 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/CheckAfterStartupFlow.cs b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/CheckAfterStartupFlow.cs new file mode 100644 index 00000000..35198f04 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/CheckAfterStartupFlow.cs @@ -0,0 +1,186 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.CheckAfterStartupFlow +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.CheckAfterStartupFlow; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckAfterStartupFlow(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_ValidExecute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidExecute", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_ValidExecuteOneNow() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidExecuteOneNow", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_ValidExecuteOneTop() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidExecuteOneTop", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupTriggerCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupTriggerCondition", + ExpectedResults = new List + { + Error.InvalidAfterStartupTriggerCondition(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupActionCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupActionCondition", + ExpectedResults = new List + { + Error.InvalidAfterStartupActionCondition(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupTriggerType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupTriggerType", + ExpectedResults = new List + { + Error.InvalidAfterStartupTriggerType(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupActionOn() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupActionOn", + ExpectedResults = new List + { + Error.InvalidAfterStartupActionOn(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupActionType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupActionType", + ExpectedResults = new List + { + Error.InvalidAfterStartupActionType(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_InvalidAfterStartupGroupType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidAfterStartupGroupType", + ExpectedResults = new List + { + Error.InvalidAfterStartupGroupType(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckAfterStartupFlow(); + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_CheckCategory() => Generic.CheckCategory(root, Category.Trigger); + + [TestMethod] + public void Trigger_CheckAfterStartupFlow_CheckId() => Generic.CheckId(root, CheckId.CheckAfterStartupFlow); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionCondition.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionCondition.xml new file mode 100644 index 00000000..1199edc7 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionCondition.xml @@ -0,0 +1,27 @@ + + + + After Startup + After Startup + + + + + After Startup + protocol + + action + + 1 + + + + + + After Startup Group + id:1 == 1 + group + execute next + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionOn.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionOn.xml new file mode 100644 index 00000000..09394f6c --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionOn.xml @@ -0,0 +1,23 @@ + + + + + + + After Startup + protocol + + action + + 1 + + + + + + After Startup Group + parameter + run actions + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionType.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionType.xml new file mode 100644 index 00000000..06458888 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupActionType.xml @@ -0,0 +1,30 @@ + + + + + After Startup + After Startup + + + + + + After Startup + protocol + + action + + 1 + + + + + + + After Startup Group + group + make + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupGroupType.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupGroupType.xml new file mode 100644 index 00000000..64ac253a --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupGroupType.xml @@ -0,0 +1,27 @@ + + + + After Startup + After Startup + action + + + + + After Startup + protocol + + action + + 1 + + + + + + After Startup Group + group + execute next + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerCondition.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerCondition.xml new file mode 100644 index 00000000..c0ea1353 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerCondition.xml @@ -0,0 +1,10 @@ + + + + After Startup + protocol + + id:1 == 1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerType.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerType.xml new file mode 100644 index 00000000..edcdb8f2 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Invalid/InvalidAfterStartupTriggerType.xml @@ -0,0 +1,9 @@ + + + + After Startup + protocol + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..038dcb20 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,30 @@ + + + + + After Startup + After Startup + + + + + + After Startup + protocol + + action + + 1 + + + + + + + After Startup Group + group + execute next + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecute.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecute.xml new file mode 100644 index 00000000..b6a3b3c0 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecute.xml @@ -0,0 +1,30 @@ + + + + + After Startup + After Startup + + + + + + After Startup + protocol + + action + + 1 + + + + + + + After Startup Group + group + execute + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneNow.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneNow.xml new file mode 100644 index 00000000..84c82cda --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneNow.xml @@ -0,0 +1,29 @@ + + + + + After Startup + After Startup + + + + + + After Startup + protocol + + action + + 1 + + + + + + After Startup Group + group + execute one now + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneTop.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneTop.xml new file mode 100644 index 00000000..4b4a3296 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckAfterStartupFlow/Samples/Validate/Valid/ValidExecuteOneTop.xml @@ -0,0 +1,29 @@ + + + + + After Startup + After Startup + + + + + + After Startup + protocol + + action + + 1 + + + + + + After Startup Group + group + execute one top + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..898126d7 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,309 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.CheckIdAttribute +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckIdAttribute_DuplicatedId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedId", + ExpectedResults = new List + { + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1, Duplicate_101_2").WithSubResults( + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_1"), + Error.DuplicatedId(null, null, null, "101", "Duplicate_101_2")), + + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1, Duplicate_102_2, Duplicate_102_3").WithSubResults( + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_1"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_2"), + Error.DuplicatedId(null, null, null, "102", "Duplicate_102_3")) + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "String"), + + Error.InvalidValue(null, null, null, "-2", "Number_Negative"), + Error.InvalidValue(null, null, null, "1.5", "Number_Double_1"), + Error.InvalidValue(null, null, null, "2,6", "Number_Double_2"), + Error.InvalidValue(null, null, null, "03", "Number_LeadingZero"), + Error.InvalidValue(null, null, null, "+4", "Number_LeadingPlusSign"), + Error.InvalidValue(null, null, null, "5x10^1", "Number_ScientificNotation"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 101"), + Error.UntrimmedAttribute(null, null, null, "102 "), + Error.UntrimmedAttribute(null, null, null, " 103 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdAttribute(); + + [TestMethod] + public void Trigger_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Trigger_CheckIdAttribute_DuplicatedId() + { + // Create ErrorMessage + var message = Error.DuplicatedId(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "5.8.5", + Category = Category.Trigger, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "More than one Trigger with same ID '2'. Trigger Names '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each trigger." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each trigger should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "5.8.2", + Category = Category.Trigger, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Empty attribute 'Trigger@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each trigger." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each trigger should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "AAA", "MyName"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "5.8.4", + Category = Category.Trigger, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Invalid value 'AAA' in attribute 'Trigger@id'. Trigger name 'MyName'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each trigger." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each trigger should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_MissingAttribute() + { + // Create ErrorMessage + var message = Error.MissingAttribute(null, null, null); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "5.8.1", + Category = Category.Trigger, + Severity = Severity.Critical, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.Breaking, + GroupDescription = "", + Description = "Missing attribute 'Trigger@id'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each trigger." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each trigger should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "5.8.3", + Category = Category.Trigger, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed attribute 'Trigger@id'. Current value '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The id attribute is used internally as the identifier for each trigger." + Environment.NewLine + "It is therefore mandatory and needs to follow a number of rules:" + Environment.NewLine + "- Each trigger should have a unique id." + Environment.NewLine + "- Should be an unsigned integer." + Environment.NewLine + "- Only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdAttribute(); + + [TestMethod] + public void Trigger_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(check, Category.Trigger); + + [TestMethod] + public void Trigger_CheckIdAttribute_CheckId() => Generic.CheckId(check, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..49dd4481 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml new file mode 100644 index 00000000..d4cfa3f6 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/DuplicatedId.xml @@ -0,0 +1,22 @@ + + + + + Duplicate_101_1 + + + Duplicate_101_2 + + + + Duplicate_102_1 + + + Duplicate_102_2 + + + Duplicate_102_3 + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..70c528e5 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,12 @@ + + + + + Empty + + + Spaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..c789b8a9 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,28 @@ + + + + + String + + + + Number_Negative + + + Number_Double_1 + + + Number_Double_2 + + + Number_LeadingZero + + + Number_LeadingPlusSign + + + Number_ScientificNotation + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..9809b1f2 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,9 @@ + + + + + Missing + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..89f8eaff --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,15 @@ + + + + + LeadingSpaces + + + TrailingSpaces + + + LeadingAndTrailingSpaces + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..cb9b4ab2 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/CheckOnTagTimeTagCombination.cs b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/CheckOnTagTimeTagCombination.cs new file mode 100644 index 00000000..041dc418 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/CheckOnTagTimeTagCombination.cs @@ -0,0 +1,126 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.CheckOnTagTimeTagCombination +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.CheckOnTagTimeTagCombination; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOnTagTimeTagCombination(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_ValidAllCombination() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidAllCombination", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_ValidNoDuplicate() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "ValidNoDuplicate", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_InvalidOnTagTimeTagCombination() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidOnTagTimeTagCombination", + ExpectedResults = new List + { + Error.InvalidOnTagTimeTagCombination(null, null, null, "parameter", "before", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_DuplicateTrigger() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicateTrigger", + ExpectedResults = new List + { + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "1, 2").WithSubResults( + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "1"), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "2")), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "10, 11").WithSubResults( + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "10"), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "11")), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "20, 21").WithSubResults( + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "20"), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "21")), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "100, 101, 102").WithSubResults( + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "100"), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "101"), + Error.DuplicateTrigger(null, null, null, Certainty.Certain, "102")), + Error.DuplicateTrigger(null, null, null, Certainty.Uncertain, "200, 201, 202").WithSubResults( + Error.DuplicateTrigger(null, null, null, Certainty.Uncertain, "200"), + Error.DuplicateTrigger(null, null, null, Certainty.Uncertain, "201"), + Error.DuplicateTrigger(null, null, null, Certainty.Uncertain, "202")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOnTagTimeTagCombination(); + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_CheckCategory() => Generic.CheckCategory(root, Category.Trigger); + + [TestMethod] + public void Trigger_CheckOnTagTimeTagCombination_CheckId() => Generic.CheckId(root, CheckId.CheckOnTagTimeTagCombination); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/DuplicateTrigger.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/DuplicateTrigger.xml new file mode 100644 index 00000000..c90d6d61 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/DuplicateTrigger.xml @@ -0,0 +1,65 @@ + + + + + parameter + + + + parameter + + + + + protocol + + + + protocol + + + + + response + + + + response + + + + + + parameter + + id=100 == 1 + + + parameter + + + + parameter + + id=100 == 3 + + + + + + parameter + + id=100 == 1 + + + parameter + + id=100 == 2 + + + parameter + + id=100 == 3 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/InvalidOnTagTimeTagCombination.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/InvalidOnTagTimeTagCombination.xml new file mode 100644 index 00000000..39008d5a --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Invalid/InvalidOnTagTimeTagCombination.xml @@ -0,0 +1,9 @@ + + + + + parameter + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..48e64117 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,9 @@ + + + + Parameter Change + parameter + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidAllCombination.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidAllCombination.xml new file mode 100644 index 00000000..49de76f4 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidAllCombination.xml @@ -0,0 +1,110 @@ + + + + + + Parameter Change + parameter + + + + Parameter Change After Response + parameter + + + + Parameter Timeout + parameter + + + + Parameter Timeout After Retries + parameter + + + + + + Command Before + command + + + + Command After + command + + + + + + Response Before + response + + + + Response After + response + + + + + + Pair Succeeded + pair + + + + Pair Timeout + pair + + + + Pair Timeout After Retries + pair + + + + + + Group Before + group + + + + Group After + group + + + + + + Session Timeout + session + + + + + + Timer Before + timer + + + + + + Protocol After Startup + protocol + + + + Protocol Link File Change + protocol + + + + + + CheckTrigger + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidNoDuplicate.xml b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidNoDuplicate.xml new file mode 100644 index 00000000..44d1aab6 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/CheckOnTagTimeTagCombination/Samples/Validate/Valid/ValidNoDuplicate.xml @@ -0,0 +1,190 @@ + + + + + + Parameter Change + parameter + + + + Parameter 2 Change + parameter + + + + Parameter 3 Change + parameter + + + + + + Command Before + command + + + + Command After + command + + + + Command 1 Before + command + + + + Command 1 After + command + + + + Command 2 Before + command + + + + Command 2 After + command + + + + + + Response Before + response + + + + Response After + response + + + + Response 1 Before + response + + + + Response 1 After + response + + + + Response 2 Before + response + + + + Response 2 After + response + + + + + + Pair Succeeded + pair + + + + Pair Timeout + pair + + + + Pair Timeout After Retries + pair + + + + Pair 1 Succeeded + pair + + + + Pair 1 Timeout + pair + + + + Pair 1 Timeout After Retries + pair + + + + + + Group Before + group + + + + Group After + group + + + + Group 1 Before + group + + + + Group 1 After + group + + + + + + Session Timeout + session + + + + Session 1 Timeout + session + + + + Session 2 Timeout + session + + + + + + Timer Before + timer + + + + Timer 1 Before + timer + + + + Timer 2 Before + timer + + + + + + Protocol After Startup + protocol + + + + Protocol Link File Change + protocol + + + + + + CheckTrigger + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/CheckConditionTag.cs b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/CheckConditionTag.cs new file mode 100644 index 00000000..15c73a58 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/CheckConditionTag.cs @@ -0,0 +1,161 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.Condition.CheckConditionTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.Condition.CheckConditionTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckConditionTag(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckConditionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckConditionTag_InvalidCondition() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidCondition", + ExpectedResults = new List + { + Error.InvalidCondition(null, null, null, "", "Condition is empty.", "1"), + Error.InvalidCondition(null, null, null, "((id:12 + \"efg\") + 10) == \"defefgabc\"", "The addition operator ('+') must be used with operands of the same type.", "2") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckConditionTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "10", "1") + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Trigger_CheckConditionTag_ConditionCanBeSimplified() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ConditionCanBeSimplified", + ExpectedResults = new List + { + Error.ConditionCanBeSimplified(null, null, null, "id:12 == (\"test\")", "1") + } + }; + + Generic.Validate(check, data); + } + #endregion + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Trigger_CheckConditionTag_InvalidCondition() + { + // Create ErrorMessage + var message = Error.InvalidCondition(null, null, null, "currentCondition", "reason", "100"); + + var expected = new ValidationResult + { + ErrorId = 1, + FullId = "5.5.1", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid condition 'currentCondition'. Reason 'reason'. Trigger ID '100'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Trigger/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckConditionTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3"); + + var expected = new ValidationResult + { + ErrorId = 2, + FullId = "5.5.2", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Trigger/Condition' references a non-existing 'Param' with PID '2'. Trigger ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "A 'Trigger/Condition' should always contain a statement returning a boolean." + Environment.NewLine + "See DDL for more information." + Environment.NewLine + "" + Environment.NewLine + "Here are a few examples of mistakes covered by this error:" + Environment.NewLine + "- Empty condition." + Environment.NewLine + "- Malformed condition:" + Environment.NewLine + " - The 'id:' placeholder used to retrieve a parameter value is incorrectly defined." + Environment.NewLine + " - The number of opening & closing parenthesis is not matching." + Environment.NewLine + " - '&&', '||' is used instead of 'AND', 'OR'." + Environment.NewLine + "- Condition that is not a boolean expression." + Environment.NewLine + "- Fully hard-coded boolean expression (No reference to any parameter value)." + Environment.NewLine + "- etc.", + HasCodeFix = false + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckConditionTag(); + + [TestMethod] + public void Trigger_CheckConditionTag_CheckCategory() => Generic.CheckCategory(check, Category.Trigger); + + [TestMethod] + public void Trigger_CheckConditionTag_CheckId() => Generic.CheckId(check, CheckId.CheckConditionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml new file mode 100644 index 00000000..f3645119 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/ConditionCanBeSimplified.xml @@ -0,0 +1,14 @@ + + + + + string + + + + + + id:12 == ("test") + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml new file mode 100644 index 00000000..9087001c --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/InvalidCondition.xml @@ -0,0 +1,18 @@ + + + + + + string + + + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..4c28d0ef --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,8 @@ + + + + + 20]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..dc223b21 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Condition/CheckConditionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,20 @@ + + + + + + double + + + + + string + + + + + + id:12) AND ((id:10 * 20) > 100)]]> + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/CheckIdTag.cs b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/CheckIdTag.cs new file mode 100644 index 00000000..9273211f --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/CheckIdTag.cs @@ -0,0 +1,341 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.Content.Id.CheckIdTag +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.Content.Id.CheckIdTag; + + [TestClass] + public class Validate + { + private readonly IValidate check = new CheckIdTag(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckIdTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(check, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Pair_CheckResponseTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null, "100"), + Error.EmptyTag(null, null, null, "101"), + Error.EmptyTag(null, null, null, "101"), + + Error.EmptyTag(null, null, null, "1000"), + Error.EmptyTag(null, null, null, "1001"), + Error.EmptyTag(null, null, null, "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "aaa", "100"), + + Error.InvalidValue(null, null, null, "-2", "1000"), + Error.InvalidValue(null, null, null, "1.5", "1000"), + Error.InvalidValue(null, null, null, "2,6", "1000"), + + Error.InvalidValue(null, null, null, "03", "1001"), + Error.InvalidValue(null, null, null, "+4", "1001"), + Error.InvalidValue(null, null, null, "5x10^1", "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null, "100"), + Error.MissingTag(null, null, null, "101"), + Error.MissingTag(null, null, null, "102"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "Trigger", "9", "100"), + Error.NonExistingId(null, null, null, "Trigger", "99", "101"), + Error.NonExistingId(null, null, null, "Trigger", "999", "101"), + + Error.NonExistingId(null, null, null, "Action", "8", "1000"), + Error.NonExistingId(null, null, null, "Action", "88", "1001"), + Error.NonExistingId(null, null, null, "Action", "888", "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_NonExistingIdNoActions() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingIdNoActions", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "Trigger", "9", "100"), + Error.NonExistingId(null, null, null, "Trigger", "99", "101"), + Error.NonExistingId(null, null, null, "Trigger", "999", "101"), + + Error.NonExistingId(null, null, null, "Action", "8", "1000"), + Error.NonExistingId(null, null, null, "Action", "88", "1001"), + Error.NonExistingId(null, null, null, "Action", "888", "1001"), + } + }; + + Generic.Validate(check, data); + } + + [TestMethod] + public void Pair_CheckResponseTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, "100", " 1000"), + Error.UntrimmedTag(null, null, null, "100", "1001 "), + Error.UntrimmedTag(null, null, null, "101", " 1000 "), + + Error.UntrimmedTag(null, null, null, "1000", " 1000"), + Error.UntrimmedTag(null, null, null, "1000", "1001 "), + Error.UntrimmedTag(null, null, null, "1001", " 1000 "), + } + }; + + Generic.Validate(check, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix check = new CheckIdTag(); + + [TestMethod] + public void Trigger_CheckIdTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(check, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Trigger_CheckIdTag_EmptyTag() + { + // Create ErrorMessage + var message = Error.EmptyTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 2, + FullId = "5.10.2", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Empty tag 'Content/Id' in Trigger '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every Trigger should contain at least one Id tag." + Environment.NewLine + "Such Id tag should contain an unsigned number and refer to the id of an existing Trigger or Action depending on the 'Trigger/Type' tag value." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdTag_InvalidValue() + { + // Create ErrorMessage + var message = Error.InvalidValue(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 4, + FullId = "5.10.4", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Invalid value '2' in tag 'Content/Id'. Trigger ID '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every Trigger should contain at least one Id tag." + Environment.NewLine + "Such Id tag should contain an unsigned number and refer to the id of an existing Trigger or Action depending on the 'Trigger/Type' tag value." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdTag_MissingTag() + { + // Create ErrorMessage + var message = Error.MissingTag(null, null, null, "2"); + + var expected = new ValidationResult() + { + ErrorId = 1, + FullId = "5.10.1", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Missing tag 'Content/Id' in Trigger '2'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every Trigger should contain at least one Id tag." + Environment.NewLine + "Such Id tag should contain an unsigned number and refer to the id of an existing Trigger or Action depending on the 'Trigger/Type' tag value." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdTag_NonExistingId() + { + // Create ErrorMessage + var message = Error.NonExistingId(null, null, null, "2", "3", "4"); + + var expected = new ValidationResult() + { + ErrorId = 5, + FullId = "5.10.5", + Category = Category.Trigger, + Severity = Severity.Major, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Tag 'Content/Id' references a non-existing '2' with ID '3'. Trigger ID '4'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every Trigger should contain at least one Id tag." + Environment.NewLine + "Such Id tag should contain an unsigned number and refer to the id of an existing Trigger or Action depending on the 'Trigger/Type' tag value." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = false, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + + [TestMethod] + public void Trigger_CheckIdTag_UntrimmedTag() + { + // Create ErrorMessage + var message = Error.UntrimmedTag(null, null, null, "2", "3"); + + var expected = new ValidationResult() + { + ErrorId = 3, + FullId = "5.10.3", + Category = Category.Trigger, + Severity = Severity.Warning, + Certainty = Certainty.Certain, + Source = Source.Validator, + FixImpact = FixImpact.NonBreaking, + GroupDescription = "", + Description = "Untrimmed tag 'Content/Id' in Trigger '2'. Current value '3'.", + HowToFix = "", + ExampleCode = "", + Details = "The Content tag of every Trigger should contain at least one Id tag." + Environment.NewLine + "Such Id tag should contain an unsigned number and refer to the id of an existing Trigger or Action depending on the 'Trigger/Type' tag value." + Environment.NewLine + "" + Environment.NewLine + "Note that only plain numbers are allowed (no leading signs, no leading zeros, no scientific notation, etc).", + HasCodeFix = true, + }; + + // Assert + message.Should().BeEquivalentTo(expected, Generic.ExcludePropertiesForErrorMessages); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot check = new CheckIdTag(); + + [TestMethod] + public void Trigger_CheckIdTag_CheckCategory() => Generic.CheckCategory(check, Category.Trigger); + + [TestMethod] + public void Trigger_CheckIdTag_CheckId() => Generic.CheckId(check, CheckId.CheckIdTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..7c241f51 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,44 @@ + + + + + + Trigger_LeadingOrTrailing + trigger + + 1000 + 1001 + + + + Trigger_LeadingAndTrailing + trigger + + 1000 + + + + + + Action_LeadingOrTrailing + action + + 1000 + 1001 + + + + Action_LeadingAndTrailing + action + + 1000 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..3430eedf --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,39 @@ + + + + + + Trigger_Empty + trigger + + + + + + Trigger_EmptyAndSpaces + trigger + + + + + + + + + Action_Empty + action + + + + + + Action_EmptyAndSpaces + action + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..beb4767f --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,31 @@ + + + + + + String + + aaa + + + + + + Number_NonUint + + -2 + 1.5 + 2,6 + + + + Number_Format + + 03 + +4 + 5x10^1 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..e262fdb6 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,20 @@ + + + + + ContentMissing + + + ContentEmpty + + + + + Typo + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..b33ee399 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,44 @@ + + + + + + Trigger_1_ID + trigger + + 9 + + + + Trigger_2_IDs + trigger + + 99 + 999 + + + + + + Action_1_ID + action + + 8 + + + + Action_2_IDs + action + + 88 + 888 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingIdNoActions.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingIdNoActions.xml new file mode 100644 index 00000000..dc7006dd --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/NonExistingIdNoActions.xml @@ -0,0 +1,39 @@ + + + + + + Trigger_1_ID + trigger + + 9 + + + + Trigger_2_IDs + trigger + + 99 + 999 + + + + + + Action_1_ID + action + + 8 + + + + Action_2_IDs + action + + 88 + 888 + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..234072f7 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,44 @@ + + + + + + Trigger_LeadingOrTrailing + trigger + + 1000 + 1001 + + + + Trigger_LeadingAndTrailing + trigger + + 1000 + + + + + + Action_LeadingOrTrailing + action + + 1000 + 1001 + + + + Action_LeadingAndTrailing + action + + 1000 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..0e4f1f70 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Content/Id/CheckIdTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,44 @@ + + + + + + Trigger_1_ID + trigger + + 1000 + + + + Trigger_2_IDs + trigger + + 1000 + 1001 + + + + + + Action_1_ID + action + + 1000 + + + + Action_2_IDs + action + + 1000 + 1001 + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/CheckNameTag.cs b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/CheckNameTag.cs new file mode 100644 index 00000000..2bda3e19 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/CheckNameTag.cs @@ -0,0 +1,70 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.Name.CheckNameTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.Name.CheckNameTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckNameTag(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckNameTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckNameTag_DuplicatedValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "DuplicatedValue", + ExpectedResults = new List + { + Error.DuplicatedValue(null, null, null, "Name1", "1, 2").WithSubResults( + Error.DuplicatedValue(null, null, null, "Name1", "1"), + Error.DuplicatedValue(null, null, null, "Name1", "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckNameTag(); + + [TestMethod] + public void Trigger_CheckNameTag_CheckCategory() => Generic.CheckCategory(root, Category.Trigger); + + [TestMethod] + public void Trigger_CheckNameTag_CheckId() => Generic.CheckId(root, CheckId.CheckNameTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml new file mode 100644 index 00000000..e71de5b2 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Invalid/DuplicatedValue.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name1 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..b4979389 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Name/CheckNameTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,10 @@ + + + + Name1 + + + Name2 + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/CheckIdAttribute.cs b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/CheckIdAttribute.cs new file mode 100644 index 00000000..323f21ba --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/CheckIdAttribute.cs @@ -0,0 +1,229 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.On.CheckIdAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.On.CheckIdAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckIdAttribute(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckIdAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckIdAttribute_MissingAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingAttribute", + ExpectedResults = new List + { + Error.MissingAttribute(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_ExcessiveAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ExcessiveAttribute", + ExpectedResults = new List + { + Error.ExcessiveAttribute(null, null, null, "protocol", "1"), + Error.ExcessiveAttribute(null, null, null, "communication", "2"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_MultipleIds() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MultipleIds", + ExpectedResults = new List + { + Error.MultipleIds(null, null, null, "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "a", "each, {uint}"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "command", "1", "11"), + Error.NonExistingId(null, null, null, "command", "each", "12"), + + Error.NonExistingId(null, null, null, "group", "1", "31"), + Error.NonExistingId(null, null, null, "group", "each", "32"), + + Error.NonExistingId(null, null, null, "pair", "1", "41"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_LeadingZeros() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "LeadingZeros", + ExpectedResults = new List + { + Error.LeadingZeros(null, null, null, "1", "01"), + Error.LeadingZeros(null, null, null, "2", "002"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " 1"), + Error.UntrimmedAttribute(null, null, null, "2 "), + Error.UntrimmedAttribute(null, null, null, " 3 "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckIdAttribute(); + + [TestMethod] + public void Trigger_CheckIdAttribute_ExcessiveAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "ExcessiveAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_LeadingZeros() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "LeadingZeros", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Trigger_CheckIdAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckIdAttribute(); + + [TestMethod] + public void Trigger_CheckIdAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Trigger); + + [TestMethod] + public void Trigger_CheckIdAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckIdAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/ExcessiveAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/ExcessiveAttribute.xml new file mode 100644 index 00000000..811b5c4a --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/ExcessiveAttribute.xml @@ -0,0 +1,10 @@ + + + + protocol + + + communication + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/LeadingZeros.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/LeadingZeros.xml new file mode 100644 index 00000000..7a4efa64 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/LeadingZeros.xml @@ -0,0 +1,14 @@ + + + + + + + + parameter + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..ecfadb77 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + + + + + parameter + + + parameter + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..4328fc0d --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,10 @@ + + + + parameter + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml new file mode 100644 index 00000000..8089a894 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/ExcessiveAttribute.xml @@ -0,0 +1,10 @@ + + + + protocol + + + communication + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..f4cde46e --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,7 @@ + + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/LeadingZeros.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/LeadingZeros.xml new file mode 100644 index 00000000..471b91b4 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/LeadingZeros.xml @@ -0,0 +1,14 @@ + + + + + + + + parameter + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml new file mode 100644 index 00000000..8b9d41d1 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MissingAttribute.xml @@ -0,0 +1,7 @@ + + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MultipleIds.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MultipleIds.xml new file mode 100644 index 00000000..11b615a2 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/MultipleIds.xml @@ -0,0 +1,11 @@ + + + + + + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..0ec6307b --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + Command 1 + command + + + Command each + command + + + + + Group 1 + group + + + Group each + group + + + + + Pair 1 + pair + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..94cbe86d --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,18 @@ + + + + + + + + + parameter + + + parameter + + + parameter + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..71150358 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/On/CheckIdAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Command 1 + command + + + Command each + command + + + + Communication + communication + + + + Group 1 + group + + + Group each + group + + + + Pair 1 + pair + + + Pair each + pair + + + + Parameter 1 + parameter + + + Parameter each + parameter + + + Parameter 65008 - DM Internal param + + parameter + + + + Protocol + protocol + + + + Response 1 + response + + + Response each + response + + + + Session 1 + session + + + Session each + session + + + + Timer 1 + timer + + + Timer each + timer + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/CheckTimeTag.cs b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/CheckTimeTag.cs new file mode 100644 index 00000000..a3d0cbf0 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/CheckTimeTag.cs @@ -0,0 +1,141 @@ +namespace SLDisValidatorUnitTests.Protocol.Triggers.Trigger.Time.CheckTimeTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Triggers.Trigger.Time.CheckTimeTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckTimeTag(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckTimeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckTimeTag_MultipleAfterStartup() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MultipleAfterStartup", + ExpectedResults = new List + { + Error.MultipleAfterStartup(null, null, null, "1, 2").WithSubResults( + Error.MultipleAfterStartup(null, null, null, "1"), + Error.MultipleAfterStartup(null, null, null, "2")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + ////[TestClass] + ////public class CodeFix + ////{ + //// private readonly ICodeFix codeFix = new CheckTimeTag(); + + //// [TestMethod] + //// public void Param_CheckTimeTag_EmptyTag() + //// { + //// Generic.FixData data = new Generic.FixData + //// { + //// FileNameBase = "EmptyTag", + //// }; + + //// Generic.Fix(codeFix, data); + //// } + + //// [TestMethod] + //// public void Param_CheckTimeTag_UntrimmedTag() + //// { + //// Generic.FixData data = new Generic.FixData + //// { + //// FileNameBase = "UntrimmedTag", + //// }; + + //// Generic.Fix(codeFix, data); + //// } + ////} + + ////[TestClass] + ////public class Compare + ////{ + //// private readonly ICompare compare = new CheckTimeTag(); + + //// #region Valid Checks + + //// [TestMethod] + //// public void Protocol_CheckTimeTag_Valid() + //// { + //// Generic.CompareData data = new Generic.CompareData + //// { + //// TestType = Generic.TestType.Valid, + //// FileNameBase = "Valid", + //// ExpectedResults = new List() + //// }; + + //// Generic.Compare(compare, data); + //// } + + //// #endregion Valid Checks + + //// #region Invalid Checks + + //// [TestMethod] + //// public void Protocol_CheckTimeTag_XXX() + //// { + //// Generic.CompareData data = new Generic.CompareData + //// { + //// TestType = Generic.TestType.Invalid, + //// FileNameBase = "XXX", + //// ExpectedResults = new List + //// { + //// ErrorCompare.XXX(null, null, "MotherChildASlot", "100", "Mother - ChildASlot"), + //// } + //// }; + + //// Generic.Compare(compare, data); + //// } + + //// #endregion Invalid Checks + ////} + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTimeTag(); + + [TestMethod] + public void Trigger_CheckTimeTag_CheckCategory() => Generic.CheckCategory(root, Category.Trigger); + + [TestMethod] + public void Trigger_CheckTimeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTimeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Invalid/MultipleAfterStartup.xml b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Invalid/MultipleAfterStartup.xml new file mode 100644 index 00000000..356f4319 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Invalid/MultipleAfterStartup.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..08dd92b7 --- /dev/null +++ b/ProtocolTests/Protocol/Triggers/Trigger/Time/CheckTimeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/CheckAdvancedAttribute.cs b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/CheckAdvancedAttribute.cs new file mode 100644 index 00000000..8a0e8ca7 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/CheckAdvancedAttribute.cs @@ -0,0 +1,221 @@ +namespace SLDisValidatorUnitTests.Protocol.Type.CheckAdvancedAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Common.Extensions; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Type.CheckAdvancedAttribute; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckAdvancedAttribute(); + + #region Valid + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_Valid_1Advanced() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_1Advanced", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_Valid_2Advanced() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_2Advanced", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_Valid_NoAdvanced() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_NoAdvanced", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UnknownConnection() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UnknownConnection", + ExpectedResults = new List + { + Error.UnknownConnection(null, null, null, "AAA", "1"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " snmp; serial ").WithSubResults( + Error.UntrimmedValueInAttribute_Sub(null, null, null, " snmp"), + Error.UntrimmedValueInAttribute_Sub(null, null, null, " serial ")) + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly IRoot codeFix = new CheckAdvancedAttribute(); + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class ErrorMessages + { + [TestMethod] + public void Protocol_CheckAdvancedAttribute_EmptyAttribute() + { + // Create ErrorMessage + var message = Error.EmptyAttribute(null, null, null); + + string description = "Empty attribute 'Protocol/Type@advanced'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UntrimmedAttribute() + { + // Create ErrorMessage + var message = Error.UntrimmedAttribute(null, null, null, " snmp;serial "); + + string description = "Untrimmed attribute 'Protocol/Type@advanced'. Current value ' snmp;serial '."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UntrimmedAttribute_Sub() + { + // Create ErrorMessage + var message = Error.UntrimmedValueInAttribute_Sub(null, null, null, " snmp "); + + string description = "Untrimmed value ' snmp ' in attribute 'Protocol/Type@advanced'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_UnknownConnection() + { + // Create ErrorMessage + var message = Error.UnknownConnection(null, null, null, "test", "1"); + + string description = "Unknown connection type 'test' in Connection '1'."; + + // Assert + Assert.AreEqual(description, message.Description); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckAdvancedAttribute(); + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckAdvancedAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckAdvancedAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..188f27d5 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..e42f9da4 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..c187ce5c --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UnknownConnection.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UnknownConnection.xml new file mode 100644 index 00000000..95c6e141 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UnknownConnection.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..93f37509 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..4ca2c54d --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + virtual + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_1Advanced.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_1Advanced.xml new file mode 100644 index 00000000..646feb01 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_1Advanced.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_2Advanced.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_2Advanced.xml new file mode 100644 index 00000000..8b95a7b5 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_2Advanced.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_NoAdvanced.xml b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_NoAdvanced.xml new file mode 100644 index 00000000..188f27d5 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckAdvancedAttribute/Samples/Validate/Valid/Valid_NoAdvanced.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/CheckDatabaseOptionsAttribute.cs b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/CheckDatabaseOptionsAttribute.cs new file mode 100644 index 00000000..fcfd90fa --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/CheckDatabaseOptionsAttribute.cs @@ -0,0 +1,67 @@ +namespace SLDisValidatorUnitTests.Protocol.Type.CheckDatabaseOptionsAttribute +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Type.CheckDatabaseOptionsAttribute; + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckDatabaseOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckDatabaseOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckDatabaseOptionsAttribute_EnabledPartitionedTrending() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "EnabledPartitionedTrending", + ExpectedResults = new List + { + ErrorCompare.EnabledPartitionedTrending(null, null), + } + }; + + Generic.Compare(compare, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckDatabaseOptionsAttribute(); + + [TestMethod] + public void Protocol_CheckDatabaseOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckDatabaseOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckDatabaseOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_New.xml b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_New.xml new file mode 100644 index 00000000..8f9e9088 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_New.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_Old.xml b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_Old.xml new file mode 100644 index 00000000..e301cee2 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Invalid/EnabledPartitionedTrending_Old.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..a83c482d --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..8f9e9088 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckDatabaseOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs new file mode 100644 index 00000000..64f269e5 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/CheckOptionsAttribute.cs @@ -0,0 +1,393 @@ +namespace SLDisValidatorUnitTests.Protocol.Type.CheckOptionsAttribute +{ + using System.Collections.Generic; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Type.CheckOptionsAttribute; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Trigger_CheckOptionsAttribute_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Trigger_CheckOptionsAttribute_EmptyAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyAttribute", + ExpectedResults = new List + { + Error.EmptyAttribute(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOptionsAttribute_NonExistingId() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "NonExistingId", + ExpectedResults = new List + { + Error.NonExistingId(null, null, null, "1000"), + Error.NonExistingId(null, null, null, "2000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + [Ignore("Covered by RTDisplay unit test")] + public void Trigger_CheckOptionsAttribute_ReferencedParamExpectingRTDisplay() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamExpectingRTDisplay", + ExpectedResults = new List + { + Error.ReferencedParamExpectingRTDisplay(null, null, null, "1000"), + Error.ReferencedParamExpectingRTDisplay(null, null, null, "2000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOptionsAttribute_ReferencedParamWrongType() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "ReferencedParamWrongType", + ExpectedResults = new List + { + Error.ReferencedParamWrongType(null, null, null, "read", "1000"), + Error.ReferencedParamWrongType(null, null, null, "bus", "2000"), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Trigger_CheckOptionsAttribute_UntrimmedAttribute() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedAttribute", + ExpectedResults = new List + { + Error.UntrimmedAttribute(null, null, null, " unicode;disableViewRefresh;exportProtocol:DVE Parent - Child 1:1000:noElementPrefix;exportProtocol:DVE Parent - Child 2:2000 "), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckOptionsAttribute(); + + [TestMethod] + public void Param_CheckOptionsAttribute_EmptyAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyAttribute", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Param_CheckOptionsAttribute_UntrimmedAttribute() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedAttribute", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Compare + { + private readonly ICompare compare = new CheckOptionsAttribute(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckOptionsAttribute_Valid() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "Valid", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_ValidUnicode() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidUnicode", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_ValidNoUnicode() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Valid, + FileNameBase = "ValidNoUnicode", + ExpectedResults = new List() + }; + + Generic.Compare(compare, data); + } + + #endregion Valid Checks + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckOptionsAttribute_UpdatedDveExportProtocolName() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedDveExportProtocolName", + ExpectedResults = new List + { + ErrorCompare.UpdatedDveExportProtocolName(null, null, "MotherChildASlot", "100", "Mother - ChildASlot"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_UpdatedDveExportProtocolNameOneDve() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedDveExportProtocolNameOneDve", + ExpectedResults = new List + { + ErrorCompare.UpdatedDveExportProtocolName(null, null, "Mother ChildA - Slot", "100", "Mother DifferentChild - Slot"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_UpdatedDveExportProtocolNameMultiDve() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedDveExportProtocolNameMultiDve", + ExpectedResults = new List + { + ErrorCompare.UpdatedDveExportProtocolName(null, null, "Mother ChildA - Slot", "100", "Mother ChildA Slot"), + ErrorCompare.UpdatedDveExportProtocolName(null, null, "Mother ChildA OldName", "150", "Mother ChildA - NewName"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_UpdatedDveExportProtocolNameElementPrefixDve() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "UpdatedDveExportProtocolNameElementPrefixDve", + ExpectedResults = new List + { + ErrorCompare.UpdatedDveExportProtocolName(null, null, "MotherChildAOldName", "150", "MotherChildA - OldName"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_RemovedDveExportProtocolName() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedDveExportProtocolName", + ExpectedResults = new List + { + ErrorCompare.RemovedDveExportProtocolName(null, null, "MotherChildASlot", "100"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_RemovedDveExportProtocolNameFullPropertyRemoval() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedDveExportProtocolNameFullPropertyRemoval", + ExpectedResults = new List + { + ErrorCompare.RemovedDveExportProtocolName(null, null, "MotherChildASlot", "100"), + ErrorCompare.RemovedDveExportProtocolName(null, null, "MotherChildAOldName", "150"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_RemovedDveExportProtocolNameFullPropertyEmpty() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedDveExportProtocolNameFullPropertyEmpty", + ExpectedResults = new List + { + ErrorCompare.RemovedDveExportProtocolName(null, null, "MotherChildASlot", "100"), + ErrorCompare.RemovedDveExportProtocolName(null, null, "MotherChildAOldName", "150"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_AddedNoElementPrefix() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedNoElementPrefix", + ExpectedResults = new List + { + ErrorCompare.AddedNoElementPrefix(null, null, "MotherChildASlot", "100"), + ErrorCompare.AddedNoElementPrefix(null, null, "MotherChildAOldName", "150"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_RemovedNoElementPrefix() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedNoElementPrefix", + ExpectedResults = new List + { + ErrorCompare.RemovedNoElementPrefix(null, null, "MotherChildAOldName", "150"), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_AddedUnicode() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "AddedUnicode", + ExpectedResults = new List + { + ErrorCompare.AddedUnicode(null, null), + } + }; + + Generic.Compare(compare, data); + } + + [TestMethod] + public void Protocol_CheckOptionsAttribute_RemovedUnicode() + { + Generic.CompareData data = new Generic.CompareData + { + TestType = Generic.TestType.Invalid, + FileNameBase = "RemovedUnicode", + ExpectedResults = new List + { + ErrorCompare.RemovedUnicode(null, null), + } + }; + + Generic.Compare(compare, data); + } + + #endregion Invalid Checks + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckOptionsAttribute(); + + [TestMethod] + public void Protocol_CheckOptionsAttribute_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckOptionsAttribute_CheckId() => Generic.CheckId(root, CheckId.CheckOptionsAttribute); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml new file mode 100644 index 00000000..dc6b4dc8 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/EmptyAttribute.xml @@ -0,0 +1,5 @@ + + + virtual + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml new file mode 100644 index 00000000..f96df6ed --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Codefix/UntrimmedAttribute.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + true + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + true + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_New.xml new file mode 100644 index 00000000..b969ed73 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_Old.xml new file mode 100644 index 00000000..5b3c7e0b --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedNoElementPrefix_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_New.xml new file mode 100644 index 00000000..ae992ff4 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_New.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_Old.xml new file mode 100644 index 00000000..e301cee2 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/AddedUnicode_Old.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_New.xml new file mode 100644 index 00000000..5bfc9c20 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_Old.xml new file mode 100644 index 00000000..67e65d91 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyEmpty_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_New.xml new file mode 100644 index 00000000..78a05a69 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_Old.xml new file mode 100644 index 00000000..67e65d91 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolNameFullPropertyRemoval_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_New.xml new file mode 100644 index 00000000..d6ff09c0 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_Old.xml new file mode 100644 index 00000000..67e65d91 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedDveExportProtocolName_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_New.xml new file mode 100644 index 00000000..5b3c7e0b --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_Old.xml new file mode 100644 index 00000000..67e65d91 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedNoElementPrefix_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_New.xml new file mode 100644 index 00000000..93690394 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_New.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_Old.xml new file mode 100644 index 00000000..ae992ff4 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/RemovedUnicode_Old.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_New.xml new file mode 100644 index 00000000..9871c430 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_Old.xml new file mode 100644 index 00000000..67e65d91 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameElementPrefixDve_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_New.xml new file mode 100644 index 00000000..4e06506e --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_Old.xml new file mode 100644 index 00000000..17e40602 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameMultiDve_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_New.xml new file mode 100644 index 00000000..c4bd6a7f --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_Old.xml new file mode 100644 index 00000000..e795e41c --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolNameOneDve_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_New.xml new file mode 100644 index 00000000..54cde9cc --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_Old.xml new file mode 100644 index 00000000..ae2a4144 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Invalid/UpdatedDveExportProtocolName_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_New.xml new file mode 100644 index 00000000..ee569621 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_Old.xml new file mode 100644 index 00000000..5bfc9c20 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidNoUnicode_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_New.xml new file mode 100644 index 00000000..f768b436 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_Old.xml new file mode 100644 index 00000000..76ff0181 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/ValidUnicode_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml new file mode 100644 index 00000000..5e7fc46a --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_New.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml new file mode 100644 index 00000000..2688e7ca --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Compare/Valid/Valid_Old.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml new file mode 100644 index 00000000..c3f2bb43 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/EmptyAttribute.xml @@ -0,0 +1,5 @@ + + + virtual + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml new file mode 100644 index 00000000..bbd73cd4 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/NonExistingId.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml new file mode 100644 index 00000000..b7cfc93a --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamExpectingRTDisplay.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + false + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml new file mode 100644 index 00000000..ead24bf3 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/ReferencedParamWrongType.xml @@ -0,0 +1,23 @@ + + DVE Parent + virtual + + + + Read_1000 + read + + true + + + + + Bus_2000 + bus + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml new file mode 100644 index 00000000..52a74104 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Invalid/UntrimmedAttribute.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + true + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + true + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..fc0a1941 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckOptionsAttribute/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,59 @@ + + DVE Parent + virtual + + + + DVE_Child1 + array + + + + + + true + + + + DVE_Child1_Instance + read + + true + + + + DVE_Child1_Element + read + + true + + + + + DVE_Child2 + array + + + + + + true + + + + DVE_Child2_Instance + read + + true + + + + DVE_Child2_Element + read + + true + + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/CheckTypeTag.cs b/ProtocolTests/Protocol/Type/CheckTypeTag/CheckTypeTag.cs new file mode 100644 index 00000000..d401fadc --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/CheckTypeTag.cs @@ -0,0 +1,281 @@ +namespace SLDisValidatorUnitTests.Protocol.Type.CheckTypeTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Type.CheckTypeTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckTypeTag(); + + #region Valid Checks + + [TestMethod] + public void Protocol_CheckTypeTag_gpib() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "gpib", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_http() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "http", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_opc() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "opc", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_serial() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "serial", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_serialSingle() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "serialSingle", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_service() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "service", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_sla() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "sla", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_smartSerial() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "smartSerial", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_smartSerialSingle() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "smartSerialSingle", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_snmp() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "snmp", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_snmpv2() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "snmpv2", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_snmpv3() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "snmpv3", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_Valid_OtherSyntax() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid_OtherSyntax", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_virtual() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "virtual", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + #endregion + + #region Invalid Checks + + [TestMethod] + public void Protocol_CheckTypeTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckTypeTag_InvalidValue() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "InvalidValue", + ExpectedResults = new List + { + Error.InvalidValue(null, null, null, "abc", "gpib, http, opc, serial, serial single, service, sla, smart-serial, smart-serial single, snmp, snmpv2, snmpv3, virtual"), + } + }; + + Generic.Validate(test, data); + } + + #endregion + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckTypeTag(); + + [TestMethod] + public void Protocol_CheckTypeTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckTypeTag_CheckId() => Generic.CheckId(root, CheckId.CheckTypeTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..a83c482d --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml new file mode 100644 index 00000000..772a585b --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/InvalidValue.xml @@ -0,0 +1,3 @@ + + abc + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..d2dfa124 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + virtual + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid_OtherSyntax.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid_OtherSyntax.xml new file mode 100644 index 00000000..7fcfd9d7 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/Valid_OtherSyntax.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/gpib.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/gpib.xml new file mode 100644 index 00000000..04ffc9c4 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/gpib.xml @@ -0,0 +1,3 @@ + + gpib + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/http.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/http.xml new file mode 100644 index 00000000..991aff02 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/http.xml @@ -0,0 +1,3 @@ + + http + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/opc.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/opc.xml new file mode 100644 index 00000000..c9a62051 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/opc.xml @@ -0,0 +1,3 @@ + + opc + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serial.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serial.xml new file mode 100644 index 00000000..7604369c --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serial.xml @@ -0,0 +1,3 @@ + + serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serialSingle.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serialSingle.xml new file mode 100644 index 00000000..44fd6d0a --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/serialSingle.xml @@ -0,0 +1,3 @@ + + serial single + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/service.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/service.xml new file mode 100644 index 00000000..2ca985fe --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/service.xml @@ -0,0 +1,3 @@ + + service + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/sla.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/sla.xml new file mode 100644 index 00000000..38958920 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/sla.xml @@ -0,0 +1,3 @@ + + sla + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerial.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerial.xml new file mode 100644 index 00000000..2644d1dd --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerial.xml @@ -0,0 +1,3 @@ + + smart-serial + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerialSingle.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerialSingle.xml new file mode 100644 index 00000000..20355cd8 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/smartSerialSingle.xml @@ -0,0 +1,3 @@ + + smart-serial single + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmp.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmp.xml new file mode 100644 index 00000000..78a05a69 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmp.xml @@ -0,0 +1,3 @@ + + snmp + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv2.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv2.xml new file mode 100644 index 00000000..57f75528 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv2.xml @@ -0,0 +1,3 @@ + + snmpv2 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv3.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv3.xml new file mode 100644 index 00000000..03be2134 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/snmpv3.xml @@ -0,0 +1,3 @@ + + snmpv3 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/virtual.xml b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/virtual.xml new file mode 100644 index 00000000..d2dfa124 --- /dev/null +++ b/ProtocolTests/Protocol/Type/CheckTypeTag/Samples/Validate/Valid/virtual.xml @@ -0,0 +1,3 @@ + + virtual + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/CheckVersionTag.cs b/ProtocolTests/Protocol/Version/CheckVersionTag/CheckVersionTag.cs new file mode 100644 index 00000000..ff4a9ded --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/CheckVersionTag.cs @@ -0,0 +1,130 @@ +namespace SLDisValidatorUnitTests.Protocol.Version.CheckVersionTag +{ + using System.Collections.Generic; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisValidator2.Interfaces; + using SLDisValidator2.Tests.Protocol.Version.CheckVersionTag; + + [TestClass] + public class Validate + { + private readonly IValidate test = new CheckVersionTag(); + + [TestMethod] + public void Protocol_CheckVersionTag_Valid() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Valid, + FileName = "Valid", + ExpectedResults = new List() + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckVersionTag_MissingTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "MissingTag", + ExpectedResults = new List + { + Error.MissingTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckVersionTag_EmptyTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "EmptyTag", + ExpectedResults = new List + { + Error.EmptyTag(null, null, null), + } + }; + + Generic.Validate(test, data); + } + + [TestMethod] + public void Protocol_CheckVersionTag_UntrimmedTag() + { + Generic.ValidateData data = new Generic.ValidateData + { + TestType = Generic.TestType.Invalid, + FileName = "UntrimmedTag", + ExpectedResults = new List + { + Error.UntrimmedTag(null, null, null, " 1.0.0.1 "), + } + }; + + Generic.Validate(test, data); + } + } + + [TestClass] + public class CodeFix + { + private readonly ICodeFix codeFix = new CheckVersionTag(); + + [TestMethod] + public void Protocol_CheckVersionTag_MissingTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "MissingTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckVersionTag_EmptyTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "EmptyTag", + }; + + Generic.Fix(codeFix, data); + } + + [TestMethod] + public void Protocol_CheckVersionTag_UntrimmedTag() + { + Generic.FixData data = new Generic.FixData + { + FileNameBase = "UntrimmedTag", + }; + + Generic.Fix(codeFix, data); + } + } + + [TestClass] + public class Attribute + { + private readonly IRoot root = new CheckVersionTag(); + + [TestMethod] + public void Protocol_CheckVersionTag_CheckCategory() => Generic.CheckCategory(root, Category.Protocol); + + [TestMethod] + public void Protocol_CheckVersionTag_CheckId() => Generic.CheckId(root, CheckId.CheckVersionTag); + } +} \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/EmptyTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/EmptyTag.xml new file mode 100644 index 00000000..1a82e7e0 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/EmptyTag.xml @@ -0,0 +1,3 @@ + + X.X.X.X + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/MissingTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/MissingTag.xml new file mode 100644 index 00000000..1a82e7e0 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/MissingTag.xml @@ -0,0 +1,3 @@ + + X.X.X.X + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/UntrimmedTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/UntrimmedTag.xml new file mode 100644 index 00000000..3feb2a00 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Codefix/UntrimmedTag.xml @@ -0,0 +1,3 @@ + + 1.0.0.1 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/EmptyTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/EmptyTag.xml new file mode 100644 index 00000000..dc1d7a59 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/EmptyTag.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/MissingTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/MissingTag.xml new file mode 100644 index 00000000..b1d1cdb0 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/MissingTag.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml new file mode 100644 index 00000000..5add4644 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Invalid/UntrimmedTag.xml @@ -0,0 +1,3 @@ + + 1.0.0.1 + \ No newline at end of file diff --git a/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Valid/Valid.xml b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Valid/Valid.xml new file mode 100644 index 00000000..3feb2a00 --- /dev/null +++ b/ProtocolTests/Protocol/Version/CheckVersionTag/Samples/Validate/Valid/Valid.xml @@ -0,0 +1,3 @@ + + 1.0.0.1 + \ No newline at end of file diff --git a/ProtocolTests/ProtocolTests.csproj b/ProtocolTests/ProtocolTests.csproj new file mode 100644 index 00000000..307791cc --- /dev/null +++ b/ProtocolTests/ProtocolTests.csproj @@ -0,0 +1,44 @@ + + + + net472;net6.0 + disable + disable + + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProtocolTests/ValidatorTests.cs b/ProtocolTests/ValidatorTests.cs new file mode 100644 index 00000000..4df2f31f --- /dev/null +++ b/ProtocolTests/ValidatorTests.cs @@ -0,0 +1,238 @@ +namespace SLDisValidatorUnitTests +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + + using FluentAssertions; + + using Microsoft.VisualStudio.TestTools.UnitTesting; + + using Skyline.DataMiner.CICD.Models.Protocol; + using Skyline.DataMiner.CICD.Models.Protocol.Read; + using Skyline.DataMiner.CICD.Parsers.Common.Xml; + using Skyline.DataMiner.CICD.Validators.Common.Data; + using Skyline.DataMiner.CICD.Validators.Common.Interfaces; + using Skyline.DataMiner.CICD.Validators.Common.Model; + + using SLDisUnitTestsShared; + + using SLDisValidator2; + using SLDisValidator2.Common; + + [TestClass] + public class ValidatorTests + { + #region Old Run Validate + + [TestMethod] + public void RunValidate_Old_MultipleResults() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + + QActionCompilationModel semanticModel = null; // not needed for old validator + ProtocolInputData input = new ProtocolInputData(protocolCode, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings(), new CancellationToken()); + + results.Should().NotBeEmpty(); + } + + [TestMethod] + public void RunValidate_Old_MultipleResults2() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + + var list = new List<(Category Category, uint CheckId)>(); + + QActionCompilationModel semanticModel = null; // not needed for old validator + ProtocolInputData input = new ProtocolInputData(protocolCode, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings().WithTestToExecute(list), new CancellationToken()); + + results.Should().NotBeEmpty(); + } + + [TestMethod] + public void RunValidate_Old_NoResults() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + + var list = new List<(Category Category, uint CheckId)>() + { + // Shouldn't give an error message + (Category.Undefined, 0), + }; + + QActionCompilationModel semanticModel = null; // not needed for old validator + ProtocolInputData input = new ProtocolInputData(protocolCode, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings().WithTestToExecute(list), new CancellationToken()); + + results.Should().BeEmpty(); + } + + #endregion + + #region New Run Validate + + [TestMethod] + public void RunValidate_New_MultipleResults() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + var parser = new Parser(protocolCode); + var model = new ProtocolModel(parser.Document); + + var semanticModel = ProtocolTestsHelper.GetQActionCompilationModel(model, protocolCode); + + var input = new ProtocolInputData(model, parser.Document, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings(), new CancellationToken()); + + results.Should().NotBeEmpty(); + } + + [TestMethod] + public void RunValidate_New_MultipleResults2() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + var parser = new Parser(protocolCode); + var model = new ProtocolModel(parser.Document); + + var list = new List<(Category Category, uint CheckId)>(); + + var semanticModel = ProtocolTestsHelper.GetQActionCompilationModel(model, protocolCode); + + var input = new ProtocolInputData(model, parser.Document, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings().WithTestToExecute(list), new CancellationToken()); + + results.Should().NotBeEmpty(); + } + + [TestMethod] + public void RunValidate_New_NoResults() + { + var validator = new Validator(); + + var protocolCode = String.Empty; + var parser = new Parser(protocolCode); + var model = new ProtocolModel(parser.Document); + + var list = new List<(Category Category, uint CheckId)>() + { + // Shouldn't give an error message + (Category.Undefined, 0), + }; + + var semanticModel = ProtocolTestsHelper.GetQActionCompilationModel(model, protocolCode); + + var input = new ProtocolInputData(model, parser.Document, semanticModel); + var results = validator.RunValidate(input, new ValidatorSettings().WithTestToExecute(list), new CancellationToken()); + + results.Should().BeEmpty(); + } + + #endregion + + #region Old Run Compare + + // Currently not possible due to issues in Compare methods (Doesn't take in account an empty protocol or empty file) + + #endregion + + #region New Run Compare + + // Currently not possible due to issues in Compare methods (Doesn't take in account an empty protocol or empty file) + + #endregion + + #region Execute CodeFix + + // Not really testable yet. + + #endregion + + #region Group Results + + [TestMethod] + public void GroupResults_NoGenericDescription() + { + List input = new List(); + List expectedOutput = new List(); + for (int i = 0; i < 20; i++) + { + var result = new ValidationResult() + { + GroupDescription = "", + }; + + input.Add(result); + expectedOutput.Add(result); + } + + List output = Validator.GroupResults(input).ToList(); + + output.Should().BeEquivalentTo(expectedOutput); + } + + [TestMethod] + public void GroupResults_TooFewToGroup() + { + List input = new List(); + List expectedOutput = new List(); + for (int i = 0; i < 9; i++) + { + var result = new ValidationResult() + { + GroupDescription = "myGroupDescription", + }; + + input.Add(result); + expectedOutput.Add(result); + } + + List output = Validator.GroupResults(input).ToList(); + + output.Should().BeEquivalentTo(expectedOutput); + } + + [TestMethod] + public void GroupResults_EnoughToGroup() + { + List input = new List(); + List expectedChildren = new List(); + for (int i = 0; i < 11; i++) + { + var result = new ValidationResult() + { + GroupDescription = "myGroupDescription", + }; + + input.Add(result); + expectedChildren.Add(result); + } + + List expectedOutput = new List() + { + new ValidationResult() + { + Description = "myGroupDescription", + SubResults = expectedChildren, + }, + }; + + List output = Validator.GroupResults(input).ToList(); + + output.Should().BeEquivalentTo(expectedOutput); + } + + #endregion + } +} \ No newline at end of file diff --git a/ProtocolTests/ValidatorUnitTestProtocols.g.xsd b/ProtocolTests/ValidatorUnitTestProtocols.g.xsd new file mode 100644 index 00000000..e4dd825f --- /dev/null +++ b/ProtocolTests/ValidatorUnitTestProtocols.g.xsd @@ -0,0 +1,1202 @@ +DataMiner Protocol XML Schema.The root element of a DataMiner protocol.Contains the actions defined in this protocol.Defines an action.Specifies a condition that must be met in order for the action to execute.Specifies the name of the action. + Not all Action/Type values can be used in combination with the different Action/On types.
+ Refer to the DataMiner Protocol Markup Language documentation for an overview of the possible combinations.]]>
+ In case the "id" attribute is not present, the trigger will apply to all items of the type specified in /Protocol/Actions/Action/On.]]> + If Action/Type is "set next", this attribute specifies the (1-based) position(s) of the pair(s) in the group. + In any case, separate multiple positions with semicolons.]]>
+ Not all Action/Type values can be used in combination with the different Action/On types.
+ Refer to the DataMiner Protocol Markup Language documentation for an overview of the possible combinations.]]>
+ If Action/Type is "replace", this attribute specifies the ID of the parameter that contains the ID of the parameter that has to be put in the command/response.
+ If Action/Type is "increment", this attribute specifies the ID of the parameter that holds the increment value. + ]]>
+ If Action/Type is "replace", this attribute specifies the (0-based) position of the parameter in the command/response.
+ If Action/Type is "set", "set and get with wait", "set with wait", "open", "close", "lock", "unlock", "priority lock" or "priority unlock", this attribute sepcifies the (0-based) connection ID.
+ ]]>
+ Refer to the DataMiner Protocol Markup Language documentation for an overview of the available options for a given type.]]> + If Type is "wmi", this attribute specifies the ID of the parameter containing the returned values (if "table" is set to "true", this ID should be the ID of a parameter of type "array").]]> + Feature introduced in DataMiner 10.1.8 (RN 30199).]]> + Expected format: lowdata;highdata;low;high (for example: scale="0;65535;-10;10").]]> + If Action/Type is "stuffing", this attribute specifies the (fixed) start position that delimits the part of the data block in which stuffing has to be performed. + ]]>
Specifies the unique action ID.
The ID of an action must be unique.The name of an action must be unique.
Specifies a number of advanced settings with regard to the protocol's commands and responses. + In other words, the trigger associated with a response will not go off if that response is identical to the previous one.
+ Note: Use this option with extreme care, as it can have a profound impact on the general behavior of the protocol.]]>
In this attribute, you can specify a number of settings with regard to stuffing. Separate these by semicolons.
Contains the source and the destination of the element in alarm and where the result needs to be placed. + An alarm level link allows aggregating alarms from DataMiner elements or table rows at runtime.
+ Contains the source and the destination of the element in alarm and where the result needs to be placed.
+ The source and destination are table columns.]]>
Specifies the column parameter ID where the result of the alarm level needs to be set.The unique ID of the AlarmLevelLink.Used to retrieve the alarm state of a different element.
The ID of an alarm level link must be unique.
+ In DataMiner Cube, protocol-based applications can be found in the Apps tab of the Surveyor.]]>Contains the chains defined in this protocol.Represents a different topology view of a CPE manager or Service Over­view Manager (SOM) element.Specifies the name of the field for which selection should be applied.Specifies the name of the group to which this Chain belongs. Feature introduced in DataMiner 10.1.3 (RN 28751, RN 28834, RN 28846).Specifies the name of the chain, which is used as the name of the corresponding tab page in DataMiner. + Refer to the DataMiner Protocol Markup Language documentation for an overview of the available options.]]>Contains the name defined in the /Protocol/Topologies/Topology@name attribute (only Service Overview Manager). See Protocol/Topologies/Topology@name.Defines a search chain in a CPE environment.Contains all tab definitions of this search chain.Defines a tab.Contains the definition of the fields to be included in this search tab.The name of a field must be unique within a tab.Specifies the table parameter ID of the table for which a search Tab will be defined.Specifies the name of the search tab.The name of a tab must be unique within a search chain.Specifies the name of the search chain.Determines the layout of the filters.The name of a chain or search chain must be unique. + Commands are sent from DataMiner to the device
+ - to request information from the device, or
+ - to change a device setting.]]>
+ DataMiner sends a command to the device
+ - to request information, or
+ - to change a device setting.
+ In both cases, DataMiner will expect a response from the device. If it requests information, it will expect a response that contains that + information, and if it changes a setting, it will expect a confirmation (although, in some cases, none is returned).]]>
+ Quite often, commands have a header parameter and a trailer parameter that demarcate the beginning and the end of the command.]]>Specifies the ID of the parameter to include in the command.Specifies the command description.Specifies the command name. + By default, the message is sent in binary format.
+ Feature introduced in DataMiner 9.5.1.]]>
Specifies the command ID. + Use semicolon-separated parameter IDs if only certain parameters should be sent as ASCII.]]>
The ID of a command must be unique.The name of a command must be unique.
Provides compliance information about this protocol.True if the protocol is compatible with a Cassandra database; otherwise, false.Specifies whether a Cassandra database is required to execute the protocol. True if Cassandra is required to use this protocol; otherwise, false. + Expected format: [MainVersion].[MainVersionIncrement].[FeatureVersionIncrement].[CurrentlyUnused] - [BuildNumber] (in which [BuildNumber] is a four-digit number) (e.g. 10.0.7.0 - 9247)]]> + Expected format: [MainVersion].[MainVersionIncrement].[FeatureVersionIncrement].[CurrentlyUnused] - [BuildNumber] (in which [BuildNumber] is a four-digit number) (e.g. 10.0.7.0 - 9247)]]>Defines communication connections.Defines a connection.Defines a Virtual connection.Defines an SNMP connection.Specifies the communication settings.Specifies whether this connection is used as part of a redundant polling pair.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Configures the get community string.Configures the get community string.Configures the timeout settings.Configures the retry settings.
Defines an SNMPv2 connection.Specifies the communication settings.Specifies whether this connection is used as part of a redundant polling pair.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Configures the get community string.Configures the get community string.Configures the timeout settings.Configures the retry settings.
Defines an SNMPv3 connection.Specifies the communication settings.Specifies whether this connection is used as part of a redundant polling pair.Specifies the dynamic context name.Specifies the dynamic context ID.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Specifies the security level settings.Specifies the authentication algorithm settings.Specifies the encryption algorithm settings.Specifies the user name settings.Specifies the authentication password settings.Specifies the encryption password settings.Configures the timeout settings.Configures the retry settings.
Defines an HTTP connection.Specifies the communication settings.Specifies whether this connection is an HTTP connection.Specifies the parameter IDs to use to monitor (dis)connects.Specifies the ID of the parameter in which the connects have to be logged.Specifies the ID of the parameter in which the disconnects have to be logged.Specifies whether the commands will be composed the moment the corresponding group is added to the group execution queue.Specifies the ID of the Session to use as a custom opening handshake.Specifies whether this connection is used as part of a redundant polling pair.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Configures the timeout settings.Configures the retry settings.
Defines a serial connection.Specifies the communication settings.Specifies whether the commands will be composed the moment the corresponding group is added to the group execution queue.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Defines a range of possible baud rate settings.Specifies the last of a range of baud rates. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
Specifies the default parity.Specifies whether the parity can be modified in the DataMiner user interface.Defines the range of possible parity values.Specifies the first of a range of parity values.Specifies the last of a range of parity values. + Note:
+ - The value specified in DefaultValue does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in DefaultValue.]]>
+ For SNMPv3, this contains the User Name.]]>Specifies whether the databits can be modified in the DataMiner user interface.Defines a range of possible databit settings.Specifies the first of a range of databits.Specifies the last of a range of databits. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Specifies the stop bits settings. + Set the default to one of the following integer values: 1, 1.5 or 2]]>Specifies whether the number of stop bits can be modified in the DataMiner user interface. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ Set Value to one of the following integer values: 1, 1.5 or 2]]>
Allows to limit flow control settings and to define a default value.Specifies whether the flow control can be modified in the DataMiner user interface.Defines the range of possible flow control values.Specifies the first of a range of flow control values.Specifies the last of a range of flow control values. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the timeout settings.Configures the retry settings.Specifies settings related to the TCP/IP port type.Specifies whether the port type TCP/IP can be selected in the DataMiner user interface.Specifies settings related to the serial port type.Specifies whether the port type serial can be selected in the DataMiner user interface.Specifies settings related to the UDP/IP port type.Specifies whether the port type UDP/IP can be selected in the DataMiner user interface.Specifies the port type settings.Specifies the default port type.Specifies the SSL/TLS settings.Specifies the default setting.Specifies the default setting.Specifies the local port settings.Specifies the default setting.Specifies the default setting.
Specifies whether this is a dedicated connection.
Defines a smart-serial connection.Specifies the communication settings.Specifies whether the commands will be composed the moment the corresponding group is added to the group execution queue.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the port settings.Specifies the default value.Specifies whether this setting can be modified in the DataMiner user interface.Configures the timeout settings.Configures the retry settings.Specifies settings related to the TCP/IP port type.Specifies whether the port type TCP/IP can be selected in the DataMiner user interface.Specifies settings related to the UDP/IP port type.Specifies whether the port type UDP/IP can be selected in the DataMiner user interface.Specifies the port type settings.Specifies the default port type.Specifies the SSL/TLS settings.Specifies the default setting.Specifies the default setting.Specifies the local port settings.Specifies whether allowed IP addresses can be provided.
Specifies whether this is a dedicated connection.
Defines a GPIB connection.Specifies the user settings.Configures the bus address. +As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
Configures the timeout settings.Configures the retry settings.
Defines a OPC connection.
Specifies the connection ID.Specifies the connection name.
+ Can be used to specify some general information about the protocol. You could, for example, specify that the protocol has been + developed for elements running a specific firmware version.
+ In protocols of DataMiner elements that are used in automation, the description must be unique.]]>
+ The device OID has to be specified right after the vendor OID. Note that the complete OID, i.e. the vendor OID followed by the device OID, must be unique. + This means that for each device from the same vendor you have to use a new device OID.]]>Defines the layout and the order of the Data Display pages.Defines a page.Specifies the name of the page.Specifies the page visibility configuration.Specifies the default visibility of the page.Specifies the ID of the parameter to use to compare its value with the value specified in the "value" attribute.Specifies the value the parameter referred to by the overridePID attribute should have in order to swap the visibility. + If you do not specify a default page, the first page will be shown.]]> + By default, the pages will be ordered alphabetically.
+ In addition to the pages, you can add a reference to a web interface by specifying
+ - Webinterface#http://[Polling Ip], or
+ - WebInterface#http://[id:parameterID]]]>
+ By default, a page will have multiple columns. Use this attribute for pages that will contain e.g. a wide table.]]>
+ The type will be shown whenever a DataMiner element is added or edited. It will also be shown in the Details section of System Display when a DataMiner element is + selected.]]>Specifies which general parameter groups should be loaded or not. Feature introduced in DataMiner 9.0.1 (RN 12263).Configures a general parameter group.Specifies the general parameter group.When set to false, the specified general parameter group will not be loaded.There must not be multiple GeneralParameterGroup children with the same group type.Contains the groups defined in the protocol. + In a group, you can assemble different parameters, command/response pairs or actions. When a group is executed, all parameters, pairs or actions included in the group will be executed one after the other.
+ Make sure that the "id" attribute contains a unique group ID.]]>
Specifies a condition that must be met in order for the group to execute. + In a /Protocol/Groups/Group/Content element, you are only allowed to specify items of the same type:
+ - action items only,
+ - pair items only,
+ - parameter items only,
+ - session items only,
+ - trigger items only.
+ Recommendation: The content of a group should not exceed 10 items.]]>
+ If you include actions in a group, do not forget to set the attribute /Protocol/Groups/Group@type to "action".]]>Specifies the number of milliseconds DataMiner has to wait after having received the response of the last executed action before executing the next action. + When a setting has to be changed, it is common practice to include in a group
+ - a "SET" pair, directly followed by
+ - a "GET" pair.
+ That way, the DataMiner interface will immediately show the changed values.]]>
Specifies the number of milliseconds DataMiner has to wait after having received the response of the last executed pair before executing the next pair.
Specifies the ID of a parameter to be included in the group.Specifies the number of milliseconds DataMiner has to wait before reading the next parameter.Specifies the ID of an HTTP session to be included in the group. + Feature introduced in DataMiner 8.5.7 (RN 9928).]]> + If the last item in the group contains this attribute, it will also cause a delay before the next group is executed.]]> + If you include triggers in a group, do not forget to set the value of the "type" attribute of this group to “trigger”.]]>Specifies the number of milliseconds DataMiner has to wait before executing the next trigger.
+ This "multipleGet" option cannot be used with parameters of Type "Array".]]>
Specifies the group description.Specifies the name of the group. This name could, for example, refer to the information that will be requested from the device. + If you specify "action" or "trigger", the group will be executed at once. + If, however, you specify "poll", "poll action" or "poll trigger", the group will be added to the group execution queue, awaiting execution.]]>
+ Default connection: 0]]>The unique group ID.
The ID of a group must be unique.The name of a group must be unique.
Represents a particular HTTP session.Specifies a connection. This typically contains a request and a response.Defines the HTTP request to be sent.Replaces the url attribute. The parameter value will be used as URL. + If you do not specify this attribute, "GET" will be used by default.]]> + If you do not specify this attribute, the root directory of the server specified in the element wizard will be used.]]>Defines the response to the HTTP request you defined in ../Connection/Request.Specifies the response headers of which you want to store the contents in a parameter. + In this context, this has to be done by means of a key/value pair.]]>Specifies the name of the header of which you want the contents to be stored in the parameter having the ID defined in the pid attribute.Specifies the ID of the parameter in which you want to store the contents of the header defined in the key attribute.The pid attribute of this element specifies the ID of the parameter in which you want the contents of the response to be stored.Specifies the ID of the parameter in which you want the contents of the response to be stored.Specifies the ID of the parameter in which the HTTP status-line has to be stored ("e.g. HTTP/1.1 200 OK".The unique connection ID. + This works in a similar way as the serial pair ignoreTimeout option.
+ Default value: false.
+ Feature introduced in DataMiner 9.0.2 (RN 10543). + ]]>
Specifies the name of the connection. + Feature introduced in DataMiner 9.0.2 (RN 12542).]]>
The unique session ID. + This works in a similar way as the serial pair ignoreTimeout option.
+ Default value: false.
+ Feature introduced in DataMiner 9.0.2 (RN 12542). + ]]>
+ Feature introduced in DataMiner 8.5.7 (RN 9929).]]>Specifies the name of the session.If you set loginMethod to "credentials", then use this attribute to specify the password. + Note: If you do not specify a proxy server, then an attempt will be made to fetch the default proxy configuration using the Web Proxy Auto-Discovery Protocol (WPAD).]]> + Feature introduced in DataMiner 9.0.2 (RN 12542).]]>If you set loginMethod to "credentials", then use this attribute to specify the user name.
The ID of a connection must be unique.
The ID of a session must be unique.The name of a session must be unique.
Defines an icon (via XAML content in a CDATA tag) to be used in the Applications list in the DataMiner Cube surveyor.Specifies the integration ID.Configures internal licensing.Configures internal licensing of the specified type.Allows providing additional content (conforming the SMI specification) that must be included in the generated MIB. + This name, which must be unique, will be used throughout the DataMiner System to identify the protocol.]]>Groups NoTimeout elements.Indicates that the specified error (response value) should not cause a timeout.Defines options for the protocol.Groups NoTimeout elements of the protocol. Feature introduced in DataMiner 8.5.3 (RN 8775). + Feature introduced in DataMiner 9.0.3 (RN 13010).]]>Groups ownership declarations of DataMiner elements.Declares ownership of specific DataMiner elements.Declares ownership of DataMiner elements running the specified protocol. Supported wildcard characters: '*' and '?'.Declares ownership of the element description.Specifies the access type.Groups ownership declarations of element properties.Declares ownership of the specified element property.Specifies the name of the element property. Supported wildcard characters: '*' and '?'.Specifies the access type.Declares ownership of the alarm template.Specifies the access type.Declares ownership of the trend template.Specifies the access type.Groups ownership declarations of view properties.Declares ownership of view properties.Groups ownership declarations of view properties.Declares ownership of the specified view property.Specifies the name of the view property. Supported wildcard characters: '*' and '?'.Specifies the access type.Groups service ownership declarations.Declares ownership of a service.Declares ownership of the service description.Specifies the access type.Groups ownership declarations of service properties.Declares ownership of the specified service property.Specifies the name of the service property. Supported wildcard characters: '*' and '?'.Specifies the access type.Groups redundancy group ownership declarations.Declares ownership of a redundancy group.Declares ownership of the redundancy group description.Specifies the access type.Declares ownership of the redundancy group maintenance.Specifies the access type.Declares ownership of the redundancy group switching.Specifies the access type.Contains all the pairs defined in the protocol.Defines a pair consisting of a command and optionally a response.Specifies a condition that must be met in order for the pair to execute. + You can specify only one command. The number of responses, however, can vary from none to several, depending on the device.
+ - If no response is expected, then specify the command, but no response.
+ - If only one single response is expected, then specify the command and the expected response.
+ - If multiple responses are expected, then specify the command and all expected responses.
+
+ When DataMiner receives a response from the device after having sent a command, it will try to match the response to one of the responses + defined in this tag. If several responses have been defined, it will check them top down.
+ If a match is found, DataMiner will move on to the next command/response pair.
+ If no match is found, DataMiner will send the command again. In the device's Element Display, a red block will indicate that an error has + occurred. The log files of the device will contain more detailed information. If the new response still does not match one of the defined + responses, DataMiner will send the command for the third and last time. If, at that point, no valid response has been received, DataMiner + will skip the command, and move to the next command/response pair.
+ By default, the number of retries in case of an invalid response is set to 3. This setting can be changed when adding or editing the device + in System Display.]]>
]]>Specifies the ID of an expected response. + If the device is able to return an error message, and if the structure of that error message is known, then you can create a response that + matches that error message, and included that response in the command/response pair as a "ResponseOnBadCommand".
+ When the device sends a response that matches the ResponseOnBadCommand, then this will be indicated in the communication indicator of the DataMiner user interface. + The command, however, will not be executed again as the received response matched one of the defined responses.
+ Also, the information received from the device in the error message can be used to inform users about the error that occurred.]]>
Contains a textual description of the pair.
Specifies the unique ID of the pair. + For an overview of all options that can be specified in this tag, refer to the DataMiner Protocol Markup Language documentation.]]> + Note: This option cannot be used in protocols of type SNMP or OPC.]]> + Using this option, you can extend the period of time DataMiner will wait for a response after having sent a command.]]>
The ID of a pair must be unique.
+ Feature introduced in DataMiner 8.0.0 (RN 5663).]]>Specifies the parameters that are included in the group.Specifies a parameter that is included in the group.Specifies the ID of the included parameter.Specifies the parameter ID of the index column (primary key).The parameters referred to in a parameter group must not contain duplicate entries.Specifies whether to disable the interface state calculation.Specifies whether the display key or the primary key should be used in the interface name (Default: false). + A parameter group cannot have an ID equal to 10000 or higher. The IDs starting from 10000 are reserved for DCF dynamic interfaces. Feature introduced in DataMiner 8.5.3 (RN 8863). Since DataMiner 9.0.4 (RN 13161), DataMiner creates new dynamic interfaces in the range 100 000 - 199 999 (instead of starting from 10 000). + ]]>Specifies whether this an internal interface (Default: false).Specifies the name of the parameter group.The ID of a parameter group must be unique.Contains all the parameters defined in the protocol.Defines a parameter. + - Severity: Critical, Major, Minor, Warning or Normal
+ - Severity Range: Low, Medium or High
+ These are combined into the following alarm levels:
+ - Critical Low (CL)
+ - Major Low (MaL)
+ - Minor Low (MiL)
+ - Warning Low (WaL)
+ - Normal (Normal)
+ - Warning High (WaH)
+ - Minor High (MiH)
+ - Major High (MaH)
+ - Critical High (CH)
+ Each alarm level is included in a /Protocol/Params/Param/Alarm element, so a value can be assigned to it. If the value of the monitored parameter is equal to or exceeds + a value included in the /Protocol/Params/Param/Alarm element, DataMiner will process an alarm depending on the alarm level that corresponds to the + value.
+ These assigned values are not only accessible via the protocol, but also via DataMiner Cuber or System Display. The alarm values of a parameter can be altered by + means of alarm templates, on condition that a /Protocol/Params/Param/Alarm element has been defined for the parameter in the protocol. The alarm + levels of a parameter can be adapted at any moment, regardless of the values specified in the protocol.]]>
Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "critical high" alarm.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "critical low" alarm.When the value of the alarm is equal to the value specified in this element, an information event is generated.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "major high" alarm.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "major low" alarm.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "minor high" alarm.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "minor low" alarm.Allows enabling or disabling the /Protocol/Params/Param/Alarm element assigned to the parameter.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "warning high" alarm.Defines the default value in the alarm template that this parameter must equal or exceed in order for DataMiner to create a new "warning low" alarm.In case of a constant alarm: the time (in milliseconds) before the alarm is cleared. + - threshold: When using this option, specify two parameter IDs, separated by a comma. If the value of the second parameter is smaller than the value of the first parameter, + no Alarm will be generated.
+ - propertyNames: In this option, specify the property labels to be added to the alarm tab. Multiple names are separated by a comma.
+ - properties: In this option, specify the format of the properties to be added to the alarm tab. Always start the properties string with the character used to separate the different formats. + Each property in the string is either a parameter ID or a combination of text and parameter IDs separated by an asterisk ("*"). If the characters between * are numbers only, then they are considered a parameter ID.]]>
+ - If set to "absolute", the alarm values defined in /Protocol/Params/Param/Alarm will be calculated in accordance with the nominal value sent by the device. + When the "Critical Low" tag contains the value 5, this value will be subtracted from the nominal value to calculate the actual alarm limit.
+ - If set to "relative", percentages will be taken instead of absolute values in order to calculate the actual alarm limits. Example: When the "Minor High" element contains 50, + the alarm limit will contain the nominal value increased with 50% of its value.
+ You can normalize an alarm by (optionally) adding two parameters, separated by a comma.
+ - First parameter: The ID of the parameter that holds the nominal value. This can be a dynamic table parameter or a normal parameter. In case of a table parameter, + each row will be compared with the nominal value found in the same row of the specified column.
+ - Second parameter: The ID of the parameter that holds the value by which to multiply the nominal value.]]>
+ Each table column is defined by one or two Parameters:
+ - one for read, and/or
+ - one for write.]]>
+ The first character denotes the separator used.
+ Integers between two separators will be used as column pids.
+ Using any other alphanumeric string between separators will display this string in the row index.]]>
+ This attribute is used in combination with snmpSetAndGet or dynamicSnmpGet functionality on tables.
+ For more information, refer to the DataMiner Protocol Markup Language documentation.
+ Feature introduced in DataMiner 8.5.7 (RN 10007). + ]]>
+ This column can be updated, and normally contains a readable key which identifies the row for the user.]]> + The column containing the primary keys has to be of type "string". Once a row is created, the value of the primary key cannot be changed.]]> + For more information about the available options, refer to the DataMiner Protocol Markup Language documentation.
+ Note: In this attribute, you can specify multiple values separated by a character of choice (a semi-colon is recommended).
+ This character has to be the first character in the value of the options attribute. If, for example, you want to separate the different options by a semi-colon, the first character of the options value has to be a semi-colon.]]>
+ A page navigator will be displayed at the bottom of the table.
+ To manually set the number of rows per page, type a colon (":") after "true", followed by the number of rows per page. This value has to be a value between 10 and 5000.]]>
+ If you want a concatenation of multiple columns, you can separate them with semicolons (";").]]>
No duplicate idx values must occur for the different ColumnOption elements.
+ Note: The first parameter of the command/response has ID 0.]]>Specifies a parameter of the command/response to be included in the CRC calculation.Defines the CRC calculation algorithm. + Can be used in combination with all possible CRC types.]]> + Only valid if the CRC type is set to one of the following values: LSB after subtract, LSB after sum, Exor, Sum]]>Specifies that a modulo operation has to be performed on the CRC after it has been calculated. + Only valid if the CRC type is set to one of the following values: LSB after subtract, LSB after sum, Rest, Subtract, Sum.]]> + - ones complement: each bit of the calculated CRC will be inverted. (Example: AAAA will become 5555)
+ - or totaloffset: the "totaloffset" value will not be added but "OR"-ed.]]>
Specifies an offset value to be added to the CRC after it has been calculated.
Allows building a direct view table using multiple columns from multiple different protocols. Feature introduced in DataMiner 10.2.9 (RN 33253).Specifies column mappings from a remote protocol to this protocol.Maps a column parameter ID from the remote protocol to this protocol.Specifies the parameter ID of the column in this protocol.Specifies the parameter ID of the column in the remote protocol.Specifies the name of the protocol.Specifies the parameter ID of the remote table.Specifies the configuration for use in dashboards.Indicates the type of button panel.Button panel: The parameter is a table containing all the buttons. Every row in the table represents a button. A button could be linked to a page (see button panel containers).Button panel containers: The parameter lists the different "paged" or "containers".Button panel collection: The parameter contains grouping information. A group is a collection of one or more button panels. Every row of this table parameter represents one group with all the necessary information for the dashboard to be able to display the button panels of that group. This parameter can be used as a feed in the dashboard that will allow the user to easily switch between dashboard groups.Groups the options that will determine how the button panel is displayed.Specifies how the button panel is displayed.Specifies whether the value denotes a column index or a parameter ID.The value denotes a column index.The value denotes a parameter ID.Specifies the name of the option.Determines which container is to be displayed by the dashboard. For this option, type should be set to "pid" and the tag should contain the ID of the parameter that allows the user to select the active container.Allows the user to specify the layout of the button using a JSON string.Determines the container the button is located in.Determines the CSS to apply to HTML content of buttons. For this option, type should be set to "pid" and the tag should contain the PID of the parameter that contains the CSS. NOTE: To apply a different CSS to a specific button, you can specify this in line in the advancedLayout JSON.Determines the width of the button (in percent).Allows the user to specify the general layout of the panel using a JSON string. For this option, type should be set to pid and the tag should contain the PID of the parameter that contains the JSON string.Determines the name of the button.Displays the different buttons, which are the same for all rows. The next option, panelButtonPossibleOperations, will determine which of these buttons are used.Allows the user to specify which operations are possible with the button. For rotate buttons, 4 types of increments are possible. For example: click,largedecrease;smalldecrease;smallincrease;largeincreaseDetermines the type of button. The user will be able to select one of the following three types: "Simple", "Advanced - HTML", "Rotate".Specifies the different selected panels. The contents of the referred parameter should be a semicolon-separated list of DMAID/ElementID/ParameterID (e.g. “346/532084/100;346/114/157”).Determines the width of the button (in percent).Determines the position of the button on the X-axis (in percent).Determines the position of the button on the Y-axis (in percent). + Feature introduced in DataMiner 9.0.0 (RN 11853).]]>Specifies the default value.Specifies connection options.Specifies the connection type.A direct connection is used to push data.Interaction with the logger table is done via SLProtocol. + Feature introduced in DataMiner 9.0.0 (RN 11853).]]> + Contains a semicolon separated list of column idx values denoting the columns that form the primary key.]]>Specifies the IDs of the parameters that are linked to this parameter.Specifies whether the dependency parameter acts as a preset or a post-set. Refer to the DataMiner Protocol Markup Language Documentation for more information. + Typically, the parameter name refers to the technical name of the parameter, while the parameter description provides a more common name or description.
+ Preferably, the description should be unique throughout the protocol.]]>
Defines if and how a parameter will be displayed on the user interface.Specifies the dynamic units that can be used.Specifies a dynamic unit.Specifies the number of decimals to be used to display the parameter value on the user interface with this unit.Defines the number of decimals to be used to display the parameter value on the user inter­face. + The parameters holding the actual values to be displayed have to be specified in /Protocol/Params/Param/Display/ParametersView/Parameters.
+ Note: When this is used, make sure to set /Protocol/Params/Param/Measurement/Type to “Chart”.]]>
+ Note: Only specify parameters of type "double".]]>Specifies the ID of the parameter.Specifies the row index (in case the “id” attribute refers to a table parameter). + - Height: Height of the chart (in pixels). If you do not specify a height, the chart will take up the rest of the page.]]> + Note:
+ - Pie charts only work if the referenced values are either all positive or all negative.
+ - StackedArea charts should not be used to display values that are constantly changing.]]>
+ Note: As a parameter can be displayed on several locations on the user interface, /Protocol/Params/Param/Display/Positions can contain more than + one position.]]>Defines the location of the parameter on the user interface. + All Data display pages specified in the protocol will appear in the page selection box at the top of the Data Display.]]> + Data display pages are divided into rows and columns. In /Protocol/Params/Param/Display/Positions/Position/Column, you can specify the column on which you want the parameter to be displayed.
+ Enter an integer value between 0 and 5.
+ Note: It is recommended to divide the user interface into two columns: a left-hand column with column value 0, and a right-hand column with column value 1.]]>
+ Data display pages are divided into rows and columns. In /Protocol/Params/Param/Display/Positions/Position/Row, you can specify the row on which you want + the parameter to be displayed.
+ Note: 0 = first row]]>
Defines the parameter value range.Specifies the lower limit of the range, i.e. the minimum value of the parameter.Specifies the upper limit of the value range, i.e. the maximum value of the parameter.Specifies whether the parameter should be pushed to the SLElement process.Defines the step size of a write parameter.Specifies the formula to be used for the average trending data of this parameter. By default, the average over a 5 minute timespan is stored.Specifies the formula used to determine the average trending data. + The specified unit will be used each time the value of the parameter is displayed: in a report, on the alarm display, etc.]]>
+ These custom commands are often hyperlinks pointing to a web page or an automation script.]]>Defines a custom command (i.e. “hyperlink”) that has to appear on the shortcut menu when users right-click an alarm of this parameter. + If you specify a string in this attribute, the command will only appear on the shortcut menu of alarms and information events of which the value matches the string you specified.
+ If you leave this attribute empty, the command will appear on the shortcut menu of every alarm and information event.
+ The string you specify in this valueParsing attribute can contain wildcards (question marks and asterisks) as well as placeholders.
+ For examples, refer to the DataMiner Protocol Markup Language documentation.]]>
+ DataMiner will show this additional information in tooltips.
+ Note: Only parameters of type "read" or "read bit" will use /Protocol/Params/Param/Information. In some cases, however, also parameters of type "write" or "write bit" will have one.]]>
Contains one or more /Protocol/Params/Param/Information/Include elements to indicate that you want additional information to be displayed in the tooltip. + Information specified in /Protocol/Params/Param/Information/Include elements will appear underneath the con­tents of the /Protocol/Params/Param/Information/Subtext element.
+ Can contain one of the following values:
+ - Range: The range of the parameter.
+ - Units: The unit of the parameter.
+ - Steps: The step size of the parameter.
+ - Time: A time stamp that refers to either the last known change or the last time the Parameter was changed by its write parameter (if any).]]>
+ Next to the title of the tooltip, a drop-down arrow will allow users to enlarge the tooltip and display the text contained in /Protocol/Params/Param/Information/Subtext.]]>Specifies the title of the tooltip.
Specifies how a parameter value is processed. + When a /Protocol/Params/Param/Interprete/Bits element is defined in a group, only a couple of bits will be used from each byte. + When a read bit parameter, with its rawtype set to “bcd”, is assigned to that group and exists of multiple bytes, the Alignment element can be needed to specify the exact starting position + of the first BCD.]]> + Contains a number between 2 and 36. Default: 10
+ Note: In case of base 36, the letters "a" through "z" (or "A" through "Z") are assigned the values 10 through 35.]]>
+ For example, when only the lower 4 bits are used from each byte, a group can be defined with /Protocol/Params/Param/Interprete/Bits set to 4.
+ When a "read bit" parameter of 8 bits is assigned to that group, 4 lower bits of 2 bytes will be taken instead of 1 complete byte.]]>
+ Each incoming byte of a group containing this ByteOffset element will be decremented with the specified byte offset, while each outgoing byte of the group will be incremented with the specified byte offset.]]>Specifies the number of decimals that will be stored in memory. + When numbers are composed of multiple bytes, Intel processors reverse the byte order before writing them to memory.
+ This optional element instructs DataMiner to either reverse the byte order or not (only relevant in case of unsigned numbers).
+ - Big: The byte order will be reversed.
+ - Little: The byte order will not be reversed.
+ Note: By default, Little Endian is used.]]>
+ However, a rare condition of a parameter can also be expressed by a symbol that is allowed by the parameter's rawtype.
+ In that case, you can use /Protocol/Params/Param/Interprete/Exceptions/Exception.
+ In /Protocol/Params/Param/Interprete/Exceptions, you can specify several /Protocol/Params/Param/Interprete/Exceptions/Exception elements, each representing a different exceptional state.
+ Note: Only useful for parameters of type "read".]]>
+ If the parameter receives an incoming symbol that matches the value specified in /Protocol/Params/Param/Interprete/Exceptions/Exception, the contents of /Protocol/Params/Param/Interprete/Exceptions/Exception/Display will be shown.]]>Specifies the text that has to be displayed when the incoming value matches the contents of the value attribute of /Protocol/Params/Param/Interprete/Exceptions/Exception.Specifies the new value to which you want to internally map the incoming exception value specified in the value attribute of the /Protocol/Params/Param/Interprete/Exceptions/Exception element.Specifies the unique ID of the exception.The ID of an exception must be unique.
Multiplies the parameter value with the specified factor. + For more information, refer to the DataMiner Protocol Markup Language documentation.]]> + When this number exceeds the number of bits used in a byte, the /Protocol/Params/Param/Interprete/Endian element can be set to "big" to make DataMiner reverse the bit order when processing them.]]>When a /Protocol/Params/Param/Interprete/Others/Other element matches the incoming symbol, the contents of /Protocol/Params/Param/Interprete/Others/Other/Display will be shown.If set to "disabled", the parameter will be displayed in gray.= 10) to the parameter , which can be useful in case you want to show an alarm when this rare condition occurs.]]> + If the incoming symbol matches the referred parameter, the contents of the/Protocol/Params/Param/Inter­prete/Others/Other/Display element will be shown.]]> + Note: This can also be used to specify a value range in case of a simulated element.]]>Specifies the lower limit of the range, i.e. the minimum value of a parameter.Specifies the upper limit of the range, i.e. the maximum value of a parameter. + If an incoming parameter value does not match the expected rawtype, DataMiner will not process it.
+ The rawtype setting can therefore be considered as a kind of filter.
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]>
+ Feature introduced in DataMiner 9.0.0 (Main Release) and DataMiner 9.0.4 (Feature Release) (RN 13519).]]>Specifies that you want DataMiner to re-interpret the value range of a particular parameter.Specifies the lowest value that can be returned by the device for the parameter in question.Specifies the highest value that can be returned by the device for the parameter in question.Specifies the value to which DataMiner has to convert the lowest value that can be returned by the device.Specifies the value to which DataMiner has to convert the highest value that can be returned by the device. + Specify at least one mathematical operation. If you specify multiple operations, separate them using semi-colons (";").
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]>
+ The value in the parameter will be automatically recalculated taking into account the loop (overflow) sequence.
+ For examples, refer to the DataMiner Protocol Markup Language documentation.]]>
+ For examples, refer to the DataMiner Protocol Markup Language documentation.]]>
+ Specify one of the following values:
+ - string: The parameter will be processed as an ASCII string.
+ - double: The parameter will be processed as a number.
+ - high nibble: The parameter will be processed as the high nibble (i.e. first four bits) of a byte.]]>
When set to "true", only printable characters will be displayed (default value: "false"). + You can specify the following values. If you add both values, separate them by a semi-colon (";").
+ - left: all leading whitespace will be removed
+ - right: all trailing whitespace will be removed.]]>
Specifies the length of the command/response.Specifies the parameters of the command/response that define the length of the com­mand/response. + Note: The first parameter of the command/response has ID 0.]]>Specifies how the parameter has to be displayed on the user interface (depending on the parameter type). + For every value, page button or button to be displayed, a separate /Protocol/Params/Param/Measure­ment/Discreets/Discreet element has to be specified. + In Data Display, the values will be displayed in the order in which they are specified in the /Protocol/Params/Param/Measure­ment/Discreets element.
+ Note: The /Protocol/Params/Param/Measurement/Discreets element only has to be used if /Proto­col/Params/Param/Measurement/Type is set to "discreet", "pagebutton", or "togglebutton".]]>
+ The latter will be displayed on the user interface if the former matches the value of the parameter.]]>When /Protocol/Params/Param/Interprete/Exceptions/Exception is used the same state needs to be placed in the write parameter. + If the value of the parameter matches the value in this element, the contents of ../Discreet/Display will be displayed.]]>If type is “dll”, the location of the DLL file.Specifies the type.Specifies the tooltip to be displayed when the mouse pointer hovers over the icon displayed in a table cell containing the discrete parameter value to which it is linked. + Feature introduced in DataMiner 9.5.7.]]>Specifies the parameter values that have to be exported.Specifies the options to be used. Refer to the DataMiner Protocol Markup Language documentation.Displays the inputs on the left and the outputs at the top. (This is the default configuration).Displays the inputs at the top and the outputs on the left.No duplicate values must occur in the discrete value list.No duplicate values must occur in the discrete display value list.
+ In some cases, when only two states are allowed (e.g. "On" and "Off") but the parameter value lies within a range of values, a turnover point has to be defined (i.e. when value + "On" is changed to "Off" and vice versa). This turnover point can be defined here. The actual "On" and "Off" values are defined as discrete entries.]]> + For more information about the values that can be specified, refer to the DataMiner Protocol Markup Language documentation.]]> + - upper: upper case
+ - lower: lower case]]>
+ - On
+ - Off]]>
Specifies whether the parameter value should be displayed as a hexadecimal number. + For more information about the available options, refer to the DataMiner Protocol Markup Language documentation.
+ If you specify multiple options, separate these by semi-colons (";").]]>
Specifies the scientific notation to be used.Specifies a deviation on analog parameters.Specifies the width of a (page) button. Only to be specified in case of measurement types "pagebutton" or "button".
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]>Defines a value mapping.Specifies the value in the other protocol.Specifies the value in the current protocol. + Supported operations:
+ *: factor
+ /: division
+ -: minus
+ +: offset
+ %: remainder
+ Example: ]]>
+ Usually, this text will appear as a pop-up warning when a potentially dangerous setting has to be changed.]]> + Although it is possible that the name is used in alarm notifications, typically the parameter description will be used. See /Protocol/Params/Param/Description.
+ Important:
+ - The name must be unique throughout the protocol.]]>
Used to replicate specific parameters from another element.Specifies the DataMiner Agent ID/element ID of the replicated element.Specifies the ID of the parameter that holds the element ID (DMA ID/element ID) of the element from which the parameter should be replicated. Feature introduced in DataMiner 9.6.1 (RN 19311).Specifies the ID of the parameter that has to be replicated.Specifies the ID of the parameter that holds the ID of the parameter that should be replicated. Feature introduced in DataMiner 9.6.1 (RN 19311).Specifies the IP address of the DataMiner Agent on which the element is located.Specifies the user name to log on to the DataMiner Agent on which the element is located.Specifies the password to log on to the DataMiner Agent on which the element is located.Specifies the domain containing the DataMiner Agent on which the element is located.. + Only used in protocols for elements that are SNMP-compliant. In case of such an element, DataMiner will interrogate the SNMP agent specified in /Proto­col/Params/Param/SNMP/OID or capture traps defined in /Protocol/Params/Param/SNMP/TrapOID.]]>Specifies whether DataMiner is allowed to interrogate the SNMP Agent. + Default factor: 1]]>Specifies the invalid response handling strategy.Specifies the response handling in case an infinite loop was detected when polling a table.The SNMP response is accepted, and the table is updated.The SNMP response is rejected, the table is not updated, and the interface’s timeout timer is triggered.Specifies the OID.Specifies the ID of the parameter holding the IP address that needs to be used to poll this SNMP parameter.Specifies that the evaluation of a certain parameter is skipped if it needs to be retrieved via a dynamic SNMP Get. + If you want to make more advanced Alarm mappings, add one or more /Protocol/Params/Param/SNMP/Trap­Mappings/TrapMapping elements to this TrapMappings element. + Note that it is possible to combine the TrapMappings element with the /Protocol/Params/Param/SNMP/TrapOID@mapAlarm attribute.]]> + At the end of the list of /Protocol/Params/Param/SNMP/TrapMappings/TrapMapping elements, you can add a TrapMapping element in which you specify a wildcard. In the event that severity or value still + cannot be determined, the method with the mapAlarm attribute on the /Protocol/Params/Param/SNMP/TrapOID element will be executed in order to try to determine the severity and value.]]> + This attribute consists of two parts, separated by a colon:
+ - The number of the binding, and
+ - A pipe-separated enumeration of values you want to compare to the value of the binding.
+ Note: Wildcards are allowed.]]>
+ Instead, you can also specify "NoAlarm" (or "NoTrap") to indicate that no Alarm should be generated.
+ Note: The severity level information will always overwrite previously assigned severity levels.]]>
Specifies the SNMP traps DataMiner has to capture via this parameter. + You can compare a certain binding to a fixed string (which optionally contains wildcards), or you can compare it to the value of another parameter.
+ Checks must be separated by pipe characters.
+ For examples, refer to the DataMiner Protocol Markup Language documentation.]]>
+ By default, only the traps received from the polling IP address of an element will be captured. However, using the ipid attribute, you can point to a parameter that contains another IP address.
+ If you use the ipid attribute, only traps received from the IP address found in the parameter referenced by the ipid attribute will be captured. Traps originating from the polling IP address will be disregarded.]]>
+ - The first part must be "true" or "false", to enable or disable the mapping of alarms.
+ - The order of the following items (separated by pipe characters) is irrelevant: Severity, Value, Link, IgnoreSingleClear
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]>
+ Set pairs have to be separated by semi-colons. Every set pair consists of a binding position (1-based) containing the value to be set and the ID of the parameter to set, + separated by a comma. If you want to set a dynamic table parameter, you can add more items to the set pair (which will then be concatenated with a "." to build an index).
+ For examples, refer to the DataMiner Protocol Markup Language documentation.]]>
+ For more information refer to the DataMiner Protocol Markup Language documentation.]]>
Specifies the SNMP type.
+ Specify 'GetCommunity:' or 'SetCommunity:', followed by the connection. Example: options="GetCommunity:0"]]>
+ For more information about the different types, refer to the DataMiner Protocol Markup Language documentation.
+ Parameters of type "elementid", "elementname", "elementdmaid" and "dataminer info" are the first parameters that are loaded by a protocol. Although they hold information, they cannot, as such, + be displayed in Element Display. Therefore, for these types of parameters, always set /Protocol/Params/Param/Display/RTDisplay "false".
+ If you do want to display the information in one of these parameters in Element Display, there is a workaround: create another parameter of type "read", and copy the value from its invisible parameter to this new parameter after protocol start-up. You can then display the "read" parameter in Element Display.]]>
Allows to trigger a QAction when specific parameters go into alarm. + By using data distribution, you can prevent data from being retrieved more than once, and also make sure that the data in your master and child are the same.
+ In a protocol, these data distribution parameters can be defined in either a fixed or a dynamic way.
+ To use data distribution, you have to add the "distribution" attribute to a Parameter in your master element. This parameter can be a "simple" parameter, or a column parameter from a table.
+ For more information about this attribute, refer to the DataMiner Protocol Markup Language documentation.]]>
+ For more information about this attribute, refer to the DataMiner Protocol Markup Language documentation.]]> + For more information about this attribute, refer to the DataMiner Protocol Markup Language documentation.]]> + You can specify multiple connection restraints, separated by a pipe character ("|").
+ A connection restraint has the following format (building blocks separated by ":")
+ - keyword "source" or "destination",
+ - optionally followed by one or more Protocol definitions ("Protocol=...") and one or more parameter descriptions ("Parameterdescription=...").]]>
+ Feature introduced in DataMiner 9.0.0 (RN 11133).]]>Specifies that the value of the parameter on which this attribute is specified should be shown in the specified view table column(s).Allows exporting a parameter to an exported protocol used by a dynamic virtual element (DVE). + If you mark a parameter as a history set parameter, its last set value will not be stored in the trending database when the element is restarted.]]> + - Normal protocols: range 1-64000
+ - Spectrum analyzers: range 50000-59999
+ Warning: Never change parameter IDs in existing protocols. This would severely affect alarms, trend displays, MS Visio files, etc.]]>
+ All users of whom the security level is above the one specified in this attribute are able to change (i.e. set) the value of the parameter.]]> + For more information about the available options, refer to the DataMiner Protocol Markup Language documentation.]]>Specifies the polling interval (ms) as a hint for the real-time trend graph. + Default: false
+ Note: Only applicable for standalone parameters. For column parameters, refer to the "save" option in the Protocol/Params/Param/ArrayOptions/ColumnOptions/ColumnOption@options attribute.]]>
+ Feature introduced in DataMiner 9.5.7 (RN 16708).]]>The duration must be larger than 0s. + Default: false]]> + This option is never set on a table, but on the columns that a snapshot should be taken from.
+ The behavior is the same as the trending attribute, but does not require a trend template. Also, the data will not be stored in the local database, but in the specified central database. This is done via settings in the Db.xml file.
+ When this attribute is not present, the snapshot is set to false. + ]]>
+ When defined on columns with the default value true, cells are retrieved via an Execute Next. The get will not be executed when the set failed.
+ For a list of possible values, see dynamicSnmpGet. + ]]>
+ Default: true]]>
Changes the order in which saved parameter data is retrieved when the element starts up.
The ID of a parameter must be unique.The combination of Type and Name of a parameter must be unique.
+ In case of a multi-type protocol, the /Protocol/Type@advanced attribute is used to any additional protocol types.
+ The port settings for those additional protocol types then have to be specified in a /Protocol/Ports/Portsettings element in which the name attribute contains the name of the additional type as specified in the /Protocol/Type@advanced attribute.]]>
Specifies the port settings for any additional protocol type specified in /Protocol/Type
+ It also allows you to restrict the capabilities of a device port, and to define the format and range of the bus address, if any.]]>Additional options for the Process Automation Queue.The additional options for the Process Automation Queue.Name of the option.Parameter ID of the parameter that will contain the option value. + Example: If a protocol was created by someone from Skyline Communications, this provider tag has to be set to "Skyline Communications".]]> + A QAction (i.e. Quick Action) is a script that can be executed when a parameter or a row changes. Inside a QAction, the following scripting languages can be used:
+ - JScript
+ - VBScript
+ - C#]]>
+ The actual script code of a QAction must be placed inside a CDATA section.
+ By placing code inside a CDATA section, characters like "<" and "&", which are normally illegal when placed inside normal XML elements, will no longer be considered as such.
+ In order to interact with SLProtocol (e.g. to access parameters or to notify DataMiner of certain events)
+ - in JScript or VBScript code, use the SLScript object
+ - in C# code, use the Skyline.DataMiner.Scripting namespace
+ For information on how to use C# in protocols, refer to the appendices of the DaaMiner Protocol Development Guide.]]>
Specifies a condition that must be met in order for the QAction to execute. + Multiple values have to be separated by semi-colons (";").
+ System DLL files must be stored in the system dll directory; all other DLL files must be stored in the C:\Skyline DataMiner\ProtocolScripts directory.
+ Note: The following DLL files do not have to be specified in this dllImport attribute. They are loaded by default.
+ - System.dll
+ - SLManagedScripting.dll
+ - Interop.sldms.dll]]>
+ - JScript
+ - VBScript
+ - CSharp
+ (case insensitive)]]>
Specifies the unique QAction ID.Specifies the name of the external script to be executed. + Multiple values have to be separated by semi-colons (";").]]>Specifies the name of the QAction. + - binary: If specified, all values in “inputParameters” are forwarded to the QAction as a byte array holding the raw content of the parameter.
+ - debug: Compiles the QAction in debug mode. + - dllName=name: With this option, the specified name will be included in the DLL name. The name of the DLL will be as follows: [ProtocolName].[ProtocolVersion].[name].dll. + - queued: The QAction will be executed asynchronously. This implies that the QAction is triggered and set in the background. Be careful when using this option and make sure to also implement thread synchronization when this QAction is called more than once.
+ - group: When this option is specified, the "OldRow()" method will return the values retrieved by that group. This option can be used in case of high-volume polling. Use it with care.]]>
+ Multiple values have to be separated by semi-colons (";").]]>
The ID of a QAction must be unique.The name of a QAction must be unique.
Configures Root Cause Analysis (RCA).*** No documentation available yet. ***Defines an RCA chain by defining relations.*** No documentation available yet ****** No documentation available yet ****** No documentation available yet ***Defines relations between tables.Defines a relation between tables. + Refer to the DataMiner Protocol Markup Language documentation for an overview of the available options.]]>Specifies the IDs of the tables that are linked to each other.Specifies the name of the relation.Contains all responses defined in the protocol. + Similar to a command, a response is a collection of parameters that describe the message that the device is expected to send back to DataMiner after having received a command.
+ When it receives a response from the device, DataMiner will compare that response to the response definition specified in /Protocol/Responses/Response. If the response does not match + the definition, DataMiner will send the command again. In the device's Element Display, a red block will indicate that an error has occurred. The log files of the device will contain + more detailed information. If the response still does not match, DataMiner will send the command for the third and last time. If, at that point, no valid response has been received, DataMiner + will skip the command, and move to the next one.
+ Note: By default, the number of retries in case of an invalid response is set to 3. This setting can be changed when adding or editing the device in System Display or DataMiner Cube.]]>
Specifies the consecutive parameters that together form the response that is expected from the device.Specifies the ID of the parameter that you want to include in the response. + Parameters included in a response definition can be marked as optional. This means, that no error will occur if they are not found in the response received from the device.
+ If a parameter matches, DataMiner will simply go on to the next parameter and check that one.
+ If an optional parameter does not match, the following special characters can be included in the "optional" attribute of the /Protocol/Responses/Response element to tell DataMiner what to do:
+ +: tells DataMiner to skip the next parameter. Multiple "+" characters can be entered to have several parameters skipped.
+ *: tells DataMiner to skip the parameters in the response until it reaches the next optional parameter.]]>
Specifies a textual description of the response.Specifies the name of the response. Often, the response will have the same name as the command with which it is associated.
Specifies the unique response ID. + - Connection: This option allows you to specify the ID of the connection (in case of multiple ports). Adding the connection ID at response level is only done in protocols of type "smart serial".]]>
The ID of a response must be unique.The name of a response must be unique.
Used to pass alarm severities to linked tables.Specifies the table path that needs to be followed when passing alarm severities. + The referred parameter must have 0 and 1 as possible values.
+ While the element is running, if the parameter value is set to 0, the bubble-up path will be disabled.
+ If the parameter value is set to 1, the bubble-up path will be enabled.
+ If this attribute is absent, the bubble-up path will be enabled by default.
+ Feature introduced in DataMiner 9.5.3 (RN 15103, RN 15843). + ]]>
Specifies how the MIB file for the protocol will be created. + Example: When a number of parameters are placed on a page called "General", the MIB will automatically create a submap named "General", which will contain all the parameters on that page.]]>Specifies additional threads that will be used by the protocol. This allows you to separate time-critical actions from device-polling actions. Use with caution. + Each additional thread you create, has its own protocol group execution queue as well as its own run-time error thread registration.
+ Note: The main protocol group execution queue will always be active, no matter how many additional threads you create.]]>
+ This can be either a real connection or a virtual connection. All groups linked to that connection will then be executed on that thread.
+ In the connection attribute, you can specify a single connection ID or a comma-separated list of multiple connection IDs in case you want to combine a number of connections into one single thread).]]>
+ Timers are used to configure recurring events (group execution, device polling, ...). Basically, a timer defines the interval between two consecutive executions of a given event.
+ By default, the interval specified in a timer is a fixed interval. However, in the protocol, you can make the interval dynamic.
+ The interval can be modified by changing the value of the [Timer base] Parameter (ID: 65017). The value of this parameter is the factor by which the interval time is multiplied.
+ So "1" means the original interval, "2" means twice as slow, "0.5" means twice as fast, etc.]]>
+ It is recommended to define multiple timers. That way, you can separate the important groups (which will be polled more frequently) from the less important groups + (which will be polled less frequently).]]>Specifies a condition that must be met in order for the timer to execute. Note: Avoid using conditions on timers.Specifies the timer name. + Important: Do not include too much groups in one timer.]]>Specifies the ID of the group to be included.Specifies the interval (in milliseconds) between two consecutive executions of groups within a timer and also between two consecutive pairs within a timer group. + If you enter "loop", the included groups will be executed over and over again.
+ If you enter an integer value > 0, the included groups will be executed every X milliseconds.]]>
+ It is good practice to set this interval to 30000 (30 seconds).
+ Note: If you set this attribute to "loop", the included groups will be executed as frequently as possible. + In some cases, this can affect overall DataMiner performance.]]>
+ - true: the timer will be started when the element is started.
+ - false: the timer will not be started when the element is started. This allows you to dynamically start the timer by performing an action.
+ - random=startvalue:endvalue : the timer will be started a random number of seconds after the start of the element. The random value will be a value between startvalue and endvalue. + E.g. random=0:300
+ By default, this attribute is omitted. As a consequence, the groups will be executed the moment the element is started.]]>
Specifies the unique timer ID. + See also: The /Protocol/Type@relativeTimers attribute.]]> + Refer to the DataMiner Protocol Markup Language documentation for an overview of the available options. + ]]>
The ID of a timer must be unique.The name of a timer must be unique.
Groups topologies defined in the protocol.Defines a topology. In this element, you can specify several Cell elements, each representing a cell in the diagram displayed in the CPE Manager.Defines a topology, representing the connections in a diagram displayed in a CPE manager.Specifies a cell within a CPE topology.Exposes this cell to the CPE crawler.Specifies the linked tables.Specifies the table parameter ID of the linked table.Specifies the ID of the column parameter that is used to link the specified table.Specifies whether the exposer is enabled.Specifies the name of the cell.Specifies a number of options (Deprecated).Specifies the table parameter to which the cell is linked.Specifies the name of the topology (Service Overview Manager only).Contains all the tree controls defined in the protocol.Defines a tree control.Defines additional tree item information to be displayed in the details section of the tree control lay­out.Defines additional tree item information to be displayed in the details section of the tree control lay­out. + If this table has multiple foreign keys, a foreign key column ID can be specified instead.]]> + This must be a parameter of type Discreet. The value of this column determines from which other table(s) additional information can be retrieved. + ]]>Specifies one of the possible discrete values.Contains additional tab definitions in the tree control.Defines an additional tab.Specifies the ID of the table this additional tab configuration relates to.Specifies the title description of the tab.Specifies the tab type.Specifies the columns to be hidden. + Rows from these tables will become items in the tree.]]> + When using a more advanced hierarchy, the table links can be defined using Table tags. In the hierarchy, the path attribute must be omitted or empty.]]>Specifies a condition.Specifies the parameter ID of the table that is needed in the tree.Specifies the parameter ID of the table that is the parent of the table specified in the id attribute.When no advanced hierarchy is needed, you can use this attribute to define the table links using a comma-separated list.Used to hide write controls for certain table columns.Used to override the display key or the index of a row by a different column of the same table. + The column must be a parameter of type Discreet and all discreet values must have an IconRef referring to an icon. If not, a default icon will be displayed.]]>Specifies the parameter ID of the tree control.If set to "true", disables all the write parameters in the tree control. Default: false. + In a trigger, you define when it should go off, and which actions it should execute.]]> + Triggers allow you to define the exact moment at which certain actions have to be executed.
+ They can, for example, be used to set the exact time at which to perform a copy operation, to calculate a CRC, etc.]]>
+ Recommendation: Do not include more than 10 items tags.]]>Specifies the ID of the action to be executed or the trigger to be activated when the trigger goes off.When a condition has been added to the trigger, the action of which the ID is specified in this attribute will be executed when the condition is not met.Specifies the name of the trigger. + This /Protocol/Triggers/Trigger/On element is always used when defining a trigger, except when the trigger has to be activated by another trigger.
+ In that case, the moment at which the trigger has to go off will already be defined in the initializing trigger. The /Protocol/Triggers/Trigger/Time element will then also be empty.]]>
+ If you do not specify an id attribute, the trigger will apply to all items of the type specified in the /Protocol/Triggers/Trigger/On element.]]>
+ Note: Not all /Protocol/Triggers/Trigger/Time values can be used in combination with the different /Protocol/Trig­gers/Trigger/On types.
+ Refer to the DataMiner Protocol Markup Language documentatio. for an overview of the possible combinations.]]>
Specifies the condition: equal, not equal, greater, less, or a logical combination of those operators. + If this attribute is omitted, the ID specified in /Protocol/Triggers/Trigger/On will be taken.]]>Set this attribute to "true" if the value attribute contains a parameter ID instead of a parameter value.Specifies the value that will be used as condition operand.
+ - execute one or more actions, or
+ - activate one or more triggers.]]>
Specifies the unique trigger ID.
The ID of a trigger must be unique.The name of a trigger must be unique.
Specifies the protocol type. In multi-connection protocols, it specifies the type of the main connection. + Protocol types have to be separated by semi-colon (";").
+ For more information on ports, see: /Protocol/Ports and /Protocol/Portsettings.]]>
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]> + For more information, refer to the DataMiner Protocol Markup Language documentation.]]>Specifies whether the DVE will go into timeout when the main element is in timeout. + *If the /Protocol/Timers/Timer@fixedTimer attribute is also set to "true", then users cannot change the timer interval.]]>
Specifies the name of the vendor of the monitored device. + This OID, to be provided either by the vendor of the device or (on request) by Skyline Communications, must be unique, as it is used to define MIB objects for all Elements using the protocol. + Typically, the vendor OID will start with the prefix 1.3.6.1.4.1, which identifies private enterprises.]]> + Within one DataMiner system, you can maintain different versions of the same protocol and assign them to different elements. If you have to make modifications to a protocol, do not create a completely new protocol.
+ Instead, make a new version of that same protocol.
+ Version can be a number (e.g. 1.0.0.3) or a string (e.g. "high power").
+ Tip: When you have two types of elements that are very similar (e.g. an optical transmitter: one with a high output power and another with a low output power), you can use the same protocol and create two + versions (e.g. version "high power" and version "low power" for the protocol "optical transmitter". The only difference between the two versions would then be e.g. the range settings for the "output power" parameter).]]>
+ Feature introduced in DataMiner 9.5.11 (RN 17697, RN 18360).]]>Provides information about a specific feature of this branch.Specifies the major changes this major change covers.Provides references to e.g. registration systems.Provides a reference to a corresponding task.Provides a reference to e.g. a registration system.Specifies the type of reference.List of all the suppressions for this version.A single suppression.Reason for the suppression.Location of the suppression.ID of the result that is being suppressed.Type of the suppression.Task ID.The ID of the minor versions for a specific major version must be unique.The ID of the major versions for a specific system version must be unique.Specifies the system version support.The ID of the system versions for a specific branch must be unique.The branch IDs must be unique.
+ In case a value is defined in this attribute, the protocol is considered a base protocol.]]>
Specifies the type of item on which the action is performed.Specifies the action type. + Feature introduced in DataMiner 8.5.3 (RN 9189).]]>Specifies the chains filter layout.Horizontal filter layout (Default).Vertical filter layout.Specifies the column option type.Auto-incremented value.Concatenates the values of the columns specified in the values attribute.Indicates that the content of the column will be managed in the protocol.DataMiner will automatically fill in this column with the display key.Used when retrieving SNMP or WMI tables. It contains the row number. + - To populate a column with a call to DataMiner using NotifyProtocol type 220 call (NT_FILL_ARRAY_WITH_COLUMN)
+ - To perform a merge action. + - To perform an aggregate action. + - To perform a swap action. + ]]>
Represents an SNMP column. + Possible values for this cell are: Updated (1), Equal (2), New (3), Deleted (4), Recreated (5)
+ With this column type, you can extend the options attribute with the value “delete”. If you do so, deleted rows will be automatically removed from the dynamic table. When you do not specify the “delete” option, deleted rows will stay in the table.]]>
+ This allows to retrieve the correct data from a direct view table if the tables in the source elements do not have unique primary keys.
+ Feature introduced in DataMiner 9.0.0 (RN 13582).]]>
Specifies the KPI value alignment.Aligns the KPI value to the left.Centers the KPI value.Aligns the KPI value to the right (default).Specifies the period used for database partitioning.HourDayMonthYearInfinite (Elastic only)Makes it possible to run a DLL at the click of a button.Used for buttons that open a URL, an element card, a view card or a service card.When used for buttons that set one or more session variables (which can be used in Visio drawings) to a particular value.Specifies the display type.Specifies the encoding.ACSII encodingUnicode encodingSpecifies the general parameter group type.Communication parametersDCF parametersReplication parametersVerification parametersSpecifies the group type.The group will be executed at once and run the action.The group will be added to the queue, awaiting execution. On execution, the parameters in the group will be retrieved.The group will be added to the queue, awaiting execution. On execution, the action will be run.The group will be added to the queue, awaiting execution. On execution the trigger will be fired.The group will be executed at once and fire the trigger.List of HTTP request headers.List of headers that can only appear in HTTP responses.The A-IM request-header field is similar to Accept, but restricts the instance-manipulations (section 10.1) that are acceptable in the response. As specified in section 10.5.2, a response may be the result of applying multiple instance-manipulations (RFC 3229).Indicates which content types (expressed as MIME types) the client is able to understand.Indicates which character set the client is able to understand.Indicates that the user agent wants to access a past state of an Original Resource.Indicates which content encoding, usually a compression algorithm, the client is able to understand.Can be used by a user agent to give information about the presence or absence of certain features in the feature set of the current request. Servers can use this information when running a remote variant selection algorithm (RFC 2295).Indicates which languages the client is able to understand, and which locale variant is preferred.Used when issuing a preflight request to let the server know which HTTP headers will be used when the actual request is made.Used when issuing a preflight request to let the server know which HTTP method will be used when the actual request is made. This header is necessary as the preflight request is always an OPTIONS and doesn't use the same method as the actual request.Lists the set of methods support by a resource.Clients include the ALPN header field in an HTTP CONNECT request to indicate the application-layer protocol that a client intends to use within the tunnel, or a set of protocols that might be used within the tunnel (RFC 7639).The optional Apply-To-Redirect-Ref header can be used on any request to a redirect reference resource. When it is present and set to "T", the request MUST be applied to the reference resource itself, and a 3xx response MUST NOT be returned (RFC 4437).Contains the credentials to authenticate a user agent with a server, usually after the server has responded with a 401 Unauthorized status and the WWW-Authenticate header. (RFC 2774).Specifies directives for caching mechanisms in both requests and responses. Caching directives are unidirectional, meaning that a given directive in a request is not implying that the same directive is to be given in the response.The "CalDAV-Timezones" request header field provides a way for a client to indicate to the server whether it wants "VTIMEZONE" components returned in any iCalendar data that is part of the HTTP response. The value "T" indicates that the client wants time zone data returned; the value "F" indicates that it does not.(RFC 7809).Allows a client to specify exactly what options it is asking about, and which allows a server to specify exactly what subset of those options are supported.Controls whether or not the network connection stays open after the current transaction finishes. If the value sent is keep-alive, the connection is persistent and not closed, allowing for subsequent requests to the same server to be done.The Content-Base entity-header field may be used to specify the base URI for resolving relative URLs within the entity. This header field is described as Base in RFC 1808, which is expected to be revised (RFC 2068). + In a multipart/form-data body, the HTTP Content-Disposition general header is a header that can be used on the subpart of a multipart body to give information about the field it applies to.]]>Used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body.Used to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users' own preferred language.Indicates the size of the entity-body, in bytes, sent to the recipient.Indicates an alternate location for the returned data.An MD5 digest of the entity-body for the purpose of providing an end-to-end message integrity check (MIC) of the entity-body (RFC 2616).Indicates the media type of the resource.Contains stored HTTP cookies previously sent by the server with the Set-Cookie header.(obsolete) Advises the server that the user agent understands "new-style" cookies.Contains the date and time at which the message was originated.The Depth request header is used with methods executed on resources that could potentially have internal members to indicate whether the method is to be applied only to the resource ("Depth: 0"), to the resource and its internal members only ("Depth: 1"), or the resource and all its members ("Depth: infinity") (RFC 4918).The Destination request header specifies the URI that identifies a destination resource for methods such as COPY and MOVE, which take two URIs as parameters (RFC 4918).Indicates expectations that need to be fulfilled by the server in order to properly handle the request.Contains information from the client-facing side of proxy servers that is altered or lost when a proxy is involved in the path of the request.Contains an Internet email address for a human user who controls the requesting user agent.Non-standard header field used by Microsoft applications and load-balancersSpecifies the domain name of the server (for virtual hosting), and (optionally) the TCP port number on which the server is listening.A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Settings header field. The HTTP2-Settings header field is a connection-specific header field that includes parameters that govern the HTTP/2 connection, provided in anticipation of the server accepting the request to upgrade. A server MUST NOT upgrade the connection to HTTP/2 if this header field is not present or if more than one is present. A server MUST NOT send this header field (RFC 7540).The If request header is intended to have similar functionality to the If-Match header defined in Section 14.24 of [RFC2616]. However, the If header handles any state token as well as ETags. A typical example of a state token is a lock token, and lock tokens are the only state tokens defined in this specification. (RFC 4918)For GET and HEAD methods, the server will send back the requested resource only if it matches one of the listed ETags. For PUT and other non-safe methods, it will only upload the resource in this case.The server will send back the requested resource, with a 200 status, only if it has been last modified after the given date.For GET and HEAD methods, the server will send back the requested resource, with a 200 status, only if it doesn't have an ETag matching the given ones. For other methods, the request will be processed only if the eventually existing resource's ETag doesn't match any of the values listed.If the condition is fulfilled, the range request will be issued and the server sends back a 206 Partial Content answer with the appropriate body. If the condition is not fulfilled, the full resource is sent back, with a 200 OK status.The If-Schedule-Tag-Match request header field is used with a method to make it conditional. Clients can set this header to the value returned in the Schedule-Tag response header, or the CALDAV:schedule-tag property, of a scheduling object resource previously retrieved from the server to avoid overwriting "consequential" changes to the scheduling object resource (RFC 6638).The server will send back the requested resource, or accept it in the case of a POST or another non-safe method, only if it has not been last modified after the given date. If the request has been modified after the given date, the response will be a 412 (Precondition Failed) error.Allows the sender to hint about how the connection may be used and to set a timeout and a maximum amount of requests.For certain methods (e.g. GET, PROPFIND), if the request-URL identifies a version-controlled resource, a label can be specified in a Label request header to cause the method to be applied to the version selected by that label from the version history of that version-controlled resource (RFC 3253).The Lock-Token request header is used with the UNLOCK method to identify the lock to be removed. The lock token in the Lock-Token request header MUST identify a lock that contains the resource identified by Request-URI as a member (RFC 4918).RFC 2774The Max-Forwards request-header field may be used with the TRACE method (section 14.31) to limit the number of proxies or gateways that can forward the request to the next inbound server. This can be useful when the client is attempting to trace a request chain which appears to be failing or looping in mid-chain (RFC 2068).Can contain directives for any content negotiation process initiated by the request. (RFC 2295).A non-compliance-option listed in a Non-Compliance response-header field indicates that the proxy server named by the proxy-host value does not support the listed compliance-option. The set of non-compliance options SHOULD be a subset of the compliance-options listed in a Compliance header field of the forwarded message.RFC 2774The Optional request-header allows a client to declare itself to support WIRE (https://tools.ietf.org/html/draft-girod-w3-id-res-ext-00).When a collection is created, the client MAY request that it be ordered and specify the semantics of the ordering by using the new Ordering-Type header (defined below) with a MKCOL request (RFC 3648).Indicates where a fetch originates from.The Overwrite request header specifies whether the server should overwrite a resource mapped to the destination URL during a COPY or MOVE (RFC 4918).When a new member is added to a collection with a client-maintained ordering (for example, with PUT, COPY, or MKCOL), its position in the ordering can be set with the new Position header (RFC 3648).An implementation-specific header that may have various effects along the request-response chain.The Prefer request header field is used to indicate that particular server behaviors are preferred by the client but are not required for successful completion of the request (RFC 7240).Used in implementation of OPS Over HTTP (https://www.w3.org/TR/NOTE-OPS-OverHTTP).PICS 1.1 Label Distribution - Label Syntax and Communication Protocols (https://www.w3.org/standards/history/REC-PICS-labels).Contains the credentials to authenticate a user agent to a proxy server, usually after the server has responded with a 407 Proxy Authentication Required status and the Proxy-Authenticate header.The proxy features header is used by a proxy sending data to a server. It specifies the features supported by the specified proxy. (https://www.w3.org/TR/WD-proxy).Indicates the part of a document that the server should return.Contains the address of the previous web page from which a link to the currently requested page was followed.The Resolution-Hint request-header can be used by a client to supply a resolution hint to the resolver (https://tools.ietf.org/html/draft-girod-w3-id-res-ext-00).The Schedule-Reply request header is used by a client to indicate to a server whether or not a scheduling operation ought to occur when an "Attendee" deletes a scheduling object resource. In particular, it controls whether a reply scheduling message is sent to the "Organizer" as a result of the removal (RFC 6638).The Sec-WebSocket-Key header field is used in the WebSocket opening handshake. It is sent from the client to the server to provide part of the information used by the server to prove that it received a valid WebSocket opening handshake. This helps ensure that the server does not accept connections from non-WebSocket clients (e.g., HTTP clients) that are being abused to send data to unsuspecting WebSocket servers (RFC 6455).The SOAPAction HTTP request header field can be used to indicate the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. An HTTP client MUST use this header field when issuing a SOAP HTTP Request (Simple Object Access Protocol (SOAP) 1.1).The SubOK request header field is used to provide directives from an end-client to a proxy cache regarding the possible substitution of an instance body from a cached response for one resource instance for the instance body of the resource instance specified by the client's request (https://tools.ietf.org/html/draft-mogul-http-dupsup-00).The Surrogate-Capabilities request header allows surrogates to advertise their capabilities with capability tokens. Capability tokens indicate sets of operations (e.g., caching, processing) that a surrogate is willing to perform (https://www.w3.org/TR/edge-arch/).Specifies the transfer encodings the user agent is willing to accept.Used with WebDAV. Clients may include Timeout headers in their LOCK requests. However, the server is not required to honor or even consider these requests. Clients MUST NOT submit a Timeout request header with any method other than a LOCK method (RFC 4918).Specifies the form of encoding used to safely transfer the entity to the user.Sends a signal to the server expressing the client’s preference for an encrypted and authenticated response, and that it can successfully handle the upgrade-insecure-requests CSP directive.Contains a characteristic string that allows the network protocol peers to identify the application type, operating system, software vendor or software version of the requesting software user agent.Gets added by proxies, both forward and reverse proxies, and can appear in the request headers and the response headers.Contains information about possible problems with the status of the message. More than one Warning header may appear in a response.Allows easier parsing of the MakeModel/Firmware that is usually found in the User-Agent String of AT&T DevicesHeader for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or a load balancer.Header for identifying the original host requested by the client in the Host HTTP request header.Header for identifying the protocol (HTTP or HTTPS) that a client used to connect to your proxy or load balancer. Links to an XML file on the Internet with a full description and details about the device currently connecting.List of HTTP response headers.List of headers that can only appear in HTTP responses.Specifies the patch document formats accepted by the server (RFC 5789).Advertises its support of partial requests.Indicates whether response to the request can be exposed to the page.Used in response to a preflight request to indicate which HTTP headers can be used during the actual request.Specifies the method or methods allowed when accessing the resource in response to a preflight request.Indicates whether the response can be shared with resources with the given origin.Indicates which headers can be exposed as part of the response by listing their names.Indicates how long the results of a preflight request (that is the information contained in the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers) can be cached.Contains the time in seconds the object has been in a proxy cache.Lists the set of methods support by a resource.Used to convey the list of variants bound to a negotiable resource (RFC 2295).The Authentication-Info header field can be used in any HTTP response, independently of request method and status code. Its semantics are defined by the authentication scheme indicated by the Authorization header field ([RFC7235], Section 4.2) of the corresponding request (RFC 7615). (RFC 2774).Used to indicate that all hop-by-hop mandatory extension declarations in the request were fulfilled (RFC 2774).Specifies directives for caching mechanisms in both requests and responses. Caching directives are unidirectional, meaning that a given directive in a request is not implying that the same directive is to be given in the response.Allows a client to specify exactly what options it is asking about, and which allows a server to specify exactly what subset of those options are supported.Controls whether or not the network connection stays open after the current transaction finishes. If the value sent is keep-alive, the connection is persistent and not closed, allowing for subsequent requests to the same server to be done.The Content-Base entity-header field may be used to specify the base URI for resolving relative URLs within the entity. This header field is described as Base in RFC 1808, which is expected to be revised (RFC 2068). + In a multipart/form-data body, the HTTP Content-Disposition general header is a header that can be used on the subpart of a multipart body to give information about the field it applies to.]]>Used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body.An MD5 digest of the entity-body for the purpose of providing an end-to-end message integrity check (MIC) of the entity-body (RFC 2616).Used to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users' own preferred language.Indicates the size of the entity-body, in bytes, sent to the recipient.Indicates an alternate location for the returned data.Indicates where in a full body message a partial message belongs.Specifies the default scripting language.Allows web site administrators to control resources the user agent is allowed to load for a given page.Allows web developers to experiment with policies by monitoring (but not enforcing) their effects. A single token specifying the type of encoding (RFC 2045).Indicates the media type of the resource.The DASL response header indicates server support for a query grammar in the OPTIONS method. The value is a URI that indicates the type of grammar. This header MAY be repeated (draft-ietf-dasl-protocol-00.txt).Contains the date and time at which the message was originated.Identifies a specific version of a resource.Contains the date/time after which the response is considered stale.Used to indicate that all end-to-end mandatory extension declarations in the request were fulfilled (RFC 2774).Used with implementation of OPS Over HTTP.The IM response-header field is used to indicate the instance-manipulations, if any, that have been applied to the instance represented by the response. Typical instance manipulations include delta encoding and compression (RFC 3229).Allows the sender to hint about how the connection and may be used to set a timeout and a maximum amount of requests.Tells the browser that the page being loaded is going to want to perform a large allocation.Contains the date and time at which the origin server believes the resource was last modified. It is used to determine if a resource received or stored is the same.Indicates the URL to redirect a page to. It only provides a meaning when served with a 3xx (redirection) or 201 (created) status response.The Lock-Token response header is used with the LOCK method to indicate the lock token created as a result of a successful LOCK request to create a new lock. (RFC 4918).RFC 2774The "Memento-Datetime" response header is used by a server to indicate that a response reflects a prior state of an Original Resource. Its value expresses the datetime of that state (RFC 7089).A non-compliance-option listed in a Non-Compliance response-header field indicates that the proxy server named by the proxy-host value does not support the listed compliance-option. The set of non-compliance options SHOULD be a subset of the compliance-options listed in a Compliance header field of the forwarded message.RFC 2774The P3P header gives one or more comma-separated directives (https://www.w3.org/2002/04/P3Pv1-header.txt).An implementation-specific header that may have various effects along the request-response chain.The Preference-Applied response header MAY be included within a response message as an indication as to which Prefer tokens were honored by the server and applied to the processing of a request (RFC 7240).Defines the authentication method that should be used to gain access to a resource behind a proxy server.The Proxy-Authentication-Info response header field is equivalent to Authentication-Info, except that it applies to proxy authentication ([RFC7235], Section 2) and its semantics are defined by the authentication scheme indicated by the Proxy-Authorization header field ([RFC7235], Section 4.4) of the corresponding request (RFC 7614).The proxy instruction header is used to reply to a proxy features header. It should only be present when a Proxy-Features header was present in the corresponding request (https://www.w3.org/TR/WD-proxy).The Public response-header field lists the set of methods supported by the server. The purpose of this field is strictly to inform the recipient of the capabilities of the server regarding unusual methods (RFC 2068).Associates a specific cryptographic public key with a certain web server to decrease the risk of MITM attacks with forged certificates. Sends reports of pinning violation to the report-uri specified in the header but, unlike Public-Key-Pins still allows browsers to connect to the server if the pinning is violated.The Redirect-Ref header is used in all 3xx responses from redirect reference resources. The value is the link target as specified during redirect reference resource creation (RFC 4437).Governs which referrer information, sent in the Referer header, should be included with requests made.The Resolver-Location header in a 350 response encodes this comma delimited set of bindings (https://tools.ietf.org/html/draft-girod-w3-id-res-ext-00).Indicates how long the user agent should wait before making a follow-up request. There are three main cases this header is used:The Safe response header field is used by origin servers to indicate whether repeating the received HTTP request is safe in the sense of Section 9.1.1 (Safe Methods) of the HTTP/1.1 specification [1] (RFC 2310).The Schedule-Tag response header provides the current value of the CALDAV:schedule-tag property value (RFC 6638).Contains information about the software used by the origin server to handle the request.The Sec-WebSocket-Accept header field is used in the WebSocket opening handshake. It is sent from the server to the client to confirm that the server is willing to initiate the WebSocket connection (RFC 6455).Used to send cookies from the server to the user agent.(Obsolete) Used to send cookies from the server to the user agent.Used with implementation of OPS Over HTTP (https://www.w3.org/TR/NOTE-OPS-OverHTTP).Links generated code to a source map, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.The Status header field contains a 3-digit integer result code that indicates the level of success of the script's attempt to handle the request. (RFC 3875).The Status-URI response header may be used with the 102 (Processing) status code to inform the client as to the status of a method (RFC 2518).The Subst response-header field MUST be used by a proxy to supply the URI of the original source of an entity-body, if the source is different from the client's Request-URI, and if the client's request included the ``inform'' directive in a SubOK request header field. Otherwise, a proxy MAY send a Subst response-header field, if it makes a substitution based on the information in a SubOK request header field (https://tools.ietf.org/html/draft-mogul-http-dupsup-00).The Surrogate-Control response header allows origin servers to dictate how surrogates should handle response entities, with control directives (https://www.w3.org/TR/edge-arch/).The TCN response header is used by a server to signal that the resource is transparently negotiated (RFC 2295).Specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions.Indicates the tracking status that applied to the corresponding request.Allows the sender to include additional fields at the end of chunked messages in order to supply metadata that might be dynamically generated while the message body is sent, such as a message integrity check, digital signature, or post-processing status.Specifies the form of encoding used to safely transfer the entity to the user.The Variant-Vary response header can be used in a choice response to record any vary information which applies to the variant data (the entity body combined with some of the entity headers) contained in the response, rather than to the response as a whole (RFC 2295).Determines how to match future request headers to decide whether a cached response can be used rather than requesting a fresh one from the origin server.Gets added by proxies, both forward and reverse proxies, and can appear in the request headers and the response headers.Defines the authentication method that should be used to gain access to a resource.Contains information about possible problems with the status of the message. More than one Warning header may appear in a response.Provides the duration of the audio or video in seconds.Content Security Policy definition.Marker used by the server to indicate that the MIME types advertised in the Content-Type headers should not be changed and be followed.Controls DNS prefetching, a feature by which browsers pro actively perform domain name resolution on both links that the user may choose to follow as well as URLs for items referenced by the document, including images, CSS, etc.Can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object>.Specifies the technology (e.g. ASP.NET, PHP, JBoss) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version).Recommends the preferred rendering engine (often a backward-compatibility mode) to use to display the content.Content Security Policy definition.A feature of Internet Explorer, Chrome and Safari that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks.List of headers that can both appear in HTTP requests and responses.Hop-by-Hop Extension Declaration (http://www.w3.org/TR/WD-http-pep).Hop-by-Hop Policy (http://www.w3.org/TR/WD-http-pep).The content identifier. Used with the HTTP Distribution and Replication Protocol (https://www.w3.org/TR/NOTE-drp-19970825).The Content-Version entity-header field defines the version tag associated with a rendition of an evolving entity. Together with the Derived-From field described in section 19.6.2.3, it allows a group of people to work simultaneously on the creation of a work as an iterative process. The field should be used to allow evolution of a particular work along a single path rather than derived works or renditions in different representations. (RFC 2068).The cost of retrieving the object is given. This is the cost of access of a copyright work, with a specification of the payment system accepted. Format to be specified. Currently refers to an unspecified charging scheme to be agreed out of band between parties (https://www.w3.org/Protocols/HTTP/Object_Headers.html#cost).When appearing in the response indicates that the resource supports the DAV schema and protocol as specified. As a request header, this header allows the client to advertise compliance with named features when the server needs that information (RFC 4918).The Delta-Base entity-header field is used in a delta-encoded response to specify the entity tag of the base instance (RFC 3229).The Derived-From entity-header field can be used to indicate the version tag of the resource from which the enclosed entity was derived before modifications were made by the sender. This field is used to help manage the process of merging successive changes to a resource, particularly when such changes are being made in parallel and from multiple sources (RFC 2068).Used with the HTTP Distribution and Replication Protocol (https://www.w3.org/TR/NOTE-drp-19970825).The Digest message header field provides a message digest of the instance described by the message (RFC 3230).The Want-Digest message header field indicates the sender's desire to receive an instance digest on messages associated with the Request-URI (RFC 3230).The EDIINT-Features header indicates the capability of the user agent to support the listed feature with its trading partner without out-of-band communication and agreement (RFC 6017).HTTP Origin-Bound Auth (HOBA) (RFC 7486).The Link entity-header field provides a means for serializing one or more links in HTTP headers (RFC 5988).The Meter header is used to carry zero or more directives (RFC 2227).Messages MAY include a single MIME-Version general-header field to indicate what version of the MIME protocol was used to construct the message (RFC 2616).Hop-by-Hop Extension Declaration (http://www.w3.org/TR/WD-http-pep).Hop-by-Hop Policy (http://www.w3.org/TR/WD-http-pep).PICS 1.1 Label Distribution -- Label Syntax and Communication Protocols (https://www.w3.org/standards/history/REC-PICS-labels).Joint Electronic Payment Initiative (https://www.w3.org/ECommerce/white-paper).Joint Electronic Payment Initiative (https://www.w3.org/ECommerce/white-paper).All S-HTTP compliant agents must generate the Security-Scheme header in the headers of all HTTP messages they generate. This header permits other agents to detect that they are communicating with an S-HTTP compliant agent and generate the appropriate cryptographic options header (RFC 2660).The |Sec-WebSocket-Extensions| header field is used in the WebSocket opening handshake. It is initially sent from the client to the server, and then subsequently sent from the server to the client, to agree on a set of protocol-level extensions to use for the duration of the connection (RFC 6455).The Sec-WebSocket-Protocol header field is used in the WebSocket opening handshake. It is sent from the client to the server and back from the server to the client to confirm the subprotocol of the connection. This enables scripts to both select a subprotocol and be sure that the server agreed to serve that subprotocol (RFC 6455).The Sec-WebSocket-Version header field is used in the WebSocket opening handshake. It is sent from the client to the server to indicate the protocol version of the connection. This enables servers to correctly interpret the opening handshake and subsequent data being sent from the data, and close the connection if the server cannot interpret that data in a safe manner. The Sec-WebSocket-Version header field is also sent from the server to the client on WebSocket handshake error, when the version received from the client does not match a version understood by the server. In such a case, the header field includes the protocol version(s) supported by the server (RFC 6455).Slug is an HTTP entity-header whose presence in a POST to a Collection constitutes a request by the client to use the header’s value as part of any URIs that would normally be used to retrieve the to-be-created Entry or Media Resources. Servers MAY use the value of the Slug header when creating the Member URI of the newly created Resource, for instance, by using some or all of the words in the value for the last URI segment (RFC 5023).The title of the document (https://www.w3.org/Protocols/HTTP/Object_Headers.html#title).https://tools.ietf.org/html/draft-mutz-http-attributes-00https://tools.ietf.org/html/draft-mutz-http-attributes-00https://tools.ietf.org/html/draft-mutz-http-attributes-00https://tools.ietf.org/html/draft-mutz-http-attributes-00https://tools.ietf.org/html/draft-mutz-http-attributes-00 + The URI header field has, in past versions of this specification, been used as a combination of the existing Location, Content-Location, and Vary header fields as well as the future Alternates field (above). Its primary purpose has been to include a list of additional URIs for the resource, including names and mirror locations. However, it has become clear that the combination of many different functions within this single field has been a barrier to consistently and correctly implementing any of those functions. Furthermore, we believe that the identification of names and mirror locations would be better performed via the Link header field. The URI header field is therefore deprecated in favor of those other fields (RFC 2068). + This is a string defining the version of an evolving object (https://www.w3.org/Protocols/HTTP/Object_Headers.html#z13).Specifies the HTTP login method.Credential-based authentication.Authentication using a client certificate. Feature introduced in DataMiner 10.0.5 (RN 25243).Specifies the HTTP request verb.Specifies the trap OID type.The resulting OID is the combination of VendorOID + DeviceOID + Param ID.The complete OID is specified in TrapOID.The resulting OID is the combination of VendorOID + DeviceOID + the value specified in TrapOID.When set to wildcard, you can use an asterisk (*) in the OID in order to capture all traps that match this OID.Specifies the OID type.The resulting OID is the combination of VendorOID + DeviceOID + Param ID.The resulting OID is the SNMP/OID value of this parameter.The resulting OID is the combination of VendorOID + DeviceOID + SNMP.OID value of this parameter.The resulting OID is the SNMP.OID value of this parameter prepended with the content of the parameter referred to by the id attribute.Specifies on or off.OnOffSpecifies the CRC type.Specifies the parameter group type.InIn-OutOutSpecifies the parameter information to include.The range of the parameter.The step size of the parameter. The last known change
The last time the parameter was changed by its write parameter (if any)]]>
The unit of the parameter.
Specifies the alignment.Left alignmentRight alignmentSpecifies the type of trimming.Remove leading whitespace.Remove trailing whitespace.Remove leading and trailing whitespace.Specifies the endian type.The bytes will be reversed.The bytes will not be reversed.Specifies the parameter interpret length type.The parameter has a fixed length, which has to be defined in the /Protocol/Params/Param/Interprete/Length element.The parameter has a variable length, which depends on the last instance of the next (fixed-length) parame­ter in the response.The parameter has a variable length, which depends on the next (fixed-length) parameter in the response.The length of the parameter will be inherited from another parameter.Specifies the parameter interpret raw type.Binary Code Decimal (BCD)DoubleNumeric textOnly othersOtherSigned numberTextUnsigned numberSpecifies the parameter interpret type.The parameter value will be processed as a number.The parameter value will be processed as the high nibble (i.e. first four bits) of a byte.The parameter value will be processed as an ASCII string.Specifies the parameter view type.Column chartPie chartRow chartStacked area chartSpecifies the parameter confirmation type.The confirmation popup will always appear, regardless of the value of the “Never ask for confirmation after setting parameter value” setting in DataMiner Cube.The confirmation popup will never appear, regardless of the value of the “Never ask for confirmation after setting parameter value” setting in DataMiner Cube.The confirmation popup will appear or not, depending on the value of the “Never ask for confirmation after setting parameter value” setting in DataMiner Cube.Specifies the parameter measurment type.Specifies the parameter measurement casing type.Lower caseUpper caseSpecifies the parameter type.Specifies the flow control type.No flow controlCTS (Clear to Send) RTS (Request to Send)CTS (Clear to Send) DTR (Data Terminal Ready)DSR (Data Set Ready) RTS (Request to Send)DSR (Data Set Ready) DTR (Data Terminal Ready)XON/XOFFSpecifies the parity.Even parityMark parityNo parityOdd paritySpace paritySpecifies the number of stop bits.Specifies the WebSocket message type.The message will be sent as binary data (Default).The message will be sent in plain text format using UTF-8 encoding.Specifies the slow poll base.The SlowPoll setting is a number of timeouts.The SlowPoll setting is a number of milliseconds.Specifies the protocol type.General Purpose Interface Bus (GPIB)Hypertext Transfer Protocol (HTTP)OLE Process Control (OPC)SerialSerial singleServiceService Level Agreement (SLA)Smart-serialSmart-serial singleSNMPSNMPv2SNMPv3VirtualSpecifies the relative timers type.If the interval is changed in the middle of the current interval, the timer will only be executed when the interval is completely finished.Each time the interval is changed the timer is executed instantly.Specifies the encoding of the QAction.JScriptVBScriptC#Specifies the QAction options string.Specifies the possible QAction options.If specified, all values in “inputParameters” are forwarded to the QAction as a byte array holding the raw content of the parameter.Compiles the QAction in debug mode. + [ProtocolName].[ProtocolVersion].QAction.[QactionID].dll
+ When you want the DLL file to include a meaningful name, enter that name in this options attribute.
+ This name will then replace the QAction.[QActionID] part.
+ For more information, refer to the DataMiner Protocol Markup Language documentation.]]>
When you specify this option, the “OldRow()” function will return the values retrieved by that group.Compiles the QAction immediately, without waiting for it to be triggered for execution.The QAction will be executed asynchronously. This implies that the QAction is triggered and set in the back­ground.
Specifies the rounding type.Specifies the scientific notation type.Displays the number using normalized scientific notation.Displays the number using engineering notation.Specifies the OID assignment type.The MIB will assign an OID to each parameter according to its number in the protocol.The MIB will not automatically create an OID for each parameter.Specifies the SNMP type.Represents a non-negative integer which monotonically increases until it reaches a maximum value of 2^32-1 (4294967295 decimal), when it wraps around and starts increasing again from zero.Represents a non-negative integer which monotonically increases until it reaches a maximum value of 2^64-1 (18446744073709551615 decimal), when it wraps around and starts increasing again from zero.Can be used to receive the SNMP counter64 as a string, where the counter64 uses double and may therefore lose definition. Introduced in DataMiner 8.5.4 (RN 9284).Represents a non-negative integer, which may increase or decrease, but shall never exceed a maximum value, nor fall below a minimum value. The maximum value can not be greater than 2^32-1 (4294967295 decimal), and the minimum value can not be smaller than 0.Represents integer-valued information between -2^31 and 2^31-1 inclusive.Represents integer-valued information between -2^31 and 2^31-1 inclusive.Represents an IP address.Represents an OSI address as a variable-length OCTET STRING.Indicates effective absence of a sequence element.Represents administratively assigned names.Represents arbitrary binary or textual data.A globally unique value associated with an object to unambiguously identify it.Provided solely for backward-compatibility, and shall not be used for newly-defined object types.Represents a non-negative integer which represents the time, modulo 2^32 (4294967296 decimal), in hundredths of a second between two epochs.The Unsigned32 type represents integer-valued information between 0 and 2^32-1 inclusive (0 to 4294967295 decimal).Specifies the trending type.Average value in the time span (default when no trending tag is present).Maximum value in the time span.Minimum value in the time span.Last value in the time span.Sum of all the values in the time span. This cannot be used for discreet parameters.Specifies the item on which the trigger triggers.Specifies the trigger time string.Specifies the trigger time.Specifies that the trigger will go off after the last retry. Feature introduced in DataMiner 8.5.2 (RN 8573).Specifies the type of items that will be executed when the trigger goes off.When the trigger goes off, the action(s) specified in /Protocol/Triggers/Trigger/Content will be executed.When the trigger goes off, the trigger(s) specified in /Protocol/Triggers/Trigger/Content will be activated.Specifies true and false values.TrueFalseSpecifies the display state.EnabledDisabledSpecifies the ownership access type.read-onlyread-writeSpecifies the port type.UDPIPRS-232Specifies the icon.Analyzer cardsApplicationArrow DownArrow UpASI PortATSCBackupCarrierConditional Access TableData PIDData CarouselDeviceDirect ConnectionDVBS CardEntitlement Control Message (Encrypted key for EMM)Event Information TableEntitlement Management MessageFixed InputFixed OutputGBE PortGeneralGeneral InputGeneral PIDGeneral ServiceGeneral Transport StreamGeneral Transport StreamIDP-OKIDP-NOKIDP-RunningIDP-UnknownInputInput and OutputInput Transport StreamBlue LED. Available from DataMiner 10.1.2 onwards (RN 28566).Cyan LED. Available from DataMiner 10.1.2 onwards (RN 28566).Lime LED. Available from DataMiner 10.1.2 onwards (RN 28566).Red LED. Available from DataMiner 10.1.2 onwards (RN 28566).Silver LED. Available from DataMiner 10.1.2 onwards (RN 28566).Yellow LED. Available from DataMiner 10.1.2 onwards (RN 28566).MainMatrixMIPMPEAudio PIDVideo PIDNew Item. Supported since DataMiner 10.0.13 (RN 28060).Network Information TableObject CarouselOutputOutput Transport StreamProgram Association TableProgram Clock ReferencePDPacketized Elementary StreamProgram Map TablePrimaryProcessorService of type RadioRectangle filled with color #FFF0F8FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFAEBD7. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00FFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF7FFFD4. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF0FFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF5F5DC. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFE4C4. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF000000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFEBCD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF0000FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF8A2BE2. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFA52A2A. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDEB887. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF5F9EA0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF7FFF00. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFD2691E. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF7F50. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF6495ED. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFF8DC. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDC143C. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00FFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00008B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF008B8B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFB8860B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFA9A9A9. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF006400. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFBDB76B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF8B008B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF556B2F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF8C00. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF9932CC. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF8B0000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFE9967A. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF8FBC8F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF483D8B. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF2F4F4F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00CED1. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF9400D3. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF1493. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00BFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF696969. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF1E90FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFB22222. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFAF0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF228B22. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF00FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDCDCDC. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF8F8FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFD700. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDAA520. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF808080. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF008000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFADFF2F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF0FFF0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF69B4. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFCD5C5C. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF4B0082. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFFF0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF0E68C. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFE6E6FA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFF0F5. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF7CFC00. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFACD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFADD8E6. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF08080. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFE0FFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFAFAD2. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFD3D3D3. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF90EE90. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFB6C1. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFA07A. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF20B2AA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF87CEFA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF778899. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFB0C4DE. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFFE0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00FF00. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF32CD32. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFAF0E6. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF00FF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF800000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF66CDAA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF0000CD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFBA55D3. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF9370DB. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF3CB371. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF7B68EE. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00FA9A. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF48D1CC. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFC71585. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF191970. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF5FFFA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFE4E1. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFE4B5. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFDEAD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF000080. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFDF5E6. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF808000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF6B8E23. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFA500. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF4500. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDA70D6. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFEEE8AA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF98FB98. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFAFEEEE. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDB7093. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFEFD5. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFDAB9. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFCD853F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFC0CB. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFDDA0DD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFB0E0E6. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF800080. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF0000. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFBC8F8F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF4169E1. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF8B4513. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFA8072. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF4A460. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF2E8B57. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFF5EE. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFA0522D. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFC0C0C0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF87CEEB. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF6A5ACD. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF708090. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFAFA. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF00FF7F. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF4682B4. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFD2B48C. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF008080. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFD8BFD8. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFF6347. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #00FFFFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF40E0D0. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFEE82EE. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF5DEB3. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFFFF. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFF5F5F5. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FFFFFF00. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).Rectangle filled with color #FF9ACD32. Supported since DataMiner 9.6.11/9.6.0 [CU5] (RN 22832).RSTSatelliteService Description TableSecondarySIStorage Cell EmptyStorage Cell FullStorage TapSubtitle PIDTime and Data TableTeletext PIDTransponderTransponder LeasedTrash can. Supported since DataMiner 10.0.13 (RN 28060).Service of type TelevisionVSATUnknownMajor Change SuppressionSpecifies a DataMiner version.9.5.1.0 - 60169.5.1.0 - 6060 - CU19.5.2.0 - 60999.5.2.0 - 6316 - CU19.5.0.0 - 64309.5.3.0 - 64879.5.0.0 - 6507 - CU19.5.4.0 - 65539.5.0.0 - 6578 - CU29.5.5.0 - 65879.5.6.0 - 66919.5.0.0 - 6712 - CU39.5.7.0 - 67629.5.0.0 - 6787 - CU49.5.8.0 - 68479.5.0.0 - 6905 - CU59.5.0.0 - 6943 - CU5 - R29.5.9.0 - 70109.5.0.0 - 7073 - CU69.5.0.0 - 7104 - CU6 - R29.5.10.0 - 71289.5.0.0 - 7177 - CU79.5.11.0 - 73089.5.12.0 - 73649.5.0.0 - 7380 - CU89.5.0.0 - 7538 - CU99.5.13.0 - 75779.5.14.0 - 77319.5.0.0 - 7607 - CU109.6.1.0 - 78399.5.0.0 - 8036 - CU11 Patch9.5.0.0 - 8068 - CU129.6.3.0 - 80929.6.4.0 - 81519.5.0.0 - 8237 - CU139.6.5.0 - 82509.6.0.0 - 82359.6.6.0 - 82709.6.0.0 - 8289 - CU19.6.7.0 - 83059.6.8.0 - 83669.6.0.0 - 8367 - CU29.5.0.0 - 8368 - CU159.5.0.0 - 8480 - CU169.6.9.0 - 84789.6.0.0 - 8482 - CU39.6.0.0 - 8578 - CU49.6.10.0 - 85809.6.11.0 - 86379.6.0.0 - 8638 - CU59.6.11.0 - 86499.6.12.0 - 86899.6.13.0 - 87479.6.0.0 - 8690 - CU69.6.0.0 - 8742 - CU79.6.0.0 - 8769 - CU89.6.13.0 - 8820 - CU110.0.2.0 - 887110.0.2.0 - 8898 - CU110.0.2.0 - 8924 - CU29.6.0.0 - 8937 - CU1010.0.3.0 - 8964 - CU110.0.4.0 - 90209.6.0.0 - 9027 - CU1110.0.4.0 - 9060 - CU19.6.0.0 - 9100 - CU1210.0.0.0 - 911810.0.4.0 - 9099 - CU210.0.5.0 - 91649.6.0.0 - 9175 - CU1310.0.0.0 - 9180 - CU110.0.6.0 - 919410.0.7.0 - 92479.6.0.0 - 9222 - CU1410.0.0.0 - 9237 - CU29.6.0.0 - 9351 - CU1610.0.0.0 - 9346 - CU410.0.8.0 - 93009.6.0.0 - 9282 - CU1510.0.0.0 - 9291 - CU310.0.0.0 - 9346 - CU410.0.9.0 - 93659.6.0.0 - 9450 - CU1710.0.0.0 - 9449 - CU510.0.10.0 - 94549.6.9.0 - 9590 - CU1910.0.0.0 - 9517 - CU610.0.11.0 - 95359.6.0.0 - 9516 - CU1810.0.0.0 – 9589 - CU710.0.12.0 - 96129.6.0.0 - 9727 - CU2010.0.0.0 - 9742 - CU810.0.13.0 - 974310.0.13.0 - 9784 - CU110.0.0.0 - 9808 - CU910.1.1.0 - 98149.6.0.0 - 9817 - CU2110.1.1.0 - 9843 - CU110.0.0.0 - 9857 - CU1010.1.2.0 - 98669.6.0.0 - 9944 - CU2210.1.0.0 - 9966 - CU010.0.0.0 - 9962 - CU1110.1.3.0 - 996310.0.0.0 - 10046 - CU1210.1.0.0 - 10049 - CU110.1.4.0 - 100779.6.0.0 - 10257 - CU2310.1.5.0 - 1022810.0.0.0 - 10226 - CU1310.1.0.0 - 10231 - CU210.0.0.0 - 10378 - CU1410.1.0.0 - 10368 - CU310.1.6.0 - 1036510.1.6.0 - 10426 - CU110.1.6.0 - 10449 - CU210.0.0.0 - 10516 - CU1510.1.7.0 - 1052310.1.0.0 - 10521 - CU1410.0.0.0 - 10596 - CU1610.1.0.0 - 10600 - CU1510.1.8.0 - 105989.6.0.0 - 10750 - CU2410.1.0.0 - 10813 - CU610.0.0.0 - 10770 - CU1710.1.9.0 - 1081410.1.0.0 - 10891 - CU710.0.0.0 - 10886 - CU1810.1.10.0 - 1089710.1.0.0 - 11030 - CU810.0.0.0 - 11025 - CU1910.1.11.0 - 1102710.1.11.0 - 11105 - CU110.1.0.0 - 11132 - CU910.0.0.0 - 11128 - CU2010.1.12.0 - 1112910.1.12.0 - 11182 - CU110.1.12.0 - 11212 - CU210.1.0.0 - 11229 - CU1010.0.0.0 - 11199 - CU2110.2.1.0 - 1124610.1.0.0 - 11319 - CU1110.2.2.0 - 1137110.1.0.0 - 11446 - CU1210.2.0.0 - 1151710.2.3.0 - 1151610.2.0.0 - 11674 - CU110.2..4.0 - 1167310.1.0.0 - 11679 - CU1410.2.0.0 - 11684 - CU210.2.5.0 - 1168110.2.5.0 - 11735 - CU110.1.0.0 - 11756 - CU1510.2.0.0 - 11774 - CU310.2.6.0 - 1180610.2.0.0 - 11897 - CU1410.1.0.0 - 11891 - CU1610.2.7.0 - 1192210.1.0.0 - 11971 - CU1710.2.0.0 - 11998 - CU510.2.8.0 - 1200510.2.9.0 - 1215410.2.0.0 - 12153 - CU610.1.0.0 - 12085 - CU1810.2.0.0 - 12184 - CU610.1.0.0 - 12183 - CU1810.2.9.0 - 12190 - CU110.1.0.0 - 12267 - CU2010.2.10.0 - 1224210.2.11.0 - 1233110.2.0.0 - 12334 - CU710.1.0.0 - 12371 - CU2010.2.0.0 - 12372 - CU810.2.11.0 - 12373 - CU110.1.0.0 - 12374 - CU2110.2.0.0 - 12391 - CU910.2.12.0 - 1241210.2.12.0 - 12434 - CU110.2.0.0 - 12501 - CU1010.3.1.0 - 1250910.2.12.0 12511 - CU210.2.0.0 - 12603 - CU1110.3.2.0 - 1262710.3.3.0 - 1275310.2.0.0 - 12706 - CU1210.3.0.0 - 1275210.3.0.0 - 1279010.3.3.0 - 12789 - CU110.2.0.0 - 12827 - CU1310.3.0.0 - 12822 - CU110.3.4.0 - 1285410.3.5.0 - 1293810.2.0.0 - 12926 - CU1410.3.0.0 - 12931 - CU2Specifies the allowed values for a Param item in a Group.Defines an unsigned integer that has no leading zeros.Represents a timer time.Represents a ping interval.Represents a port numberRepresents a retry count.Represents a slow poll value.Represents a semi-colon separated list of validator IDs.Represents a comma-separated list of numbers.Represents a semicolon-separated list of numbers.Represents a comma-separated list of numbers or the value "true".Represents a non empty string.Represents an empty string.Represents a vendor OID.Represents an unsigned integer or a number prefixed with "col:".Represents a number prefixed with "col:".Represents a wildcard (*) or a number.Represents a wildcard (*).*Represents the allowed values for the dllImport string.Represents a protocol version. + Default value: right.
+ Feature introduced in DataMiner 8.5.4.3 (RN 9430).]]>
+ Note: The ColumnOption elements have to be defined in order of their idx attribute.]]> + For more information about this attribute, refer to the DataMiner Protocol Markup Language documentation.
+ Note: In this attribute, you can specify multiple values separated by a character of choice (a semicolon is recommended).
+ This character has to be the first character in the value of the options attribute.
+ If, for example, you want to separate the different options by a semi-colon, the first character of the options value has to be a semi-colon.]]>
Specifies the parameter ID of the column data. + Feature introduced in DataMiner 9.5.6 (RN 16411).
+ Refer to the DataMiner Protocol Markup Language documentation for more information.]]>
Specifies column type options. For more information on the values allowed in this attribute, refer to the DataMiner Protocol Markup Language documentation. +- If type is "concatenation", then value is the comma-separated list of the indexes of the columns to be concatenated.
+- If type is "autoincrement", then value is the offset for the automatic increment of the indexes.]]>
Represents export rules.Defines a rule that are used for changing the displayed items in a Dynamic Virtual Element (DVE), for example changing the location of a parameter.Specifies the name of the export rule.Specifies a regular expression to match particular values.Specifies the ID of table parameter that will generate the DVEs.Specifies the XML element on which to apply this rule.Specifies the value that needs to be set. + If the whereAttribute is defined, the whereValue will be the indication to verify the attribute's value of the XML element defined by the whereTag.
+ If the whereAttribute is not defined, the whereValue will be the indication to verify the value of the XML element defined by the whereTag.
+ Example with a condition on the value of an attribute:
+ Example with a condition on the value of an XML element: ]]>
+ If the whereAttribute is defined, the whereValue will be the indication to verify the attribute's value of the XML element defined by the whereTag.
+ If the whereAttribute is not defined, the whereValue will be the indication to verify the value of the XML element defined by the whereTag.
+ Example with a condition on the value of an attribute:
+ Example with a condition on the value of an XML element: ]]>
+ If the whereAttribute is defined, the whereValue will be the indication to verify the attribute's value of the XML element defined by the whereTag.
+ If the whereAttribute is not defined, the whereValue will be the indication to verify the value of the XML element defined by the whereTag.
+ Example with a condition on the value of an attribute:
+ Example with a condition on the value of an XML element: ]]>
+ Alternatively, you can put this data in parameters, which you should then specify in the Parameters element.]]> + Note: either use this attribute (and provide the data to be sent in the referred parameter) or specify the data to be sent in Data (e.g. data.]]> + Via HTTP, this has to be done by means of key/value pairs.]]>Specifies the key of the key/value pair. + If you do not specify the pid attribute, you have to provide a fixed value in the Header element.]]> + Via HTTP, this has to be done by means of key/value pairs.]]>Specifies the key of the key/value pair. + If you do not specify the pid attribute, you have to provide a value in the Parameter element.]]>Represents an icon. + Using this attribute in a table or table column parameter will display an icon in the tree control.]]>Defines a ping interval.Specifies the default ping interval in milliseconds. The specified value must be in the range [1000,300000] and should be a multiple of 1000 as the resolution is in seconds.Specifies whether the ping interval can be modified in the DataMiner user interface.Defines a slow poll configuration.Specifies the default slow poll settings.Specifies whether the slow poll settings can be modified in the DataMiner user interface.Defines a slow poll base.Specifies the default slow poll base.Specifies whether the slow poll settings can be modified in the DataMiner user interface.Defines user settings.Defines port settings.Defines a range of possible baud rate settings.Specifies the last of a range of baud rates. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
+ For SNMPv3, this contains the User Name.]]>Specifies whether the databits can be modified in the DataMiner user interface.Defines a range of possible databit settings.Specifies the first of a range of databits.Specifies the last of a range of databits. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
+ For SNMPv3, this contains the Encryption Algorithm.]]>Specifies whether the flow control can be modified in the DataMiner user interface.Defines the range of possible flow control values.Specifies the first of a range of flow control values.Specifies the last of a range of flow control values. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
When set to true, any datagram received on the connection will be forwarded to SLProtocol immediately, which will then store it in the response parameter. Only applicable for a smart-serial UDP connection. + GetCommunity string for SNMP and SNMPv2 communication.
+ For SNMPv3, this contains the Authentication Password]]>
Specifies the default value of the GetCommunity string that will be used in the DataMiner user interface for SNMP protocols.Specifies whether the get community string can be modified in the DataMiner user interface.
Specifies the IP port configuration.Specifies the default port number.Specifies whether the port number can be configured via the DataMiner user interface.Specifies the local IP port configuration.Specifies the default local port number.Specifies whether the local port number can be configured via the DataMiner user interface. + For SNMPv3, this contains the Authentication Algorithm.]]>Specifies the default parity.Specifies whether the parity can be modified in the DataMiner user interface.Defines the range of possible parity values.Specifies the first of a range of parity values.Specifies the last of a range of parity values. + Note:
+ - The value specified in DefaultValue does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in DefaultValue.]]>
Configures the ping interval.Specifies settings related to the TCP/IP port type.Specifies whether the port type TCP/IP can be selected in the DataMiner user interface.Specifies settings related to the serial port type.Specifies whether the port type serial can be selected in the DataMiner user interface.Specifies settings related to the UDP/IP port type.Specifies whether the port type UDP/IP can be selected in the DataMiner user interface.Configures the number of retries.Specifies the default value for the maximum number of times that a request will be re-sent.Specifies whether the maximum number of retries can be modified in the DataMiner user interface. + For SNMPv3, this contains the Encryption Password.]]>Specifies the default value of the SNMP set community string that will be used.Specifies whether the SetCommunity string can be modified in the DataMiner user interface. + Feature introduced in DataMiner 9.5.9 (RN 17732).]]>Specifies the SSH credentials.Specifies the user name.Specifies the ID of the parameter that holds the user name.Specifies the password.Specifies the ID of the parameter that holds the password.Specifies the identity settings.Specifies the ID of the parameter that holds the identity info. + For SNMPv3, this contains the Security Level.]]> + Set the default to one of the following integer values: 1, 1.5 or 2]]>Specifies whether the number of stop bits can be modified in the DataMiner user interface. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ Set Value to one of the following integer values: 1, 1.5 or 2]]>
Specifies settings related to the element timeout.Specifies the default element timeout value (in milliseconds). The specified value must be in the range [1000, 120000] and should be a multiple of 1000 as the resolution is in seconds.Specifies whether the element timeout time for this connection can be configured via the DataMiner user interface.Specifies settings related to the timeout of a command/request.Specifies the default timeout value (in milliseconds).Specifies whether the timeout value can be modified in the DataMiner user interface.Specifies the port type settings.Specifies the default port type.
If set to “false”, users cannot see or change the port settings for this additional protocol type when creating or editing an element.
Defines main port settings.Defines a range of possible baud rate settings.Specifies the last of a range of baud rates. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]>Specifies whether the bus address can be modified in the DataMiner user interface.Defines a range of possible bus addresses.Specifies the first of a range of bus addresses.Specifies the last of a range of bus addresses. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
+ For SNMPv3, this contains the User Name.]]>Specifies whether the databits can be modified in the DataMiner user interface.Defines a range of possible databit settings.Specifies the first of a range of databits.Specifies the last of a range of databits. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
+ For SNMPv3, this contains the Encryption Algorithm.]]>Specifies whether the flow control can be modified in the DataMiner user interface.Defines the range of possible flow control values.Specifies the first of a range of flow control values.Specifies the last of a range of flow control values. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.]]>
When set to true, any datagram received on the connection will be forwarded to SLProtocol immediately, which will then store it in the response parameter. Only applicable for a smart-serial UDP connection. + GetCommunity string for SNMP and SNMPv2 communication.
+ For SNMPv3, this contains the Authentication Password]]>
Specifies the default value of the GetCommunity string that will be used in the DataMiner user interface for SNMP protocols.Specifies whether the get community string can be modified in the DataMiner user interface.
Specifies the IP port configuration.Specifies the default port number.Specifies whether the port number can be configured via the DataMiner user interface.Specifies the local IP port configuration.Specifies the default local port number.Specifies whether the local port number can be configured via the DataMiner user interface. + For SNMPv3, this contains the Authentication Algorithm.]]>Specifies the default parity.Specifies whether the parity can be modified in the DataMiner user interface.Defines the range of possible parity values.Specifies the first of a range of parity values.Specifies the last of a range of parity values. + Note:
+ - The value specified in DefaultValue does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in DefaultValue.]]>
Configures the ping interval.Specifies settings related to the TCP/IP port type.Specifies whether the port type TCP/IP can be selected in the DataMiner user interface.Specifies settings related to the serial port type.Specifies whether the port type serial can be selected in the DataMiner user interface.Specifies settings related to the UDP/IP port type.Specifies whether the port type UDP/IP can be selected in the DataMiner user interface.Configures the number of retries.Specifies the default value for the maximum number of times that a request will be re-sent.Specifies whether the maximum number of retries can be modified in the DataMiner user interface. + For SNMPv3, this contains the Encryption Password.]]>Specifies the default value of the SNMP set community string that will be used.Specifies whether the SetCommunity string can be modified in the DataMiner user interface.Specifies the slow poll configuration.Specifies the slow poll base settings. + Feature introduced in DataMiner 9.5.9 (RN 17732).]]>Specifies the SSH credentials.Specifies the user name.Specifies the ID of the parameter that holds the user name.Specifies the password.Specifies the ID of the parameter that holds the password.Specifies the identity settings.Specifies the ID of the parameter that holds the identity info. + For SNMPv3, this contains the Security Level.]]> + Set the default to one of the following integer values: 1, 1.5 or 2]]>Specifies whether the number of stop bits can be modified in the DataMiner user interface. + Note:
+ - The value specified in the DefaultValue element does not have to be specified in a Value element.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in the DefaultValue element.
+ Set Value to one of the following integer values: 1, 1.5 or 2]]>
Specifies settings related to the element timeout.Specifies the default element timeout value (in milliseconds). The specified value must be in the range [1000, 120000] and should be a multiple of 1000 as the resolution is in seconds.Specifies whether the element timeout time for this connection can be configured via the DataMiner user interface.Specifies settings related to the timeout of a command/request.Specifies the default timeout value (in milliseconds).Specifies whether the timeout value can be modified in the DataMiner user interface.Specifies the port type settings.Specifies the default port type.
Defines port settings with values. + Note:
+ - The value specified in the DefaultValue tag does not have to be specified in a Value tag.
+ - When no Value tags are specified, users will only be allowed to enter the value specified in the DefaultValue tag.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ As a bus address is not always needed, the default value can also be set to "false". In that case, it will not be possible to specify a bus address.]]> + Note:
+ - The value specified in the DefaultValue tag does not have to be specified in a Value tag.
+ - When no Value tags are specified, users will only be allowed to enter the value specified in the DefaultValue tag.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ For SNMPv3, this contains the User Name.]]> + Note:
+ - The value specified in the DefaultValue tag does not need to defined here again.
+ - When no Value elements are specified, users will only be allowed to enter the value specified in DefaultValue.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ For SNMPv3, this contains the Encryption Algorithm.]]> + Note:
+ - The value specified in the DefaultValue tag does not have to be specified in a Value tag.
+ - When no Value tags are specified, users will only be allowed to enter the value specified in the DefaultValue tag.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ For SNMPv3, this contains the Authentication Password]]>Specifies settings related to the port.Specifies the default port number.Specifies whether the user is be able to set the port number.Specifies settings related to the local port.Specifies the default local port number.Specifies whether the user is able to set the local port number. + For SNMPv3, this contains the Authentication Algorithm.]]> + Note:
+ - The value specified in the DefaultValue tag does not have to be specified in a Value tag.
+ - When no Value tags are specified, users will only be allowed to enter the value specified in the DefaultValue tag.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ For SNMPv3, this contains the Encryption Password.]]> + For SNMPv3, this contains the Security Level.]]> + Set the default to one of the following integer values: 1, 1.5 or 2]]> + Note:
+ - The value specified in the DefaultValue tag does not have to be specified in a Value tag.
+ - When no Value tags are specified, users will only be allowed to enter the value specified in the DefaultValue tag.
+ The following wildcards can be used: * (a series of characters) and ? (one single character)]]>
+ OR
+ The name of the additional Protocol type as specified in the /Protocol/Type@advanced attribute.]]>
Specifies how a cell in a CPE topology is linked to another cell in that topology, using foreign key relations (which can also be inside the same table).(CPE) Specifies the ID of the parameter column if you want to make a topology with foreign key relations inside a table.Configures chain display settings.Specifies the values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies one of the possible values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies the default visibility when none of the conditions are met (Default: true).Configures chain display settings.Specifies the values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies one of the possible values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies the default visibility when none of the conditions are met (Default: true).Configures chain field display settings.Specifies the values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies one of the possible values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies the default visibility when none of the conditions are met (Default: true).Defines a field to be included in this tab of the search chain.Defines possible substitutions to be applied to the field content.Defines a substitution to be applied on the field content.Defines a substitution based on a regular expression.Specifies the regular expression defining the pattern of the field content.Defines the output after substitution.Defines field validation.Defines the error message to be displayed in case the input is invalid.Defines the regular expression defining the pattern of allowed field content.Specifies the column parameter ID of a column of the table referred to by the tablePid attribute of the enclosing Tab, or a column of a table that is linked with this table.Specifies the name of the search field.Configures chain field display settings.Specifies the values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies one of the possible values the specified parameter must have to toggle the visibility to the opposite setting of the one defined in the default attribute.Specifies the default visibility when none of the conditions are met (Default: true).Each field in a chain is a possible block in the drill-down diagram displayed on the visual pages of a CPE Manager. + Feature introduced in DataMiner 9.5.1 (RN 14442, RN 14468).]]> + Feature introduced in DataMiner 9.5.1 (RN 14442, RN 14468).]]> + Feature introduced in DataMiner 9.5.1 (RN 14442, RN 14468).
+ Refer to the DataMiner Protocol Markup Language documentation for more information.]]>
Specifies the name of the block in the drill-down diagram. + Refer to the DataMiner Protocol Markup Language documentation for an overview of the available options.]]> + From DataMiner 8.0.1 onwards (RN 5828), it is also possible to configure pid="0", in case you wish to dis­play lists when no filter is selected.]]>
Defines a topology, representing the connections in a diagram displayed in a CPE manager.Specifies a cell within a CPE topology.Specifies how a cell in a CPE topology is linked to another cell in that topology, using foreign key relations (which can also be inside the same table).(CPE) Specifies the ID of the parameter column if you want to make a topology with foreign key relations inside a table.Specifies the name of the cell.Specifies a number of options (Deprecated).Specifies the table parameter to which the cell is linked.Specifies the name of the topology (Service Overview Manager only).List of Process Automation Option names.Specifies the default values in the alarm template.List of Process Automation Option names that can be used.Current Queue Size.Maximum Queue Size.List of types that can be used as value in the matrix mapping.Parameter ID.List of options that can be used as type in the matrix mapping.Indicates the index of the input.Indicates the label of the input.Indicates the state of the input.Indicates the lock state of the input.Indicates the page on which the input is located.List of options that can be used as type in the matrix mapping.Indicates the index of the output.Indicates the label of the output.Indicates the state of the output.Indicates the lock state of the output.Indicates the page on which the output is located.Indicates the input on which the output is connected.Indicates the tooltip of the output which is shown on the crosspoint.Indicates the lock override of the output. This can be used to (un)set a crosspoint while locked.List of types that can be used in the matrix option type.A value without a link to components of the protocol.List of types that can be used in the matrix option name.Indicates to position inputs or outputs at the top or on the left. Note: For table matrices, the only supported values are 'InputTopOutputLeft' or 'InputLeftOutputTop'.Indicates to enable auto-paging. Note: custom pages can be set via the page column on the table.Indicates the minimum of connected inputs for an output. Note: 0 for no minimum.Indicates the maximum of connected inputs for an output. Note: Always 1 for table matrices.Indicates the minimum of connected outputs for an input. Note: 0 for no minimum.Indicates the maximum of connected outputs for an input. Note: auto for no maximum.
\ No newline at end of file diff --git a/Skyline.DataMiner.CICD.Validators.sln b/Skyline.DataMiner.CICD.Validators.sln index 013dccfa..38cc520c 100644 --- a/Skyline.DataMiner.CICD.Validators.sln +++ b/Skyline.DataMiner.CICD.Validators.sln @@ -7,9 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "Common\Common.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonTests", "CommonTests\CommonTests.csproj", "{F760B82D-32DB-4E92-BE56-AF7851D613F0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Protocol", "Protocol\Protocol.csproj", "{6FC9147E-BC54-423B-8944-4DD0FB6C8D67}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protocol", "Protocol\Protocol.csproj", "{6FC9147E-BC54-423B-8944-4DD0FB6C8D67}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Protocol.Features", "Protocol.Features\Protocol.Features.csproj", "{F0CFD8E3-CD0F-44CC-8084-D0A7763ACFB6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protocol.Features", "Protocol.Features\Protocol.Features.csproj", "{F0CFD8E3-CD0F-44CC-8084-D0A7763ACFB6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protocol.FeaturesTests", "Protocol.FeaturesTests\Protocol.FeaturesTests.csproj", "{0FFE732D-8E87-49BE-851A-F712FA9D3C2D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProtocolTests", "ProtocolTests\ProtocolTests.csproj", "{42E0CF2D-0C8F-4684-B558-CA9B21F511A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Testing", "Common.Testing\Common.Testing.csproj", "{35C04876-E62F-4114-B18B-161442AF71DC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProtocolTests.SchemaGenerator", "ProtocolTests.SchemaGenerator\ProtocolTests.SchemaGenerator.csproj", "{A3278AF2-05A5-4953-9746-2821B4D07740}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +41,22 @@ Global {F0CFD8E3-CD0F-44CC-8084-D0A7763ACFB6}.Debug|Any CPU.Build.0 = Debug|Any CPU {F0CFD8E3-CD0F-44CC-8084-D0A7763ACFB6}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0CFD8E3-CD0F-44CC-8084-D0A7763ACFB6}.Release|Any CPU.Build.0 = Release|Any CPU + {0FFE732D-8E87-49BE-851A-F712FA9D3C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FFE732D-8E87-49BE-851A-F712FA9D3C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FFE732D-8E87-49BE-851A-F712FA9D3C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FFE732D-8E87-49BE-851A-F712FA9D3C2D}.Release|Any CPU.Build.0 = Release|Any CPU + {42E0CF2D-0C8F-4684-B558-CA9B21F511A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42E0CF2D-0C8F-4684-B558-CA9B21F511A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42E0CF2D-0C8F-4684-B558-CA9B21F511A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42E0CF2D-0C8F-4684-B558-CA9B21F511A1}.Release|Any CPU.Build.0 = Release|Any CPU + {35C04876-E62F-4114-B18B-161442AF71DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35C04876-E62F-4114-B18B-161442AF71DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35C04876-E62F-4114-B18B-161442AF71DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35C04876-E62F-4114-B18B-161442AF71DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A3278AF2-05A5-4953-9746-2821B4D07740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3278AF2-05A5-4953-9746-2821B4D07740}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3278AF2-05A5-4953-9746-2821B4D07740}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3278AF2-05A5-4953-9746-2821B4D07740}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE