diff --git a/src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs b/src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs index dd0bffb..278a06c 100644 --- a/src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs +++ b/src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2024, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; using System.Reflection; using Moryx.AbstractionLayer; using Moryx.ControlSystem.Cells; @@ -133,5 +136,19 @@ private static VisualInstruction[] GetInstructions(ActivityStart activity) return parameters.Instructions; } + + /// + /// Returns a text instruction for the given string. + /// + /// Instruction text + /// with type `Text` the given string as content + public static VisualInstruction AsInstruction(this string text) + { + return new VisualInstruction + { + Content = text, + Type = InstructionContentType.Text, + }; + } } } diff --git a/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs b/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs new file mode 100644 index 0000000..b7e0ac6 --- /dev/null +++ b/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2024, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using Moq; +using Moryx.ControlSystem.VisualInstructions; +using NUnit.Framework; +using System; + +namespace Moryx.ControlSystem.Tests.VisualInstructions +{ + [TestFixture] + + public class VisualInstructorExtensionsTests + { + [Test] + public void ExtensionCreatesStringAsInstruction() + { + var str = "text instruction"; + + var instruction = str.AsInstruction(); + + Assert.That(instruction.Type, Is.EqualTo(InstructionContentType.Text)); + Assert.That(instruction.Content, Is.EqualTo(str)); + } + + } +}