Пример #1
0
        public void WritesAndReadsRoundTrip()
        {
            // Arrange/Act
            var tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            var writer = new BlazorWriteSatelliteAssemblyFile
            {
                BuildEngine       = Mock.Of <IBuildEngine>(),
                WriteFile         = new TaskItem(tempFile),
                SatelliteAssembly = new[]
                {
                    new TaskItem("Resources.fr.dll", new Dictionary <string, string>
                    {
                        ["Culture"] = "fr",
                        ["DestinationSubDirectory"] = "fr\\",
                    }),
                    new TaskItem("Resources.ja-jp.dll", new Dictionary <string, string>
                    {
                        ["Culture"] = "ja-jp",
                        ["DestinationSubDirectory"] = "ja-jp\\",
                    }),
                },
            };

            var reader = new BlazorReadSatelliteAssemblyFile
            {
                BuildEngine = Mock.Of <IBuildEngine>(),
                ReadFile    = new TaskItem(tempFile),
            };

            writer.Execute();

            Assert.True(File.Exists(tempFile), "Write should have succeeded.");

            reader.Execute();

            Assert.Collection(
                reader.SatelliteAssembly,
                assembly =>
            {
                Assert.Equal("Resources.fr.dll", assembly.ItemSpec);
                Assert.Equal("fr", assembly.GetMetadata("Culture"));
                Assert.Equal("fr\\", assembly.GetMetadata("DestinationSubDirectory"));
            },
                assembly =>
            {
                Assert.Equal("Resources.ja-jp.dll", assembly.ItemSpec);
                Assert.Equal("ja-jp", assembly.GetMetadata("Culture"));
                Assert.Equal("ja-jp\\", assembly.GetMetadata("DestinationSubDirectory"));
            });
        }
        public void WritesAndReadsRoundTrip()
        {
            // Arrange/Act
            var tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            var writer = new BlazorWriteSatelliteAssemblyFile
            {
                BuildEngine       = Mock.Of <IBuildEngine>(),
                WriteFile         = new TaskItem(tempFile),
                SatelliteAssembly = new[]
                {
                    new TaskItem("Resources.fr.dll", new Dictionary <string, string>
                    {
                        ["Culture"] = "fr",
                        ["DestinationSubDirectory"] = "fr\\",
                    }),
                    new TaskItem("Resources.ja-jp.dll", new Dictionary <string, string>
                    {
                        ["Culture"] = "ja-jp",
                        ["DestinationSubDirectory"] = "ja-jp\\",
                    }),
                },
            };

            var reader = new BlazorReadSatelliteAssemblyFile
            {
                BuildEngine = Mock.Of <IBuildEngine>(),
                ReadFile    = new TaskItem(tempFile),
            };

            writer.Execute();

            File.Exists(tempFile).Should().BeTrue();

            reader.Execute();

            reader.SatelliteAssembly.Should().Contain(assembly =>
                                                      assembly.ItemSpec == "Resources.fr.dll" &&
                                                      assembly.GetMetadata("Culture") == "fr" &&
                                                      assembly.GetMetadata("DestinationSubDirectory") == "fr\\"
                                                      );

            reader.SatelliteAssembly.Should().Contain(assembly =>
                                                      assembly.ItemSpec == "Resources.ja-jp.dll" &&
                                                      assembly.GetMetadata("Culture") == "ja-jp" &&
                                                      assembly.GetMetadata("DestinationSubDirectory") == "ja-jp\\"
                                                      );
        }