Exemple #1
0
    public void CreateFile()
    {
        var pathOfFileToCreate = "file.jpg";

        File.Delete(pathOfFileToCreate);
        #region CreateFile
        AllFiles.CreateFile(pathOfFileToCreate);
        #endregion
        Assert.True(File.Exists(pathOfFileToCreate));
        File.Delete(pathOfFileToCreate);

        AllFiles.CreateFile("foo.txt", true);
        Assert.True(File.Exists("foo.txt"));
        File.Delete("foo.txt");

        Assert.True(AllFiles.TryCreateFile(pathOfFileToCreate));
        Assert.True(File.Exists(pathOfFileToCreate));
        File.Delete(pathOfFileToCreate);

        Assert.False(AllFiles.TryCreateFile("foo.txt"));
        Assert.False(File.Exists("foo.txt"));
        File.Delete("foo.txt");

        Assert.True(AllFiles.TryCreateFile("foo.txt", true));
        Assert.True(File.Exists("foo.txt"));
        File.Delete("foo.txt");
    }
Exemple #2
0
 public void Unknown_extension()
 {
     Assert.Throws <Exception>(() => AllFiles.GetPathFor("txt"));
     Assert.False(AllFiles.TryGetPathFor("txt", out var result));
     Assert.Null(result);
     Assert.False(AllFiles.TryGetPathFor(".txt", out result));
     Assert.Null(result);
     Assert.False(AllFiles.TryCreateFile("foo.txt"));
     Assert.Null(result);
     Assert.Throws <Exception>(() => AllFiles.GetPathFor(".txt"));
     Assert.Throws <Exception>(() => AllFiles.CreateFile("foo.txt"));
 }