public async Task GetLayoutInfo(string layoutHashId, string geometry, string expectedGeometry, bool exist)
        {
            // Arrange
            ILayoutService layoutService = new LayoutService();
            ErgodoxLayout  response      = null;

            // Act
            if (exist)
            {
                response = await layoutService.GetLayoutInfo(layoutHashId, geometry, "latest");
            }
            else
            {
                await Assert.ThrowsAsync <ArgumentException>(() => layoutService.GetLayoutInfo(layoutHashId, geometry, "latest"));
            }

            // Assert
            if (exist)
            {
                Assert.NotNull(response);
                Assert.IsType <ErgodoxLayout>(response);
                Assert.NotNull(response.Revision);
                Assert.False(string.IsNullOrWhiteSpace(response.HashId));
                Assert.False(string.IsNullOrWhiteSpace(response.Title));
                Assert.Equal(expectedGeometry, response.Geometry);
            }
        }
Example #2
0
        public void PrepareEZLayout_KeyCategoryShortcuts(string keyCode, string command, string expectedLabel, KeyCategory expectedCategory)
        {
            // Arrange
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = "", Code = keyCode, Command = command
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First();

            Assert.Equal(expectedLabel, keyResult.Label.Content);
            Assert.Null(keyResult.Modifier);
            Assert.Equal(expectedCategory, keyResult.KeyCategory);
        }
Example #3
0
        public void PrepareEZLayout_ColorKey(string layerColor, string keyColor, string expectedColor)
        {
            // Arrange
            var ergodoxLayer = new ErgodoxLayer {
                Color = layerColor, Keys = new List <ErgodoxKey> {
                    new ErgodoxKey {
                        GlowColor = keyColor
                    }
                }
            };
            ErgodoxLayout ergodoxLayout = new ErgodoxLayout
            {
                Title = "", HashId = "", Revision = new Revision {
                    HashId = HashId, Layers = new List <ErgodoxLayer> {
                        ergodoxLayer
                    }
                }
            };

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Equal(expectedColor, ezLayoutResult.EZLayers.First().EZKeys.First().Color);
        }
Example #4
0
        public void PrepareEZLayout_KeyCategoryWithGlyphs(string keyCode, string expectedLabel, KeyDisplayType expectedDisplayType, KeyCategory expectedCategory, bool expectedIsGlyph)
        {
            // Arrange
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = "", Code = keyCode
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First();

            Assert.Equal(expectedLabel, keyResult.Label.Content);
            Assert.Equal(expectedIsGlyph, keyResult.Label.IsGlyph);
            Assert.Equal(expectedDisplayType, keyResult.DisplayType);
            Assert.Equal(expectedCategory, keyResult.KeyCategory);
        }
Example #5
0
        public void PrepareEZLayout_InitializeEZLayer(int expectedIndex, string expectedTitle, string expectedColor)
        {
            // Arrange
            var ergodoxLayer = new ErgodoxLayer()
            {
                Color = expectedColor, Title = expectedTitle, Position = expectedIndex, Keys = new List <ErgodoxKey>()
            };
            ErgodoxLayout ergodoxLayout = new ErgodoxLayout
            {
                Title = "", HashId = "", Revision = new Revision {
                    HashId = HashId, Layers = new List <ErgodoxLayer> {
                        ergodoxLayer
                    }
                }
            };

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Equal(expectedTitle, ezLayoutResult.EZLayers.First().Name);
            Assert.Equal(expectedIndex, ezLayoutResult.EZLayers.First().Index);
            Assert.Equal(expectedColor, ezLayoutResult.EZLayers.First().Color);
        }
        private static ErgodoxLayout PrepareLayoutTree(string geometry = "ergodox-ez", string tag = "Tag 1")
        {
            var expectedInfo = new ErgodoxLayout()
            {
                Geometry = geometry,
                Title    = "ezlayout",
                HashId   = "asdf",
                Tags     = new List <ErgodoxTag> {
                    new ErgodoxTag {
                        Name = tag
                    }
                },
                Revision = new Revision
                {
                    HashId     = RevisionHashId,
                    HexUrl     = "",
                    SourcesUrl = "",
                    Model      = "Model",
                    Layers     = new List <ErgodoxLayer> {
                        new ErgodoxLayer()
                        {
                            Title    = "Layer",
                            Position = 1
                        }
                    }
                }
            };

            return(expectedInfo);
        }
        public async Task GetErgodoxLayout(string layoutHashId, bool exist)
        {
            // Arrange
            ILayoutService layoutService = new LayoutService();

            // Act
            ErgodoxLayout response = null;

            if (exist)
            {
                response = await layoutService.GetErgodoxLayout(layoutHashId, "ergodox-ez", "latest");
            }
            else
            {
                await Assert.ThrowsAsync <ArgumentException>(() => layoutService.GetErgodoxLayout(layoutHashId, "ergodox-ez", "latest"));
            }

            // Assert
            if (exist)
            {
                Assert.NotNull(response);
                Assert.IsType <ErgodoxLayout>(response);
                Assert.NotNull(response.Revision);
                Assert.False(string.IsNullOrWhiteSpace(response.HashId));
                Assert.False(string.IsNullOrWhiteSpace(response.Title));
            }
        }
