From 3734023699f9ebb35959e5301fc106cf4cb2580a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Herceg?= Date: Sun, 22 Oct 2023 11:11:38 +0200 Subject: [PATCH] Fixed unit tests to run in the order used in VS --- .../Hosting/DotvvmPropertySerializableList.cs | 5 ++++- .../Binding/JavascriptCompilationTests.cs | 20 +++++++++++++------ src/Tests/DotVVM.Framework.Tests.csproj | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Framework/Framework/Hosting/DotvvmPropertySerializableList.cs b/src/Framework/Framework/Hosting/DotvvmPropertySerializableList.cs index f474ef3b28..45f44103ba 100644 --- a/src/Framework/Framework/Hosting/DotvvmPropertySerializableList.cs +++ b/src/Framework/Framework/Hosting/DotvvmPropertySerializableList.cs @@ -14,6 +14,7 @@ static class DotvvmPropertySerializableList { public static SortedDictionary> Properties => DotvvmProperty.AllProperties + .Where(p => !p.DeclaringType.Assembly.IsDynamic) .Where(p => p is not DotvvmCapabilityProperty) .Select(p => new { @@ -46,6 +47,7 @@ static class DotvvmPropertySerializableList public static SortedDictionary> Capabilities => DotvvmProperty.AllProperties + .Where(p => !p.DeclaringType.Assembly.IsDynamic) .OfType() .Select(p => new { @@ -65,6 +67,7 @@ static class DotvvmPropertySerializableList public static SortedDictionary> PropertyGroups => DotvvmPropertyGroup.AllGroups + .Where(p => !p.DeclaringType.Assembly.IsDynamic) .Select(p => new { declaringType = p.DeclaringType, @@ -91,7 +94,7 @@ static class DotvvmPropertySerializableList public static SortedDictionary GetControls(CompiledAssemblyCache assemblies) { var result = new SortedDictionary(StringComparer.OrdinalIgnoreCase); - foreach (var a in assemblies.GetAllAssemblies()) + foreach (var a in assemblies.GetAllAssemblies().Where(a => !a.IsDynamic)) { foreach (var c in a.GetLoadableTypes()) { diff --git a/src/Tests/Binding/JavascriptCompilationTests.cs b/src/Tests/Binding/JavascriptCompilationTests.cs index 0afcb96536..c028ef10e7 100644 --- a/src/Tests/Binding/JavascriptCompilationTests.cs +++ b/src/Tests/Binding/JavascriptCompilationTests.cs @@ -63,17 +63,24 @@ public string CompileBinding(Func, Expression> ex [DataRow("'Local' == _this", "\"Local\"==$data")] [DataRow("_this == 2", "$data==\"Local\"")] [DataRow("2 == _this", "\"Local\"==$data")] - [DataRow("_this & 'Local'", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"G0/GAE51KlQlMR5T\")&2,\"G0/GAE51KlQlMR5T\")")] - [DataRow("'Local' & _this", "dotvvm.translations.enums.fromInt(2&dotvvm.translations.enums.toInt($data,\"G0/GAE51KlQlMR5T\"),\"G0/GAE51KlQlMR5T\")")] - [DataRow("_this | 'Local'", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"G0/GAE51KlQlMR5T\")|2,\"G0/GAE51KlQlMR5T\")")] - [DataRow("_this & 1", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"G0/GAE51KlQlMR5T\")&1,\"G0/GAE51KlQlMR5T\")")] - [DataRow("1 & _this", "dotvvm.translations.enums.fromInt(1&dotvvm.translations.enums.toInt($data,\"G0/GAE51KlQlMR5T\"),\"G0/GAE51KlQlMR5T\")")] + [DataRow("_this & 'Local'", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"bmCpvOUHn4NxUNdc\")&2,\"bmCpvOUHn4NxUNdc\")")] + [DataRow("'Local' & _this", "dotvvm.translations.enums.fromInt(2&dotvvm.translations.enums.toInt($data,\"bmCpvOUHn4NxUNdc\"),\"bmCpvOUHn4NxUNdc\")")] + [DataRow("_this | 'Local'", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"bmCpvOUHn4NxUNdc\")|2,\"bmCpvOUHn4NxUNdc\")")] + [DataRow("_this & 1", "dotvvm.translations.enums.fromInt(dotvvm.translations.enums.toInt($data,\"bmCpvOUHn4NxUNdc\")&1,\"bmCpvOUHn4NxUNdc\")")] + [DataRow("1 & _this", "dotvvm.translations.enums.fromInt(1&dotvvm.translations.enums.toInt($data,\"bmCpvOUHn4NxUNdc\"),\"bmCpvOUHn4NxUNdc\")")] public void JavascriptCompilation_EnumOperators(string expr, string expectedJs) { - var js = CompileBinding(expr, typeof(DateTimeKind)); + var js = CompileBinding(expr, typeof(OurDateTimeKind)); Assert.AreEqual(expectedJs, js); } + enum OurDateTimeKind + { + Unspecified = 0, + Utc = 1, + Local = 2, + } + [DataTestMethod] [DataRow("StringProp + StringProp", "(StringProp()??\"\")+(StringProp()??\"\")")] [DataRow("StringProp + null", "StringProp()??\"\"")] @@ -1282,6 +1289,7 @@ public void JavascriptCompilation_ApiRefreshOn() [TestMethod] public void JavascriptCompilation_MarkupControlProperty() { + _ = TestMarkupControl.SomePropertyProperty; var dataContext = bindingHelper.CreateDataContext(new [] { typeof(object) }, markupControl: typeof(TestMarkupControl)); var result = bindingHelper.ValueBindingToJs("_control.SomeProperty + 'aa'", dataContext, niceMode: false); Assert.AreEqual("($control.SomeProperty()??\"\")+\"aa\"", result); diff --git a/src/Tests/DotVVM.Framework.Tests.csproj b/src/Tests/DotVVM.Framework.Tests.csproj index 3194a2cba2..13b8d7c0b7 100644 --- a/src/Tests/DotVVM.Framework.Tests.csproj +++ b/src/Tests/DotVVM.Framework.Tests.csproj @@ -42,7 +42,7 @@ - +