diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3d5371 --- /dev/null +++ b/.gitignore @@ -0,0 +1,323 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# TypeScript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + diff --git a/OnScreenKeyboard.sln b/OnScreenKeyboard.sln new file mode 100644 index 0000000..6092abc --- /dev/null +++ b/OnScreenKeyboard.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2024 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnScreenKeyboard", "OnScreenKeyboard\OnScreenKeyboard.csproj", "{9CEB7FEC-6F4F-4B77-A206-CF26E06724BF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnScreenKeyboardTests", "OnScreenKeyboardTests\OnScreenKeyboardTests.csproj", "{2A9ADA85-7A95-4B78-98E2-A4CFC2177674}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9CEB7FEC-6F4F-4B77-A206-CF26E06724BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CEB7FEC-6F4F-4B77-A206-CF26E06724BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CEB7FEC-6F4F-4B77-A206-CF26E06724BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CEB7FEC-6F4F-4B77-A206-CF26E06724BF}.Release|Any CPU.Build.0 = Release|Any CPU + {2A9ADA85-7A95-4B78-98E2-A4CFC2177674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A9ADA85-7A95-4B78-98E2-A4CFC2177674}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A9ADA85-7A95-4B78-98E2-A4CFC2177674}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A9ADA85-7A95-4B78-98E2-A4CFC2177674}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D2CED830-FA83-4935-8EC2-78EEFF4655FF} + EndGlobalSection +EndGlobal diff --git a/OnScreenKeyboard/App.config b/OnScreenKeyboard/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/OnScreenKeyboard/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OnScreenKeyboard/Input.cs b/OnScreenKeyboard/Input.cs new file mode 100644 index 0000000..894765f --- /dev/null +++ b/OnScreenKeyboard/Input.cs @@ -0,0 +1,24 @@ +using System; + +namespace SoftWriters { + public class Input { + public static Input UP = new Input("UP", keyboard => keyboard.MoveCursor(new Position(0, 1))); + public static Input DOWN = new Input("DOWN", keyboard => keyboard.MoveCursor(new Position(0, -1))); + public static Input LEFT = new Input("LEFT", keyboard => keyboard.MoveCursor(new Position(-1, 0))); + public static Input RIGHT = new Input("RIGHT", keyboard => keyboard.MoveCursor(new Position(1, 0))); + public static Input SPACE = new Input("SPACE", keyboard => keyboard.AddSpace()); + public static Input SELECT = new Input("SELECT", keyboard => keyboard.AddKeyAtCursor()); + + private string name; + private Action keyboardAction; + + public Input(string name, Action keyboardAction) { + this.name = name; + this.keyboardAction = keyboardAction; + } + + public void Trigger(Keyboard keyboard) { + keyboardAction(keyboard); + } + } +} diff --git a/OnScreenKeyboard/Keyboard.cs b/OnScreenKeyboard/Keyboard.cs new file mode 100644 index 0000000..ea94b50 --- /dev/null +++ b/OnScreenKeyboard/Keyboard.cs @@ -0,0 +1,59 @@ +namespace SoftWriters { + public class Keyboard { + public static string[] KeyLayout { get; } = new string[] { + "ABCDEF", + "GHIJKL", + "MNOPQR", + "STUVWX", + "YZ1234", + "567890" + }; + + public static int ColumnCount = KeyLayout[0].Length; + public static int RowCount = KeyLayout.Length; + + // In a real application, the Keyboard wouldn't hold the text + // but would likely pass keys to another class that would build up a string + // (e.g., something like Reactive Extensions for event passing) + public string Text { get; set; } + + private Position InitialPosition = new Position(0, 0); + private Position cursor; + + public Keyboard() { + Reset(); + } + + public void Reset() { + cursor = InitialPosition; + Text = ""; + } + + // Handles wrap-around cases + public void MoveCursor(Position movement) { + // Since origin is in upper-left corner, all Y values are <= 0 and + // all X values are >= 0. Therefore, Y wrap-around check subtracts the RowCount, to ensure + // value is in range and negative + cursor = new Position( + (cursor.X + movement.X + ColumnCount) % ColumnCount, + (cursor.Y + movement.Y - RowCount) % RowCount + ); + } + + public void AddKeyAtCursor() { + Text += keyFromPosition(cursor); + } + + private char keyFromPosition(Position position) { + // Since the origin point is the upper-left corner, all Y values are <= 0. + // Invert Y before accessing correct row. + return KeyLayout[-position.Y][position.X]; + } + + public void AddSpace() { + Text += " "; + } + } + +} + diff --git a/OnScreenKeyboard/KeyboardPathGenerator.cs b/OnScreenKeyboard/KeyboardPathGenerator.cs new file mode 100644 index 0000000..f79c135 --- /dev/null +++ b/OnScreenKeyboard/KeyboardPathGenerator.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace SoftWriters { + public class KeyboardPathGenerator { + private static Regex validInputCharacter = new Regex("[a-zA-Z0-9]", RegexOptions.Compiled); + private static Dictionary keyPositions = generateLookupTable(); + private Position InitialPosition = new Position(0, 0); + private Position cursor; + + + public KeyboardPathGenerator() { + Reset(); + } + + public void Reset() { + cursor = InitialPosition; + } + + public string GenerateShorthandFrom(string testCase) { + Reset(); + if(testCase == "") { + return ""; + } + + List shorthand = new List(); + for(var i = 0; i < testCase.Length; i++) { + var character = toUpperCase(testCase[i]); + if (character == ' ') { + shorthand.Add("S"); + } + else if (!validInputCharacter.IsMatch(character.ToString())) { + return "Invalid input: " + testCase; + } + else { + shorthand.Add(shorthandForMoveTo(character)); + } + } + + return String.Join(",", shorthand); + } + + //Assumes validated input + private string shorthandForMoveTo(char character) { + var characterPosition = keyPositions[character]; + var distance = characterPosition - cursor; + + cursor = characterPosition; + + var shorthand = ""; + if(distance.Y > 0) { + shorthand += optimizedDirection('D', 'U', distance.Y, Keyboard.RowCount); + } + else if(distance.Y < 0) { + shorthand += optimizedDirection('U', 'D', -distance.Y, Keyboard.RowCount); + } + if(distance.X > 0) { + shorthand += optimizedDirection('R', 'L', distance.X, Keyboard.ColumnCount); + } + else if(distance.X < 0) { + shorthand += optimizedDirection('L', 'R', -distance.X, Keyboard.ColumnCount); + } + + if (shorthand == "") { + return "#"; + } + else { + return String.Join(",", shorthand.ToCharArray()) + ",#"; + } + } + + + private string optimizedDirection(char forward, char backward, int distance, int dimensionSize) { + if (distance == 0) return ""; + + if(distance <= dimensionSize / 2.0) { + return new string(forward, distance); + } + else { + return new string(backward, dimensionSize - distance); + } + } + + // Assumes character is on keyboard + private static Dictionary generateLookupTable() { + var table = new Dictionary(); + for(var i = 0; i < Keyboard.RowCount; i++) { + for(var j = 0; j < Keyboard.ColumnCount; j++) { + // Positions are x,y, so positions use j,i indexes + table.Add(Keyboard.KeyLayout[i][j], new Position(j, i)); + } + } + return table; + } + + private static char toUpperCase(char character) { + return character.ToString().ToUpper()[0]; + } + } +} diff --git a/OnScreenKeyboard/OnScreenKeyboard.csproj b/OnScreenKeyboard/OnScreenKeyboard.csproj new file mode 100644 index 0000000..c86d0ef --- /dev/null +++ b/OnScreenKeyboard/OnScreenKeyboard.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {9CEB7FEC-6F4F-4B77-A206-CF26E06724BF} + Exe + SoftWriters + SoftWriters + v4.6.1 + 512 + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + SoftWriters.Program + + + + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/OnScreenKeyboard/Position.cs b/OnScreenKeyboard/Position.cs new file mode 100644 index 0000000..51792dd --- /dev/null +++ b/OnScreenKeyboard/Position.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SoftWriters { + public class Position { + public int X {get;set; } + public int Y {get;set; } + + public Position(int x, int y) { + X = x; + Y = y; + } + + public static Position operator +(Position a, Position b) { + return new Position(a.X + b.X, a.Y + b.Y); + } + + public static Position operator -(Position a, Position b) { + return new Position(a.X - b.X, a.Y - b.Y); + } + } +} diff --git a/OnScreenKeyboard/Program.cs b/OnScreenKeyboard/Program.cs new file mode 100644 index 0000000..e82abeb --- /dev/null +++ b/OnScreenKeyboard/Program.cs @@ -0,0 +1,25 @@ +using System.IO; +using System.Threading; + +namespace SoftWriters { + public class Program { + static void Main(string[] args) { + if(args.Length == 0) { + System.Console.WriteLine("Usage: "); + } + + var keyboardPathGenerator = new KeyboardPathGenerator(); + try { + var testCases = File.ReadAllLines(args[0]); + foreach(var testCase in testCases) { + var shorthand = keyboardPathGenerator.GenerateShorthandFrom(testCase); + System.Console.WriteLine(shorthand); + } + } + catch(IOException e) { + System.Console.Error.WriteLine("Error accessing path: " + args[0]); + System.Console.Error.WriteLine(e.Message); + } + } + } +} diff --git a/OnScreenKeyboard/Properties/AssemblyInfo.cs b/OnScreenKeyboard/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2cf5180 --- /dev/null +++ b/OnScreenKeyboard/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OnScreenKeyboard")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OnScreenKeyboard")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9ceb7fec-6f4f-4b77-a206-cf26e06724bf")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OnScreenKeyboardTests/KeyboardPathGeneratorTests.cs b/OnScreenKeyboardTests/KeyboardPathGeneratorTests.cs new file mode 100644 index 0000000..44e4a2f --- /dev/null +++ b/OnScreenKeyboardTests/KeyboardPathGeneratorTests.cs @@ -0,0 +1,82 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using SoftWriters; + +namespace OnScreenKeyboardTests { + [TestClass] + public class KeyboardPathGeneratorTests { + KeyboardPathGenerator generator = new KeyboardPathGenerator(); + + + [TestMethod] + //Degenerate case + public void EmptyString() { + var shorthand = generator.GenerateShorthandFrom(""); + var expected = ""; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void ShorthandFor_() { + var shorthand = generator.GenerateShorthandFrom(" "); + var expected = "S"; + Assert.AreEqual(expected, shorthand); + } + [TestMethod] + public void ShorthandForA() { + var shorthand = generator.GenerateShorthandFrom("A"); + var expected = "#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void SimpleRight() { + var shorthand = generator.GenerateShorthandFrom("ABC"); + var expected = "#,R,#,R,#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void SimpleDown() { + var shorthand = generator.GenerateShorthandFrom("AGM"); + var expected = "#,D,#,D,#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void OptimizedWrapping() { + var shorthand = generator.GenerateShorthandFrom("A50FA"); + var expected = "#,U,#,L,#,D,#,R,#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void CaseDoesNotMatter() { + var shorthand = generator.GenerateShorthandFrom("Aa"); + var expected = "#,#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void ShorthandForA_A() { + var shorthand = generator.GenerateShorthandFrom("A A"); + var expected = "#,S,#"; + Assert.AreEqual(expected, shorthand); + } + + [TestMethod] + public void InvalidInput() { + var shorthand = generator.GenerateShorthandFrom("!"); + var expected = "Invalid input: !"; + Assert.AreEqual(expected, shorthand); + } + + + [TestMethod] + public void ExampleTest() { + var shorthand = generator.GenerateShorthandFrom("IT Crowd"); + var expected = "D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,#"; + Assert.AreEqual(expected, shorthand); + } + } +} diff --git a/OnScreenKeyboardTests/KeyboardTests.cs b/OnScreenKeyboardTests/KeyboardTests.cs new file mode 100644 index 0000000..80eb0a3 --- /dev/null +++ b/OnScreenKeyboardTests/KeyboardTests.cs @@ -0,0 +1,82 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using SoftWriters; +using System; +using System.Collections.Generic; + +namespace OnScreenKeyboardTests { + [TestClass] + public class KeyboardTests { + Keyboard keyboard = new Keyboard(); + + [TestInitialize] + public void Initialize() { + keyboard.Reset(); + } + + [TestMethod] + public void StartsAtA() { + triggerFromShorthand("#"); + Assert.AreEqual("A", keyboard.Text); + } + + [TestMethod] + public void AddingASpace() { + triggerFromShorthand("#,S,#"); + Assert.AreEqual("A A", keyboard.Text); + } + + [TestMethod] + public void MoveRightForB() { + triggerFromShorthand("R,#"); + Assert.AreEqual("B", keyboard.Text); + } + + [TestMethod] + public void MoveLeftForF() { + triggerFromShorthand("L,#"); + Assert.AreEqual("F", keyboard.Text); + } + + [TestMethod] + public void MoveDownForG() { + triggerFromShorthand("D,#"); + Assert.AreEqual("G", keyboard.Text); + } + + [TestMethod] + public void MoveUpFor5() { + triggerFromShorthand("U,#"); + Assert.AreEqual("5", keyboard.Text); + } + + [TestMethod] + public void MovingWithoutSelecting() { + triggerFromShorthand("U,D,D,L,L,R,R,R,R"); + Assert.AreEqual("", keyboard.Text); + } + + [TestMethod] + public void ExampleTest() { + var shorthand = "D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,#"; + triggerFromShorthand(shorthand); + Assert.AreEqual("IT CROWD", keyboard.Text); + } + + private Dictionary> shorthandLookup = new Dictionary>() { + {"U", keyboard => Input.UP.Trigger(keyboard) }, + {"D", keyboard => Input.DOWN.Trigger(keyboard) }, + {"L", keyboard => Input.LEFT.Trigger(keyboard) }, + {"R", keyboard => Input.RIGHT.Trigger(keyboard) }, + {"#", keyboard => Input.SELECT.Trigger(keyboard) }, + {"S", keyboard => Input.SPACE.Trigger(keyboard) }, + }; + + private void triggerFromShorthand(string shorthand) { + var items = shorthand.Split(','); + foreach(var item in items) { + shorthandLookup[item](keyboard); + } + } + } +} diff --git a/OnScreenKeyboardTests/OnScreenKeyboardTests.csproj b/OnScreenKeyboardTests/OnScreenKeyboardTests.csproj new file mode 100644 index 0000000..1b48c48 --- /dev/null +++ b/OnScreenKeyboardTests/OnScreenKeyboardTests.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {2A9ADA85-7A95-4B78-98E2-A4CFC2177674} + Library + Properties + OnScreenKeyboardTests + OnScreenKeyboardTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + {9ceb7fec-6f4f-4b77-a206-cf26e06724bf} + OnScreenKeyboard + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/OnScreenKeyboardTests/Properties/AssemblyInfo.cs b/OnScreenKeyboardTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b1d8dad --- /dev/null +++ b/OnScreenKeyboardTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("OnScreenKeyboardTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OnScreenKeyboardTests")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("2a9ada85-7a95-4b78-98e2-a4cfc2177674")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OnScreenKeyboardTests/packages.config b/OnScreenKeyboardTests/packages.config new file mode 100644 index 0000000..cf2d094 --- /dev/null +++ b/OnScreenKeyboardTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file