コード例 #1
0
        public void GvSearch_RowDataBound_Success_DropDownsAreInitialized(string fieldValue, string searchValue)
        {
            //Arrange
            InitializeSessionVariables();
            var gridViewRowObject = InitializeGrid(fieldValue, searchValue).Rows[0];
            var gridItem          = ReflectionHelper.CreateInstance(typeof(GridItem));

            gridItem.SelectedField     = fieldValue;
            gridViewRowObject.DataItem = gridItem;
            ReflectionHelper.SetField(_testEntity, "gvSearch", InitializeGrid(fieldValue, searchValue));
            var methodArgs           = new object[] { null, new GridViewRowEventArgs(gridViewRowObject) };
            var dropDownsInitialized = false;

            ShimSF_Search.AllInstances.GetLogicBoolean = (x, y) =>
            {
                dropDownsInitialized = true;
                return(new List <string>());
            };

            // Act
            ReflectionHelper.CallMethod(typeof(SF_Search), MethodGvSearchRowDataBound, methodArgs, _testEntity);

            //Assert
            dropDownsInitialized.ShouldBeTrue();
        }
コード例 #2
0
        public void LoadList()
        {
            ReflectionHelper.CallMethod(typeof(MruProjects), "LoadList", new object[] { null });
            Assert.AreEqual(0, _paths.Count);

            // Load some non existant paths into our collection of paths.

            var prjFile = Path.Combine(Path.GetTempPath(), "~frog");

            prjFile = Path.Combine(prjFile, "~frog.sprj");
            _prjFiles.Insert(0, prjFile);

            prjFile = Path.Combine(Path.GetTempPath(), "~lizard");
            prjFile = Path.Combine(prjFile, "~lizard.sprj");
            _prjFiles.Insert(0, prjFile);

            prjFile = Path.Combine(Path.GetTempPath(), "~toad");
            prjFile = Path.Combine(prjFile, "~toad.sprj");
            _prjFiles.Insert(0, prjFile);

            Assert.IsTrue(_prjFiles.Count > MruProjects.MaxMRUListSize);
            ReflectionHelper.CallMethod(typeof(MruProjects), "LoadList", _prjFiles);
            Assert.AreEqual(MruProjects.MaxMRUListSize, _paths.Count);

            // Make sure only the first MaxMRUListSize valid paths in our collection were loaded.
            for (int i = 0; i < MruProjects.MaxMRUListSize; i++)
            {
                Assert.AreEqual(_prjFiles[i + 3], _paths[i]);
            }
        }
コード例 #3
0
ファイル: ExportXmlTests.cs プロジェクト: sillsdev/WorldPad
        public void ExportNotationParagraphs_WritingSystems()
        {
            IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                   ScrStyleNames.NormalParagraph);
            IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
                                                                      NoteType.Translator, "This is some text with espa\u00F1ol.");
            TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents;
            ITsStrBldr       bldr     = tssaDisc.UnderlyingTsString.GetBldr();

            bldr.SetProperties(bldr.Length - 8, bldr.Length - 1,
                               StyleUtils.CharStyleTextProps(null, InMemoryFdoCache.s_wsHvos.Es));
            tssaDisc.UnderlyingTsString = bldr.GetString();

            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                       "ExportNotationParagraphs_WritingSystems");

            ReflectionHelper.SetField(m_exporter, "m_writer", writer);
            ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA,
                                        "notationDiscussion");
            Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" +
                            "<span>This is some text with </span>" +
                            "<span xml:lang=\"es\">espa\u00F1ol</span>" +
                            "<span>.</span>" +
                            "</para></notationDiscussion>", stream.ToString());
        }
