public void PopulateImportantNoticesTest()
        {
            var          document = new UnitTestDocument();
            var          view     = new UnitTestDocumentView();
            var          target   = new InsuranceRenewealReportWizardPresenter(document, view);
            const string im       = "http://mockImportantNotes.doc";
            const string priv     = "http://mockPrivacy.doc";
            const string fsg      = "http://mockFSG.doc";
            const string toe      = "http://mockTOE.doc";

            document.MockBookmarks = new List <string> {
                Constants.WordBookmarks.ImportantNotes
            };

            target.PopulateImportantNotices(Enums.Statutory.Retail, im, priv, fsg, toe);
            Assert.AreEqual(3, document.InsertedFiles.Count);

            document.InsertedFiles.Clear();
            target.PopulateImportantNotices(Enums.Statutory.Wholesale, im, priv, fsg, toe);
            Assert.AreEqual(3, document.InsertedFiles.Count);

            document.InsertedFiles.Clear();
            target.PopulateImportantNotices(Enums.Statutory.WholesaleWithRetail, im, priv, fsg, toe);
            Assert.AreEqual(4, document.InsertedFiles.Count);
        }
        public void PopulateBasisOfCoverTest()
        {
            var document = new UnitTestDocument {
                MockBookmarks = new List <string> {
                    "aBookMark", "bBookMark", "cBookMark"
                }
            };

            var view   = new UnitTestDocumentView();
            var target = new InsuranceRenewealReportWizardPresenter(document, view);
            var frags  = new List <IPolicyClass>();


            for (int i = 0; i < 2; i++)
            {
                var newFrag = new PolicyClass {
                    MajorClass = "A", Title = "A" + i, Url = "http//A" + i
                };
                frags.Add(newFrag);
            }

            for (int i = 0; i < 3; i++)
            {
                var newFrag = new PolicyClass {
                    MajorClass = "B", Title = "B" + i, Url = "http//B" + i
                };
                frags.Add(newFrag);
            }
            target.PopulateBasisOfCover(frags, "http://templates.oamps.com.au/Fragments/Class%20of%20Insurance.docx");
        }
        public void LoadIncludedPolicyClassesTest()
        {
            var       document = new UnitTestDocument();
            IBaseView view     = null;

            document.MockDocumentProperties = new List <string>();

            var target   = new InsuranceRenewealReportWizardPresenter(document, view);
            var template = new InsuranceRenewalReport
            {
                ClientName       = "client name test",
                ClientCommonName = "client common name test"
            };

            var expected = new InsuranceRenewalReport
            {
                ClientName       = "client name test",
                ClientCommonName = "client common name test"
            };
            IInsuranceRenewalReport actual = target.LoadIncludedPolicyClasses(template);

            Assert.AreEqual(expected.ClientCommonName, actual.ClientCommonName);
            Assert.AreEqual(expected.ClientName, actual.ClientName);
            Assert.AreEqual(expected.CoverPageTitle, actual.CoverPageTitle);
        }
        public void CheckNameTest()
        {
            var          document = new UnitTestDocument();
            IBaseView    view     = null;
            var          target   = new InsuranceRenewealReportWizardPresenter(document, view);
            const string name     = "Unit Test";
            bool         actual   = target.CheckName(name);

            Assert.AreEqual(true, actual);
        }
        public void PopulateGraphicsTest()
        {
            var document = new UnitTestDocument {
                MockPageCount = 5
            };
            var template = new BaseTemplate {
                CoverPageTitle = "a cover page", CoverPageImageUrl = "http://mockUrl", LogoTitle = "a logo", LogoImageUrl = "http://mockUrl"
            };

            var view   = new UnitTestDocumentView();
            var target = new InsuranceRenewealReportWizardPresenter(document, view);

            target.PopulateGraphics(template, String.Empty, String.Empty);
            Assert.IsNotNull(document.ImageAltText[0]);
            Assert.IsNotNull(document.ImageAltText[1]);
            Assert.IsNotNull(document.ImageUrl[0]);
            Assert.IsNotNull(document.ImageUrl[1]);

            target.PopulateGraphics(template, "previousCoverPage", String.Empty);
            Assert.IsNotNull(document.ImageAltText[0]);
            Assert.IsNotNull(document.ImageAltText[1]);
            Assert.IsNotNull(document.ImageUrl[0]);
            Assert.IsNotNull(document.ImageUrl[1]);

            target.PopulateGraphics(template, String.Empty, "previous Logo");
            Assert.IsNotNull(document.ImageAltText[0]);
            Assert.IsNotNull(document.ImageAltText[1]);
            Assert.IsNotNull(document.ImageUrl[0]);
            Assert.IsNotNull(document.ImageUrl[1]);

            target.PopulateGraphics(template, "Previous Cover Page", "previous Logo");
            Assert.IsNotNull(document.ImageAltText[0]);
            Assert.IsNotNull(document.ImageAltText[1]);
            Assert.IsNotNull(document.ImageUrl[0]);
            Assert.IsNotNull(document.ImageUrl[1]);

            target.PopulateGraphics(template, "a cover page", "a logo");
            Assert.IsNull(document.ImageAltText[0]);
            Assert.IsNull(document.ImageAltText[1]);
            Assert.IsNull(document.ImageUrl[0]);
            Assert.IsNull(document.ImageUrl[1]);


            target.PopulateGraphics(template, "a cover page", "something here");
            Assert.IsNull(document.ImageAltText[0]);
            Assert.IsNotNull(document.ImageAltText[1]);
            Assert.IsNull(document.ImageUrl[0]);
            Assert.IsNotNull(document.ImageUrl[1]);

            target.PopulateGraphics(template, "somerthing here", "a logo");
            Assert.IsNotNull(document.ImageAltText[0]);
            Assert.IsNull(document.ImageAltText[1]);
            Assert.IsNotNull(document.ImageUrl[0]);
            Assert.IsNull(document.ImageUrl[1]);
        }
        public void DeletePageTest()
        {
            var document = new UnitTestDocument {
                MockPageCount = 3
            };
            var view       = new UnitTestDocumentView();
            var target     = new InsuranceRenewealReportWizardPresenter(document, view);
            int pageNumber = 2;

            target.DeletePage(pageNumber);
            Assert.AreSame(null, view.ReturnMessage);
            Assert.AreEqual(document.MockPageCount, 2);

            document.MockPageCount = 1;
            pageNumber             = 1;
            target.DeletePage(pageNumber);
            Assert.AreNotSame(null, view.ReturnMessage);
        }
