11using libmsstyle ;
22using Microsoft . VisualStudio . TestTools . UnitTesting ;
33using System ;
4+ using System . Collections ;
45using System . Collections . Generic ;
56using System . Drawing ;
67using System . IO ;
@@ -19,22 +20,45 @@ public class LoadSaveConsistency
1920 [ DataRow ( @"..\..\..\styles\w10_1709_aero.msstyles" ) ]
2021 [ DataRow ( @"..\..\..\styles\w10_1809_aero.msstyles" ) ]
2122 [ DataRow ( @"..\..\..\styles\w10_1903_aero.msstyles" ) ]
23+ [ DataRow ( @"..\..\..\styles\w10_2004_aero\aero.msstyles" ) ]
2224 [ DataRow ( @"..\..\..\styles\w10_20h2_aero.msstyles" ) ]
2325 [ DataRow ( @"..\..\..\styles\w11_pre_aero.msstyles" ) ]
24- public void VerifyLoadSave ( string file )
26+ [ DataRow ( @"..\..\..\styles\w11_pre_aero.msstyles" , true ) ]
27+ public void VerifyLoadSave ( string file , bool standalone = false )
2528 {
2629 using ( var original = new VisualStyle ( ) )
2730 using ( var saved = new VisualStyle ( ) )
2831 {
2932 original . Load ( file ) ;
30- original . Save ( "tmp.msstyles" ) ;
33+ original . Save ( "tmp.msstyles" , standalone ) ;
3134 saved . Load ( "tmp.msstyles" ) ;
3235
3336 bool result = CompareStyles ( original , saved ) ;
3437 Assert . IsTrue ( result ) ;
3538 }
3639 }
3740
41+
42+ [ DataTestMethod ]
43+ [ DataRow ( @"..\..\..\styles\w10_2004_aero\aero.msstyles" , true ) ]
44+ public void VerifyLoadSave_WithStringTable ( string file , bool standalone )
45+ {
46+ using ( var original = new VisualStyle ( ) )
47+ using ( var saved = new VisualStyle ( ) )
48+ {
49+ original . Load ( file ) ;
50+ original . Save ( "tmp.msstyles" , standalone ) ;
51+ saved . Load ( "tmp.msstyles" ) ;
52+
53+ bool result = CompareStyles ( original , saved ) ;
54+ Assert . IsTrue ( result ) ;
55+
56+ bool sresult = CompareStringTables ( original . StringTables , saved . StringTables ) ;
57+ Assert . IsTrue ( sresult ) ;
58+ }
59+ }
60+
61+
3862 [ TestCleanup ]
3963 public void TestCleanup ( )
4064 {
@@ -147,5 +171,47 @@ bool CompareStyles(VisualStyle s1, VisualStyle s2)
147171
148172 return result ;
149173 }
174+
175+
176+ bool CompareStringTables ( Dictionary < int , Dictionary < int , string > > s1 , Dictionary < int , Dictionary < int , string > > s2 )
177+ {
178+ bool result = true ;
179+
180+ // for all languages in the original style
181+ foreach ( var langTable in s1 )
182+ {
183+ // see if there is a table in the other one
184+ Dictionary < int , string > s2table ;
185+ if ( s2 . TryGetValue ( langTable . Key , out s2table ) )
186+ {
187+ // foreach entry in the languages string table
188+ foreach ( var entry in langTable . Value )
189+ {
190+ // see if the entry exists and matches in the other one
191+ string s2tablevalue ;
192+ if ( s2table . TryGetValue ( entry . Key , out s2tablevalue ) )
193+ {
194+ if ( ! entry . Value . Equals ( s2tablevalue ) )
195+ {
196+ LogMessage ( ConsoleColor . DarkRed , "For language {0}, entry {1} mismatches\r \n " , langTable . Key , entry . Key ) ;
197+ result = false ;
198+ }
199+ }
200+ else
201+ {
202+ LogMessage ( ConsoleColor . DarkRed , "For language {0}, entry {1} is missing!\r \n " , langTable . Key , entry . Key ) ;
203+ result = false ;
204+ }
205+ }
206+ }
207+ else
208+ {
209+ LogMessage ( ConsoleColor . DarkRed , "Missing string table for language {0}\r \n " , langTable . Key ) ;
210+ result = false ;
211+ }
212+ }
213+
214+ return result ;
215+ }
150216 }
151217}
0 commit comments