Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a simulated range selection
        /// </summary>
        /// <param name="hvoPara1"></param>
        /// <param name="hvoPara2"></param>
        /// <param name="ichAnchor"></param>
        /// <param name="ichEnd"></param>
        /// ------------------------------------------------------------------------------------
        public void SetupSelectionForParas(int hvoPara1, int hvoPara2, int ichAnchor, int ichEnd)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("NumberOfLevels", 1);
            SelLevInfo[] topInfo = new SelLevInfo[1];
            topInfo[0].tag = StTextTags.kflidParagraphs;
            topInfo[0].hvo = hvoPara1;
            SelLevInfo[] bottomInfo = new SelLevInfo[1];
            bottomInfo[0].tag = StTextTags.kflidParagraphs;
            bottomInfo[0].hvo = hvoPara2;
            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("IchAnchor", ichAnchor);
            fakeSelHelper.SetupResult("IchEnd", ichEnd);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Anchor);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.Bottom);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.End);
            fakeSelHelper.SetupResultForParams("GetIch", ichAnchor,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
                                               SelectionHelper.SelLimitType.Bottom);
            m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }
Exemple #2
0
        public void ShouldReturnBuildPluginLinksRelevantToThisProject()
        {
            DynamicMock buildPluginMock1 = new DynamicMock(typeof(IBuildPlugin));
            DynamicMock buildPluginMock2 = new DynamicMock(typeof(IBuildPlugin));
            DynamicMock buildPluginMock3 = new DynamicMock(typeof(IBuildPlugin));

            buildPluginMock1.SetupResult("LinkDescription", "Description 1");
            buildPluginMock1.SetupResult("NamedActions", new INamedAction[] { action1 });
            buildPluginMock1.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier));
            buildPluginMock2.SetupResult("LinkDescription", "Description 2");
            buildPluginMock2.SetupResult("NamedActions", new INamedAction[] { action2 });
            buildPluginMock2.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier));
            buildPluginMock3.SetupResult("IsDisplayedForProject", false, typeof(IProjectSpecifier));

            configurationMock.ExpectAndReturn("BuildPlugins", new IBuildPlugin[]
            {
                (IBuildPlugin)buildPluginMock1.MockInstance, (IBuildPlugin)buildPluginMock2.MockInstance, (IBuildPlugin)buildPluginMock3.MockInstance
            });
            linkFactoryMock.ExpectAndReturn("CreateBuildLink", link1, buildSpecifier, "Description 1", "Action Name 1");
            linkFactoryMock.ExpectAndReturn("CreateBuildLink", link2, buildSpecifier, "Description 2", "Action Name 2");

            IAbsoluteLink[] buildLinks = Plugins.GetBuildPluginLinks(buildSpecifier);

            Assert.AreSame(link1, buildLinks[0]);
            Assert.AreSame(link2, buildLinks[1]);
            Assert.AreEqual(2, buildLinks.Length);
            VerifyAll();
        }
Exemple #3
0
        private ProjectState CombinedState(ProjectState state1, ProjectState state2, ProjectState state3)
        {
            monitor1.SetupResult("ProjectState", state1);
            monitor2.SetupResult("ProjectState", state2);
            monitor3.SetupResult("ProjectState", state3);

            return(aggregator.ProjectState);
        }
