Ejemplo n.º 1
0
        public void Test_ManifestResourceName_NonResx_DynamicPrefix()
        {
            VbcTask vbcTask = new VbcTask();

            vbcTask.Project       = CreateEmptyProject();
            vbcTask.CallStack     = vbcTask.Project.RootTargetCallStack;
            vbcTask.RootNamespace = "TestRootNamespace";

            ResourceFileSet resources = new ResourceFileSet();

            resources.BaseDirectory = TempDirectory;
            resources.DynamicPrefix = true;

            // holds the path to the resource file
            string resourceFile = null;

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.txt");
            // create resource file
            CreateTempFile(resourceFile);
            // assert manifest resource name
            Assert.AreEqual("SubDir" + "." + "ResourceFile.en-US.dunno.txt",
                            vbcTask.GetManifestResourceName(resources, resourceFile));
        }
Ejemplo n.º 2
0
        private void PerformDependentResxTests(VbcTask vbcTask, ResourceFileSet resources)
        {
            // holds the path to the resource file
            string resourceFile = null;

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName,
                                        "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCodeWithNamespace, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile.en-US.dunno." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".ResourceTest.HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));

            // initialize resource file
            resourceFile = Path.Combine(resources.BaseDirectory.FullName, "SubDir"
                                        + Path.DirectorySeparatorChar + "ResourceFile.en-US.dunno.en-US.resx");
            // create resource file
            CreateTempFile(resourceFile);
            // create dependent file
            TempFile.CreateWithContents(_sourceCode, Path.Combine(
                                            resources.BaseDirectory.FullName, "SubDir" + Path.DirectorySeparatorChar
                                            + "ResourceFile.en-US.dunno." + vbcTask.Extension));
            // assert manifest resource name
            Assert.AreEqual(vbcTask.RootNamespace + ".HelloWorld.en-US.resources",
                            vbcTask.GetManifestResourceName(resources, resourceFile));
        }