Example #8
0
        public void PrepareEZLayout_ProcessModifiers(bool leftAlt,
                                                     bool leftCtrl,
                                                     bool leftShift,
                                                     bool leftWin,
                                                     bool rightAlt,
                                                     bool rightCtrl,
                                                     bool rightShift,
                                                     bool rightWin,
                                                     string expectedSubLabel,
                                                     KeyDisplayType expectedDisplayType)
        {
            // Arrange
            var modifiers = new ErgodoxModifiers
            {
                LeftAlt    = leftAlt,
                LeftCtrl   = leftCtrl,
                LeftShift  = leftShift,
                LeftWin    = leftWin,
                RightAlt   = rightAlt,
                RightCtrl  = rightCtrl,
                RightShift = rightShift,
                RightWin   = rightWin
            };
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = "", Code = "KC_A", Modifiers = modifiers
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First();

            Assert.Equal("A", keyResult.Label.Content);

            if (expectedDisplayType == KeyDisplayType.SimpleLabel)
            {
                Assert.Null(keyResult.Modifier);
            }
            else
            {
                Assert.Equal(expectedSubLabel, keyResult.Modifier.Content);
                Assert.False(keyResult.Modifier.IsGlyph);
            }

            Assert.Equal(expectedDisplayType, keyResult.DisplayType);
        }
        /// <inheritdoc />
        public EZLayout PrepareEZLayout(ErgodoxLayout ergodoxLayout)
        {
            Logger.TraceMethod();

            var      ezLayoutMaker = new EZLayoutMaker();
            EZLayout ezLayout      = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            return(ezLayout);
        }
Example #10
0
        public async Task <ErgodoxLayout> GetLayoutInfo(string layoutHashId, string layoutRevisionId)
        {
            Debug.WriteLine("Layout retrieved.");

            var layoutInfo = new ErgodoxLayout();

            layoutInfo.Title = "Layout title v1.0";

            return(await new Task <ErgodoxLayout>(() => layoutInfo));
        }
        public void DownloadHexFileCommand_Execute(string hexUrl, string sourcesUrl, int expectedCommandExecute)
        {
            // Arrange
            var expectedInfo = new ErgodoxLayout()
            {
                Geometry = "",
                Title    = "ezlayout",
                HashId   = "asdf",
                Tags     = new List <ErgodoxTag> {
                    new ErgodoxTag {
                        Name = "Tag 1"
                    }
                },
                Revision = new Revision
                {
                    HashId     = "hashId-1",
                    HexUrl     = hexUrl,
                    SourcesUrl = sourcesUrl,
                    Model      = "Model",
                    Layers     = new List <ErgodoxLayer> {
                        new ErgodoxLayer()
                        {
                            Title = "Layer", Position = 1
                        }
                    }
                }
            };
            var mockSettingsService = new Mock <ISettingsService>();

            mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
            var mockWindowService = new Mock <IWindowService>();
            var mockLayoutService = new Mock <ILayoutService>();

            mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(expectedInfo));
            var mockProcessService = new Mock <IProcessService>();

            mockProcessService.Setup(p => p.StartWebUrl(hexUrl)).Verifiable();

            // Act
            var settingsViewModel = new SettingsViewModel(mockSettingsService.Object, mockWindowService.Object, mockLayoutService.Object, mockProcessService.Object);

            settingsViewModel.DownloadHexFileCommand.Execute(null);

            // Assert
            mockProcessService.Verify(p => p.StartWebUrl(hexUrl), Times.Exactly(expectedCommandExecute));
        }
        public void UpdateErgoDoxInfo_DownloadUrls(string hexUrl, string sourcesUrl, string expectedLayoutStatus, bool expectedButtonStatus)
        {
            // Arrange
            var expectedInfo = new ErgodoxLayout()
            {
                Geometry = "ergodox-ez",
                Title    = "ezlayout",
                HashId   = "asdf",
                Tags     = new List <ErgodoxTag> {
                    new ErgodoxTag {
                        Name = "Tag 1"
                    }
                },
                Revision = new Revision
                {
                    HexUrl     = hexUrl,
                    SourcesUrl = sourcesUrl,
                    Model      = "Model",
                    Layers     = new List <ErgodoxLayer> {
                        new ErgodoxLayer()
                        {
                            Title    = "Layer",
                            Position = 1
                        }
                    }
                }
            };
            var mockSettingsService = new Mock <ISettingsService>();

            mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
            var mockWindowService = new Mock <IWindowService>();
            var mockLayoutService = new Mock <ILayoutService>();

            mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(expectedInfo));
            var mockProcessService = new Mock <IProcessService>();

            // Act
            var settingsViewModel = new SettingsViewModel(mockSettingsService.Object, mockWindowService.Object, mockLayoutService.Object, mockProcessService.Object);

            // Assert
            Assert.Equal(expectedLayoutStatus, settingsViewModel.LayoutStatus);
            Assert.Equal(expectedButtonStatus, settingsViewModel.DownloadHexFileCommand.CanExecute(null));
            Assert.Equal(expectedButtonStatus, settingsViewModel.DownloadSourcesCommand.CanExecute(null));
        }
