Skip to content
This repository was archived by the owner on Nov 25, 2023. It is now read-only.

Commit 4e39858

Browse files
committed
Update SettingsViewModel tests
1 parent 4f9e73a commit 4e39858

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/InvvardDev.EZLayoutDisplay.Tests/ViewModel/SettingsViewModelTest.cs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void SettingsViewModel_Constructor()
5454
mockSettingsService.Setup(s => s.ErgodoxLayoutUrl).Returns(tbContentInitial);
5555
var mockWindowService = new Mock<IWindowService>();
5656
var mockLayoutService = new Mock<ILayoutService>();
57-
mockLayoutService.Setup(s => s.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(It.IsAny<ErgodoxLayout>()));
57+
mockLayoutService.Setup(s => s.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(It.IsAny<ErgodoxLayout>()));
5858
var mockProcessService = new Mock<IProcessService>();
5959

6060
//Act
@@ -218,30 +218,31 @@ public void CloseCommand_Execute(bool mustSave)
218218
}
219219

220220
[Theory]
221-
[InlineData("https://configure.zsa.io/layouts/abcd/latest/0", LatestRevisionHashId, "default", RevisionHashId)]
222-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/abcd/sdfs/0", "sdfs", "abcd", "sdfs")]
223-
[InlineData("https://configure.zsa.io/planck-ez/layouts/abcd/latest/0", LatestRevisionHashId, "abcd", RevisionHashId)]
224-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/1234/asdf/0", "asdf", "1234", "asdf")]
225-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/a2Vt/latest/0", LatestRevisionHashId, "a2Vt", RevisionHashId)]
226-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/default/latest/0", LatestRevisionHashId, "default", RevisionHashId)]
227-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/j3o4", LatestRevisionHashId, "j3o4", RevisionHashId)]
228-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/j3o4/", LatestRevisionHashId, "j3o4", RevisionHashId)]
229-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/r2d2/lat/9", "lat", "r2d2", "lat")]
230-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/def/latest/0", LatestRevisionHashId, "default", RevisionHashId)] // Less than 4 layout ID character length
231-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/_t3s/latest/0", LatestRevisionHashId, "default", RevisionHashId)]
232-
[InlineData("https://configure.zsa.ioergodox-ez/layouts/t3s/latest/0", LatestRevisionHashId, "default", RevisionHashId)]
233-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/adbcd/latest/0", LatestRevisionHashId, "adbcd", RevisionHashId)]
234-
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0", LatestRevisionHashId, "asdfasdfasdfasdfgfasdffgasf", RevisionHashId)]
235-
[InlineData("https://configure.zsa.io/plante-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0", LatestRevisionHashId, "default", RevisionHashId)]
236-
public void UpdateLayoutCommand_Execute(string layoutUrl, string urlRevisionId, string expectedHashId, string expectedRevisionHashId)
221+
[InlineData("https://configure.zsa.io/layouts/abcd/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)]
222+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/abcd/sdfs/0", "sdfs", "abcd", "ergodox-ez", "sdfs")]
223+
[InlineData("https://configure.zsa.io/planck-ez/layouts/abcd/latest/0", LatestRevisionHashId, "abcd", "planck-ez", RevisionHashId)]
224+
[InlineData("https://configure.zsa.io/moonlander/layouts/abcd/latest/0", LatestRevisionHashId, "abcd", "moonlander", RevisionHashId)]
225+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/1234/asdf/0", "asdf", "1234", "ergodox-ez", "asdf")]
226+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/a2Vt/latest/0", LatestRevisionHashId, "a2Vt", "ergodox-ez", RevisionHashId)]
227+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/default/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)]
228+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/j3o4", LatestRevisionHashId, "j3o4", "ergodox-ez", RevisionHashId)]
229+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/j3o4/", LatestRevisionHashId, "j3o4", "ergodox-ez", RevisionHashId)]
230+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/r2d2/lat/9", "lat", "r2d2", "ergodox-ez", "lat")]
231+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/def/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)] // Less than 4 layout ID character length
232+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/_t3s/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)]
233+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/t3s/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)]
234+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/adbcd/latest/0", LatestRevisionHashId, "adbcd", "ergodox-ez", RevisionHashId)]
235+
[InlineData("https://configure.zsa.io/ergodox-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0", LatestRevisionHashId, "asdfasdfasdfasdfgfasdffgasf", "ergodox-ez", RevisionHashId)]
236+
[InlineData("https://configure.zsa.io/plante-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0", LatestRevisionHashId, "default", "ergodox-ez", RevisionHashId)]
237+
public void UpdateLayoutCommand_Execute(string layoutUrl, string urlRevisionId, string expectedHashId, string expectedGeometry, string expectedRevisionHashId)
237238
{
238239
//Arrange
239240
var mockSettingsService = new Mock<ISettingsService>();
240241
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, layoutUrl);
241242
var mockWindowService = new Mock<IWindowService>();
242243
var mockLayoutService = new Mock<ILayoutService>();
243-
mockLayoutService.Setup(l => l.GetLayoutInfo(expectedHashId, urlRevisionId)).Returns(Task.FromResult(PrepareLayoutTree()));
244-
mockLayoutService.Setup(l => l.GetErgodoxLayout(expectedHashId, expectedRevisionHashId)).Returns(Task.FromResult(It.IsAny<ErgodoxLayout>())).Verifiable();
244+
mockLayoutService.Setup(l => l.GetLayoutInfo(expectedHashId, expectedGeometry, urlRevisionId)).Returns(Task.FromResult(PrepareLayoutTree(expectedGeometry)));
245+
mockLayoutService.Setup(l => l.GetErgodoxLayout(expectedHashId, expectedGeometry, expectedRevisionHashId)).Returns(Task.FromResult(It.IsAny<ErgodoxLayout>())).Verifiable();
245246
mockLayoutService.Setup(l => l.PrepareEZLayout(It.IsAny<ErgodoxLayout>())).Verifiable();
246247
var mockProcessService = new Mock<IProcessService>();
247248

