FileReader.cs with Framework Wrapper
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