public void GivenPath_AndContent_AndPathNotExists_WhenWriteAllText_ThenFileCreatedAtPathContainingContent() { // Arrange var id = Guid.NewGuid().ToString(); var path = $"{id}.txt"; var contents = id; var sut = new FileIOService(); // Act sut.WriteAllText( path, contents); // Assert Assert.True(File.Exists(path)); _tempFiles.Add(path); Assert.Equal(contents, File.ReadAllText(path)); }
public void GivenPath_AndContent_AndPathExists_WhenWriteAllText_ThenFileOverwrittenAtPathWithNewContent() { // Arrange var id = Guid.NewGuid().ToString(); var path = $"{id}.txt"; var contents1 = $"{id}.1"; var contents2 = $"{id}.1"; File.WriteAllText( path, contents1); _tempFiles.Add(path); var sut = new FileIOService(); // Act sut.WriteAllText( path, contents2); // Assert Assert.True(File.Exists(path)); Assert.Equal(contents2, File.ReadAllText(path)); }