Ejemplo n.º 1
0
 public void Setup()
 {
     file = new StringWriter();
     file.Write("(This file must be converted with BinHex 4.0)");
     stm = new MemoryStream();
     enc = new BinHexEncoder(file);
 }
Ejemplo n.º 2
0
        public void LoadHeader()
        {
            StringWriter file = new StringWriter();
            BinHexEncoder enc = new BinHexEncoder(file);
            enc.WriteHeader();
            Encoding ascii = Encoding.ASCII;
            byte [] filename = ascii.GetBytes("foo.bar");
            enc.Encode((byte)filename.Length);
            enc.Encode(filename);
            enc.Encode(0x00);
            enc.Encode(ascii.GetBytes("FTYP"));
            enc.Encode(ascii.GetBytes("CREA"));
            enc.Encode(ascii.GetBytes("FL"));
            enc.Encode(new byte[] { 0x01, 0x02, 0x03, 0x04 });
            enc.Encode(new byte[] { 0x05, 0x06, 0x07, 0x08 });
            enc.Encode(0x00);
            enc.Encode(0x00);
            enc.Flush();

            BinHexImageLoader loader = new BinHexImageLoader(null, "foo.bar", null);
            BinHexHeader hdr = loader.LoadBinHexHeader(CreateDecoder(file).GetBytes().GetEnumerator());
            Assert.AreEqual("foo.bar", hdr.FileName);
            Assert.AreEqual("FTYP", hdr.FileType);
            Assert.AreEqual("CREA", hdr.FileCreator);
            Assert.AreEqual(0x01020304, hdr.DataForkLength, string.Format("{0:X8}:{1:X8}", 0x01020304, hdr.DataForkLength));
            Assert.AreEqual(0x05060708, hdr.ResourceForkLength);
        }