示例#1
0
        private void t06_sequence(SPOViewModel vm, string basename, int maxFolder, int maxFile, bool folderFull)
        {
            int           add       = folderFull ? 1 : 0;
            SPOClientMock spoClient = new SPOClientMock();

            spoClient.MaxExistingFolderNumer = maxFolder;
            vm.FT.MaxCapacity = maxFile;
            SPOExport export = new SPOExport(spoClient);

            for (int i = 0; i < maxFile; i++)
            {
                t06_testExport(vm, spoClient, export, string.Format("{0}_{1:D4}", basename, maxFolder));
            }
            t06_testExport(vm, spoClient, export, string.Format("{0}_{1:D4}", basename, maxFolder + add));
        }
示例#2
0
        private void t06_testExport
            (SPOViewModel vm,
            SPOClientMock spoClient,
            SPOExport export, string expectedFolder)
        {
            SIEEDocument document = new SIEEDocument()
            {
                PDFFileName = "file.pdf"
            };
            string documentName = "document";

            export.Init(vm.Settings);
            export.ExportDocument(vm.Settings, document, documentName, vm.Settings.CreateSchema());
            Assert.AreEqual(
                spoClient.LastExportResult.Folder,
                expectedFolder);
        }
示例#3
0
        public void t04_Export()
        {
            SPOViewModel vm = createViewModel();

            vm.LT.SelectedList = new SPOList()
            {
                Title = "SomeList"
            };
            vm.LoadFieldsButtonHandler();
            SIEEFieldlist schema = vm.Settings.CreateSchema();

            Assert.AreEqual(2, schema.Count);

            schema.Where(n => n.ExternalId == "Id1").First().Value = "myTitle";
            schema.Where(n => n.ExternalId == "Id3").First().Value = "true";
            schema.Add(new SIEEField()
            {
                Name = "SomeName", ExternalId = "xx", Value = "SomeValue"
            });

            SPOClientMock spoClient = new SPOClientMock();
            SPOExport     export    = new SPOExport(spoClient);

            export.Init(vm.Settings);

            SIEEDocument document = new SIEEDocument()
            {
                PDFFileName = "file.pdf"
            };

            export.ExportDocument(vm.Settings, document, "sub/Document", schema);

            Assert.AreEqual("SomeList", spoClient.LastExportResult.ListTitle);
            Assert.AreEqual("sub/Document.pdf", spoClient.LastExportResult.DocumentPath);
            Assert.AreEqual("file.pdf", spoClient.LastExportResult.FilePath);
            verifyField("Id1", "myTitle", schema, spoClient.LastExportResult.Fields);
            verifyField("Id3", "true", schema, spoClient.LastExportResult.Fields);
        }
示例#4
0
        // Simulate some exports and verify the final location
        public void t05_SubfolderHandling()
        {
            SPOViewModel vm = createViewModel();

            // Create schema based on mocked SPOList
            vm.LT.SelectedList = new SPOList()
            {
                Title = "SomeList"
            };
            vm.LoadFieldsButtonHandler();
            SIEEFieldlist schema = vm.Settings.CreateSchema();

            Assert.AreEqual(2, schema.Count);

            schema.Where(n => n.ExternalId == "Id1").First().Value = "myTitle";
            schema.Where(n => n.ExternalId == "Id3").First().Value = "true";
            schema.Add(new SIEEField()
            {
                Name = "SomeName", ExternalId = "xx", Value = "SomeValue"
            });

            SIEEDocument document = new SIEEDocument()
            {
                PDFFileName = "file.pdf"
            };

            SPOClientMock spoClient    = vm.SPOClient as SPOClientMock; // was: new SPOClientMock();
            SPOExport     export       = new SPOExport(spoClient);
            string        documentName = "abc/document";

            var td = new[]
            {
                new {
                    n            = 0, folderType = SPOSettings.FolderHandlingType.None,
                    folder       = string.Empty, auxField = false, expError = false,
                    fieldContent = string.Empty,
                    result       = documentName,
                },
                new {
                    n            = 1, folderType = SPOSettings.FolderHandlingType.Folder,
                    folder       = "sub/subsub", auxField = false, expError = false,
                    fieldContent = string.Empty,
                    result       = "sub/subsub/" + documentName,
                },
                new {
                    n            = 2, folderType = SPOSettings.FolderHandlingType.Folder,
                    folder       = "/sub/subsub/", auxField = false, expError = false,
                    fieldContent = string.Empty,
                    result       = "sub/subsub/" + documentName,
                },
                new {
                    n            = 3, folderType = SPOSettings.FolderHandlingType.Folder,
                    folder       = "/", auxField = false, expError = false,
                    fieldContent = string.Empty,
                    result       = documentName,
                },
                new {
                    n            = 4, folderType = SPOSettings.FolderHandlingType.Field,
                    folder       = string.Empty, auxField = false, expError = false,
                    fieldContent = "sub/subsub",
                    result       = "sub/subsub/" + documentName,
                },
                new {
                    n            = 5, folderType = SPOSettings.FolderHandlingType.Field,
                    folder       = string.Empty, auxField = false, expError = false,
                    fieldContent = "/sub/subsub/",
                    result       = "sub/subsub/" + documentName,
                },
                new {
                    n            = 6, folderType = SPOSettings.FolderHandlingType.Field,
                    folder       = string.Empty, auxField = false, expError = false,
                    fieldContent = "/",
                    result       = documentName,
                },
                new {
                    n            = 7, folderType = SPOSettings.FolderHandlingType.Field,
                    folder       = string.Empty, auxField = true, expError = false,
                    fieldContent = "/sub/subsub/",
                    result       = "sub/subsub/" + documentName,
                },
                new {
                    n            = 8, folderType = SPOSettings.FolderHandlingType.Field,
                    folder       = string.Empty, auxField = true, expError = true,
                    fieldContent = "/sub/subsub/",
                    result       = "sub/subsub/" + documentName,
                },
            };
            int doOnly = -1;

            for (int i = 0; i != td.Length; i++)
            {
                if (doOnly > 0 && td[i].n != doOnly)
                {
                    continue;
                }

                vm.FT.FolderHandling = SPOSettings.FolderHandlingType.None;
                vm.FT.FolderName     = td[i].folder;
                vm.FT.FieldName      = string.Empty;

                document.AuxFields = new SIEEFieldlist();

                if (td[i].folderType == SPOSettings.FolderHandlingType.Field)
                {
                    if (td[i].auxField == false)
                    {
                        vm.FT.FieldName = "SomeName";
                        schema.Where(n => n.Name == "SomeName").First().Value = td[i].fieldContent;
                    }
                    else
                    {
                        vm.FT.FieldName = "auxField" + (td[i].expError ? "-err" : "");
                        document.AuxFields.Add(new SIEEField("auxField", "", td[i].fieldContent));
                    }
                }
                vm.FT.FolderHandling = td[i].folderType;
                document.Fieldlist   = schema;

                export.Init(vm.Settings);
                bool exception = false;
                try
                {
                    export.ExportDocument(vm.Settings, document, documentName, schema);
                } catch { exception = true; }
                if (td[i].expError)
                {
                    Assert.IsTrue(exception);
                }
                else
                {
                    Assert.IsFalse(exception);
                    Assert.AreEqual(td[i].result + ".pdf", spoClient.LastExportResult.DocumentPath);
                }
            }
            Assert.IsTrue(doOnly < 0, "Not all tests executed");
        }