|
1 | | -using DotVVM.Framework.Binding; |
2 | | -using DotVVM.Framework.Controls; |
3 | | -using DotVVM.Framework.Runtime; |
4 | | -using Microsoft.VisualStudio.TestTools.UnitTesting; |
5 | 1 | using System; |
6 | 2 | using System.Collections.Generic; |
7 | 3 | using System.Linq; |
| 4 | +using System.Linq.Expressions; |
| 5 | +using System.Text.Json.Serialization; |
8 | 6 | using System.Threading.Tasks; |
| 7 | +using DotVVM.Framework.Binding; |
| 8 | +using DotVVM.Framework.Binding.Expressions; |
| 9 | +using DotVVM.Framework.Binding.Properties; |
9 | 10 | using DotVVM.Framework.Compilation; |
10 | 11 | using DotVVM.Framework.Compilation.Binding; |
11 | 12 | using DotVVM.Framework.Compilation.ControlTree; |
12 | 13 | using DotVVM.Framework.Compilation.Javascript; |
13 | 14 | using DotVVM.Framework.Compilation.Javascript.Ast; |
14 | | -using DotVVM.Framework.Testing; |
15 | 15 | using DotVVM.Framework.Configuration; |
16 | | -using System.Linq.Expressions; |
17 | | -using Microsoft.Extensions.DependencyInjection; |
| 16 | +using DotVVM.Framework.Controls; |
| 17 | +using DotVVM.Framework.Runtime; |
| 18 | +using DotVVM.Framework.Testing; |
18 | 19 | using DotVVM.Framework.Utils; |
19 | 20 | using DotVVM.Framework.ViewModel; |
20 | | -using System.Text.Json.Serialization; |
| 21 | +using Microsoft.Extensions.DependencyInjection; |
| 22 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 23 | +using static DotVVM.Framework.Configuration.FreezableUtils; |
21 | 24 |
|
22 | 25 | namespace DotVVM.Framework.Tests.Binding |
23 | 26 | { |
@@ -1511,6 +1514,19 @@ public void JavascriptCompilation_StringFunctions(string input, string expected) |
1511 | 1514 | Assert.AreEqual(expected, result); |
1512 | 1515 | } |
1513 | 1516 |
|
| 1517 | + [TestMethod] |
| 1518 | + [DataRow("VmArray.Where(v => string.IsNullOrEmpty(v.SomeString)).ToList()")] |
| 1519 | + [DataRow("VmArray.Where(v => string.IsNullOrWhiteSpace(v.SomeString)).ToList()")] |
| 1520 | + // Regression test: FormatParametrizedScript was called on a frozen JsBinaryExpression (from string.IsNullOrEmpty/IsNullOrWhiteSpace |
| 1521 | + // translation) causing ObjectIsFrozenException when computing SimplePathExpressionBindingProperty. |
| 1522 | + public void JavascriptCompilation_IsNullOrEmpty_InWhereLambda_DoesNotThrowOnSimplePathExpression(string expression) |
| 1523 | + { |
| 1524 | + var binding = bindingHelper.ValueBinding<IEnumerable<TestViewModel2>>( |
| 1525 | + expression, |
| 1526 | + new[] { typeof(TestViewModel) }); |
| 1527 | + var simplePath = binding.GetProperty(typeof(SimplePathExpressionBindingProperty), ErrorHandlingMode.ThrowException); |
| 1528 | + } |
| 1529 | + |
1514 | 1530 | [TestMethod] |
1515 | 1531 | public void JavascriptCompilation_CustomPrimitiveToString() |
1516 | 1532 | { |
|
0 commit comments