Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -184,5 +184,33 @@ namespace MonoTests.System.IO.Packaging {
d.RelationshipType == node.Attributes["Type"].InnerText));
}
}
[Test]
public void CheckRelationshipDeletion ()
{
AddThreeRelationShips ();
package.Flush ();
foreach (PackageRelationship p in new List<PackageRelationship> (package.GetRelationships ()).Skip(1))
package.DeleteRelationship (p.Id);
PackagePart part = package.GetPart (new Uri ("/_rels/.rels", UriKind.Relative));
Assert.IsNotNull (package.GetPart (new Uri ("/_RELS/.RELS", UriKind.Relative)), "#0");
package.Flush ();
Assert.IsNotNull (part, "#1");
Stream stream = part.GetStream ();
Assert.IsTrue (stream.Length > 0, "#2a");
XmlDocument doc = new XmlDocument ();
XmlNamespaceManager manager = new XmlNamespaceManager (doc.NameTable);
manager.AddNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
doc.Load (new StreamReader (stream));
Assert.IsNotNull (doc.SelectSingleNode ("/rel:Relationships", manager), "#2b");
XmlNodeList list = doc.SelectNodes ("/rel:Relationships/*", manager);
Assert.AreEqual (1, list.Count);
}
}
}

View File

@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.IO.Packaging;
using System.Linq;
using System.Text;
@@ -116,7 +117,7 @@ namespace MonoTests.System.IO.Packaging {
package = Package.Open (path);
package.Close ();
package = Package.Open (path);
}
}
[Test]
public void Close_FileStreamNotClosed ()
@@ -416,5 +417,27 @@ namespace MonoTests.System.IO.Packaging {
File.Create (path).Close ();
package = Package.Open (path, FileMode.OpenOrCreate, FileAccess.Write);
}
[Test]
public void Check_ZipDateTime ()
{
using (var zipStream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
using (package = Package.Open (zipStream, FileMode.OpenOrCreate)) {
var part = package.CreatePart (new Uri ("/test", UriKind.Relative), "test/type");
using (var stream = part.GetStream ())
stream.Write (new byte [1024 * 1024], 0, 1024 * 1024);
}
using (var stream = new FileStream (path, FileMode.Open, FileAccess.Read))
using (var archive = new ZipArchive(stream))
{
foreach (var entry in archive.Entries)
{
Assert.AreEqual (DateTime.Now.Year, entry.LastWriteTime.Year);
Assert.AreEqual (DateTime.Now.Month, entry.LastWriteTime.Month);
Assert.AreEqual (DateTime.Now.Day, entry.LastWriteTime.Day);
}
}
}
}
}