diff options
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs b/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs deleted file mode 100644 index 15e5d334..00000000 --- a/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | |||
| 2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 3 | |||
| 4 | namespace WixToolsetTest.CoreIntegration | ||
| 5 | { | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using WixToolset.Core; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Data.Bind; | ||
| 10 | using WixToolset.Extensibility.Services; | ||
| 11 | using Xunit; | ||
| 12 | |||
| 13 | public class VariableResolverFixture | ||
| 14 | { | ||
| 15 | [Fact] | ||
| 16 | public void CanRecursivelyResolveVariables() | ||
| 17 | { | ||
| 18 | var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); | ||
| 19 | var variableResolver = serviceProvider.GetService<IVariableResolver>(); | ||
| 20 | |||
| 21 | var variables = new Dictionary<string, BindVariable>() | ||
| 22 | { | ||
| 23 | { "ProductName", new BindVariable() { Id = "ProductName", Value = "Localized Product Name" } }, | ||
| 24 | { "ProductNameEdition", new BindVariable() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" } }, | ||
| 25 | { "ProductNameEditionVersion", new BindVariable() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" } }, | ||
| 26 | }; | ||
| 27 | |||
| 28 | var localization = new Localization(0, null, "x-none", variables, new Dictionary<string,LocalizedControl>()); | ||
| 29 | |||
| 30 | variableResolver.AddLocalization(localization); | ||
| 31 | |||
| 32 | var result = variableResolver.ResolveVariables(null, "These are not the loc strings you're looking for."); | ||
| 33 | Assert.Equal("These are not the loc strings you're looking for.", result.Value); | ||
| 34 | Assert.False(result.UpdatedValue); | ||
| 35 | |||
| 36 | result = variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductName)"); | ||
| 37 | Assert.Equal("Welcome to Localized Product Name", result.Value); | ||
| 38 | Assert.True(result.UpdatedValue); | ||
| 39 | |||
| 40 | result = variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductNameEdition)"); | ||
| 41 | Assert.Equal("Welcome to Localized Product Name Enterprise Edition", result.Value); | ||
| 42 | Assert.True(result.UpdatedValue); | ||
| 43 | |||
| 44 | result = variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductNameEditionVersion)"); | ||
| 45 | Assert.Equal("Welcome to Localized Product Name Enterprise Edition v1.2.3", result.Value); | ||
| 46 | Assert.True(result.UpdatedValue); | ||
| 47 | |||
| 48 | result = variableResolver.ResolveVariables(null, "Welcome to !(bind.property.ProductVersion)"); | ||
| 49 | Assert.Equal("Welcome to !(bind.property.ProductVersion)", result.Value); | ||
| 50 | Assert.False(result.UpdatedValue); | ||
| 51 | Assert.True(result.DelayedResolve); | ||
| 52 | |||
| 53 | var withUnknownLocString = "Welcome to !(loc.UnknownLocalizationVariable)"; | ||
| 54 | Assert.Throws<WixException>(() => variableResolver.ResolveVariables(null, withUnknownLocString)); | ||
| 55 | |||
| 56 | result = variableResolver.ResolveVariables(null, withUnknownLocString, errorOnUnknown: false); | ||
| 57 | Assert.Equal(withUnknownLocString, result.Value); | ||
| 58 | Assert.False(result.UpdatedValue); | ||
| 59 | |||
| 60 | result = variableResolver.ResolveVariables(null, "Welcome to !!(loc.UnknownLocalizationVariable)"); | ||
| 61 | Assert.Equal("Welcome to !(loc.UnknownLocalizationVariable)", result.Value); | ||
| 62 | Assert.True(result.UpdatedValue); | ||
| 63 | |||
| 64 | result = variableResolver.ResolveVariables(null, "Welcome to !!(loc.UnknownLocalizationVariable) v!(bind.property.ProductVersion)"); | ||
| 65 | Assert.Equal("Welcome to !(loc.UnknownLocalizationVariable) v!(bind.property.ProductVersion)", result.Value); | ||
| 66 | Assert.True(result.UpdatedValue); | ||
| 67 | Assert.True(result.DelayedResolve); | ||
| 68 | |||
| 69 | result = variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductNameEditionVersion) !!(loc.UnknownLocalizationVariable) v!(bind.property.ProductVersion)"); | ||
| 70 | Assert.Equal("Welcome to Localized Product Name Enterprise Edition v1.2.3 !(loc.UnknownLocalizationVariable) v!(bind.property.ProductVersion)", result.Value); | ||
| 71 | Assert.True(result.UpdatedValue); | ||
| 72 | Assert.True(result.DelayedResolve); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
