Skip to content

Commit

Permalink
moves strings to resources
Browse files Browse the repository at this point in the history
  • Loading branch information
manne committed Aug 7, 2016
1 parent fa609b8 commit e7238f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions TestingHelpers/MockDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public override string[] GetFiles(string path, string searchPattern, SearchOptio

if (!Exists(path))
{
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, path));
}

return GetFilesInternal(mockFileDataAccessor.AllFiles, path, searchPattern, searchOption);
Expand Down Expand Up @@ -423,7 +423,7 @@ public override IEnumerable<string> EnumerateDirectories(string path, string sea

if (!Exists(path))
{
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, path));
}

var dirs = GetFilesInternal(mockFileDataAccessor.AllDirectories, path, searchPattern, searchOption);
Expand Down
12 changes: 6 additions & 6 deletions TestingHelpers/MockFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void AppendAllText(string path, string contents, Encoding encodi
var dir = mockFileDataAccessor.Path.GetDirectoryName(path);
if (!mockFileDataAccessor.Directory.Exists(dir))
{
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, path));
}

mockFileDataAccessor.AddFile(path, new MockFileData(contents, encoding));
Expand Down Expand Up @@ -101,12 +101,12 @@ public override void Copy(string sourceFileName, string destFileName, bool overw
{
if (sourceFileName == null)
{
throw new ArgumentNullException("sourceFileName", "File name cannot be null.");
throw new ArgumentNullException("sourceFileName", Properties.Resources.FILENAME_CANNOT_BE_NULL);
}

if (destFileName == null)
{
throw new ArgumentNullException("destFileName", "File name cannot be null.");
throw new ArgumentNullException("destFileName", Properties.Resources.FILENAME_CANNOT_BE_NULL);
}

mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(sourceFileName, "sourceFileName");
Expand All @@ -115,7 +115,7 @@ public override void Copy(string sourceFileName, string destFileName, bool overw
var directoryNameOfDestination = mockPath.GetDirectoryName(destFileName);
if (!mockFileDataAccessor.Directory.Exists(directoryNameOfDestination))
{
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", destFileName));
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, destFileName));
}

var fileExists = mockFileDataAccessor.FileExists(destFileName);
Expand Down Expand Up @@ -316,12 +316,12 @@ public override void Move(string sourceFileName, string destFileName)
{
if (sourceFileName == null)
{
throw new ArgumentNullException("sourceFileName", "File name cannot be null.");
throw new ArgumentNullException("sourceFileName", Properties.Resources.FILENAME_CANNOT_BE_NULL);
}

if (destFileName == null)
{
throw new ArgumentNullException("destFileName", "File name cannot be null.");
throw new ArgumentNullException("destFileName", Properties.Resources.FILENAME_CANNOT_BE_NULL);
}

mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(sourceFileName, "sourceFileName");
Expand Down
9 changes: 9 additions & 0 deletions TestingHelpers/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions TestingHelpers/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,7 @@
<data name="PATH_CANNOT_BE_THE_EMPTY_STRING_OR_ALL_WHITESPACE" xml:space="preserve">
<value>Path cannot be the empty string or all whitespace.</value>
</data>
<data name="FILENAME_CANNOT_BE_NULL" xml:space="preserve">
<value>File name cannot be null.</value>
</data>
</root>

0 comments on commit e7238f2

Please sign in to comment.