public void ReadHeader() { var sc = new ServiceContainer(); var arch = new M68kArchitecture(sc, "m68k", new Dictionary <string, object>()); var macOS = new MacOSClassic(sc, arch); MemoryStream stm = new MemoryStream(); WriteBeUint32(stm, 0x00000010); WriteBeUint32(stm, 0x00000020); WriteBeUint32(stm, 0x00000010); WriteBeUint32(stm, 0x00000010); stm.Write(Encoding.ASCII.GetBytes("Hello world!Hello world!"), 0, 0x10); stm.Write(new byte[0x10], 0, 0x10); // copy of header WriteBeUint32(stm, 0); // next resource map. WriteBeUint16(stm, 0); WriteBeUint16(stm, 0); WriteBeUint16(stm, 0x1C); WriteBeUint16(stm, 0); WriteBeUint16(stm, 0); WriteAsciiString(stm, "CODE"); // 001E: type list WriteBeUint16(stm, 0); WriteBeUint16(stm, 8); WriteBeUint16(stm, 0); // resource ID WriteBeUint16(stm, 0x0C); stm.WriteByte(0); stm.WriteByte(0); stm.WriteByte(0); stm.WriteByte(0x10); WriteBeUint32(stm, 0); stm.WriteByte(4); WriteAsciiString(stm, "Test"); ResourceFork rsrc = new ResourceFork(macOS, stm.GetBuffer()); Assert.AreEqual(1, rsrc.ResourceTypes.Count); IEnumerator <ResourceFork.ResourceType> ert = rsrc.ResourceTypes.GetEnumerator(); Assert.IsTrue(ert.MoveNext()); ResourceFork.ResourceType rt = ert.Current; Assert.AreEqual("CODE", rt.Name); Assert.AreEqual(1, rt.References.Count); }
public void ReadHeader() { MemoryStream stm = new MemoryStream(); WriteBeUint32(stm, 0x00000010); WriteBeUint32(stm, 0x00000020); WriteBeUint32(stm, 0x00000010); WriteBeUint32(stm, 0x00000010); stm.Write(Encoding.ASCII.GetBytes("Hello world!Hello world!"), 0, 0x10); stm.Write(new byte[0x10], 0, 0x10); // copy of header WriteBeUint32(stm, 0); // next resource map. WriteBeUint16(stm, 0); WriteBeUint16(stm, 0); WriteBeUint16(stm, 0x1C); WriteBeUint16(stm, 0); WriteBeUint16(stm, 0); WriteAsciiString(stm, "CODE"); // 001E: type list WriteBeUint16(stm, 0); WriteBeUint16(stm, 8); WriteBeUint16(stm, 0); // resource ID WriteBeUint16(stm, 0x0C); stm.WriteByte(0); stm.WriteByte(0); stm.WriteByte(0); stm.WriteByte(0x10); WriteBeUint32(stm, 0); stm.WriteByte(4); WriteAsciiString(stm, "Test"); ResourceFork rsrc = new ResourceFork(stm.GetBuffer(), new UnitTests.Mocks.FakeArchitecture()); Assert.AreEqual(1, rsrc.ResourceTypes.Count); IEnumerator <ResourceFork.ResourceType> ert = rsrc.ResourceTypes.GetEnumerator(); Assert.IsTrue(ert.MoveNext()); ResourceFork.ResourceType rt = ert.Current; Assert.AreEqual("CODE", rt.Name); Assert.AreEqual(1, rt.References.Count); }