using System; using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; using CPF; using System.Text; using HWModules; using Microsoft.SPOT; namespace CPFUnitTests { [TestClass] public class UnitTestEngLogger { [TestMethod] public void TestLotsOfLoggerWrites() { Init(); int n = 0; while (n < 10) { n++; EngrLogger.writeToColumns("HELLO WORLD"); } return; } [TestMethod] public void TestStateChange() { TestLotsOfLoggerWrites(); } private bool runonce = false; private void Init() { if (!runonce) { runonce = true; //EngrLogger.init(Program.cpfState); } } /// /// This test creates a file, writes a few bytes to it, then /// prints out the number of files in a single directory. /// [TestMethod] public void TestManyFileCreations() { Init(); StringBuilder fname = new StringBuilder("test_"); FileStream fid; byte[] msg = {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x2E}; for (int n = 1; n < 20000; n++) { fname.Clear().Append("\\SD\\test\\test_").Append(n.ToString("D6")).Append(".txt"); if (File.Exists(fname.ToString())) File.Delete(fname.ToString()); Debug.Print("Writing File: " + fname); fid = new FileStream(fname.ToString(), FileMode.Append); for (int i = 0; i<100; i++) fid.Write(msg, 0, msg.Length); fid.Close(); String[] dirbuff = Directory.GetFiles("\\SD\\test\\"); Debug.Print("Files: " + dirbuff.Length); } } } }