コード例 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnRegExpressionShowSearchResults(object args)
        {
            SearchQuery query = args as SearchQuery;

            if (query == null || m_findPhoneWnd == null || m_findPhoneWnd.ResultViewManger == null)
            {
                return(true);
            }

            ISearchResultsViewHost srchRsltVwHost = ReflectionHelper.GetField(
                m_findPhoneWnd.ResultViewManger, "m_srchRsltVwHost") as ISearchResultsViewHost;

            if (srchRsltVwHost != null)
            {
                srchRsltVwHost.BeforeSearchPerformed(query, null);
            }

            //PaApp.InitializeProgressBar(ResourceHelper.GetString("kstidQuerySearchingMsg"));

            RegExpressionSearch regExpSrch  = new RegExpressionSearch(query);
            WordListCache       resultCache = regExpSrch.Search();

            if (resultCache != null)
            {
                resultCache.SearchQuery = query.Clone();
                ReflectionHelper.CallMethod(m_findPhoneWnd.ResultViewManger,
                                            "ShowResults", resultCache, SearchResultLocation.CurrentTabGroup);
            }

            //PaApp.UninitializeProgressBar();

            return(true);
        }
コード例 #5
0
        public void CreateScrBookRefs()
        {
            ReflectionHelper.CallMethod(typeof(TeScrBookRefsInit), "SetNamesAndAbbreviations",
                                        new DummyProgressDlg(), Cache);

            IFdoOwningSequence <IScrBookRef> books =
                Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS;

            // Make sure the right number of books was generated.
            Assert.AreEqual(66, books.Count);

            ILgWritingSystemFactory wsf = Cache.WritingSystemFactory;
            int wsEnglish = wsf.GetWsFromStr("en");
            int wsSpanish = wsf.GetWsFromStr("es");

            // Check English Genesis
            IScrBookRef genesis = books[0];

            Assert.AreEqual("Genesis",
                            genesis.BookName.get_String(wsEnglish).Text);
            Assert.AreEqual("Gen",
                            genesis.BookAbbrev.get_String(wsEnglish).Text);
            Assert.IsNull(genesis.BookNameAlt.get_String(wsEnglish).Text);

            // Check Spanish Matthew
            IScrBookRef mateo = books[39];

            Assert.AreEqual("Mateo",
                            mateo.BookName.get_String(wsSpanish).Text);
            Assert.AreEqual("Mt",
                            mateo.BookAbbrev.get_String(wsSpanish).Text);
            Assert.IsNull(mateo.BookNameAlt.get_String(wsSpanish).Text);

            // Check English 2 Corinthians
            IScrBookRef iiCor = books[46];

            Assert.AreEqual("2 Corinthians",
                            iiCor.BookName.get_String(wsEnglish).Text);
            Assert.AreEqual("2Cor",
                            iiCor.BookAbbrev.get_String(wsEnglish).Text);
            Assert.AreEqual("II Corinthians",
                            iiCor.BookNameAlt.get_String(wsEnglish).Text);

            // Check Spanish Revelation
            IScrBookRef apocalipsis = books[65];

            Assert.AreEqual("Apocalipsis",
                            apocalipsis.BookName.get_String(wsSpanish).Text);
            Assert.AreEqual("Ap",
                            apocalipsis.BookAbbrev.get_String(wsSpanish).Text);
            Assert.IsNull(apocalipsis.BookNameAlt.get_String(wsSpanish).Text);

            MultilingScrBooks mlsb = new MultilingScrBooks(m_scr.ScrProjMetaDataProvider);

            foreach (IScrBookRef brf in books)
            {
                Assert.IsTrue(!String.IsNullOrEmpty(brf.BookName.get_String(wsEnglish).Text));
                Assert.IsTrue(!String.IsNullOrEmpty(brf.BookAbbrev.get_String(wsEnglish).Text));
            }
        }
コード例 #6
0
        public void AddFilters_WhenFieldTypeIndexIsFour_CompareValueIsNotEmptyString(string comparator)
        {
            // Arrange
            ReflectionHelper.SetField(_page, "FilterIDValue", new TextBox {
                Text = One
            });
            SetDataType(Four);
            SetComparator(comparator);
            CreateShims();
            ShimContentFilterDetail.SaveContentFilterDetailUser = (contentFilterDetail, user) =>
            {
                _contentFilterFieldName    = contentFilterDetail.FieldName;
                _contentFilterCompareValue = contentFilterDetail.CompareValue;
            };
            var methodArgs = new object[] { null, EventArgs.Empty };

            // Act
            ReflectionHelper.CallMethod(typeof(contentfilters), MethodAddFilter, methodArgs, _page);

            // Assert
            _page.ShouldSatisfyAllConditions(
                () => _filtersGridLoaded.ShouldBeTrue(),
                () => _contentFilterFieldName.ShouldNotBeNullOrWhiteSpace(),
                () => _contentFilterCompareValue.ShouldNotBeNullOrWhiteSpace());
        }
