public void test2() { MemoryStream memoryStream = new MemoryStream(new byte[] { 0x31, 0x32, 0x33 }); // "123" in ascii/unicode hex MFileStream mFileStream = new MFileStream(); mFileStream.CanReadGet = () => memoryStream.CanRead; mFileStream.ReadByteArrayInt32Int32 = (byte[] array, int offset, int length) => memoryStream.Read(array, offset, length); MFile.OpenStringFileMode = (string path, FileMode mode) => mFileStream; Class13 clazz = new Class13(); Assert.AreEqual(2 * 123, clazz.generate2()); }