Cosmos/Tests/Cosmos.Kernel.Tests.Fat/System.IO/FileStreamTest.cs
fanoI 6d2f9d5a8d [NOT MERGE THIS] Stack Overflow everywhere
During the test and plugging of DirectoryInfo I've benn hit by a lot of stack overflows / stack corruptions.
I do this PR because I've not the necessary competency to find where the issue his, executing the Cosmos.Kernel.Tests.Fat.Kernel you will be soon hit by a stack overflow.
2017-08-22 13:23:23 +02:00

36 lines
1.5 KiB
C#

using System.IO;
using Cosmos.TestRunner;
using Cosmos.Debug.Kernel;
using Cosmos.Common.Extensions;
namespace Cosmos.Kernel.Tests.Fat.System.IO
{
class FileStreamTest
{
/// <summary>
/// Tests System.IO.FileStream plugs.
/// </summary>
public static void Execute(Debugger mDebugger)
{
mDebugger.Send("START TEST: Filestream:");
using (var xFS = new FileStream(@"0:\Kudzu.txt", FileMode.Create))
{
mDebugger.Send("Start writing");
var xStr = "Test FAT Write.";
byte[] xWriteBuff = xStr.GetUtf8Bytes(0, (uint)xStr.Length);
xFS.Write(xWriteBuff, 0, xWriteBuff.Length);
mDebugger.Send("---- Data written");
xFS.Position = 0;
byte[] xReadBuff = new byte[xWriteBuff.Length];
xFS.Read(xReadBuff, 0, xWriteBuff.Length);
mDebugger.Send("xWriteBuff " + xWriteBuff.GetUtf8String(0, (uint)xWriteBuff.Length) + " xReadBuff " +
xReadBuff.GetUtf8String(0, (uint)xWriteBuff.Length));
string xWriteBuffAsString = xWriteBuff.GetUtf8String(0, (uint)xWriteBuff.Length);
string xReadBuffAsString = xReadBuff.GetUtf8String(0, (uint)xReadBuff.Length);
Assert.IsTrue(xWriteBuffAsString == xReadBuffAsString, "Failed to write and read file");
mDebugger.Send("END TEST");
}
}
}
}