コード例 #7
0
        public void AddFilters_WhenFieldTypeIndexIsGreaterThanZero_CompareValueIsNotEmptyString(string comparator)
        {
            // Arrange
            ReflectionHelper.SetField(_page, "FilterIDValue", new TextBox {
                Text = One
            });
            SetDataType(Two);
            SetComparator(comparator);
            SetCompFieldName(comparator);
            CreateShims();
            var contentFilterDetailObject = ReflectionHelper.CreateInstance(typeof(ContentFilterDetail));

            contentFilterDetailObject.Comparator           = comparator;
            ShimContentFilterDetail.GetByFilterIDInt32User = (x, y) => new List <ContentFilterDetail> {
                contentFilterDetailObject
            };
            ShimContentFilterDetail.SaveContentFilterDetailUser = (contentFilterDetail, user) =>
            {
                _contentFilterFieldName    = contentFilterDetail.FieldName;
                _contentFilterCompareValue = contentFilterDetail.CompareValue;
            };
            var methodArgs = new object[] { null, EventArgs.Empty };

            // Act
            ReflectionHelper.CallMethod(typeof(contentfilters), MethodAddFilter, methodArgs, _page);

            // Assert
            _page.ShouldSatisfyAllConditions(
                () => _filtersGridLoaded.ShouldBeTrue(),
                () => _contentFilterFieldName.ShouldNotBeNullOrWhiteSpace(),
                () => _contentFilterFieldName.Contains(comparator),
                () => _contentFilterCompareValue.ShouldNotBeNullOrWhiteSpace());
        }
コード例 #8
0
        public void RemoveStalePaths()
        {
            Assert.IsNotNull(_paths);
            Assert.AreEqual(0, _paths.Count);

            foreach (string file in _prjFiles)
            {
                _paths.Add(file);
            }

            var prjFile = Path.Combine(Path.GetTempPath(), "~frog");

            prjFile = Path.Combine(prjFile, "~frog.sprj");
            _paths.Insert(2, prjFile);

            prjFile = Path.Combine(Path.GetTempPath(), "~lizard");
            prjFile = Path.Combine(prjFile, "~lizard.sprj");
            _paths.Insert(2, prjFile);

            prjFile = Path.Combine(Path.GetTempPath(), "~toad");
            prjFile = Path.Combine(prjFile, "~toad.sprj");
            _paths.Insert(2, prjFile);

            Assert.AreEqual(_prjFiles.Count + 3, _paths.Count);
            ReflectionHelper.CallMethod(typeof(MruProjects), "RemoveStalePaths", null);
            Assert.AreEqual(_prjFiles.Count, _paths.Count);

            foreach (string file in _prjFiles)
            {
                Assert.IsTrue(_paths.Contains(file));
            }
        }
コード例 #9
0
ファイル: ExportXmlTests.cs プロジェクト: sillsdev/WorldPad
        public void ExportNotationParagraphs_Hyperlink()
        {
            IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                   ScrStyleNames.NormalParagraph);
            IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
                                                                      NoteType.Translator, "This is some text with a hyperlink!");
            TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents;

            tssaDisc.MarkTextAsHyperlink(tssaDisc.Length - 10, tssaDisc.Length - 1,
                                         "http://www.myspace.com", m_stylesheet);

            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                       "ExportNotationParagraphs_Hyperlink");

            ReflectionHelper.SetField(m_exporter, "m_writer", writer);
            ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA,
                                        "notationDiscussion");
            Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" +
                            "<span>This is some text with a </span>" +
                            "<a href=\"http://www.myspace.com\">hyperlink</a>" +
                            "<span>!</span>" +
                            "</para></notationDiscussion>", stream.ToString());
        }
