public void ParseFile_Exists() { Keypath result = processor.ParseFile(Constants.FilePaths.TESTINPUT); result.Should().NotBeNull(); result.Inputs.Should().NotBeNullOrEmpty(); result.Inputs.Count().Should().Be(3); }
public void ConvertKeypath_KeyPathNull() { Keypath keypath = null; Keyboard keyboard = new Keyboard(); string result = processor.ConvertKeypath(keypath, keyboard); result.Should().BeNull(); }
public void ConvertKeypath_Whitespace() { Keypath keypath = new Keypath { Inputs = new List <string> { "SSSS" } }; Keyboard keyboard = new Keyboard(); string result = processor.ConvertKeypath(keypath, keyboard); result.Should().BeEmpty(); //We trim whitespace so input of only whitespace will not be returned }
public void ConvertKeypath_Valid() { Keypath keypath = new Keypath { Inputs = new List <string> { "DR*R*SDLL*RR*LL*" } }; Keyboard keyboard = new Keyboard(); string result = processor.ConvertKeypath(keypath, keyboard); result.Should().Be("HI MOM"); }
public void ConvertKeypath_KeyboardNull() { Keypath keypath = new Keypath { Inputs = new List <string> { "UUDDLLRRS*" } }; Keyboard keyboard = null; string result = processor.ConvertKeypath(keypath, keyboard); result.Should().BeNull(); }
public void ConvertKeypath_MultipleInputs() { Keypath keypath = new Keypath { Inputs = new List <string> { "DR*R*SDLL*RR*LL*", "D*DRR**UUR*SDDLLL*RR*RRR*LLLL*SDD*R*" } }; Keyboard keyboard = new Keyboard(); string result = processor.ConvertKeypath(keypath, keyboard); result.Should().Be("HI MOM\r\nGOOD MORN Z1"); }
public void ConvertKeypath_WrapAround() { Keypath keypath = new Keypath { Inputs = new List <string> { "L*", "U*", "RRRRRR*", "DDDDDD*" } }; Keyboard keyboard = new Keyboard(); string result = processor.ConvertKeypath(keypath, keyboard); result.Should().Be("F\r\n5\r\nA\r\nA"); //Tests wrap around points to ensure transition is correct }
/// <summary> /// Driver that converts an input file's keypath to text. /// Logs data to both console and file /// </summary> public static void Main(string[] args) { //Using Serilog for logging. Makes output simple and will write results to file. Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File(Constants.FilePaths.LOG, rollingInterval: RollingInterval.Day) .CreateLogger(); KeypathProcessor processor = new KeypathProcessor(Log.Logger); string filepath = string.Empty; //Allowing user to enter multiple files for path conversion do { Console.Write("Enter the path of the file to convert (0 to exit): "); filepath = Console.ReadLine(); if (filepath == "0") { break; } Keypath keypath = processor.ParseFile(filepath); string convertedMessage = processor.ConvertKeypath(keypath, new Keyboard()); if (!string.IsNullOrWhiteSpace(convertedMessage)) { Log.Logger.Information($"Input: {keypath} converts to\n{convertedMessage}"); } } while (filepath != "0"); Console.WriteLine($"Thanks for using PathConverter. Results saved in {Constants.FilePaths.LOG}. Press any key to exit."); Console.ReadKey(); }