예제 #1
0
        public async Task GenerateCode()
        {
            const string projectName  = "MyTest";
            var          fakeTemplate = $"{InfoPlistGenerator.ApplicationNameReplacement}-{InfoPlistGenerator.IndentifierReplacement}";
            var          tmpPath      = Path.GetTempPath();
            var          templatePath = Path.Combine(tmpPath, Path.GetRandomFileName());

            using (var file = new StreamWriter(templatePath, false))
            {
                await file.WriteAsync(fakeTemplate);
            }

            var result = await InfoPlistGenerator.GenerateCodeAsync(File.OpenRead(templatePath), projectName);

            try
            {
                Assert.DoesNotContain(InfoPlistGenerator.ApplicationNameReplacement, result);
                Assert.DoesNotContain(InfoPlistGenerator.IndentifierReplacement, result);
                Assert.Contains(projectName, result);
            }
            finally
            {
                File.Delete(templatePath);
            }
        }
예제 #2
0
        public void GenerateCodeNullProjectName()
        {
            var tmp = Path.GetTempFileName();

            File.WriteAllText(tmp, "Hello");
            using (var stream = new FileStream(tmp, FileMode.Open)) {
                Assert.ThrowsAsync <ArgumentNullException> (() => InfoPlistGenerator.GenerateCodeAsync(stream, null));
            }

            File.Delete(tmp);
        }
 public void GenerateCodeNullProjectName()
 {
     Assert.Throws <ArgumentNullException> (() => InfoPlistGenerator.GenerateCode("Hello", null));
 }
 public void GenerateCodeNullTemplateFile()
 {
     Assert.Throws <ArgumentNullException> (() =>
                                            InfoPlistGenerator.GenerateCode(null, "Project Name"));
 }