Example #13
0
        public void PrepareEZLayout_KeyCategoryLayerShortcut(string keyCode,
                                                             string command,
                                                             string expectedLabel,
                                                             string expectedSubLabel,
                                                             KeyDisplayType expectedDisplayType,
                                                             KeyCategory expectedCategory)
        {
            // Arrange
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = "", Code = keyCode, Command = command, Layer = 1
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            var keyResult = ezLayoutResult.EZLayers.First().EZKeys.First();

            Assert.Equal(expectedLabel, keyResult.Label.Content);

            if (expectedDisplayType == KeyDisplayType.SimpleLabel)
            {
                Assert.Null(keyResult.Modifier);
            }
            else
            {
                Assert.Equal(expectedSubLabel, keyResult.Modifier.Content);
                Assert.False(keyResult.Modifier.IsGlyph);
            }

            Assert.Equal(expectedCategory, keyResult.KeyCategory);
        }
        public void PrepareEZLayout_OneLayer_ManyKeys()
        {
            // Arrange
            ILayoutService layoutService = new LayoutService();
            ErgodoxLayout  ergodoxLayout = InitializeDataTree();
            var            keys          = ergodoxLayout.Revision.Layers.First().Keys;

            keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_A"
            });
            keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_0"
            });
            keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_TRANSPARENT"
            });
            EZLayout ezLayoutResult;

            // Act
            ezLayoutResult = layoutService.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Equal(3, ezLayoutResult.EZLayers.First().EZKeys.Count);

            var keyResults = ezLayoutResult.EZLayers.First().EZKeys;

            Assert.Equal("A", keyResults[0].Label.Content);
            Assert.Equal(KeyCategory.Letters, keyResults[0].KeyCategory);
            Assert.Equal("0", keyResults[1].Label.Content);
            Assert.Equal(KeyCategory.Digit, keyResults[1].KeyCategory);
            Assert.Equal("", keyResults[2].Label.Content);
            Assert.Equal(KeyCategory.Other, keyResults[2].KeyCategory);
        }
Example #15
0
        public void PrepareEZLayout_InitializeEZKey(string expectedKeyCode, string expectedColor)
        {
            // Arrange
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = expectedColor, Code = expectedKeyCode
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            Assert.Equal(expectedColor, ezLayoutResult.EZLayers.First().EZKeys.First().Color);
        }
Example #16
0
        public void PrepareEZLayout_InitializeEZLayout(string expectedTitle, string expectedHashId)
        {
            // Arrange
            var revision = new Revision {
                Layers = new List <ErgodoxLayer>()
            };
            ErgodoxLayout ergodoxLayout = new ErgodoxLayout {
                Title = expectedTitle, HashId = expectedHashId, Revision = new Revision {
                    HashId = HashId
                }
            };

            ergodoxLayout.Revision = revision;
            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Equal(expectedTitle, ezLayoutResult.Name);
            Assert.Equal(expectedHashId, ezLayoutResult.HashId);
        }
