Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StorageStream"/> class.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <remarks></remarks>
        public StorageStream(StorageStream s)
        {
            if (s == null) {
                throw new ArgumentNullException();
            }

            s.CopyTo(this);
        }
Пример #2
0
        public void SetUp()
        {
            commonUri = new Uri("SplashScreenImage.jpg", UriKind.Relative);
            commonIOStore = new IOStorage(commonUri);

            // delete the file from previous test
            IOStorage.GetUserFileArea.DeleteFile(commonUri.OriginalString);

            // Create the file with one stream and load it with a different stream
            commonStream = new StorageStream(Application.GetResourceStream(commonUri).Stream);
            commonIOStore.Save(commonStream);
        }
        public void TestStorageStreamCopyConstructor1()
        {
            Stream s = new MemoryStream();
            StorageStream srcStream = new StorageStream(s);
            srcStream.Position = 10;

            Assert.IsTrue(s.Position == 0);
            Assert.IsTrue(srcStream.Position == 10);

            // this should throw ArgumentNullException
            s = new StorageStream((Stream)null);
        }
Пример #4
0
        /// <summary>
        /// Reads all the bytes from the current stream and writes them to the destination stream.
        /// </summary>
        /// <param name="destination">The destination.</param>
        /// <remarks></remarks>
        public void CopyTo(StorageStream destination)
        {
            if (destination == null) {
                throw new ArgumentNullException();
            }

            base.CopyTo(destination);
            destination.Position = 0;
        }
 public void TestStorageStreamDefaultConstructor()
 {
     StorageStream s = new StorageStream();
     Assert.IsTrue(s.Position == 0);
 }
 public void TestStorageStreamCopyTo()
 {
     StorageStream srcStream = new StorageStream();
     StorageStream destStream = null;
     srcStream.CopyTo(destStream);
 }
Пример #7
0
        public void TestDefaultLoad()
        {
            // test load withOUT Uri argument
            IOStorage ss = new IOStorage(commonUri);
            StorageStream result = new StorageStream(commonIOStore.Load());
            Assert.IsTrue(result.Length == commonStream.Length);

            // delete the file
            IOStorage.GetUserFileArea.DeleteFile(commonUri.OriginalString);
        }
Пример #8
0
        public void TestSaveRaw()
        {
            // Make sure the stream is at the beginning of the file
            commonStream.Position = 0;
            Uri uri = new Uri("TestFile.jpg", UriKind.Relative);
            IOStorage s = new IOStorage(uri);

            // Create a stream with image data
            byte[] buffer = new byte[commonStream.Length];
            commonStream.Read(buffer, 0, (int)commonStream.Length);

            s.Save(buffer, commonStream.Length);
            StorageStream strm = new StorageStream(s.Load());
            Assert.IsTrue(commonStream.Length == strm.Length);

            IOStorage.GetUserFileArea.DeleteFile(uri.OriginalString);
        }
Пример #9
0
        public void TestRemove()
        {
            // Make sure the stream is at the beginning of the file
            commonStream.Position = 0;
            Uri uri = new Uri("TestFile.jpg", UriKind.Relative);
            IOStorage s = new IOStorage(uri);

            // Create a stream with image data
            byte[] buffer = new byte[commonStream.Length];
            commonStream.Read(buffer, 0, (int)commonStream.Length);

            // save it then remove it.
            s.Save(buffer, commonStream.Length);
            s.Remove();
            StorageStream strm = new StorageStream(s.Load());
        }
Пример #10
0
 public void TestLoadWithUrl()
 {
     // test load with Uri argument
     StorageStream result = new StorageStream(commonIOStore.Load(commonUri));
     Assert.IsTrue(result.Length == commonStream.Length);
 }
Пример #11
0
        /// <summary>
        /// Saves the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <remarks></remarks>
        public void Save(StorageStream stream)
        {
            if (stream == null) {
                throw new ArgumentNullException();
            }

            // Make sure the stream is at the beginning of the file
            stream.Position = 0;

            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, (int)stream.Length);
            this.Save(buffer, (int)stream.Length);
        }