@@ -12,7 +12,37 @@ namespace InvvardDev.EZLayoutDisplay.Tests.ViewModel
1212{
1313 public class SettingsViewModelTest
1414 {
15- [ Fact ]
15+ private static ErgodoxLayout PrepareLayoutTree ( string geometry = "ergodox-ez" , string tag = "Tag 1" )
16+ {
17+ var expectedInfo = new ErgodoxLayout ( )
18+ {
19+ Geometry = geometry ,
20+ Title = "ezlayout" ,
21+ HashId = "asdf" ,
22+ Tags = new List < ErgodoxTag > {
23+ new ErgodoxTag {
24+ Name = tag
25+ }
26+ } ,
27+ Revisions = new List < Revision > {
28+ new Revision {
29+ HexUrl = "" ,
30+ SourcesUrl = "" ,
31+ Model = "Model" ,
32+ Layers = new List < ErgodoxLayer > {
33+ new ErgodoxLayer ( ) {
34+ Title = "Layer" ,
35+ Position = 1
36+ }
37+ }
38+ }
39+ }
40+ } ;
41+
42+ return expectedInfo ;
43+ }
44+
45+ [ Fact ]
1646 public void SettingsViewModel_Constructor ( )
1747 {
1848 //Arrange
@@ -205,7 +235,7 @@ public void UpdateLayoutCommand_Execute(string layoutUrl, string expectedHashId)
205235 var mockWindowService = new Mock < IWindowService > ( ) ;
206236 var mockLayoutService = new Mock < ILayoutService > ( ) ;
207237 mockLayoutService . Setup ( l => l . GetErgodoxLayout ( expectedHashId ) ) . Returns ( Task . FromResult ( It . IsAny < ErgodoxLayout > ( ) ) ) . Verifiable ( ) ;
208- mockLayoutService . Setup ( l => l . PrepareEZLayout ( It . IsAny < ErgodoxLayout > ( ) ) ) . Verifiable ( ) ;
238+ mockLayoutService . Setup ( l => l . PrepareEZLayout ( It . IsAny < ErgodoxLayout > ( ) , It . IsAny < string > ( ) ) ) . Verifiable ( ) ;
209239 var mockProcessService = new Mock < IProcessService > ( ) ;
210240
211241 //Act
@@ -274,9 +304,7 @@ public void OpenTagSearchCommandExecute(string tag, string keyboardGeometry, int
274304 var mockWindowService = new Mock < IWindowService > ( ) ;
275305 var mockLayoutService = new Mock < ILayoutService > ( ) ;
276306 mockLayoutService . Setup ( l => l . GetLayoutInfo ( It . IsAny < string > ( ) ) )
277- . Returns ( Task . FromResult ( new ErgodoxLayout ( ) {
278- Geometry = keyboardGeometry
279- } ) ) ;
307+ . Returns ( Task . FromResult ( PrepareLayoutTree ( keyboardGeometry , tag ) ) ) ;
280308 var mockProcessService = new Mock < IProcessService > ( ) ;
281309 mockProcessService . Setup ( p => p . StartWebUrl ( It . IsAny < string > ( ) ) ) . Verifiable ( ) ;
282310
@@ -360,29 +388,7 @@ public void UpdateErgoDoxInfo_LayoutInfoNotNull(string geometry, string expected
360388 {
361389 // Arrange
362390 var expectedLayoutStatus = "Not compiled" ;
363- var expectedInfo = new ErgodoxLayout ( ) {
364- Geometry = geometry ,
365- Title = "ezlayout" ,
366- HashId = "asdf" ,
367- Tags = new List < ErgodoxTag > {
368- new ErgodoxTag {
369- Name = "Tag 1"
370- }
371- } ,
372- Revisions = new List < Revision > {
373- new Revision {
374- HexUrl = "" ,
375- SourcesUrl = "" ,
376- Model = "Model" ,
377- Layers = new List < ErgodoxLayer > {
378- new ErgodoxLayer ( ) {
379- Title = "Layer" ,
380- Position = 1
381- }
382- }
383- }
384- }
385- } ;
391+ var expectedInfo = PrepareLayoutTree ( geometry ) ;
386392 var mockSettingsService = new Mock < ISettingsService > ( ) ;
387393 mockSettingsService . SetupProperty ( s => s . ErgodoxLayoutUrl , "" ) ;
388394 var mockWindowService = new Mock < IWindowService > ( ) ;
@@ -452,25 +458,25 @@ public void UpdateErgoDoxInfo_DownloadUrls(string hexUrl, string sourcesUrl, str
452458 Assert . Equal ( expectedButtonStatus , settingsViewModel . DownloadSourcesCommand . CanExecute ( null ) ) ;
453459 }
454460
455- [ Theory ]
456- [ InlineData ( "https://url.com/hex-file" , "" , 0 ) ]
457- [ InlineData ( "" , "https://url.com/source-file" , 0 ) ]
458- [ InlineData ( "https://url.com/hex-file" , "https://url.com/source-file" , 1 ) ]
461+ [ Theory ]
462+ [ InlineData ( "https://url.com/hex-file" , "" , 0 ) ]
463+ [ InlineData ( "" , "https://url.com/source-file" , 0 ) ]
464+ [ InlineData ( "https://url.com/hex-file" , "https://url.com/source-file" , 1 ) ]
459465 public void DownloadHexFileCommand_Execute ( string hexUrl , string sourcesUrl , int expectedCommandExecute )
460466 {
461467 // Arrange
462- var expectedInfo = new ErgodoxLayout ( )
463- {
464- Geometry = "" ,
465- Title = "ezlayout" ,
466- HashId = "asdf" ,
467- Tags = new List < ErgodoxTag > {
468+ var expectedInfo = new ErgodoxLayout ( ) {
469+ Geometry = "" ,
470+ Title = "ezlayout" ,
471+ HashId = "asdf" ,
472+ Tags = new List < ErgodoxTag > {
468473 new ErgodoxTag {
469474 Name = "Tag 1"
470475 }
471476 } ,
472- Revisions = new List < Revision > {
477+ Revisions = new List < Revision > {
473478 new Revision {
479+ HashId = "hashId-1" ,
474480 HexUrl = hexUrl ,
475481 SourcesUrl = sourcesUrl ,
476482 Model = "Model" ,
@@ -482,7 +488,7 @@ public void DownloadHexFileCommand_Execute(string hexUrl, string sourcesUrl, int
482488 }
483489 }
484490 }
485- } ;
491+ } ;
486492 var mockSettingsService = new Mock < ISettingsService > ( ) ;
487493 mockSettingsService . SetupProperty ( s => s . ErgodoxLayoutUrl , "" ) ;
488494 var mockWindowService = new Mock < IWindowService > ( ) ;
@@ -499,24 +505,23 @@ public void DownloadHexFileCommand_Execute(string hexUrl, string sourcesUrl, int
499505 mockProcessService . Verify ( p => p . StartWebUrl ( hexUrl ) , Times . Exactly ( expectedCommandExecute ) ) ;
500506 }
501507
502- [ Theory ]
503- [ InlineData ( "https://url.com/hex-file" , "" , 0 ) ]
504- [ InlineData ( "" , "https://url.com/source-file" , 0 ) ]
505- [ InlineData ( "https://url.com/hex-file" , "https://url.com/source-file" , 1 ) ]
508+ [ Theory ]
509+ [ InlineData ( "https://url.com/hex-file" , "" , 0 ) ]
510+ [ InlineData ( "" , "https://url.com/source-file" , 0 ) ]
511+ [ InlineData ( "https://url.com/hex-file" , "https://url.com/source-file" , 1 ) ]
506512 public void DownloadSourcesCommand_Execute ( string hexUrl , string sourcesUrl , int expectedCommandExecute )
507513 {
508514 // Arrange
509- var expectedInfo = new ErgodoxLayout ( )
510- {
511- Geometry = "" ,
512- Title = "ezlayout" ,
513- HashId = "asdf" ,
514- Tags = new List < ErgodoxTag > {
515+ var expectedInfo = new ErgodoxLayout ( ) {
516+ Geometry = "" ,
517+ Title = "ezlayout" ,
518+ HashId = "asdf" ,
519+ Tags = new List < ErgodoxTag > {
515520 new ErgodoxTag {
516521 Name = "Tag 1"
517522 }
518523 } ,
519- Revisions = new List < Revision > {
524+ Revisions = new List < Revision > {
520525 new Revision {
521526 HexUrl = hexUrl ,
522527 SourcesUrl = sourcesUrl ,
@@ -529,7 +534,7 @@ public void DownloadSourcesCommand_Execute(string hexUrl, string sourcesUrl, int
529534 }
530535 }
531536 }
532- } ;
537+ } ;
533538 var mockSettingsService = new Mock < ISettingsService > ( ) ;
534539 mockSettingsService . SetupProperty ( s => s . ErgodoxLayoutUrl , "" ) ;
535540 var mockWindowService = new Mock < IWindowService > ( ) ;
0 commit comments