Example #17
0
        public void PrepareEZLayout_KeyCodeUnknown()
        {
            // Arrange
            var ergodoxKey = new ErgodoxKey()
            {
                GlowColor = "", Code = "KC_UNKNOWN_ADSLKFJ"
            };
            ErgodoxLayout ergodoxLayout = InitializeDataTree();

            ergodoxLayout.Revision.Layers.First().Keys.Add(ergodoxKey);

            EZLayout ezLayoutResult;

            // Act
            var ezLayoutMaker = new EZLayoutMaker();

            ezLayoutResult = ezLayoutMaker.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Single(ezLayoutResult.EZLayers);
            Assert.Single(ezLayoutResult.EZLayers.First().EZKeys);
            Assert.Equal("", ezLayoutResult.EZLayers.First().EZKeys.First().Label.Content);
            Assert.False(ezLayoutResult.EZLayers.First().EZKeys.First().Label.IsGlyph);
        }
        public EZLayout PrepareEZLayout(ErgodoxLayout ergodoxLayout)
        {
            Logger.TraceMethod();
            Logger.DebugInputParam(nameof(ergodoxLayout), ergodoxLayout);

            var ezLayout = new EZLayout {
                HashId = ergodoxLayout.HashId, Name = ergodoxLayout.Title, Geometry = ergodoxLayout.Geometry
            };

            var ergodoxLayers = ergodoxLayout.Revision.Layers ?? ergodoxLayout.Revision.Layers;

            if (ergodoxLayers?.Any() != null)
            {
                foreach (var ergodoxLayer in ergodoxLayers)
                {
                    var ezLayer = PrepareEZLayer(ergodoxLayer);
                    ezLayout.EZLayers.Add(ezLayer);
                }
            }

            Logger.DebugOutputParam(nameof(ezLayout), ezLayout);

            return(ezLayout);
        }
Example #19
0
        /// <inheritdoc />
        public EZLayout PrepareEZLayout(ErgodoxLayout ergodoxLayouts)
        {
            Debug.WriteLine("Layout prepared");

            return(new EZLayout());
        }
        public void PrepareEZLayout_TwoLayer_ManyKeys()
        {
            // Arrange
            ILayoutService layoutService = new LayoutService();
            ErgodoxLayout  ergodoxLayout = InitializeDataTree();
            var            layer0Keys    = ergodoxLayout.Revision.Layers.First().Keys;

            layer0Keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_A"
            });
            layer0Keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_0"
            });
            layer0Keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_TRANSPARENT"
            });

            ergodoxLayout.Revision
            .Layers.Add(new ErgodoxLayer {
                Color    = "color",
                Title    = "Layer 2",
                Position = 1,
                Keys     = new List <ErgodoxKey>()
            });
            var layer1Keys = ergodoxLayout.Revision.Layers[1].Keys;

            layer1Keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_F1"
            });
            layer1Keys.Add(new ErgodoxKey()
            {
                GlowColor = "",
                Code      = "KC_SPACE"
            });

            // Act
            var ezLayoutResult = layoutService.PrepareEZLayout(ergodoxLayout);

            // Assert
            Assert.Equal(2, ezLayoutResult.EZLayers.Count);
            Assert.Equal(3, ezLayoutResult.EZLayers[0].EZKeys.Count);
            Assert.Equal(2, ezLayoutResult.EZLayers[1].EZKeys.Count);

            var layer0KeyResults = ezLayoutResult.EZLayers[0].EZKeys;

            Assert.Equal("A", layer0KeyResults[0].Label.Content);
            Assert.Equal(KeyCategory.Letters, layer0KeyResults[0].KeyCategory);
            Assert.Equal("0", layer0KeyResults[1].Label.Content);
            Assert.Equal(KeyCategory.Digit, layer0KeyResults[1].KeyCategory);
            Assert.Equal("", layer0KeyResults[2].Label.Content);
            Assert.Equal(KeyCategory.Other, layer0KeyResults[2].KeyCategory);

            var layer1KeyResults = ezLayoutResult.EZLayers[1].EZKeys;

            Assert.Equal("F1", layer1KeyResults[0].Label.Content);
            Assert.Equal(KeyCategory.Fn, layer1KeyResults[0].KeyCategory);
            Assert.Equal("\u23b5", layer1KeyResults[1].Label.Content);
            Assert.Equal(KeyCategory.Spacing, layer1KeyResults[1].KeyCategory);
        }