コード例 #10
0
 public void BeforeCheckCalled_FirstNode()
 {
     m_treeView.BeforeCheck += OnBeforeCheck;
     ReflectionHelper.CallMethod(m_treeView, "ChangeNodeState", m_aNode);
     Assert.IsTrue(m_fBeforeCheck);
     Assert.AreEqual(TriStateTreeView.CheckState.Checked, m_treeView.GetChecked(m_aNode));
 }
コード例 #11
0
        public void UpdateVerseBridgesInParagraph_ValidRtoLBridge()
        {
            // Set up a verse with invalid verse bridge
            IScrTxtPara para = AddParaToMockedSectionContent(m_exodus.SectionsOS[0], ScrStyleNames.NormalParagraph);

            AddVerse(para, 0, 5, "Verse five.");
            // Right-to-Left Bridge: 6-24
            // NOTE: The verse number format is how TE represents verse numbers with bridges.
            // This method should not change anything but the verse bridge character.
            AddVerse(para, 0, "6" + '\u200f' + '\u200f' + "@" + '\u200f' + '\u200f' + '\u200f' + "24",
                     "Verse with valid R-to-L bridge.");

            using (ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true, null))
            {
                ReflectionHelper.CallMethod(dlg, "UpdateVerseBridgesInParagraph", para,
                                            '\u200f' + "@" + '\u200f', '\u200f' + "&" + '\u200f');

                AssertEx.RunIsCorrect(para.Contents, 0, "5", ScrStyleNames.VerseNumber,
                                      Cache.DefaultVernWs);
                AssertEx.RunIsCorrect(para.Contents, 1, "Verse five.", null, Cache.DefaultVernWs);
                AssertEx.RunIsCorrect(para.Contents, 2, "6" + '\u200f' + '\u200f' + "&" +
                                      '\u200f' + '\u200f' + '\u200f' + "24", ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
                AssertEx.RunIsCorrect(para.Contents, 3, "Verse with valid R-to-L bridge.",
                                      null, Cache.DefaultVernWs);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_dialog_FormClosed(object sender, FormClosedEventArgs e)
        {
            m_dialog.FormClosed -= m_dialog_FormClosed;

            try
            {
                // Before the grid's settings get saved by the call to SaveSettings below,
                // remove the column we added in the grid so it's display order (and all
                // that stuff) don't get saved. Put this in a try/catch because, it
                // triggers the row enter event in the dialog and the event handler in the
                // dialog references an object that's already null by this point.
                m_grid.Columns.Remove(kLoadColName);
            }
            catch { }

            // Since we interupted the settings being saved in out OnDialogSaveSettings
            // method, force the settings to be saved now.
            ReflectionHelper.CallMethod(m_dialog, "SaveSettings", null);

            if (m_grid != null)
            {
                // Release our event handlers from the grid.
                m_grid.RowsAdded   -= grid_RowsAdded;
                m_grid.RowsRemoved -= m_grid_RowsRemoved;
                m_grid.ColumnDisplayIndexChanged -= m_grid_ColumnDisplayIndexChanged;
                m_grid.CellValueChanged          -= m_grid_CellValueChanged;
                m_grid = null;
            }

            m_dialog = null;
            PaApp.MsgMediator.RemoveColleague(this);
        }
コード例 #13
0
        public void UpdateVerseBridgesInParagraph_InvalidRtoLBridge()
        {
            // Set up a verse with invalid verse bridge
            StTxtPara para = AddPara(m_exodus.SectionsOS[0]);

            AddVerse(para, 0, 1, "Verse one.");
            // NOTE: The verse number format is how TE represents verse numbers with bridges.
            // This method should not change anything but the verse bridge character.
            AddVerse(para, 0, "2" + '\u200F' + '\u200F' + "&" + '\u200F' + '\u200F' + '\u200F',
                     "Verse with invalid bridge.");

            ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true);

            ReflectionHelper.CallMethod(dlg, "UpdateVerseBridgesInParagraph", para,
                                        '\u200f' + "&" + '\u200f', '\u200f' + "@" + '\u200f');

            AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "1",
                                  ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
            AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 1, "Verse one.",
                                  ScrStyleNames.NormalParagraph, Cache.DefaultVernWs);
            AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 2, "2" + '\u200F' + '\u200F' + "@" + '\u200F' + '\u200F' + '\u200F',
                                  ScrStyleNames.VerseNumber, Cache.DefaultVernWs);
            AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 3, "Verse with invalid bridge.",
                                  ScrStyleNames.NormalParagraph, Cache.DefaultVernWs);
        }
