Ejemplo n.º 1
0
        public void TestWrite3()
        {
            MemoryStream        stream  = new MemoryStream();
            POIFSDocumentWriter dstream = new POIFSDocumentWriter(stream, 25);

            byte[] array = new byte[50];

            for (int j = 0; j < 50; j++)
            {
                array[j] = (byte)j;
            }
            dstream.Write(array, 1, 25);
            try
            {
                dstream.Write(array, 0, 1);
                Assert.Fail("Should have caught IOException");
            }
            catch (IOException)
            {
            }
            byte[] output = stream.ToArray();

            Assert.AreEqual(25, output.Length);
            for (int j = 0; j < 25; j++)
            {
                Assert.AreEqual((byte)(j + 1), output[j]);
            }
            stream.Close();
        }
Ejemplo n.º 2
0
        public void TestWrite2()
        {
            MemoryStream        stream  = new MemoryStream();
            POIFSDocumentWriter dstream = new POIFSDocumentWriter(stream, 25);

            for (int j = 0; j < 6; j++)
            {
                byte[] array = new byte[4];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = (byte)j;
                }
                dstream.Write(array);
            }
            try
            {
                byte[] array = new byte[4];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = (byte)7;
                }

                dstream.Write(array);
                Assert.Fail("Should have caught IOException");
            }
            catch (IOException)
            {
            }
            byte[] output = stream.ToArray();

            Assert.AreEqual(24, output.Length);
            for (int j = 0; j < 6; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    Assert.AreEqual((byte)j,
                                    output[(j * 4) + k], ((j * 4) + k).ToString());
                }
            }
            stream.Close();
        }