Beispiel #7
0
        public void btnConvertToManual_Click(IRibbonControl control)
        {
            var reportDoc          = new OfficeDocument(Globals.ThisAddIn.Application.ActiveDocument);
            var presenterreportDoc = new InsuranceRenewealReportWizardPresenter(reportDoc, null);

            var reportTemplate = new InsuranceRenewalReport();

            reportTemplate = (InsuranceRenewalReport)presenterreportDoc.LoadData(reportTemplate);

            reportTemplate = (InsuranceRenewalReport)presenterreportDoc.LoadIncludedPolicyClasses(reportTemplate);


            ObjectCache cache = MemoryCache.Default;

            cache.Add(Constants.CacheNames.ConvertWizard, reportTemplate, new CacheItemPolicy());

            var manualDoc = reportDoc.OpenFile(Settings.Default.TemplateInsuranceManual);


            var allTables = reportDoc.GetTablesByNamePrefix(string.Empty);

            foreach (var tableName in allTables)
            {
                if (!manualDoc.TableExists(tableName))
                {
                    continue;
                }

                if (tableName.Contains("Policy Wording"))
                {
                    var text = reportDoc.GetTableCellText(tableName, 0, 2);
                    manualDoc.TypeTableCellText(tableName, 0, 2, text);
                }
                else
                {
                    reportDoc.CopyTable(tableName);
                    manualDoc.SelectTable(tableName);
                    manualDoc.DeleteTable(tableName);
                    manualDoc.InsertParagraphBreak();
                    manualDoc.PasteClipboardOriginalFormatting();
                }
            }

            //if (reportDoc.TableExists(Constants.WordTables.PolicyWording) && manualDoc.TableExists(Constants.WordTables.PolicyWording))
            //{
            //    reportDoc.CopyTable(Constants.WordTables.PolicyWording);
            //    manualDoc.DeleteTable(Constants.WordTables.PolicyWording);
            //    manualDoc.PasteClipboard();
            //}
            var allBookmarkedSections = reportDoc.GetBookmarksByPartialName(Constants.WordBookmarks.SummaryOfCoverStart);

            foreach (var bookmark in allBookmarkedSections)
            {
                var id = bookmark.Replace(Constants.WordBookmarks.SummaryOfCoverStart, string.Empty);
                if (reportDoc.HasBookmark(Constants.WordBookmarks.SummaryOfCoverStart + id) &&
                    reportDoc.HasBookmark(Constants.WordBookmarks.SummaryOfCoverEnd + id))
                {
                    var rs = reportDoc.GetBookmarkStartRange(Constants.WordBookmarks.SummaryOfCoverStart + id);
                    var re = reportDoc.GetBookmarkStartRange(Constants.WordBookmarks.SummaryOfCoverEnd + id);
                    reportDoc.CopyRange(rs, re);

                    if (manualDoc.HasBookmark(Constants.WordBookmarks.SummaryOfCoverStart + id))
                    {
                        //var ms = manualDoc.GetBookmarkStartRange(Constants.WordBookmarks.SummaryOfCoverStart + id);
                        manualDoc.MoveCursorToStartOfBookmark(Constants.WordBookmarks.SummaryOfCoverStart + id);
                        manualDoc.PasteClipboard();
                    }
                }
            }


            if (reportDoc.HasBookmark(Constants.WordBookmarks.InsertClientProfile) &&
                reportDoc.HasBookmark(Constants.WordBookmarks.InsertClientProfileEnd))
            {
                var rs = reportDoc.GetBookmarkStartRange(Constants.WordBookmarks.InsertClientProfile);
                var re = reportDoc.GetBookmarkStartRange(Constants.WordBookmarks.InsertClientProfileEnd);
                reportDoc.CopyRange(rs, re);
                if (manualDoc.HasBookmark(Constants.WordBookmarks.InsertClientProfile))
                {
                    var ms = manualDoc.GetBookmarkStartRange(Constants.WordBookmarks.InsertClientProfile);
                    var me = manualDoc.GetBookmarkStartRange(Constants.WordBookmarks.InsertClientProfileEnd);
                    manualDoc.DeleteRange(ms, me);

                    manualDoc.MoveCursorToStartOfBookmark(Constants.WordBookmarks.InsertClientProfile);

                    manualDoc.PasteClipboard();
                }
            }

            manualDoc.MoveToStartOfDocument();

            //var presenterManualDoc = new RibbonWizardPresenter(manualDoc, null);

            //var p = reportDoc.TurnOffProtection(string.Empty);
            //presenterManualDoc.PopulateData(reportTemplate);

            //manualDoc.PopulateControl(Constants.WordContentControls.DocumentTitle, "Insurance Manual");
            //reportDoc.TurnOnProtection(p, string.Empty);

            //var w = new BaseWizardForm();
            //var t = new InsuranceManual();
            //t.DocumentTitle = "Insurance Manual zzzz";
            //w.LogUsage(t, Enums.UsageTrackingType.ConvertDocument);
        }