Created
October 7, 2019 17:34
-
-
Save CopperStarSystems/1ae59643bd8bf8163441cd7eaf8d486d to your computer and use it in GitHub Desktop.
FileReader.cs with Framework Wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers; | |
namespace Tdd.FrameworkWrappers.Lib | |
{ | |
public class FileReader | |
{ | |
private readonly IFile file; | |
private readonly ILogger logger; | |
public FileReader(IFile file, ILogger logger) | |
{ | |
this.file = file; | |
this.logger = logger; | |
} | |
public string ReadText(string filePath) | |
{ | |
try | |
{ | |
return file.ReadAllText(filePath); | |
} | |
catch (Exception e) | |
{ | |
string message = $"Error reading file {filePath}"; | |
logger.Log(LogLevelEnum.Error, message); | |
throw; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment