Beispiel #1
0
        public void Setup()
        {
            DebuggerFactory.WriteToConsole = true;
            var xDevice    = new TestBlockDevice();
            var xPartition = new Partition(xDevice, 0, xDevice.BlockCount);

            BlockDevice.Devices.Clear();
            Partition.Partitions.Clear();

            BlockDevice.Devices.Add(xDevice);
            Partition.Partitions.Add(xPartition);
            CosmosVFS cosmosVFS = new CosmosVFS();

            VFSManager.RegisterVFS(cosmosVFS, true);

            foreach (var disk in VFSManager.GetDisks())
            {
                foreach (var part in disk.Partitions)
                {
                    if (part.RootPath == @"0:\")
                    {
                        ourDisk = disk;
                        ourPart = part;
                        break;
                    }
                }
            }
            if (ourDisk == null)
            {
                throw new Exception("Failed to find our drive.");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Tests DiskManager.
        /// </summary>
        public static void Execute(Debugger mDebugger)
        {
            string           driveName = @"0:\";
            Disk             ourDisk   = null;
            ManagedPartition ourPart   = null;

            foreach (var disk in Kernel.mVFS.GetDisks())
            {
                foreach (var part in disk.Partitions)
                {
                    if (part.RootPath == driveName)
                    {
                        ourDisk = disk;
                        ourPart = part;
                        break;
                    }
                }
            }
            if (ourDisk == null)
            {
                throw new Exception("Failed to find our drive.");
            }

            mDebugger.Send("START TEST: Get Name");

            Assert.IsTrue(ourPart.RootPath == driveName, "ManagedPartition.RootPath failed drive has wrong name");

            mDebugger.Send("END TEST");

            //How to really test this? I fear the other tests relies on the fact that there are files on 0:

            mDebugger.Send("START TEST: Format");

            ourDisk.FormatPartition(0, "FAT32", true);

            mDebugger.Send("Format done testing HDD is really empty");

            var xDi = new DriveInfo(driveName);

            //If the drive is empty all Space should be free
            //Assert.IsTrue(xDi.TotalSize == xDi.TotalFreeSpace, "DiskManager.Format (quick) failed TotalFreeSpace is not the same of TotalSize");

            //Let's try to create a new file on the Root Directory
            File.Create(@"0:\newFile.txt");

            Assert.IsTrue(File.Exists(@"0:\newFile.txt") == true, "Failed to create new file after disk format");

            mDebugger.Send("END TEST");

            mDebugger.Send("Testing if you can create directories");

            Directory.CreateDirectory(@"0:\SYS\");
            Assert.IsTrue(Directory.GetDirectories(@"0:\SYS\").Length == 0, "Can create a directory and its content is emtpy");

            mDebugger.Send("END TEST");
        }