Exemple #4
0
        public MockPluginEnvironment(IResourceStore storage)
        {
            _picoContainer     = new DefaultPicoContainer();
            _mockPicoContainer = new DefaultPicoContainer(_picoContainer);

            Storage = storage;
            if (storage != null)
            {
                _picoContainer.RegisterComponentInstance(storage);
            }
            File.Delete(".\\MockPluginEnvironment.ini");
            _settingStore = new Ini.IniFile(".\\MockPluginEnvironment.ini");

            DynamicMock actionManagerMock = new DynamicMock(typeof(IActionManager));

            actionManagerMock.SetupResult("GetKeyboardShortcut", "", typeof(IAction));
            _actionManager = (IActionManager)actionManagerMock.MockInstance;

            _uiManager       = (IUIManager) new DynamicMock(typeof(IUIManager)).MockInstance;
            _pluginLoader    = (IPluginLoader) new DynamicMock(typeof(IPluginLoader)).MockInstance;
            _resourceBrowser = (IResourceBrowser) new DynamicMock(typeof(IResourceBrowser)).MockInstance;
            _tabManager      = new MockTabManager();
            _resourceAP      = new MockAsyncProcessor();
            _networkAP       = new MockAsyncProcessor();
            _uiAP            = new MockAsyncProcessor();

            DynamicMock resourceIconManagerMock = new DynamicMock(typeof(IResourceIconManager));

            resourceIconManagerMock.SetupResult("IconColorDepth", ColorDepth.Depth8Bit);
            resourceIconManagerMock.SetupResult("GetIconIndex", 0, typeof(IResource));
            _resourceIconManager = (IResourceIconManager)resourceIconManagerMock.MockInstance;

            _notificationManager  = (INotificationManager) new DynamicMock(typeof(INotificationManager)).MockInstance;
            _textIndexManager     = (ITextIndexManager) new DynamicMock(typeof(ITextIndexManager)).MockInstance;
            _messageFormatter     = (IMessageFormatter) new DynamicMock(typeof(IMessageFormatter)).MockInstance;
            _displayColumnManager = (IDisplayColumnManager) new DynamicMock(typeof(IDisplayColumnManager)).MockInstance;

//            DynamicMock filterManagerMock = new DynamicMock( typeof(IFilterRegistry) );
            DynamicMock filterEngineMock = new DynamicMock(typeof(IFilterEngine));

            filterEngineMock.SetupResult("ExecRules", true, typeof(string), typeof(IResource));

            DynamicMock filterManagerMock = new DynamicMock(typeof(IFilterRegistry));

            _filterRegistry = (IFilterRegistry)filterManagerMock.MockInstance;

            _rcManager             = (IRemoteControlManager) new DynamicMock(typeof(IRemoteControlManager)).MockInstance;
            _trayIconManager       = (ITrayIconManager) new DynamicMock(typeof(ITrayIconManager)).MockInstance;
            _formattingRuleManager = (IFormattingRuleManager) new DynamicMock(typeof(IFormattingRuleManager)).MockInstance;
            _expirationRuleManager = (IExpirationRuleManager) new DynamicMock(typeof(IExpirationRuleManager)).MockInstance;
            _filteringFormsManager = (IFilteringFormsManager) new DynamicMock(typeof(IFilteringFormsManager)).MockInstance;
            _searchQueryExtensions = (ISearchQueryExtensions) new DynamicMock(typeof(ISearchQueryExtensions)).MockInstance;
            _filterEngine          = (IFilterEngine) new DynamicMock(typeof(IFilterEngine)).MockInstance;

            theInstance = this;
        }
        public void ShouldBuildAFingerprintWithValuesFromRequestIfBothHeadersAreAvailable()
        {
            DateTime lastModifiedDate = new DateTime(2007, 4, 20);
            string   etagValue        = "\"some opaque value\"";

            mockRequest.SetupResult("IfModifiedSince", lastModifiedDate.ToString("r"));
            mockRequest.SetupResult("IfNoneMatch", etagValue);
            ConditionalGetFingerprint fingerprint = new FingerprintFactory(null, null).BuildFromRequest(request);

            Assert.AreEqual(new ConditionalGetFingerprint(lastModifiedDate, etagValue), fingerprint);
        }
Exemple #6
0
        public void UserPromptChangeWSWhenPasting()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache,
                                               m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
                            SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
