コード例 #1
0
        public void OpenXMLFileDuplicationTest()
        {
            var fileSystemConnector = new FileSystemConnector(
                    String.Format(@"{0}\..\..\Resources",
                    AppDomain.CurrentDomain.BaseDirectory),
                    "Templates");

            int retries = 3;
            while (retries-- > 0)
            {

                var openXMLConnector = new OpenXMLConnector(packageFileName,
                fileSystemConnector,
                "OfficeDevPnP Automated Test");

                SaveFileInPackage(fileSystemConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + @"\garagelogo.png", "Images\\OpenXMLFileDuplicationTest", openXMLConnector);
                SaveFileInPackage(fileSystemConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + @"\garagebg.jpg", "Images/OpenXMLFileDuplicationTest", openXMLConnector);

                var files = openXMLConnector.GetFiles("Images\\OpenXMLFileDuplicationTest");
                Assert.IsTrue(files.Count == 2);

                files = openXMLConnector.GetFiles("Images/OpenXMLFileDuplicationTest");
                Assert.IsTrue(files.Count == 2);

                if (openXMLConnector is ICommitableFileConnector)
                {
                    ((ICommitableFileConnector)openXMLConnector).Commit();
                }
            }
        }
コード例 #2
0
        public void OpenXMLGetFilesFromFolder()
        {
            var fileSystemConnector = new FileSystemConnector(
                    String.Format(@"{0}\..\..\Resources",
                    AppDomain.CurrentDomain.BaseDirectory),
                    "Templates");

            var openXMLConnector = new OpenXMLConnector(packageFileName,
                fileSystemConnector,
                "OfficeDevPnP Automated Test");

            SaveFileInPackage(fileSystemConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + @"\garagelogo.png", "Images", openXMLConnector);
            SaveFileInPackage(fileSystemConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + @"\garagelogo.png", "Images\\Test", openXMLConnector);
            SaveFileInPackage(fileSystemConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + @"\garagebg.jpg", "Images/Test", openXMLConnector);

            if (openXMLConnector is ICommitableFileConnector)
            {
                ((ICommitableFileConnector)openXMLConnector).Commit();
            }

            openXMLConnector = new OpenXMLConnector(packageFileName,
                fileSystemConnector,
                "OfficeDevPnP Automated Test");

            var folders = openXMLConnector.GetFolders();
            Assert.IsTrue(folders.Count > 0);
            Assert.IsTrue(folders.Exists(s => string.Equals(s, "Images", StringComparison.OrdinalIgnoreCase)));
            var files = openXMLConnector.GetFiles("Images");
            Assert.IsTrue(files.Count > 0);

            files = openXMLConnector.GetFiles("Images\\Test");
            Assert.IsTrue(files.Count == 2);

            files = openXMLConnector.GetFiles("Images/Test");
            Assert.IsTrue(files.Count == 2);
        }