public void CarrierClusterStream_Write_Read_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); IList<Stream> streams = new List<Stream>(); foreach (string fileName in _fileNames) streams.Add(File.Open(fileName, FileMode.Open)); using (Stream carrierClusterStream = factory.BuildClusterStream<CarrierClusterStream>( new OneKeySequence(), streams)) { carrierClusterStream.Write(WRITE_READ_VALUE, 0, WRITE_READ_VALUE.Length); } streams.Clear(); foreach (string fileName in _fileNames) streams.Add(File.Open(fileName, FileMode.Open)); using (Stream carrierClusterStream = factory.BuildClusterStream<CarrierClusterStream>( new OneKeySequence(), streams)) { byte[] readResult = new byte[WRITE_READ_VALUE.Length]; carrierClusterStream.Seek(0, SeekOrigin.Begin); int readLength = carrierClusterStream.Read(readResult, 0, readResult.Length); Assert.AreEqual(WRITE_READ_VALUE.Length, readLength); Assert.AreEqual(WRITE_READ_VALUE, readResult); } }
public void BuildClusterStream_Throws_Exception_When_KeySequence_Is_Null() { CarrierStreamFactory clusterStreamFactory = new CarrierStreamFactory(); Assert.Throws <ArgumentNullException>(() => clusterStreamFactory.BuildClusterStream <CarrierClusterStream>(null, new List <Stream>())); }
public void BuildClusterStream_Throws_Exception_When_Stream_List_Is_Null() { CarrierStreamFactory clusterStreamFactory = new CarrierStreamFactory(); Assert.Throws <ArgumentNullException>(() => clusterStreamFactory.BuildClusterStream <CarrierClusterStream>(new OneKeySequence(), null)); }
public void BuildClusterStream_Throws_Exception_When_Stream_List_Is_Null() { CarrierStreamFactory clusterStreamFactory = new CarrierStreamFactory(); Assert.Throws<ArgumentNullException>(() => clusterStreamFactory.BuildClusterStream<CarrierClusterStream>(new OneKeySequence(), null)); }
public void BuildClusterStream_Throws_Exception_When_KeySequence_Is_Null() { CarrierStreamFactory clusterStreamFactory = new CarrierStreamFactory(); Assert.Throws<ArgumentNullException>(() => clusterStreamFactory.BuildClusterStream<CarrierClusterStream>(null, new List<Stream>())); }
public void CarrierClusterStream_Loads_Binary_Carrier_Stream_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); using (Stream carrierClusterStream = factory.BuildClusterStream <CarrierClusterStream>( new OneKeySequence(), new List <Stream> { File.Open(_fileName, FileMode.Open) })) { Assert.AreEqual(1000, carrierClusterStream.Length); } }
public void CarrierClusterStream_Write_Read_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); IList <Stream> streams = new List <Stream>(); foreach (string fileName in _fileNames) { streams.Add(File.Open(fileName, FileMode.Open)); } using (Stream carrierClusterStream = factory.BuildClusterStream <CarrierClusterStream>( new OneKeySequence(), streams)) { carrierClusterStream.Write(WRITE_READ_VALUE, 0, WRITE_READ_VALUE.Length); } streams.Clear(); foreach (string fileName in _fileNames) { streams.Add(File.Open(fileName, FileMode.Open)); } using (Stream carrierClusterStream = factory.BuildClusterStream <CarrierClusterStream>( new OneKeySequence(), streams)) { byte[] readResult = new byte[WRITE_READ_VALUE.Length]; carrierClusterStream.Seek(0, SeekOrigin.Begin); int readLength = carrierClusterStream.Read(readResult, 0, readResult.Length); Assert.AreEqual(WRITE_READ_VALUE.Length, readLength); Assert.AreEqual(WRITE_READ_VALUE, readResult); } }
public void CarrierClusterStream_Loads_Binary_Carrier_Stream_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); IList<Stream> streams = new List<Stream>(); foreach(string fileName in _fileNames) streams.Add(File.Open(fileName, FileMode.Open)); using (Stream carrierClusterStream = factory.BuildClusterStream<CarrierClusterStream>( new OneKeySequence(), streams)) { Assert.AreEqual(12, carrierClusterStream.Length); } }
static void Main(string[] args) { ICarrierStreamFactory factory = new CarrierStreamFactory(CARRIER_STREAM_PROVIDER_DIRECTORY); using (Stream carrierClusterStream = factory.BuildClusterStream("Basic", new OneKeySequence(), GetClusterFiles())) { DiscUtils.FileSystemInfo[] fsInfos = FileSystemManager.DetectDefaultFileSystems(carrierClusterStream); if (fsInfos != null && fsInfos.Count() > 0) { using (FatFileSystem fs = (FatFileSystem)fsInfos[0].Open(carrierClusterStream)) { foreach (DiscDirectoryInfo info in fs.Root.GetDirectories()) { Console.WriteLine(info.FullName); } DisplayDiskSize(fs); } } else { carrierClusterStream.Position = 0; Geometry geometry = Geometry.FromCapacity(carrierClusterStream.Length - 512); using (FatFileSystem fs = FatFileSystem.FormatPartition(carrierClusterStream, string.Empty, geometry, 0, geometry.TotalSectors, 13)) { DateTime start = DateTime.Now; for (int i = 0; i < 511; ++i) { fs.CreateDirectory(@"D" + i); } Console.WriteLine("511 Directories created in {0}", DateTime.Now - start); foreach (DiscDirectoryInfo info in fs.Root.GetDirectories()) { Console.WriteLine(info.FullName); } DisplayDiskSize(fs); } } } Console.ReadLine(); }
public void CarrierClusterStream_Loads_Binary_Carrier_Stream_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); IList <Stream> streams = new List <Stream>(); foreach (string fileName in _fileNames) { streams.Add(File.Open(fileName, FileMode.Open)); } using (Stream carrierClusterStream = factory.BuildClusterStream <CarrierClusterStream>( new OneKeySequence(), streams)) { Assert.AreEqual(12, carrierClusterStream.Length); } }
public void CarrierClusterStream_Write_Read_Successfully() { ICarrierStreamFactory factory = new CarrierStreamFactory(); factory.RegisterCarrierStreams(); using (Stream carrierClusterStream = factory.BuildClusterStream <CarrierClusterStream>( new OneKeySequence(), new List <Stream> { File.Open(_fileName, FileMode.Open) })) { byte[] writeHelloWorld = Encoding.ASCII.GetBytes("Hello World"); carrierClusterStream.Write(writeHelloWorld, 0, writeHelloWorld.Length); byte[] readHelloWorld = new byte[writeHelloWorld.Length]; carrierClusterStream.Seek(0, SeekOrigin.Begin); int readLength = carrierClusterStream.Read(readHelloWorld, 0, readHelloWorld.Length); Assert.AreEqual(writeHelloWorld.Length, readLength); Assert.AreEqual(writeHelloWorld, readHelloWorld); } }