Esempio n. 1
0
        public void GeneratesCSharpForResxWithFormatMethods()
        {
            var resx       = Path.Combine(AppContext.BaseDirectory, "testassets", "Resources", "TestStrings.resx");
            var actualFile = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName());

            var engine = new MockEngine(_output);
            var task   = new GenerateResxSource
            {
                BuildEngine       = engine,
                ResourceFile      = resx,
                ResourceName      = "Microsoft.DotNet.TestStrings",
                ResourceClassName = "Microsoft.DotNet.TestStrings",
                EmitFormatMethods = true,
                Language          = "C#",
                OutputPath        = actualFile,
            };

            var expectedFile = Path.Combine(AppContext.BaseDirectory, "testassets", "Resources", "TestStrings.EmitFormatMethods.cs.txt");

            if (File.Exists(actualFile))
            {
                File.Delete(actualFile);
            }

            Assert.True(task.Execute(), "Task failed");

            Assert.Empty(engine.Warnings);

            Assert.True(File.Exists(actualFile), "Actual file does not exist");
            var actualFileContents = File.ReadAllText(actualFile);

            _output.WriteLine(actualFileContents);
            Assert.Equal(File.ReadAllText(expectedFile), actualFileContents, ignoreLineEndingDifferences: true);
        }
Esempio n. 2
0
        public void Errors_ResourceName()
        {
            var engine = new MockEngine();

            var task = new GenerateResxSource
            {
                BuildEngine = engine
            };

            bool result = task.Execute();

            Assert.Equal("ERROR : ResourceName not specified" + Environment.NewLine, engine.Log);
            Assert.False(result);
        }
 public void GetIdentifierFromResourceName(string name, string expectedIdentifier)
 {
     Assert.Equal(expectedIdentifier, GenerateResxSource.GetIdentifierFromResourceName(name));
 }