Exemple #7
0
        public void NextIsRaining()
        {
            IMock         random  = new DynamicMock(typeof(System.Random));
            WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);

            random.SetupResult("NextDouble", 0.0);
            Assertion.Assert("is raining", weather.NextIsRaining());

            random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
            Assertion.Assert("is not raining", !weather.NextIsRaining());

            random.SetupResult("NextDouble", 1.0);
            Assertion.Assert("is not raining", !weather.NextIsRaining());
        }
Exemple #8
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set the location of the m_selection
 /// </summary>
 /// <param name="rcPrimary">m_selection rectangle (from top of view)</param>
 /// <param name="fEndBeforeAnchor"><c>true</c> if end is before anchor</param>
 /// <param name="scrollPos">The scroll position</param>
 /// <param name="fIsRange"><c>true</c> if it is a range m_selection</param>
 /// ------------------------------------------------------------------------------------
 protected void SetLocation(Rect rcPrimary, bool fEndBeforeAnchor, Point scrollPos,
                            bool fIsRange)
 {
     m_mockSelection.SetupResult("Location", null, kLocationArgs,
                                 new object[] { null, null, null, new Rect(rcPrimary.left - scrollPos.X,
                                                                           rcPrimary.top - scrollPos.Y, rcPrimary.right - scrollPos.X,
                                                                           rcPrimary.bottom - scrollPos.Y), new Rect(0, 0, 0, 0), false,
                                                fEndBeforeAnchor });
     m_mockSelection.SetupResult("IsRange", fIsRange);
     m_mockSelection.SetupResult("SelType", VwSelType.kstText);
     m_mockSelection.SetupResult("EndBeforeAnchor", fEndBeforeAnchor);
     m_selection           = (IVwSelection)m_mockSelection.MockInstance;
     m_site.ScrollPosition = scrollPos;
 }
Exemple #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a simulated selection anywhere in the given title (Does NOT set para and
        /// character info)
        /// </summary>
        /// <param name="hvoTitle">The StText of the book title</param>
        /// ------------------------------------------------------------------------------------
        public void SetupSelectionForTitle(int hvoTitle)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("NumberOfLevels", 1);
            SelLevInfo[] topInfo = new SelLevInfo[1];
            topInfo[0].tag = ScrBookTags.kflidTitle;
            topInfo[0].hvo = hvoTitle;
            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("GetLevelInfo", topInfo, typeof(SelectionHelper.SelLimitType));
            m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setup the selection in footnote.
        /// </summary>
        /// <param name="footnote">The footnote.</param>
        /// <param name="book">The book.</param>
        /// <param name="iBook">The 0-based index of the book.</param>
        /// <param name="ichStart">The 0-based starting character index.</param>
        /// <param name="ichEnd">The 0-based ending character index.</param>
        /// ------------------------------------------------------------------------------------
        public void SetupSelectionInFootnote(IStFootnote footnote, IScrBook book,
                                             int iBook, int ichStart, int ichEnd)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("GetTextPropId", StTxtParaTags.kflidContents, typeof(SelectionHelper.SelLimitType));
            fakeSelHelper.SetupResult("NumberOfLevels", 3);
            // Setup the anchor
            SelLevInfo[] topInfo = new SelLevInfo[3];
            IStTxtPara   para    = footnote[0];

            topInfo[0].tag  = StTextTags.kflidParagraphs;
            topInfo[0].ihvo = 0;                // only one para per footnote allowed
            topInfo[0].hvo  = para.Hvo;

            topInfo[1].tag  = ScrBookTags.kflidFootnotes;
            topInfo[1].ihvo = footnote.IndexInOwner;
            topInfo[1].hvo  = footnote.Hvo;

            topInfo[2].tag  = BookFilter.Tag;
            topInfo[2].ihvo = iBook;
            topInfo[2].hvo  = book.Hvo;

            // Setup the end
            SelLevInfo[] bottomInfo = new SelLevInfo[3];
            for (int i = 0; i < 3; i++)
            {
                bottomInfo[i] = topInfo[i];
            }

            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("IchAnchor", ichStart);
            fakeSelHelper.SetupResult("IchEnd", ichEnd);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Anchor);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.Bottom);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.End);
            fakeSelHelper.SetupResultForParams("GetIch", ichStart,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
                                               SelectionHelper.SelLimitType.Bottom);
            m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }
