Exemplo n.º 1
0
        public void EnumeratePartsBreak()
        {
            FakePackage package = new FakePackage(FileAccess.ReadWrite, false);

            package.CreatePart(uris [0], "a/a");
            package.CreatePart(uris [1], "a/a");
            package.CreatePart(uris [2], "a/a");

            Assert.IsTrue(package.GetParts() == package.GetParts(), "#1");
            try {
                foreach (PackagePart part in package.GetParts())
                {
                    package.DeletePart(part.Uri);
                }
                Assert.Fail("This should throw an exception");
            } catch {
            }

            PackagePartCollection c = package.GetParts();

            package.CreatePart(new Uri("/dfds", UriKind.Relative), "a/a");
            int count = 0;

            foreach (PackagePart p in c)
            {
                count++;
            }
            Assert.AreEqual(3, count, "Three added, one deleted, one added");
        }
 public void CheckAutomaticParts()
 {
     package.CreatePart(uris[0], contentType);
     Assert.AreEqual(1, package.CreatedParts.Count(), "#1");
     Assert.AreEqual(uris[0], package.CreatedParts[0], "#2");
     Assert.AreEqual(0, package.DeletedParts.Count(), "#3");
     Assert.AreEqual(1, package.GetParts().Count(), "#4");
 }
        public void TestWordDoc()
        {
            MemoryStream stream  = new MemoryStream();
            Package      package = CreateWordDoc(stream);

            Assert.IsTrue(package.PartExists(new Uri("/word/document.xml", UriKind.Relative)), "#1");
            Assert.IsTrue(package.RelationshipExists("rel1"), "#2");
            package.Close();
            package = Package.Open(new MemoryStream(stream.ToArray()), FileMode.Open);
            Assert.AreEqual(10, package.GetParts().Count(), "#3");
            Assert.AreEqual(9, package.GetRelationships().Count(), "#4");
            Assert.IsTrue(package.PartExists(new Uri("/word/document.xml", UriKind.Relative)), "#5");
            Assert.IsTrue(package.RelationshipExists("rel1"), "#6");
        }
        public void EnumeratePartsBreak ()
        {
            FakePackage package = new FakePackage (FileAccess.ReadWrite, false);

            package.CreatePart (uris [0], "a/a");
            package.CreatePart (uris [1], "a/a");
            package.CreatePart (uris [2], "a/a");

            Assert.IsTrue (package.GetParts () == package.GetParts (), "#1");
            try {
                foreach (PackagePart part in package.GetParts ())
                    package.DeletePart (part.Uri);
                Assert.Fail ("This should throw an exception");
            } catch {
            }

            PackagePartCollection c = package.GetParts ();
            package.CreatePart (new Uri ("/dfds", UriKind.Relative), "a/a");
            int count = 0;
            foreach (PackagePart p in c) { count++; }
            Assert.AreEqual (3, count, "Three added, one deleted, one added");
        }
 public void TestWordDoc()
 {
     MemoryStream stream = new MemoryStream();
     Package package = CreateWordDoc(stream);
     Assert.IsTrue(package.PartExists(new Uri("/word/document.xml", UriKind.Relative)), "#1");
     Assert.IsTrue(package.RelationshipExists("rel1"), "#2");
     package.Close();
     package = Package.Open(new MemoryStream(stream.ToArray()), FileMode.Open);
     Assert.AreEqual(10, package.GetParts().Count(), "#3");
     Assert.AreEqual (9, package.GetRelationships ().Count (), "#4");
     Assert.IsTrue(package.PartExists(new Uri("/word/document.xml", UriKind.Relative)), "#5");
     Assert.IsTrue(package.RelationshipExists("rel1"), "#6");
 }