aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/WixToolsetTest.Data/SerializeFixture.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.Data/SerializeFixture.cs b/src/test/WixToolsetTest.Data/SerializeFixture.cs
index 9883053f..1e03481d 100644
--- a/src/test/WixToolsetTest.Data/SerializeFixture.cs
+++ b/src/test/WixToolsetTest.Data/SerializeFixture.cs
@@ -6,6 +6,7 @@ namespace WixToolsetTest.Data
6 using System.IO; 6 using System.IO;
7 using System.Linq; 7 using System.Linq;
8 using WixToolset.Data; 8 using WixToolset.Data;
9 using WixToolset.Data.Bind;
9 using WixToolset.Data.Tuples; 10 using WixToolset.Data.Tuples;
10 using Xunit; 11 using Xunit;
11 12
@@ -39,5 +40,60 @@ namespace WixToolsetTest.Data
39 Assert.Equal("TestFolder", tuple.Directory_); 40 Assert.Equal("TestFolder", tuple.Directory_);
40 Assert.Equal(2, tuple.Attributes); 41 Assert.Equal(2, tuple.Attributes);
41 } 42 }
43
44 [Fact]
45 public void CanSaveAndLoadIntermediateWithLocalization()
46 {
47 var sln = new SourceLineNumber("test.wxs", 10);
48
49 var bindVariables = new[]
50 {
51 new BindVariable { Id = "TestVar1", Value = "TestValue1", SourceLineNumbers = sln },
52 new BindVariable { Id = "TestVar2", Value = "TestValue2", Overridable = true, SourceLineNumbers = sln },
53 };
54
55 var controls = new[]
56 {
57 new LocalizedControl("TestDlg1", "TestControl1", 10, 10, 100, 100, 0, null),
58 new LocalizedControl("TestDlg1", "TestControl2", 100, 90, 50, 70, 0, "localized"),
59 };
60
61 var localizations = new[]
62 {
63 new Localization(65001, null, bindVariables.ToDictionary(b => b.Id), controls.ToDictionary(c => c.GetKey()))
64 };
65
66 var section = new IntermediateSection("test", SectionType.Product, 65001);
67
68 section.Tuples.Add(new ComponentTuple(sln, new Identifier("TestComponent", AccessModifier.Public))
69 {
70 ComponentId = new Guid(1, 0, 0, new byte[8]).ToString("B"),
71 Directory_ = "TestFolder",
72 Attributes = 2,
73 });
74
75 var intermediate = new Intermediate("TestIntermediate", new[] { section }, localizations.ToDictionary(l => l.Culture), null);
76
77 var path = Path.GetTempFileName();
78 try
79 {
80 intermediate.Save(path);
81
82 var loaded = Intermediate.Load(path);
83
84 var loc = loaded.Localizations.Single();
85 Assert.Equal(65001, loc.Codepage);
86 Assert.Empty(loc.Culture);
87 Assert.Equal(new[]
88 {
89 "TestVar1/TestValue1/False",
90 "TestVar2/TestValue2/True",
91 }, loc.Variables.Select(v => String.Join("/", v.Id, v.Value, v.Overridable)).ToArray());
92 }
93 finally
94 {
95 File.Delete(path);
96 }
97 }
42 } 98 }
43} 99}