@@ -149,6 +149,84 @@ public void UndoRedoChangeGroupTest()
149149 AssertLog ( "" ) ;
150150 }
151151
152+ [ Test ]
153+ public void UndoRedoImplicitList ( )
154+ {
155+ UndoRedoListInternal ( false ) ;
156+ }
157+
158+ [ Test ]
159+ public void UndoRedoExplicitList ( )
160+ {
161+ UndoRedoListInternal ( true ) ;
162+ }
163+
164+ void UndoRedoListInternal ( bool useExplicitList )
165+ {
166+ DesignItem button = CreateCanvasContext ( "<Button/>" ) ;
167+ UndoService s = button . Context . Services . GetService < UndoService > ( ) ;
168+ IComponentService component = button . Context . Services . Component ;
169+ string expectedXamlWithList ;
170+
171+ Assert . IsFalse ( s . CanUndo ) ;
172+ Assert . IsFalse ( s . CanRedo ) ;
173+
174+ using ( ChangeGroup g = button . OpenGroup ( "UndoRedoListInternal test" ) ) {
175+ DesignItem containerItem = component . RegisterComponentForDesigner ( new ICSharpCode . WpfDesign . Tests . XamlDom . ExampleClassContainer ( ) ) ;
176+
177+ var otherListProp = containerItem . Properties [ "OtherList" ] ;
178+
179+ if ( useExplicitList ) {
180+ otherListProp . SetValue ( new ICSharpCode . WpfDesign . Tests . XamlDom . ExampleClassList ( ) ) ;
181+
182+ expectedXamlWithList = @"<Button>
183+ <Button.Tag>
184+ <Controls0:ExampleClassContainer>
185+ <Controls0:ExampleClassContainer.OtherList>
186+ <Controls0:ExampleClassList>
187+ <Controls0:ExampleClass StringProp=""String value"" />
188+ </Controls0:ExampleClassList>
189+ </Controls0:ExampleClassContainer.OtherList>
190+ </Controls0:ExampleClassContainer>
191+ </Button.Tag>
192+ </Button>" ;
193+ }
194+ else {
195+ expectedXamlWithList = @"<Button>
196+ <Button.Tag>
197+ <Controls0:ExampleClassContainer>
198+ <Controls0:ExampleClassContainer.OtherList>
199+ <Controls0:ExampleClass StringProp=""String value"" />
200+ </Controls0:ExampleClassContainer.OtherList>
201+ </Controls0:ExampleClassContainer>
202+ </Button.Tag>
203+ </Button>" ;
204+ }
205+
206+ DesignItem exampleClassItem = component . RegisterComponentForDesigner ( new ICSharpCode . WpfDesign . Tests . XamlDom . ExampleClass ( ) ) ;
207+ exampleClassItem . Properties [ "StringProp" ] . SetValue ( "String value" ) ;
208+ otherListProp . CollectionElements . Add ( exampleClassItem ) ;
209+
210+ button . Properties [ "Tag" ] . SetValue ( containerItem ) ;
211+ g . Commit ( ) ;
212+ }
213+
214+ Assert . IsTrue ( s . CanUndo ) ;
215+ Assert . IsFalse ( s . CanRedo ) ;
216+ AssertCanvasDesignerOutput ( expectedXamlWithList , button . Context , "xmlns:Controls0=\" " + ICSharpCode . WpfDesign . Tests . XamlDom . XamlTypeFinderTests . XamlDomTestsNamespace + "\" " ) ;
217+
218+ s . Undo ( ) ;
219+ Assert . IsFalse ( s . CanUndo ) ;
220+ Assert . IsTrue ( s . CanRedo ) ;
221+ AssertCanvasDesignerOutput ( "<Button>\n </Button>" , button . Context , "xmlns:Controls0=\" " + ICSharpCode . WpfDesign . Tests . XamlDom . XamlTypeFinderTests . XamlDomTestsNamespace + "\" " ) ;
222+
223+ s . Redo ( ) ;
224+ Assert . IsTrue ( s . CanUndo ) ;
225+ Assert . IsFalse ( s . CanRedo ) ;
226+ AssertCanvasDesignerOutput ( expectedXamlWithList , button . Context , "xmlns:Controls0=\" " + ICSharpCode . WpfDesign . Tests . XamlDom . XamlTypeFinderTests . XamlDomTestsNamespace + "\" " ) ;
227+
228+ AssertLog ( "" ) ;
229+ }
152230
153231 [ Test ]
154232 public void AddTextBoxToCanvas ( )
0 commit comments