コード例 #14
0
        public void NormalizeFileData_Hebrew()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);

                // First string is the normalized order that ICU produces.
                // Second string is the normalized order that .Net produces.
                var icuStyleNormalizationOrder    = "\u05E9\u05c1\u05b4\u0596";
                var dotnetStyleNormalizationOrder = "\u05E9\u05b4\u05c1\u0596";
                ReflectionHelper.SetField(ctrl, "m_fileData",
                                          new[] { icuStyleNormalizationOrder, dotnetStyleNormalizationOrder });

                // SUT
                ReflectionHelper.CallMethod(ctrl, "NormalizeFileData");

                // Verify
                var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData");
                Assert.That(results.Length, Is.EqualTo(2));
                Assert.That(results[0], Is.EqualTo(icuStyleNormalizationOrder),
                            GetMessage("Expect ICU-style normalization (from ICU order)",
                                       icuStyleNormalizationOrder,
                                       results[0]));
                Assert.That(results[1], Is.EqualTo(icuStyleNormalizationOrder),
                            GetMessage("Expect ICU-style normalization (from .NET order)",
                                       icuStyleNormalizationOrder,
                                       results[1]));
            }
        }
コード例 #15
0
        public void RemoveStalePaths()
        {
            Assert.IsEmpty(_paths);

            var path1 = Path.Combine(_mruFileFolder, "mru1.tmp");

            File.CreateText(path1).Close();
            MruFiles.AddNewPath(path1);

            var path2 = Path.Combine(_mruFileFolder, "mru2.tmp");

            File.CreateText(path2).Close();
            MruFiles.AddNewPath(path2);

            Assert.AreEqual(2, _paths.Count);
            Assert.Contains(path1, _paths);
            Assert.Contains(path2, _paths);

            File.Delete(path1);
            ReflectionHelper.CallMethod(typeof(MruFiles), "RemoveStalePaths", null);
            Assert.AreEqual(1, _paths.Count);
            Assert.IsFalse(_paths.Contains(path1));
            Assert.Contains(path2, _paths);

            File.Delete(path2);
            ReflectionHelper.CallMethod(typeof(MruFiles), "RemoveStalePaths", null);
            Assert.IsEmpty(_paths);
        }
コード例 #16
0
        public void Initialize()
        {
            VerifyProject(_prj, kTestPrjName);
            Assert.AreEqual(0, _prj.Sessions.Count);

            var path1 = Path.Combine(_prj.SessionsFolder, "bacon");
            var path2 = Path.Combine(_prj.SessionsFolder, "eggs");

            Directory.CreateDirectory(path1);
            Directory.CreateDirectory(path2);

            var writer = XmlWriter.Create(Path.Combine(path1, "bacon.session"));

            writer.WriteStartElement("session");
            writer.WriteEndElement();
            writer.Close();

            writer = XmlWriter.Create(Path.Combine(path2, "eggs.session"));
            writer.WriteStartElement("session");
            writer.WriteEndElement();
            writer.Close();

            ReflectionHelper.CallMethod(_prj, "Initialize", new[] { kTestPrjName, null });

            Assert.AreEqual(2, _prj.Sessions.Count);
            Assert.AreEqual("bacon", _prj.Sessions[0].Id);
            Assert.AreEqual("eggs", _prj.Sessions[1].Id);
        }
