1010using DotVVM . Framework . ViewModel ;
1111using Microsoft . VisualStudio . TestTools . UnitTesting ;
1212using DotVVM . Framework . Testing ;
13- using System . Security . Claims ;
13+ using DotVVM . Framework . Compilation . Styles ;
1414
1515namespace DotVVM . Framework . Tests . ControlTests
1616{
1717 [ TestClass ]
1818 public class ResourceDataContextTests
1919 {
2020 static readonly ControlTestHelper cth = new ControlTestHelper ( config : config => {
21+ _ = Controls . Repeater . RenderAsNamedTemplateProperty ;
22+ config . Styles . Register < Repeater > ( ) . SetProperty ( r => r . RenderAsNamedTemplate , false , StyleOverrideOptions . Ignore ) ;
2123 } ) ;
2224 OutputChecker check = new OutputChecker ( "testoutputs" ) ;
2325
@@ -82,8 +84,6 @@ public async Task Repeater()
8284 <span class=name data-id={resource: Id}>{{resource: Name}}</span>
8385
8486 <span>{{value: _parent.CommandData}}</span>
85-
86- <dot:Button Click={command: _root.TestMethod(Name)} />
8787 </dot:Repeater>
8888
8989 <!-- with wrapper tag -->
@@ -100,6 +100,17 @@ public async Task Repeater()
100100 ) ;
101101
102102 check . CheckString ( r . FormattedHtml , fileExtension : "html" ) ;
103+ }
104+
105+ [ TestMethod ]
106+ public async Task RepeaterWithCommand ( )
107+ {
108+ var r = await cth . RunPage ( typeof ( TestViewModel ) , @"
109+ <dot:Repeater DataSource={resource: Customers.Items}>
110+ <dot:Button Click={command: _root.TestMethod(Name)} />
111+ </dot:Repeater>
112+ "
113+ ) ;
103114
104115 await r . RunCommand ( "_root.TestMethod(Name)" , x => x is TestViewModel . CustomerData { Id : 1 } ) ;
105116 Assert . AreEqual ( ( string ) r . ViewModel . CommandData , "One" ) ;
@@ -108,6 +119,25 @@ public async Task Repeater()
108119 Assert . AreEqual ( ( string ) r . ViewModel . CommandData , "Two" ) ;
109120 }
110121
122+ [ TestMethod ]
123+ public async Task DataContextRevert ( )
124+ {
125+ // revert client-side data context by DataContext={value: _root...}
126+ var r = await cth . RunPage ( typeof ( TestViewModel ) , @"
127+
128+ <dot:Repeater DataSource={resource: Customers.Items} RenderWrapperTag=false>
129+ <span class=name data-id={resource: Id}>{{resource: Name}}</span>
130+
131+ <dot:Repeater DataSource={value: _root.FewStrings}>
132+ {{value: _root.StringPrefix + _this}}
133+ </dot:Repeater>
134+ </dot:Repeater>
135+ "
136+ ) ;
137+
138+ check . CheckString ( r . FormattedHtml , fileExtension : "html" ) ;
139+ }
140+
111141 public class TestViewModel : DotvvmViewModelBase
112142 {
113143 public string NullableString { get ; } = null ;
@@ -127,6 +157,10 @@ public class TestViewModel: DotvvmViewModelBase
127157 }
128158 } ;
129159
160+ public List < string > FewStrings { get ; set ; } = new List < string > ( ) { "Hi!" , "Ahoj!" } ;
161+
162+ public string StringPrefix { get ; set ; } = "..." ;
163+
130164 public UploadedFilesCollection Files { get ; set ; } = new UploadedFilesCollection ( ) ;
131165
132166 public record CustomerData (
0 commit comments