public void ReturnsExistFalse_OnExistingTemplate()
        {
            string templateKey = "Assets/Files/IDoNotExist.cshtml";
            var    fileInfo    = new FileInfo(Path.Combine(DirectoryUtils.RootDirectory, templateKey));

            var item = new FileSystemRazorProjectItem(templateKey, fileInfo);

            Assert.False(item.Exists);
        }
        public void Ensure_ConstructorParams_AreApplied()
        {
            string templateKey = "Assets/Files/Empty.cshtml";
            var    fileInfo    = new FileInfo(Path.Combine(DirectoryUtils.RootDirectory, templateKey));

            var item = new FileSystemRazorProjectItem(templateKey, fileInfo);

            Assert.NotNull(item);
            Assert.Equal(item.Key, templateKey);
            Assert.Equal(item.File, fileInfo);
        }
        public void Read_ReturnsFileContent()
        {
            string templateKey  = "Assets/Files/Empty.cshtml";
            string templatePath = Path.Combine(DirectoryUtils.RootDirectory, templateKey);
            string fileContent  = File.ReadAllText(templatePath);

            var    item        = new FileSystemRazorProjectItem(templateKey, new FileInfo(templatePath));
            string itemContent = null;

            using (var reader = new StreamReader(item.Read()))
            {
                itemContent = reader.ReadToEnd();
            }

            Assert.NotNull(itemContent);
            Assert.Equal(fileContent, itemContent);
        }
Esempio n. 4
0
        private VirtualRazorProjectFileSystem GetVirtualRazorProjectSystem(SourceItem[] inputItems)
        {
            var project = new VirtualRazorProjectFileSystem();

            foreach (var item in inputItems)
            {
                var projectItem = new FileSystemRazorProjectItem(
                    basePath: "/",
                    filePath: item.FilePath,
                    relativePhysicalPath: item.RelativePhysicalPath,
                    file: new FileInfo(item.SourcePath));

                project.Add(projectItem);
            }

            return(project);
        }