コード例 #17
0
        public void ImagesToShowDR_SelectedIndexChanged_ImgListViewRBSelectedValueIsDetails_CallsLoadImagesTableAndSetsPagerProperties()
        {
            // Arrange
            var isCalled = false;

            ShimimageGallery.AllInstances.loadImagesTable = (g) => isCalled = true;

            var pager = ReflectionHelper.GetFieldValue(_gallery, ImageListRepeaterPager) as ActiveUp.WebControls.PagerBuilder;

            pager.PageSize    = AnyNumber;
            pager.CurrentPage = One;

            var imageList = ReflectionHelper.GetFieldValue(_gallery, ImgListViewRB) as RadioButtonList;

            imageList.SelectedValue = DetailsOption;

            var dataGrid     = ReflectionHelper.GetFieldValue(_gallery, ImageListGrid) as DataGrid;
            var imagesToShow = ReflectionHelper.GetFieldValue(_gallery, ImagesToShowDR) as DropDownList;

            imagesToShow.Items.Add(AnyNumber.ToString());
            imagesToShow.SelectedValue = AnyNumber.ToString();

            // Act
            ReflectionHelper.CallMethod(typeof(imageGallery), "ImagesToShowDR_SelectedIndexChanged", new object[] { this, EventArgs.Empty }, _gallery);

            // Assert
            isCalled.ShouldBeTrue();
            dataGrid.CurrentPageIndex.ShouldBe(0);
            dataGrid.PageSize.ShouldBe(AnyNumber);
        }
コード例 #18
0
        public void BackTranslation_ReportBTTextNotPartOfPara()
        {
            CheckDisposed();

            m_importer.Settings.ImportBackTranslation = true;
            m_importer.TextSegment.FirstReference     = new BCVRef(2, 0, 0);
            m_importer.TextSegment.LastReference      = new BCVRef(2, 0, 0);
            m_importer.ProcessSegment("", @"\id");

            ReflectionHelper.SetField(m_importer, "m_importDomain", ImportDomain.BackTrans);

            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.ReplaceRgch(0, 0, "Exodus", 6, null);
            Dictionary <int, ITsStrBldr> bldrs = ReflectionHelper.GetField(m_importer, "m_BTStrBldrs") as Dictionary <int, ITsStrBldr>;

            bldrs[1] = bldr;

            try
            {
                ReflectionHelper.CallMethod(m_importer, "ReportBTTextNotPartOfPara");
            }
            catch (Exception e)
            {
                ScriptureUtilsException sue = e.InnerException as ScriptureUtilsException;
                Assert.IsFalse(sue.InterleavedImport);
            }
        }
コード例 #19
0
        public void Page_Load_WithDeleteFilterDetailsActionAndDifferentComparator_FilterIsUpdatedAndSaved(string comparator)
        {
            // Arrange
            Initialize();
            _queryString.Add(Folder, TrueString);
            _queryString.Add(Action, DeleteDetail);
            CreatePageLoadShims();
            var contentFilterUpdated      = false;
            var contentFilterDetailObject = ReflectionHelper.CreateInstance(typeof(ContentFilterDetail));

            contentFilterDetailObject.Comparator           = comparator;
            ShimContentFilterDetail.GetByFilterIDInt32User = (x, y) => new List <ContentFilterDetail> {
                contentFilterDetailObject
            };
            ShimContentFilter.SaveContentFilterUser = (x, y) =>
            {
                contentFilterUpdated = true;
            };
            var methodArgs = new object[] { null, EventArgs.Empty };

            // Act
            ReflectionHelper.CallMethod(typeof(contentfilters), MethodPageLoad, methodArgs, _page);

            // Assert

            var pageSession = _page.Session;

            _page.ShouldSatisfyAllConditions(
                () => pageSession.ShouldNotBeNull(),
                () => pageSession[SelectedFolder].ShouldNotBeNull(),
                () => contentFilterUpdated.ShouldBeTrue());
        }
