diff --git a/src/Tests/ControlTests/ResourceDataContextTests.cs b/src/Tests/ControlTests/ResourceDataContextTests.cs index 2bf0e800b6..249f6a1caa 100644 --- a/src/Tests/ControlTests/ResourceDataContextTests.cs +++ b/src/Tests/ControlTests/ResourceDataContextTests.cs @@ -10,7 +10,7 @@ using DotVVM.Framework.ViewModel; using Microsoft.VisualStudio.TestTools.UnitTesting; using DotVVM.Framework.Testing; -using System.Security.Claims; +using DotVVM.Framework.Compilation.Styles; namespace DotVVM.Framework.Tests.ControlTests { @@ -18,6 +18,8 @@ namespace DotVVM.Framework.Tests.ControlTests public class ResourceDataContextTests { static readonly ControlTestHelper cth = new ControlTestHelper(config: config => { + _ = Controls.Repeater.RenderAsNamedTemplateProperty; + config.Styles.Register().SetProperty(r => r.RenderAsNamedTemplate, false, StyleOverrideOptions.Ignore); }); OutputChecker check = new OutputChecker("testoutputs"); @@ -82,8 +84,6 @@ public async Task Repeater() {{resource: Name}} {{value: _parent.CommandData}} - - @@ -95,13 +95,22 @@ public async Task Repeater() {{resource: Name}} {{value: _parent.CommandData}} - - " ); check.CheckString(r.FormattedHtml, fileExtension: "html"); + } + + [TestMethod] + public async Task RepeaterWithCommand() + { + var r = await cth.RunPage(typeof(TestViewModel), @" + + + + " + ); await r.RunCommand("_root.TestMethod(Name)", x => x is TestViewModel.CustomerData { Id: 1 }); Assert.AreEqual((string)r.ViewModel.CommandData, "One"); @@ -110,6 +119,25 @@ public async Task Repeater() Assert.AreEqual((string)r.ViewModel.CommandData, "Two"); } + [TestMethod] + public async Task DataContextRevert() + { + // revert client-side data context by DataContext={value: _root...} + var r = await cth.RunPage(typeof(TestViewModel), @" + + + {{resource: Name}} + + + {{value: _root.StringPrefix + _this}} + + + " + ); + + check.CheckString(r.FormattedHtml, fileExtension: "html"); + } + public class TestViewModel: DotvvmViewModelBase { public string NullableString { get; } = null; @@ -129,6 +157,10 @@ public class TestViewModel: DotvvmViewModelBase } }; + public List FewStrings { get; set; } = new List() { "Hi!", "Ahoj!" }; + + public string StringPrefix { get; set; } = "..."; + public UploadedFilesCollection Files { get; set; } = new UploadedFilesCollection(); public record CustomerData( diff --git a/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.DataContextRevert.html b/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.DataContextRevert.html new file mode 100644 index 0000000000..8ebd8c519f --- /dev/null +++ b/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.DataContextRevert.html @@ -0,0 +1,15 @@ + + + + One +
+ + +
+ Two +
+ + +
+ + diff --git a/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.Repeater.html b/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.Repeater.html index 2307a6f7e6..f20094a32f 100644 --- a/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.Repeater.html +++ b/src/Tests/ControlTests/testoutputs/ResourceDataContextTests.Repeater.html @@ -5,21 +5,17 @@ One - ------------------- Two -
One - ------------------- Two -