/// <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); }
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); }
/// <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); }
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); }
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); }
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()); }
public void TestLoadWithUrl() { // test load with Uri argument StorageStream result = new StorageStream(commonIOStore.Load(commonUri)); Assert.IsTrue(result.Length == commonStream.Length); }
/// <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); }