@@ -263,7 +264,7 @@ public void UpdateLayoutCommandExecute_ArgumentExceptionRaised()
263264
var mockWindowService = new Mock<IWindowService>();
264265
mockWindowService.Setup(w => w.ShowWarning(It.IsAny<string>())).Verifiable();
265266
var mockLayoutService = new Mock<ILayoutService>();
266-
mockLayoutService.Setup(l => l.GetErgodoxLayout(It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentException>();
267+
mockLayoutService.Setup(l => l.GetErgodoxLayout(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentException>();
267268
var processService = new Mock<IProcessService>();
268269

269270
// Act
@@ -284,7 +285,7 @@ public void UpdateLayoutCommandExecute_ArgumentNullExceptionRaised()
284285
var mockWindowService = new Mock<IWindowService>();
285286
mockWindowService.Setup(w => w.ShowWarning(It.IsAny<string>())).Verifiable();
286287
var mockLayoutService = new Mock<ILayoutService>();
287-
mockLayoutService.Setup(l => l.GetErgodoxLayout(It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentNullException>();
288+
mockLayoutService.Setup(l => l.GetErgodoxLayout(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentNullException>();
288289
var processService = new Mock<IProcessService>();
289290

290291
// Act
@@ -302,15 +303,15 @@ public void UpdateLayoutCommandExecute_ArgumentNullExceptionRaised()
302303
[InlineData(" ", null, 0)]
303304
[InlineData(null, "", 0)]
304305
[InlineData(null, " ", 0)]
305-
[InlineData("tag", "geometry", 1)]
306+
[InlineData("tag", "ergodox-ez", 1)]
306307
public void OpenTagSearchCommandExecute(string tag, string keyboardGeometry, int callNumber)
307308
{
308309
// Arrange
309310
var mockSettingsService = new Mock<ISettingsService>();
310311
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
311312
var mockWindowService = new Mock<IWindowService>();
312313
var mockLayoutService = new Mock<ILayoutService>();
313-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>()))
314+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
314315
.Returns(Task.FromResult(PrepareLayoutTree(keyboardGeometry, tag)));
315316
var mockProcessService = new Mock<IProcessService>();
316317
mockProcessService.Setup(p => p.StartWebUrl(It.IsAny<string>())).Verifiable();
@@ -332,7 +333,7 @@ public void OpenTagSearchCommandExecute_ArgumentNullException()
332333
var mockWindowService = new Mock<IWindowService>();
333334
mockWindowService.Setup(w => w.ShowWarning("Value cannot be null.")).Verifiable();
334335
var mockLayoutService = new Mock<ILayoutService>();
335-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentNullException>().Verifiable();
336+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentNullException>().Verifiable();
336337
var mockProcessService = new Mock<IProcessService>();
337338

338339
// Act
@@ -352,7 +353,7 @@ public void OpenTagSearchCommandExecute_ArgumentException()
352353
var mockWindowService = new Mock<IWindowService>();
353354
mockWindowService.Setup(w => w.ShowWarning("Value does not fall within the expected range.")).Verifiable();
354355
var mockLayoutService = new Mock<ILayoutService>();
355-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentException>().Verifiable();
356+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Throws<ArgumentException>().Verifiable();
356357
var mockProcessService = new Mock<IProcessService>();
357358

358359
// Act
@@ -371,7 +372,7 @@ public void UpdateErgoDoxInfo_LayoutInfoNull()
371372
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
372373
var mockWindowService = new Mock<IWindowService>();
373374
var mockLayoutService = new Mock<ILayoutService>();
374-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult<ErgodoxLayout>(null));
375+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult<ErgodoxLayout>(null));
375376
var mockProcessService = new Mock<IProcessService>();
376377

377378
// Act
@@ -400,7 +401,7 @@ public void UpdateErgoDoxInfo_LayoutInfoNotNull(string geometry, string expected
400401
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
401402
var mockWindowService = new Mock<IWindowService>();
402403
var mockLayoutService = new Mock<ILayoutService>();
403-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
404+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
404405
var mockProcessService = new Mock<IProcessService>();
405406

406407
// Act
@@ -428,7 +429,7 @@ public void UpdateErgoDoxInfo_DownloadUrls(string hexUrl, string sourcesUrl, str
428429
// Arrange
429430
var expectedInfo = new ErgodoxLayout()
430431
{
431-
Geometry = "",
432+
Geometry = "ergodox-ez",
432433
Title = "ezlayout",
433434
HashId = "asdf",
434435
Tags = new List<ErgodoxTag> {
@@ -453,7 +454,7 @@ public void UpdateErgoDoxInfo_DownloadUrls(string hexUrl, string sourcesUrl, str
453454
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
454455
var mockWindowService = new Mock<IWindowService>();
455456
var mockLayoutService = new Mock<ILayoutService>();
456-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
457+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
457458
var mockProcessService = new Mock<IProcessService>();
458459

459460
// Act
@@ -491,7 +492,7 @@ public void DownloadHexFileCommand_Execute(string hexUrl, string sourcesUrl, int
491492
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
492493
var mockWindowService = new Mock<IWindowService>();
493494
var mockLayoutService = new Mock<ILayoutService>();
494-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
495+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
495496
var mockProcessService = new Mock<IProcessService>();
496497
mockProcessService.Setup(p => p.StartWebUrl(hexUrl)).Verifiable();
497498

@@ -528,7 +529,7 @@ public void DownloadSourcesCommand_Execute(string hexUrl, string sourcesUrl, int
528529
mockSettingsService.SetupProperty(s => s.ErgodoxLayoutUrl, "");
529530
var mockWindowService = new Mock<IWindowService>();
530531
var mockLayoutService = new Mock<ILayoutService>();
531-
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
532+
mockLayoutService.Setup(l => l.GetLayoutInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(expectedInfo));
532533
var mockProcessService = new Mock<IProcessService>();
533534
mockProcessService.Setup(p => p.StartWebUrl(hexUrl)).Verifiable();
534535

0 commit comments

Comments
 (0)