public void GetFile_NonExistingFile_ReturnsNullVirtualFileInstance(string virtualPath)
        {
            // arrange

            // act
            var virtualFile = _virtualFiles.GetFile(virtualPath);

            // assert
            Assert.Equal(NullVirtualFile.Instance, virtualFile);
        }
Exemplo n.º 2
0
        public void Update_Razor_and_Markdown_pages_at_runtime()
        {
            var fs = new FileSystemVirtualFiles("~/../RazorRockstars.WebHost".MapHostAbsolutePath());

            var kurtRazor = fs.GetFile("stars/dead/cobain/default.cshtml");

            s3.WriteFile(kurtRazor.VirtualPath, "[UPDATED RAZOR] " + kurtRazor.ReadAllText());

            var kurtMarkdown = fs.GetFile("stars/dead/cobain/Content.md");

            s3.WriteFile(kurtMarkdown.VirtualPath, "[UPDATED MARKDOWN] " + kurtMarkdown.ReadAllText());
        }
        public void ExistingFile_ReturnsCorrectMetadata(
            string virtualPath,
            string expectedFileName,
            string expectedExtension,
            string expectedVirtualPath)
        {
            // arrange
            _virtualFiles.WriteFile(virtualPath, "some content");
            var virtualFile = _virtualFiles.GetFile(virtualPath);

            // act

            // assert
            Assert.Equal(expectedFileName, virtualFile.Name);
            Assert.Equal(expectedExtension, virtualFile.Extension);
            Assert.False(virtualFile.IsDirectory);
            Assert.Equal(expectedVirtualPath, virtualFile.VirtualPath);
            Assert.Equal(
                $"{TestConfiguration.RootDirectory}\\{expectedVirtualPath.Replace('/', '\\')}",
                virtualFile.RealPath
                );
        }
Exemplo n.º 4
0
    public async Task Create_TypeScript_Definitions_Publish()
    {
        Directory.SetCurrentDirectory(NetCoreTestsDir);
        await ProcessUtils.RunShellAsync("rd /q /s types && tsc",
                                         onOut :   Console.WriteLine,
                                         onError : Console.Error.WriteLine);

        // Export API Explorer's .d.ts to 'explorer'
        Directory.Move("types/ui", "types/explorer");
        Directory.Move("types/admin-ui", "types/admin");

        FileSystemVirtualFiles.RecreateDirectory("dist");
        File.Copy("../NorthwindAuto/node_modules/@servicestack/client/dist/index.d.ts", "dist/client.d.ts");
        File.Copy("../NorthwindAuto/node_modules/@servicestack/client/dist/index.d.ts", "../NorthwindAuto/lib/client.d.ts", overwrite: true);

        var memFs   = new MemoryVirtualFiles();
        var typesFs = new FileSystemVirtualFiles("types");
        var distFs  = new FileSystemVirtualFiles("dist");

        var typesFile = typesFs.GetFile("lib/types.d.ts");

        memFs.WriteFile("0_" + typesFile.Name, typesFile);
        memFs.TransformAndCopy("shared", typesFs, distFs);

        memFs.Clear();
        memFs.TransformAndCopy("locode", typesFs, distFs);

        memFs.Clear();
        memFs.TransformAndCopy("explorer", typesFs, distFs);

        memFs.Clear();
        memFs.TransformAndCopy("admin", typesFs, distFs);

        var libFs = new FileSystemVirtualFiles("../../../../servicestack-ui".AssertDir());

        libFs.CopyFrom(distFs.GetAllFiles());
    }