Exemple #11
0
        public void ShouldUseBuildLogTransformerToGenerateView()
        {
            DynamicMock buildLogTransformerMock = new DynamicMock(typeof(IBuildLogTransformer));
            DynamicMock cruiseRequestMock       = new DynamicMock(typeof(ICruiseRequest));
            DynamicMock buildSpecifierMock      = new DynamicMock(typeof(IBuildSpecifier));
            DynamicMock requestStub             = new DynamicMock(typeof(IRequest));

            ICruiseRequest  cruiseRequest  = (ICruiseRequest)cruiseRequestMock.MockInstance;
            IBuildSpecifier buildSpecifier = (IBuildSpecifier)buildSpecifierMock.MockInstance;
            IRequest        request        = (IRequest)requestStub.MockInstance;

            cruiseRequestMock.ExpectAndReturn("BuildSpecifier", buildSpecifier);
            cruiseRequestMock.SetupResult("Request", request);
            requestStub.SetupResult("ApplicationPath", "myAppPath");
            Hashtable expectedXsltArgs = new Hashtable();

            expectedXsltArgs["applicationPath"] = "myAppPath";
            buildLogTransformerMock.ExpectAndReturn("Transform", "transformed", buildSpecifier, new string[] { @"xsl\myxsl.xsl" }, new HashtableConstraint(expectedXsltArgs), null);

            XslReportBuildAction action = new XslReportBuildAction((IBuildLogTransformer)buildLogTransformerMock.MockInstance, null);

            action.XslFileName = @"xsl\myxsl.xsl";

            Assert.AreEqual("transformed", ((HtmlFragmentResponse)action.Execute(cruiseRequest)).ResponseFragment);

            buildLogTransformerMock.Verify();
            cruiseRequestMock.Verify();
            buildSpecifierMock.Verify();
        }
Exemple #12
0
        public void ShouldConvertPathSeparatorForMono()
        {
            DynamicMock mockMono = new DynamicMock(typeof(IExecutionEnvironment));

            mockMono.SetupResult("DirectorySeparator", '/');
            Assert.AreEqual(@"/home/build/files", new SystemPath(@"\home\build\files", (IExecutionEnvironment)mockMono.MockInstance).ToString());
        }
Exemple #13
0
        public void ShouldConvertPathSeparatorForWindows()
        {
            DynamicMock mockWindows = new DynamicMock(typeof(IExecutionEnvironment));

            mockWindows.SetupResult("DirectorySeparator", '\\');
            Assert.AreEqual(@"c:\temp\files", new SystemPath("c:/temp/files", (IExecutionEnvironment)mockWindows.MockInstance).ToString());
        }
Exemple #14
0
        public void CreateOwnedObjects_MultipleAtEnd()
        {
            CheckDisposed();

            StTxtPara para = (StTxtPara)m_currentText.ParagraphsOS[0];

            // We use m_archivedText with para from m_currentText to create a footnote.
            // This simulates a "paragraph with footnote" just copied from m_archivedText.
            // The important thing here is that we have a footnote that links to a
            // different owner.
            m_inMemoryCache.AddFootnote(m_archivedFootnotesOS, para, 0, null);
            m_inMemoryCache.AddFootnote(m_archivedFootnotesOS, para, para.Contents.Length, null);
            int paraLen = para.Contents.Length;

            NMock.DynamicMock mockIObjectMetaInfoProvider =
                new DynamicMock(typeof(IObjectMetaInfoProvider));
            mockIObjectMetaInfoProvider.Strict = true;
            mockIObjectMetaInfoProvider.ExpectAndReturn("NextFootnoteIndex", 0, new object[] { para, 0 });
            mockIObjectMetaInfoProvider.SetupResult("FootnoteMarkerStyle", "Note Marker");

            Assert.AreEqual(0, m_currentFootnotesOS.Count);

            para.CreateOwnedObjects(0, paraLen,
                                    (IObjectMetaInfoProvider)mockIObjectMetaInfoProvider.MockInstance);

            mockIObjectMetaInfoProvider.Verify();

            Assert.AreEqual(2, m_currentFootnotesOS.Count);

            VerifyFootnote((StFootnote)m_currentFootnotesOS[0], para, 0);
            VerifyFootnote((StFootnote)m_currentFootnotesOS[1], para, paraLen - 1);
        }