コード例 #20
0
ファイル: ExportXmlTests.cs プロジェクト: sillsdev/WorldPad
        public void ExportBookSection_IntroWithNotes()
        {
            IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduction",
                                                           ScrStyleNames.IntroSectionHead);
            StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph);

            AddVerse(introPara, 0, 0, "Some intro text");
            IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(introPara, new BCVRef(01001000),
                                                                      NoteType.Consultant, "This is a basic note about the intro.");

            note.ResolutionStatus = NoteStatus.Open;
            note.BeginOffset      = 5;
            note.EndOffset        = 10;

            DateTime now    = DateTime.Now;
            string   strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff");

            note.DateCreated  = now;
            note.DateModified = now;

            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            writer.Formatting = Formatting.None;
            m_exporter        = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                              "ExportBookSection_IntroWithNotes");

            ReflectionHelper.SetField(m_exporter, "m_writer", writer);
            string sCanon = "ot";

            ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null);


            XmlDocument actual = new XmlDocument();

            actual.Load(new StringReader(stream.ToString()));
            string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" +
                                 "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" +
                                 "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" +
                                 "<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"5\" endOffset=\"10\">" +
                                 "<created>" + strNow + "</created><modified>" + strNow + "</modified>" +
                                 "<resolved /><notationDiscussion><para xml:lang=\"en\">" +
                                 "<run>This is a basic note about the intro.</run></para></notationDiscussion></annotation>" +
                                 "<trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr></trGroup>" +
                                 "<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>";

            XmlDocument expected = new XmlDocument();

            expected.Load(new StringReader(strExpected));

            string strDifference;

            if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
            {
                Assert.Fail(strDifference);
            }
        }
コード例 #21
0
        public void CallMethod()
        {
            CallMethodTestClass testClass = new CallMethodTestClass();

            Assert.AreEqual(testClass.PublicMethodWithNoParameters(), ReflectionHelper.CallMethod(testClass, "PublicMethodWithNoParameters"));
            Assert.AreEqual(testClass.PublicMethodWithParameters(5), ReflectionHelper.CallMethod(testClass, "PublicMethodWithParameters", 5));
            Assert.AreEqual(testClass.PublicMethodWithParameters(5, 20L), ReflectionHelper.CallMethod(testClass, "PublicMethodWithParameters", 5, 20L));
        }
コード例 #22
0
ファイル: ExportXmlTests.cs プロジェクト: sillsdev/WorldPad
        public void ExportBookSection_MultipleBT()
        {
            Cache.LangProject.AnalysisWssRC.Add(InMemoryFdoCache.s_wsHvos.Hbo);
            Cache.LangProject.CurAnalysisWssRS.Append(InMemoryFdoCache.s_wsHvos.Hbo);
            int         wsAnal       = Cache.DefaultAnalWs;
            IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduccion",
                                                           ScrStyleNames.IntroSectionHead);
            StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph);

            AddVerse(introPara, 0, 0, "Texto de introduccion");

            // Add a back translation for the default analysis language.
            CmTranslation trans = (CmTranslation)m_scrInMemoryCache.AddTransToMockedParagraph(introPara,
                                                                                              LangProject.kguidTranBackTranslation, wsAnal);

            trans.Translation.SetAlternative("Default BT", wsAnal);
            trans.Status.SetAlternative("finished", wsAnal);

            // Add a back translation for Hebrew.
            trans.Translation.SetAlternative("Hbo BT", InMemoryFdoCache.s_wsHvos.Hbo);

            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            writer.Formatting = Formatting.None;
            m_exporter        = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                              "ExportBookSection_IntroWithNotes");
            // Initialize writing systems for export (required to export back translations), but
            // called from ExportTE.
            ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null);
            ReflectionHelper.SetField(m_exporter, "m_writer", writer);
            string sCanon = "ot";

            ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null);

            XmlDocument actual = new XmlDocument();

            actual.Load(new StringReader(stream.ToString()));
            string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" +
                                 "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" +
                                 "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" +
                                 "<p><trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr>" +
                                 "<bt xml:lang=\"en\" status=\"finished\">Default BT</bt><bt xml:lang=\"hbo\">Hbo BT</bt></trGroup>" +
                                 "<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>";

            XmlDocument expected = new XmlDocument();

            expected.Load(new StringReader(strExpected));

            string strDifference;

            if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
            {
                Assert.Fail(strDifference);
            }
        }
