diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cafa2b5..7051e02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,7 @@ name: Key-n-Stroke Continuous Integration # Trigger on every master branch push and pull request -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [ push ] jobs: @@ -23,11 +19,13 @@ jobs: env: Solution_Path: KeyNStroke.sln - #Test_Project_Path: KeyNStroke.Tests\KeyNStroke.Tests.csproj + Test_Project_Path: KeyNStrokeTests\KeyNStrokeTests.csproj + Test_Output_Directory: KeyNStrokeTests\bin App_Project_Path: KeyNStroke\KeyNStroke.csproj App_Output_Directory: KeyNStroke\bin App_Assembly: Key-n-Stroke.exe Actions_Allow_Unsecure_Commands: true # Allows AddPAth and SetEnv commands + Configuration: Debug steps: - name: Checkout @@ -41,42 +39,41 @@ jobs: with: setAllVars: true - # Install the .NET Core workload - - name: Install .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '5.0.x' - # Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.1 - #- name: Execute Unit Tests - # run: dotnet test $env:Test_Project_Path + # Use cached packages if available + - name: Try to restore packages from cache first + uses: actions/cache@v2 + env: + cache-name: app-packages + with: + path: packages/ + key: ${{ env.cache-name }}-${{ env.Configuration }}-${{ env.NBGV_CloudBuildNumber }} + restore-keys: | + ${{ env.cache-name }}-${{ env.Configuration }}-${{ env.NBGV_Version }} + ${{ env.cache-name }}-${{ env.Configuration }}-${{ env.NBGV_SimpleVersion }} # Restore the application - - name: Restore the application to populate the obj and packages folder + - name: Restore the application to populate the obj and packages folder run: msbuild $env:Solution_Path /t:Restore /p:RestorePackagesConfig=true /p:Configuration=$env:Configuration - env: - Configuration: Release - # Actual build - - name: Build the application + - name: Build the solution run: msbuild $env:Solution_Path /t:Rebuild /p:Configuration=$env:Configuration /p:Platform="Any CPU" + + # Run built tests + - name: Execute Unit Tests + uses: microsoft/vstest-action@v1.0.0 + with: + testAssembly: KeyNStrokeTests.dll + searchFolder: ${{ env.Test_Output_Directory }}\${{ env.Configuration }}\ - env: - Configuration: Release - - - # Signing - # https://github.com/dlemstra/code-sign-action - # https://github.com/GabrielAcostaEngler/signtool-code-sign - # https://archi-lab.net/code-signing-assemblies-with-github-actions/ - + # Add artefacts to - name: Upload build artifacts uses: actions/upload-artifact@v1 with: name: KeyNStroke-${{env.NBGV_SemVer2}} - path: ${{ env.App_Output_Directory }}\Release\ - + path: ${{ env.App_Output_Directory }}\${{ env.Configuration }}\ + \ No newline at end of file diff --git a/KeyNStroke.sln b/KeyNStroke.sln index 929fcb0..bd336af 100644 --- a/KeyNStroke.sln +++ b/KeyNStroke.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyNStroke", "KeyNStroke\KeyNStroke.csproj", "{BA117557-FEBC-45C5-8895-4017D05C3DCD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyNStrokeTests", "KeyNStrokeTests\KeyNStrokeTests.csproj", "{3B189090-03C5-41B4-B975-028E31A119EE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {BA117557-FEBC-45C5-8895-4017D05C3DCD}.Debug|Any CPU.Build.0 = Debug|Any CPU {BA117557-FEBC-45C5-8895-4017D05C3DCD}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA117557-FEBC-45C5-8895-4017D05C3DCD}.Release|Any CPU.Build.0 = Release|Any CPU + {3B189090-03C5-41B4-B975-028E31A119EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B189090-03C5-41B4-B975-028E31A119EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B189090-03C5-41B4-B975-028E31A119EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B189090-03C5-41B4-B975-028E31A119EE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/KeyNStrokeTests/ImageResourcesTests.cs b/KeyNStrokeTests/ImageResourcesTests.cs new file mode 100644 index 0000000..b73b736 --- /dev/null +++ b/KeyNStrokeTests/ImageResourcesTests.cs @@ -0,0 +1,32 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using KeyNStroke; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace KeyNStroke.Tests +{ + [TestClass()] + public class ImageResourcesTests + { + [TestMethod()] + public void ApplyScalingFactorTest() + { + KeyNStroke.SettingsStore mySettings = new KeyNStroke.SettingsStore(); + + mySettings.WindowLocationDefault = new Point( + System.Windows.SystemParameters.PrimaryScreenWidth - mySettings.WindowSizeDefault.Width - 20, + System.Windows.SystemParameters.PrimaryScreenHeight - mySettings.WindowSizeDefault.Height - 40); + + //mySettings.ResetAll(); // test defaults + mySettings.LoadAll(); + + ImageResources.Init(mySettings.ButtonIndicatorCustomIconsFolder); + ImageResources.ApplyScalingFactor(1.0); + ImageResources.ApplyScalingFactor(1.4f); + } + } +} \ No newline at end of file diff --git a/KeyNStrokeTests/KeyNStrokeTests.csproj b/KeyNStrokeTests/KeyNStrokeTests.csproj new file mode 100644 index 0000000..48728a5 --- /dev/null +++ b/KeyNStrokeTests/KeyNStrokeTests.csproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + {3B189090-03C5-41B4-B975-028E31A119EE} + Library + Properties + KeyNStrokeTests + KeyNStrokeTests + v4.8 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.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 + + + + + + + + + + + + + + + + + + + + + + + 2.1.1 + + + 2.1.1 + + + + + {BA117557-FEBC-45C5-8895-4017D05C3DCD} + KeyNStroke + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/KeyNStrokeTests/KeystrokeParserTests.cs b/KeyNStrokeTests/KeystrokeParserTests.cs new file mode 100644 index 0000000..6dbfeb6 --- /dev/null +++ b/KeyNStrokeTests/KeystrokeParserTests.cs @@ -0,0 +1,23 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using KeyNStroke; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KeyNStroke.Tests +{ + [TestClass()] + public class KeystrokeParserTests + { + [TestMethod()] + public void KeystrokeParserTest() + { + var myKeyboardHook = new KeyboardHook(); + var myKeystrokeConverter = new KeystrokeParser(myKeyboardHook); + Assert.IsNotNull(myKeystrokeConverter); + + } + } +} \ No newline at end of file diff --git a/KeyNStrokeTests/Properties/AssemblyInfo.cs b/KeyNStrokeTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3526c32 --- /dev/null +++ b/KeyNStrokeTests/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("KeyNStrokeTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("KeyNStrokeTests")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[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("3b189090-03c5-41b4-b975-028e31a119ee")] + +// 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")]