public void Rename_NormalFile()
    {
        var          mockFileSystem  = CreateMockFileSystem();
        var          mockFile        = new MockFileInfo(mockFileSystem, filePathA);
        const string renamedFileName = "newFileName.txt";
        string       renamedFilePath = Path.Combine(targetDirPath, renamedFileName);

        mockFile.Rename(renamedFilePath);
        mockFile.Refresh();

        mockFile.FullName
        .Should().Be(renamedFilePath);

        mockFile.Name
        .Should().Be(renamedFileName);

        mockFileSystem.AllPaths
        .Should().NotContain(filePathA);
        mockFileSystem.AllPaths
        .Should().Contain(renamedFilePath);
    }
    public void Rename_File_OnlyCase()
    {
        var          mockFileSystem  = CreateMockFileSystem();
        var          mockFile        = new MockFileInfo(mockFileSystem, filePathA);
        const string renamedFileName = "a.txt";
        string       renamedFilePath = Path.Combine(targetDirPath, renamedFileName);

        mockFile.Rename(renamedFilePath);
        mockFile.Refresh();

        mockFile.FullName
        .Should().Be(renamedFilePath);

        mockFile.Name
        .Should().Be(renamedFileName);

        //MockFileSystemのバグ?変更されない
        //mockFileSystem.AllPaths
        //    .Should().NotContain(filePathA);
        //mockFileSystem.AllPaths
        //    .Should().Contain(renamedFilePath);
    }
Exemplo n.º 3
0
 public void Refresh()
 {
     _fileInfo.Refresh();
 }