コード例 #23
0
        private void ConfigureScrollBars()
        {
            // AdjustControls ends up getting called when running Flex
            ReflectionHelper.CallMethod(m_view.m_bv, "AdjustControls");

            var sizeRequestedBySRSUpdateScrollRange = new Size(m_view.AutoScrollMinSize.Width, m_view.GetScrollRange().Height);

            m_view.ScrollMinSize = sizeRequestedBySRSUpdateScrollRange;
        }
コード例 #24
0
        public void RemoveFile_fullPath_Invalid()
        {
            File.CreateText(_mainAppFldr.Combine("chicken.wav")).Close();
            _viewModel.SelectedFolder = _mainAppFldr.FolderPath;

            Assert.AreEqual("chicken.wav", _viewModel.Files[0].FileName);
            ReflectionHelper.CallMethod(_viewModel, "RemoveFile", _mainAppFldr.Combine("nonexistent.wav"));
            Assert.AreEqual("chicken.wav", _viewModel.Files[0].FileName);
        }
コード例 #25
0
ファイル: MultiStringSlice.cs プロジェクト: sillsdev/WorldPad
        private void DoSideEffects()
        {
            string sideEffectMethod = XmlUtils.GetOptionalAttributeValue(m_configurationNode, "sideEffectMethod");

            if (string.IsNullOrEmpty(sideEffectMethod))
            {
                return;
            }
            ReflectionHelper.CallMethod(this.Object, sideEffectMethod, null);
        }
コード例 #26
0
 public void AddFile_fullPath_AlreadyInList()
 {
     File.CreateText(_mainAppFldr.Combine("goat.mpg")).Close();
     _viewModel.SelectedFolder = _mainAppFldr.FolderPath;
     Assert.AreEqual(1, _viewModel.Files.Count);
     Assert.AreEqual("goat.mpg", _viewModel.Files[0].FileName);
     ReflectionHelper.CallMethod(_viewModel, "AddFile", _mainAppFldr.Combine("goat.mpg"));
     Assert.AreEqual(1, _viewModel.Files.Count);
     Assert.AreEqual("goat.mpg", _viewModel.Files[0].FileName);
 }
コード例 #27
0
        public void LoadFilesFromFolder_FolderArgumentIsNull()
        {
            var path = _mainAppFldr.Combine("bird.doc");

            File.CreateText(path).Close();
            _viewModel.Files.Add(new NewSessionFile(path));
            Assert.AreEqual(1, _viewModel.Files.Count);
            ReflectionHelper.CallMethod(_viewModel, "LoadFilesFromFolder", new object[] { null });
            Assert.AreEqual(0, _viewModel.Files.Count);
        }
コード例 #28
0
 private object CallMethod(Type type, string methodName, object[] parametersValues, object instance = null, bool paramCount = true)
 {
     if (paramCount)
     {
         return(ReflectionHelper.CallOverloadedMethod(type, methodName, parametersValues, 9, instance));
     }
     else
     {
         return(ReflectionHelper.CallMethod(type, methodName, parametersValues, instance));
     }
 }
コード例 #29
0
        public void AddFilesToSession_AfterAddingSomeFiles()
        {
            var files = new List <string>(new[] { "Sonics", "Huskies", "Cougars" });

            ReflectionHelper.CallMethod(_viewModel, "AddFilesToSession", files);

            Assert.AreEqual(3, _viewModel.SessionFiles.Length);
            Assert.AreEqual("Sonics", _viewModel.SessionFiles[0]);
            Assert.AreEqual("Huskies", _viewModel.SessionFiles[1]);
            Assert.AreEqual("Cougars", _viewModel.SessionFiles[2]);
        }
コード例 #30
0
 public void LayoutIgnoredDuringColumnResizing()
 {
     using (var chart = new FakeConstituentChart(Cache))
     {
         // Reset count
         chart.m_SetHeaderColAndButtonWidths_callCount = 0;
         ReflectionHelper.CallMethod(chart, "m_headerMainCols_ColumnWidthChanging", new object[] { null, null });
         ReflectionHelper.CallMethod(chart, "m_headerMainCols_Layout", new object[] { null, null });
         Assert.That(chart.m_SetHeaderColAndButtonWidths_callCount, Is.EqualTo(0), "Layout event during column resizing should have done nothing.");
     }
 }