Exemplo n.º 1
0
		public void TestRead()
		{
			var Stream1 = new ZeroStream(5, 0x11);
			var Stream2 = new ZeroStream(3, 0x22);
			var MapStream = new MapStream();
			byte[] Readed1, Readed2, Readed3, Readed4;

			MapStream.Map(3, Stream1);
			MapStream.Map(3 + 5, Stream2);

			MapStream.Position = 4;

			Readed1 = MapStream.ReadBytesUpTo(3);
			CollectionAssert.AreEqual(new byte[] { 0x11, 0x11, 0x11 }, Readed1);

			Readed2 = MapStream.ReadBytesUpTo(3);
			CollectionAssert.AreEqual(new byte[] { 0x11, 0x22, 0x22 }, Readed2);

			Readed3 = MapStream.ReadBytesUpTo(1);
			CollectionAssert.AreEqual(new byte[] { 0x22 }, Readed3);

			MapStream.Position = 3;
			Readed4 = MapStream.ReadBytesUpTo(8);
			CollectionAssert.AreEqual(new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22 }, Readed4);
		}
Exemplo n.º 2
0
 public void TestRead()
 {
     var Stream = new ZeroStream(7, 0x11);
     byte[] Read1, Read2;
     Read1 = Stream.ReadBytesUpTo(3);
     CollectionAssert.AreEqual(new byte[] { 0x11, 0x11, 0x11 }, Read1);
     Read2 = Stream.ReadBytesUpTo(7);
     CollectionAssert.AreEqual(new byte[] { 0x11, 0x11, 0x11, 0x11 }, Read2);
 }
        public void TestReadAnalyzing()
        {
            var ZeroStream = new ZeroStream(0x1000000);
            var StreamAnalyzer = new ProxyStreamReadWriteAnalyzer(ZeroStream);
            StreamAnalyzer.Position = 100;
            StreamAnalyzer.ReadBytes(8);
            StreamAnalyzer.Position = 104;
            StreamAnalyzer.ReadBytes(8);

            StreamAnalyzer.Position = 200;
            StreamAnalyzer.ReadBytes(16);

            var Usage = StreamAnalyzer.ReadUsage;

            Assert.AreEqual(
                "Space(Min=100, Max=112),Space(Min=200, Max=216)",
                Usage.ToStringArray()
            );
        }