From aab5747c7b13236fb7bcdda8412814168a3979c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20=C5=A0est=C3=A1k?= Date: Thu, 18 Feb 2021 17:49:35 +0100 Subject: [PATCH] Fixed common tests --- .../Binding/StaticCommandCompilationTests.cs | 4 +- .../ConfigurationSerializationTests.cs | 62 +++++++++++-------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/DotVVM.Framework.Tests.Common/Binding/StaticCommandCompilationTests.cs b/src/DotVVM.Framework.Tests.Common/Binding/StaticCommandCompilationTests.cs index a2a3d27cf1..f3ac30bc4c 100644 --- a/src/DotVVM.Framework.Tests.Common/Binding/StaticCommandCompilationTests.cs +++ b/src/DotVVM.Framework.Tests.Common/Binding/StaticCommandCompilationTests.cs @@ -348,14 +348,14 @@ public void StaticCommandCompilation_MarkupControlCommandPropertyUsed_WithSamePr { TestMarkupControl.CreateInitialized(); - var result = CompileBinding("StringProp = _control.Chanege(StringProp) + injectedService.Load(StringProp)", niceMode: true, new[] { typeof(TestViewModel) }, typeof(Command), typeof(TestMarkupControl)); + var result = CompileBinding("StringProp = _control.Change(StringProp) + injectedService.Load(StringProp)", niceMode: true, new[] { typeof(TestViewModel) }, typeof(Command), typeof(TestMarkupControl)); var expectedReslt = @" (function(a, c, b) { return new Promise(function(resolve, reject) { ( b = dotvvm.staticCommandPostback(a, ""WARNING/NOT/ENCRYPTED+++WyJEb3RWVk0uRnJhbWV3b3JrLlRlc3RzLkJpbmRpbmcuVGVzdFNlcnZpY2UsIERvdFZWTS5GcmFtZXdvcmsuVGVzdHMuQ29tbW9uIiwiTG9hZCIsW10sIkFRQT0iXQ=="", [c.$data.StringProp()], options) , - Promise.resolve(c.$control.Chanege()(c.$data.StringProp())).then(function(r_0) { + Promise.resolve(c.$control.Change()(c.$data.StringProp())).then(function(r_0) { b.then(function(r_1) { resolve(c.$data.StringProp(r_0 + r_1).StringProp()); }, reject); diff --git a/src/DotVVM.Framework.Tests.Common/Runtime/ConfigurationSerializationTests.cs b/src/DotVVM.Framework.Tests.Common/Runtime/ConfigurationSerializationTests.cs index 792adbe191..d668d0b5b8 100644 --- a/src/DotVVM.Framework.Tests.Common/Runtime/ConfigurationSerializationTests.cs +++ b/src/DotVVM.Framework.Tests.Common/Runtime/ConfigurationSerializationTests.cs @@ -32,19 +32,28 @@ void checkConfig(DotvvmConfiguration config, string checkName = null, string fil [TestMethod] public void SerializeDefaultConfig() { - checkConfig(DotvvmConfiguration.CreateDefault()); + var c = DotvvmConfiguration.CreateDefault(); + c.DefaultCulture = "en-US"; + checkConfig(c); + } + + private static DotvvmConfiguration CreateTestConfiguration() + { + var c = new DotvvmConfiguration(); + c.DefaultCulture = "en-US"; + return c; } [TestMethod] public void SerializeEmptyConfig() { - checkConfig(new DotvvmConfiguration()); + checkConfig(CreateTestConfiguration()); } [TestMethod] public void SerializeRoutes() { - var c = new DotvvmConfiguration(); + var c = CreateTestConfiguration(); c.RouteTable.Add("route1", "url1", "file1.dothtml", new { a = "ccc" }); c.RouteTable.Add("route2", "url2/{int}", "file1.dothtml", new { a = "ccc" }); @@ -66,28 +75,29 @@ public void SerializeRoutes() [TestMethod] public void SerializeResources() { - var c = new DotvvmConfiguration(); + var c = CreateTestConfiguration(); + c.Resources.Register("r1", new ScriptResource( new UrlResourceLocation("x")) { - IntegrityHash = "hash, maybe", - VerifyResourceIntegrity = true, - RenderPosition = ResourceRenderPosition.Head - }); + IntegrityHash = "hash, maybe", + VerifyResourceIntegrity = true, + RenderPosition = ResourceRenderPosition.Head + }); c.Resources.Register("r2", new ScriptResource( new UrlResourceLocation("x")) { - Dependencies = new [] { "r1" }, - LocationFallback = new ResourceLocationFallback("window.x", new IResourceLocation [] { + Dependencies = new[] { "r1" }, + LocationFallback = new ResourceLocationFallback("window.x", new IResourceLocation[] { new UrlResourceLocation("y"), new UrlResourceLocation("z"), new FileResourceLocation("some-script.js") }) - } + } ); c.Resources.Register("r3", new StylesheetResource( new UrlResourceLocation("s")) { - IntegrityHash = "hash, maybe", - VerifyResourceIntegrity = true - } + IntegrityHash = "hash, maybe", + VerifyResourceIntegrity = true + } ); c.Resources.Register("r4", new InlineStylesheetResource("body { display: none }")); c.Resources.Register("r5", new InlineStylesheetResource(new FileResourceLocation("some-style.css"))); @@ -97,25 +107,23 @@ public void SerializeResources() c.Resources.Register("r9", new TemplateResource("
")); - checkConfig(c); + checkConfig(c); } [TestMethod] public void ExperimentalFeatures() { - var c = new DotvvmConfiguration(); - - c.ExperimentalFeatures.LazyCsrfToken.EnableForAllRoutesExcept(new [] { "r1", "r2" }); - c.ExperimentalFeatures.ServerSideViewModelCache.EnableForRoutes(new [] { "r1", "r2" }); + var c = CreateTestConfiguration(); + c.ExperimentalFeatures.LazyCsrfToken.EnableForAllRoutesExcept(new[] { "r1", "r2" }); + c.ExperimentalFeatures.ServerSideViewModelCache.EnableForRoutes(new[] { "r1", "r2" }); - checkConfig(c); + checkConfig(c); } [TestMethod] public void Markup() { - var c = new DotvvmConfiguration(); - + var c = CreateTestConfiguration(); c.Markup.DefaultDirectives.Add("dir1", "MyDirective"); c.Markup.AddCodeControls("myControls", typeof(ControlLifeCycleMock)); c.Markup.AddMarkupControl("myControls", "C1", "./Controls/C1.dotcontrol"); @@ -126,23 +134,23 @@ public void Markup() c.Markup.ImportedNamespaces.Add(new NamespaceImport("System.Collections", "Collections")); c.Markup.HtmlAttributeTransforms.Add(new HtmlTagAttributePair { AttributeName = "data-uri", TagName = "div" }, new HtmlAttributeTransformConfiguration { Type = typeof(TranslateVirtualPathHtmlAttributeTransformer) }); - checkConfig(c); + checkConfig(c); } [TestMethod] public void RestAPI() { - var c = new DotvvmConfiguration(); + var c = CreateTestConfiguration(); c.RegisterApiClient(typeof(Binding.TestApiClient), "http://server/api", "./apiscript.js", "_testApi"); - checkConfig(c); + checkConfig(c); } [TestMethod] public void AuxOptions() { - var c = new DotvvmConfiguration(); + var c = CreateTestConfiguration(); c.Debug = true; c.ApplicationPhysicalPath = "/opt/myApp"; @@ -150,7 +158,7 @@ public void AuxOptions() c.DefaultCulture = "cs-CZ"; c.UseHistoryApiSpaNavigation = true; - checkConfig(c); + checkConfig(c); } }