Exemple #15
0
        public void CreatesAClientWithGivenClientNameIfSpecified()
        {
            // Setup
            DynamicMock p4Mock = new DynamicMock(typeof(P4));
            P4          p4     = (P4)p4Mock.MockInstance;

            p4.Client = "myClient";

            p4Mock.SetupResult("ViewForSpecifications", new string[] { "//mydepot/...", "//myotherdepot/..." });

            ProcessInfo processInfo = new ProcessInfo("createclient");
            ProcessInfo processInfoWithStdInContent = new ProcessInfo("createclient");

            processInfoWithStdInContent.StandardInputContent = "Client: myClient\n\nRoot:   c:\\my\\working\\dir\n\nView:\n //mydepot/... //myClient/mydepot/...\n //myotherdepot/... //myClient/myotherdepot/...\n";

            processInfoCreatorMock.ExpectAndReturn("CreateProcessInfo", processInfo, p4, "client -i");
            processExecutorMock.ExpectAndReturn("Execute", new ProcessResult("", "", 0, false), processInfoWithStdInContent);

            // Execute
            p4Initializer.Initialize(p4, "myProject", @"c:\my\working\dir");

            // Verify
            p4Mock.Verify();
            VerifyAll();
        }
        public void ShouldReturnCorrectMessageIfBuildForcedSuccessfully()
        {
            DefaultProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(
                new DefaultServerSpecifier("myServer"), "myProject");

            cruiseRequestMock.SetupResult("ProjectSpecifier", projectSpecifier);
            cruiseRequestMock.SetupResult("ProjectName", "myProject");

            mockFarmService.Expect("ForceBuild", projectSpecifier, (string)null);

            IResponse response = reportAction.Execute(cruiseRequest);

            Assert.IsTrue(response is XmlFragmentResponse);
            Assert.AreEqual("<ForceBuildResult>Build Forced for myProject</ForceBuildResult>",
                            ((XmlFragmentResponse)response).ResponseFragment);
        }
Exemple #17
0
        public void MultiMessageSynchronize_DifferentCache()
        {
            CheckDisposed();

            m_mainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
            m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance);

            InMemoryFdoCache differentCache = InMemoryFdoCache.CreateInMemoryFdoCache();

            try
            {
                DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd));
                otherMainWnd.SetupResult("Cache", differentCache.Cache);
                otherMainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
                otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
                m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance);

                m_app.SuppressSynchronize(Cache);
                m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), Cache);
                m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), differentCache.Cache);

                // This should call (Pre)Synchronize once for each main window
                m_app.ResumeSynchronize(Cache);

                m_mainWnd.Verify();
                otherMainWnd.Verify();
            }
            finally
            {
                differentCache.Dispose();
            }
        }
Exemple #18
0
        public void MultiMessageSynchronize_IdenticalMessages()
        {
            CheckDisposed();

            m_mainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
            m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance);

            DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd));

            otherMainWnd.SetupResult("Cache", Cache);
            otherMainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
            otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance);

            m_app.SuppressSynchronize(Cache);
            // we expect that the identical message will be discarded
            m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), Cache);
            m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), Cache);

            // This should call (Pre)Synchronize only once on each window
            m_app.ResumeSynchronize(Cache);

            m_mainWnd.Verify();
            otherMainWnd.Verify();
        }
