Fixed: U4-6054 "Unit test 'Umbraco.Tests.IO.AbstractFileSystemTests.Can_Get_Size()' fails" by looking at the size of the string not the file which can vary - possibly dependent on encoding.

This commit is contained in:
Chris Randle
2014-12-27 00:11:59 +00:00
parent 2f74dfe5cb
commit bc776d787e

View File

@@ -7,13 +7,22 @@ namespace Umbraco.Core.IO
{
public static long GetSize(this IFileSystem fs, string path)
{
using (var s = fs.OpenFile(path))
{
var size = s.Length;
s.Close();
return size;
}
using (var ms = new MemoryStream())
{
using (var sr = new StreamReader(ms))
{
using (Stream file = fs.OpenFile(path))
{
var bytes = new byte[file.Length];
file.Read(bytes, 0, (int) file.Length);
ms.Write(bytes, 0, (int) file.Length);
file.Close();
ms.Position = 0;
string str = sr.ReadToEnd();
return str.Length;
}
}
}
}
public static void CopyFile(this IFileSystem fs, string path, string newPath)