@@ -12,20 +12,22 @@ namespace InvvardDev.EZLayoutDisplay.Tests.ViewModel
1212{
1313 public class SettingsViewModelTest
1414 {
15+ private const string RevisionHashId = "hashId-1" ;
16+
1517 private static ErgodoxLayout PrepareLayoutTree ( string geometry = "ergodox-ez" , string tag = "Tag 1" )
1618 {
17- var expectedInfo = new ErgodoxLayout ( )
18- {
19- Geometry = geometry ,
20- Title = "ezlayout" ,
21- HashId = "asdf" ,
22- Tags = new List < ErgodoxTag > {
19+ var expectedInfo = new ErgodoxLayout ( ) {
20+ Geometry = geometry ,
21+ Title = "ezlayout" ,
22+ HashId = "asdf" ,
23+ Tags = new List < ErgodoxTag > {
2324 new ErgodoxTag {
2425 Name = tag
2526 }
2627 } ,
27- Revisions = new List < Revision > {
28+ Revisions = new List < Revision > {
2829 new Revision {
30+ HashId = RevisionHashId ,
2931 HexUrl = "" ,
3032 SourcesUrl = "" ,
3133 Model = "Model" ,
@@ -37,12 +39,12 @@ private static ErgodoxLayout PrepareLayoutTree(string geometry = "ergodox-ez", s
3739 }
3840 }
3941 }
40- } ;
42+ } ;
4143
4244 return expectedInfo ;
4345 }
4446
45- [ Fact ]
47+ [ Fact ]
4648 public void SettingsViewModel_Constructor ( )
4749 {
4850 //Arrange
@@ -212,30 +214,31 @@ public void CloseCommand_Execute(bool mustSave)
212214 }
213215
214216 [ Theory ]
215- [ InlineData ( "https://configure.ergodox-ez.com/layouts/abcd/latest/0" , "default" ) ]
216- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/abcd/sdfs/0" , "abcd" ) ]
217- [ InlineData ( "https://configure.ergodox-ez.com/planck-ez/layouts/abcd/latest/0" , "abcd" ) ]
218- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/1234/asdf/0" , "1234" ) ]
219- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/a2Vt/latest/0" , "a2Vt" ) ]
220- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/default/latest/0" , "default" ) ]
221- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/j3o4" , "j3o4" ) ]
222- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/j3o4/" , "j3o4" ) ]
223- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/r2d2/lat/9" , "r2d2" ) ]
224- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/def/latest/0" , "default" ) ] // Less than 4 layout ID character length
225- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/_t3s/latest/0" , "default" ) ]
226- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/t3s/latest/0" , "default" ) ]
227- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/adbcd/latest/0" , "adbcd" ) ]
228- [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0" , "asdfasdfasdfasdfgfasdffgasf" ) ]
229- [ InlineData ( "https://configure.ergodox-ez.com/plante-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0" , "default" ) ]
230- public void UpdateLayoutCommand_Execute ( string layoutUrl , string expectedHashId )
217+ [ InlineData ( "https://configure.ergodox-ez.com/layouts/abcd/latest/0" , "default" , RevisionHashId ) ]
218+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/abcd/sdfs/0" , "abcd" , "sdfs" ) ]
219+ [ InlineData ( "https://configure.ergodox-ez.com/planck-ez/layouts/abcd/latest/0" , "abcd" , RevisionHashId ) ]
220+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/1234/asdf/0" , "1234" , "asdf" ) ]
221+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/a2Vt/latest/0" , "a2Vt" , RevisionHashId ) ]
222+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/default/latest/0" , "default" , RevisionHashId ) ]
223+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/j3o4" , "j3o4" , RevisionHashId ) ]
224+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/j3o4/" , "j3o4" , RevisionHashId ) ]
225+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/r2d2/lat/9" , "r2d2" , "lat" ) ]
226+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/def/latest/0" , "default" , RevisionHashId ) ] // Less than 4 layout ID character length
227+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/_t3s/latest/0" , "default" , RevisionHashId ) ]
228+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/t3s/latest/0" , "default" , RevisionHashId ) ]
229+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/adbcd/latest/0" , "adbcd" , RevisionHashId ) ]
230+ [ InlineData ( "https://configure.ergodox-ez.com/ergodox-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0" , "asdfasdfasdfasdfgfasdffgasf" , RevisionHashId ) ]
231+ [ InlineData ( "https://configure.ergodox-ez.com/plante-ez/layouts/asdfasdfasdfasdfgfasdffgasf/latest/0" , "default" , RevisionHashId ) ]
232+ public void UpdateLayoutCommand_Execute ( string layoutUrl , string expectedHashId , string expectedRevisionHashId )
231233 {
232234 //Arrange
233235 var mockSettingsService = new Mock < ISettingsService > ( ) ;
234236 mockSettingsService . SetupProperty ( s => s . ErgodoxLayoutUrl , layoutUrl ) ;
235237 var mockWindowService = new Mock < IWindowService > ( ) ;
236238 var mockLayoutService = new Mock < ILayoutService > ( ) ;
239+ mockLayoutService . Setup ( l => l . GetLayoutInfo ( expectedHashId ) ) . Returns ( Task . FromResult ( PrepareLayoutTree ( ) ) ) ;
237240 mockLayoutService . Setup ( l => l . GetErgodoxLayout ( expectedHashId ) ) . Returns ( Task . FromResult ( It . IsAny < ErgodoxLayout > ( ) ) ) . Verifiable ( ) ;
238- mockLayoutService . Setup ( l => l . PrepareEZLayout ( It . IsAny < ErgodoxLayout > ( ) , It . IsAny < string > ( ) ) ) . Verifiable ( ) ;
241+ mockLayoutService . Setup ( l => l . PrepareEZLayout ( It . IsAny < ErgodoxLayout > ( ) , expectedRevisionHashId ) ) . Verifiable ( ) ;
239242 var mockProcessService = new Mock < IProcessService > ( ) ;
240243
241244 //Act
0 commit comments