Exemple #19
0
        public ICruiseServerManager RetrieveServerManager()
        {
            DynamicMock serverMock = new DynamicMock(typeof(ICruiseServerManager));

            serverMock.SetupResult("Configuration", configuration);
            return(serverMock.MockInstance as ICruiseServerManager);
        }
Exemple #20
0
        public ICruiseProjectManager RetrieveProjectManager(string projectName)
        {
            DynamicMock projectManagerMock = new DynamicMock(typeof(ICruiseProjectManager));

            projectManagerMock.SetupResult("ProjectName", projectName);
            return(projectManagerMock.MockInstance as ICruiseProjectManager);
        }
Exemple #21
0
        public void MultiMessageSynchronize_DifferentCache()
        {
            m_mainWnd.Expect("PreSynchronize", new IsAnything());
            m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance);

            FdoCache differentCache = FdoCache.CreateCache(FDOBackendProviderType.kMemoryOnly, BackendBulkLoadDomain.All, null);

            try
            {
                DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd));
                otherMainWnd.SetupResult("Cache", differentCache);
                otherMainWnd.Expect("PreSynchronize", new IsAnything());
                otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
                m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance);

                m_app.SuppressSynchronize(Cache);
                m_app.Synchronize(SyncMsg.ksyncUndoRedo, Cache);
                m_app.Synchronize(SyncMsg.ksyncUndoRedo, differentCache);

                // This should call (Pre)Synchronize once for each main window
                m_app.ResumeSynchronize(Cache);

                m_mainWnd.Verify();
                otherMainWnd.Verify();
            }
            finally
            {
                differentCache.Dispose();
            }
        }
        public void Setup()
        {
            ProjectStatusOnServer server = new ProjectStatusOnServer(new ProjectStatus("myProject", IntegrationStatus.Success, DateTime.Now),
                                                                     new DefaultServerSpecifier("myServer"));
            ProjectStatusListAndExceptions statusList = new ProjectStatusListAndExceptions(
                new ProjectStatusOnServer[] {
                server
            }, new CruiseServerException[] {
            });

            farmServiceMock = new DynamicMock(typeof(IFarmService));
            farmServiceMock.SetupResult("GetProjectStatusListAndCaptureExceptions", statusList, typeof(IServerSpecifier), typeof(string));
            viewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator));
            linkFactoryMock   = new DynamicMock(typeof(ILinkFactory));
            ServerLocation serverConfig = new ServerLocation();

            serverConfig.ServerName = "myServer";
            configuration.Servers   = new ServerLocation[] {
                serverConfig
            };
            var urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder));

            urlBuilderMock.SetupResult("BuildProjectUrl", string.Empty, typeof(string), typeof(IProjectSpecifier));

            plugin = new ProjectReportProjectPlugin((IFarmService)farmServiceMock.MockInstance,
                                                    (IVelocityViewGenerator)viewGeneratorMock.MockInstance,
                                                    (ILinkFactory)linkFactoryMock.MockInstance,
                                                    configuration,
                                                    (ICruiseUrlBuilder)urlBuilderMock.MockInstance);

            cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest));
            cruiseRequest     = (ICruiseRequest )cruiseRequestMock.MockInstance;
        }
Exemple #23
0
        protected void SetUp()
        {
            IMock mockDateTimeProvider = new DynamicMock(typeof(DateTimeProvider));

            mockDateTimeProvider.SetupResult("Now", new DateTime(2005, 1, 1));
            labeller = new DateLabeller((DateTimeProvider)mockDateTimeProvider.MockInstance);
        }
