Exemplo n.º 1
0
        public void LooksLikeCultureButIsnt()
        {
            AssignCulture t = new AssignCulture();
            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.yy.resx");
            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(1, t.CultureNeutralAssignedFiles.Length);
            Assert.Equal(String.Empty, t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("MyResource.yy.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.yy.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 2
0
        public void Basic()
        {
            AssignCulture t = new AssignCulture();
            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.fr.resx");
            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(1, t.CultureNeutralAssignedFiles.Length);
            Assert.Equal("fr", t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("MyResource.fr.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 3
0
        public void Regress283991()
        {
            AssignCulture t = new AssignCulture();
            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.fr.resx");
            i.SetMetadata("DependentUpon", "MyResourcE.fr.vb");
            t.Files = new ITaskItem[] { i };

            t.Execute();

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(0, t.AssignedFilesWithCulture.Length);
            Assert.Equal(1, t.AssignedFilesWithNoCulture.Length);
        }
Exemplo n.º 4
0
        public void CultureAttributePrecedenceWithBogusCulture()
        {
            AssignCulture t = new AssignCulture();
            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.fr.resx");
            i.SetMetadata("Culture", "invalid");   // Bogus culture.
            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(1, t.CultureNeutralAssignedFiles.Length);
            Assert.Equal("fr", t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("MyResource.fr.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 5
0
        [InlineData("qps-Latn-x-sh")] // Windows 10+
        public void PseudoLocalization(string culture)
        {
            AssignCulture t = new AssignCulture();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem($"MyResource.{culture}.resx");

            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Single(t.AssignedFiles);
            Assert.Single(t.CultureNeutralAssignedFiles);
            Assert.Equal(culture, t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal($"MyResource.{culture}.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 6
0
        public void DoubleDot()
        {
            AssignCulture t = new AssignCulture();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource..resx");

            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Single(t.AssignedFiles);
            Assert.Single(t.CultureNeutralAssignedFiles);
            Assert.Equal(String.Empty, t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("MyResource..resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource..resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 7
0
        public void AttributeForwarding()
        {
            AssignCulture t = new AssignCulture();
            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.fr.resx");
            i.SetMetadata("MyAttribute", "My Random String");
            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Equal(1, t.AssignedFiles.Length);
            Assert.Equal(1, t.CultureNeutralAssignedFiles.Length);
            Assert.Equal("fr", t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("My Random String", t.AssignedFiles[0].GetMetadata("MyAttribute"));
            Assert.Equal("MyResource.fr.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 8
0
        public void NoExtension()
        {
            AssignCulture t = new AssignCulture();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource");

            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.AreEqual(1, t.AssignedFiles.Length);
            Assert.AreEqual(1, t.CultureNeutralAssignedFiles.Length);
            Assert.IsTrue(String.Empty == t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.AreEqual("MyResource", t.AssignedFiles[0].ItemSpec);
            Assert.AreEqual("MyResource", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }
Exemplo n.º 9
0
        public void CultureAttributePrecedence()
        {
            AssignCulture t = new AssignCulture();

            t.BuildEngine = new MockEngine();
            ITaskItem i = new TaskItem("MyResource.fr.resx");

            i.SetMetadata("Culture", "en-GB");
            t.Files = new ITaskItem[] { i };
            t.Execute();

            Assert.Single(t.AssignedFiles);
            Assert.Single(t.CultureNeutralAssignedFiles);
            Assert.Equal("fr", t.AssignedFiles[0].GetMetadata("Culture"));
            Assert.Equal("MyResource.fr.resx", t.AssignedFiles[0].ItemSpec);
            Assert.Equal("MyResource.resx", t.CultureNeutralAssignedFiles[0].ItemSpec);
        }