Exemple #24
0
        public void SetUp()
        {
            CheckDisposed();

            if (m_emptyTsString != null)
            {
                Marshal.ReleaseComObject(m_emptyTsString);
            }
            // Create an empty TsString
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, string.Empty, null);
            m_emptyTsString = bldr.GetString();

            // Set up the FDO mock and populate it with some values
            m_inMemoryCache = ScrInMemoryFdoCache.Create();
            m_inMemoryCache.InitializeLangProject();
            m_inMemoryCache.InitializeScripture();
            m_book = m_inMemoryCache.AddBookToMockedScripture(57, "Philemon");

            // Set up IVwEnv object
            m_vwenvMock = new DynamicMock(typeof(IVwEnv));
            m_vwenvMock.SetupResult("DataAccess", m_inMemoryCache.CacheAccessor);

            // save settings
            m_oldPromptSetting = Options.ShowEmptyParagraphPromptsSetting;
        }
        public void RethrowExceptionIfLoadingStateFileThrowsException()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", true, ProjectName);
            mockStateManager.ExpectAndThrow("LoadState", new CruiseControlException("expected exception"), ProjectName);

            DynamicMock resultMock = new DynamicMock(typeof(IIntegrationResult));

            resultMock.SetupResult("Status", IntegrationStatus.Unknown);
            resultMock.SetupResult("StartTime", DateTime.Now);
            resultMock.SetupResult("Succeeded", false);


            Assert.That(delegate { project.Integrate(ModificationExistRequest()); },
                        Throws.TypeOf <CruiseControlException>());
            VerifyAll();
        }
Exemple #26
0
        public override void TestSetup()
        {
            base.TestSetup();

            m_mainWnd = new DynamicMock(typeof(IFwMainWnd));
            m_mainWnd.SetupResult("Cache", Cache);
            m_app = new DummyFwApp();
        }
Exemple #27
0
        public void UserPromptChangeWSWhenTyping()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc   stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);
            ITsStrFactory tsf  = TsStrFactoryClass.Create();
            ITsString     tssVal;
            tssVal = tsf.MakeString("TEST", m_inMemoryCache.Cache.DefaultVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            ITsStrBldr bldr = TsStrBldrClass.Create();
            bldr.Replace(0, 0, "TEST", ttpBldr.GetTextProps());
            string diff;
            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(bldr.GetString(),
                                                           para.Contents.UnderlyingTsString, out diff), diff);

            m_vwenvMock.Verify();
        }
Exemple #28
0
        public void SetUp()
        {
            CheckDisposed();

            m_inMemoryCache = InMemoryFdoCache.CreateInMemoryFdoCache();
            m_mainWnd       = new DynamicMock(typeof(IFwMainWnd));
            m_mainWnd.SetupResult("Cache", Cache);
            m_app = new DummyFwApp();
        }
Exemple #29
0
        public void Setup()
        {
            m_site = new DummyRootSite();

            NMock.Dynamic.ClassGenerator.CreateSourceFile = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("Height", 10000);
            rootb.SetupResult("Width", m_site.ClientRectangle.X);
            m_rootb = (IVwRootBox)rootb.MockInstance;

            m_site.RootBox = m_rootb;

            m_mockSelection = new DynamicMock(typeof(IVwSelection));
            m_mockSelection.SetupResult("IsValid", true);
            m_site.CreateControl();
            m_site.ScrollMinSize = new Size(m_site.ClientRectangle.Width, 10000);
        }
Exemple #30
0
        public void Setup()
        {
            m_site = new DummyRootSite();

            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("Height", 10000);
            rootb.SetupResult("Width", m_site.ClientRectangle.X);
            rootb.SetupResult("IsPropChangedInProgress", false);
            m_rootb = (IVwRootBox)rootb.MockInstance;

            m_site.RootBox = m_rootb;

            m_mockSelection = new DynamicMock(typeof(IVwSelection));
            m_mockSelection.SetupResult("IsValid", true);
            m_site.CreateControl();
            m_site.ScrollMinSize = new Size(m_site.ClientRectangle.Width, 10000);
        }