本文整理匯總了C#中NMock.DynamicMock.Ignore方法的典型用法代碼示例。如果您正苦於以下問題:C# DynamicMock.Ignore方法的具體用法?C# DynamicMock.Ignore怎麽用?C# DynamicMock.Ignore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NMock.DynamicMock
的用法示例。
在下文中一共展示了DynamicMock.Ignore方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CanSetStubsAndExpectationsOnMethodsInTheSameClass
[Test] public void CanSetStubsAndExpectationsOnMethodsInTheSameClass()
{
DynamicMock mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
SameClass sc = (SameClass)mock.MockInstance;
mock.ExpectAndReturn("c", true);
mock.SetupResult("b", "hello");
AssertEquals("Should have overriden B()", "hello", sc.A());
mock.Verify();
}
示例2: ReuseGeneratedAssembly
public void ReuseGeneratedAssembly()
{
DynamicMock mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
mock.Ignore("c");
SameClass sc = (SameClass)mock.MockInstance;
mock.SetupResult("b", "hello");
Assertion.AssertEquals("hello", sc.A());
mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
sc = (SameClass)mock.MockInstance;
mock.ExpectAndReturn("c", true);
mock.SetupResult("b", "hello");
AssertEquals("Should have overriden B()", "hello", sc.A());
mock.Verify();
}
示例3: SetupRootBox
/// ------------------------------------------------------------------------------------
/// <summary>
/// Setup the mock rootbox
/// </summary>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
private IVwRootBox SetupRootBox()
{
m_rootBox = new DynamicMock(typeof(IVwRootBox));
m_rootBox.SetupResult("SetSite", null, typeof(IVwRootSite));
m_rootBox.SetupResult("DataAccess", Cache.DomainDataByFlid);
m_rootBox.SetupResult("SetRootObject", null, typeof(int), typeof(IVwViewConstructor),
typeof(int), typeof(IVwStylesheet));
m_rootBox.SetupResult("Height", 200); // JT: arbitrary values.
m_rootBox.SetupResult("Width", 200);
m_rootBox.SetupResult("Site", m_btView);
m_rootBox.Ignore("Close");
m_rootBox.Ignore("FlashInsertionPoint");
m_rootBox.SetupResult("GetRootObject", null,
new string[] { typeof(int).FullName + "&", typeof(IVwViewConstructor).FullName + "&", typeof(int).FullName + "&", typeof(IVwStylesheet).FullName + "&" },
new object[] { 0, null, 0, null });
return (IVwRootBox)m_rootBox.MockInstance;
}
示例4: StubbedMethodsCanBeCalledByOtherMethodsWithinObject
[Test] public void StubbedMethodsCanBeCalledByOtherMethodsWithinObject()
{
DynamicMock mock = new DynamicMock(typeof(SameClass));
mock.Ignore("A");
mock.Ignore("c");
SameClass sc = (SameClass)mock.MockInstance;
mock.SetupResult("b", "hello");
Assertion.AssertEquals("hello", sc.A());
}
示例5: SetupRangeSelection
//.........這裏部分代碼省略.........
}
topInfo[iLev].tag = (int)StText.StTextTags.kflidParagraphs;
topInfo[iLev].ihvo = iParaStart;
topInfo[iLev].hvo = paraStart.Hvo;
topInfo[++iLev].tag = setupForHeadingStart ? (int)ScrSection.ScrSectionTags.kflidHeading :
(int)ScrSection.ScrSectionTags.kflidContent;
topInfo[iLev].ihvo = 0;
topInfo[iLev].hvo = setupForHeadingStart ? sectionStart.HeadingOA.Hvo :
sectionStart.ContentOA.Hvo;
topInfo[++iLev].tag = (int)ScrBook.ScrBookTags.kflidSections;
topInfo[iLev].ihvo = iSecStart;
topInfo[iLev].hvo = sectionStart.Hvo;
topInfo[++iLev].tag = BookFilter.Tag;
topInfo[iLev].ihvo = iBookStart;
topInfo[iLev].hvo = bookStart.Hvo;
// Setup the end
int cLevelsBottom = wsEnd > 0 ? 5 : 4;
SelLevInfo[] bottomInfo = new SelLevInfo[cLevelsBottom];
iLev = 0;
if (wsEnd > 0)
{
bottomInfo[iLev].tag = -1;
bottomInfo[iLev].ihvo = 0;
bottomInfo[iLev].hvo = paraEnd.TranslationsOC.HvoArray[0];
iLev++;
}
bottomInfo[iLev].tag = (int)StText.StTextTags.kflidParagraphs;
bottomInfo[iLev].ihvo = iParaEnd;
bottomInfo[iLev].hvo = paraEnd.Hvo;
bottomInfo[++iLev].tag = setupForHeadingEnd ? (int)ScrSection.ScrSectionTags.kflidHeading :
(int)ScrSection.ScrSectionTags.kflidContent;
bottomInfo[iLev].ihvo = 0;
bottomInfo[iLev].hvo = setupForHeadingEnd ? sectionEnd.HeadingOA.Hvo :
sectionEnd.ContentOA.Hvo;
bottomInfo[++iLev].tag = (int)ScrBook.ScrBookTags.kflidSections;
bottomInfo[iLev].ihvo = iSecEnd;
bottomInfo[iLev].hvo = sectionEnd.Hvo;
bottomInfo[++iLev].tag = BookFilter.Tag;
bottomInfo[iLev].ihvo = iBookEnd;
bottomInfo[iLev].hvo = bookEnd.Hvo;
fakeSelHelper.SetupResult("NumberOfLevels", cLevelsTop);
fakeSelHelper.SetupResultForParams("GetNumberOfLevels", cLevelsTop,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetNumberOfLevels", cLevelsTop,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetNumberOfLevels", cLevelsBottom,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetNumberOfLevels", cLevelsBottom,
SelectionHelper.SelLimitType.End);
fakeSelHelper.SetupResult("LevelInfo", topInfo);
fakeSelHelper.SetupResult("IchAnchor", ichStart);
fakeSelHelper.SetupResult("IchEnd", ichEnd);
fakeSelHelper.SetupResult("Ws", wsStart);
fakeSelHelper.SetupResult("IsValid", true);
fakeSelHelper.SetupResult("AssocPrev", false);
fakeSelHelper.Ignore("get_IsRange");
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("GetTextPropId", wsStart > 0 ?
(int)CmTranslation.CmTranslationTags.kflidTranslation :
(int)StTxtPara.StTxtParaTags.kflidContents,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetTextPropId", wsStart > 0 ?
(int)CmTranslation.CmTranslationTags.kflidTranslation :
(int)StTxtPara.StTxtParaTags.kflidContents,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetTextPropId", wsEnd > 0 ?
(int)CmTranslation.CmTranslationTags.kflidTranslation :
(int)StTxtPara.StTxtParaTags.kflidContents,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetTextPropId", wsEnd > 0 ?
(int)CmTranslation.CmTranslationTags.kflidTranslation :
(int)StTxtPara.StTxtParaTags.kflidContents,
SelectionHelper.SelLimitType.End);
fakeSelHelper.SetupResultForParams("GetIch", ichStart,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetIch", ichStart,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
SelectionHelper.SelLimitType.End);
fakeSelHelper.SetupResultForParams("GetWritingSystem", wsStart == -1 ? m_cache.DefaultVernWs : wsStart,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetWritingSystem", wsStart == -1 ? m_cache.DefaultVernWs : wsStart,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetWritingSystem", wsEnd == -1 ? m_cache.DefaultVernWs : wsEnd,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetWritingSystem", wsEnd == -1 ? m_cache.DefaultVernWs : wsEnd,
SelectionHelper.SelLimitType.End);
m_viewSelection = (SelectionHelper)fakeSelHelper.MockInstance;
}
示例6: SetupRangeSelection
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="bookStart"></param>
/// <param name="iBookStart"></param>
/// <param name="sectionStart"></param>
/// <param name="iSecStart"></param>
/// <param name="paraStart"></param>
/// <param name="iParaStart"></param>
/// <param name="ichStart"></param>
/// <param name="setupForHeadingStart"></param>
/// <param name="bookEnd"></param>
/// <param name="iBookEnd"></param>
/// <param name="sectionEnd"></param>
/// <param name="iSecEnd"></param>
/// <param name="paraEnd"></param>
/// <param name="iParaEnd"></param>
/// <param name="ichEnd"></param>
/// <param name="setupForHeadingEnd"></param>
/// ------------------------------------------------------------------------------------
public void SetupRangeSelection(IScrBook bookStart, int iBookStart, IScrSection sectionStart,
int iSecStart, IStTxtPara paraStart, int iParaStart, int ichStart,
bool setupForHeadingStart, IScrBook bookEnd, int iBookEnd, IScrSection sectionEnd,
int iSecEnd, IStTxtPara paraEnd, int iParaEnd, int ichEnd, bool setupForHeadingEnd)
{
CheckDisposed();
DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));
fakeSelHelper.SetupResult("NumberOfLevels", 4);
// Setup the anchor
SelLevInfo[] topInfo = new SelLevInfo[4];
topInfo[0].tag = StTextTags.kflidParagraphs;
topInfo[0].ihvo = iParaStart;
topInfo[0].hvo = paraStart.Hvo;
topInfo[1].tag = setupForHeadingStart ? ScrSectionTags.kflidHeading :
ScrSectionTags.kflidContent;
topInfo[1].ihvo = 0;
topInfo[1].hvo = setupForHeadingStart ? sectionStart.HeadingOA.Hvo :
sectionStart.ContentOA.Hvo;
topInfo[2].tag = ScrBookTags.kflidSections;
topInfo[2].ihvo = iSecStart;
topInfo[2].hvo = sectionStart.Hvo;
topInfo[3].tag = ScriptureTags.kflidScriptureBooks;
topInfo[3].ihvo = iBookStart;
topInfo[3].hvo = bookStart.Hvo;
// Setup the end
SelLevInfo[] bottomInfo = new SelLevInfo[4];
bottomInfo[0].tag = StTextTags.kflidParagraphs;
bottomInfo[0].ihvo = iParaEnd;
bottomInfo[0].hvo = paraEnd.Hvo;
bottomInfo[1].tag = setupForHeadingEnd ? ScrSectionTags.kflidHeading :
ScrSectionTags.kflidContent;
bottomInfo[1].ihvo = 0;
bottomInfo[1].hvo = setupForHeadingEnd ? sectionEnd.HeadingOA.Hvo :
sectionEnd.ContentOA.Hvo;
bottomInfo[2].tag = ScrBookTags.kflidSections;
bottomInfo[2].ihvo = iSecEnd;
bottomInfo[2].hvo = sectionEnd.Hvo;
bottomInfo[3].tag = ScriptureTags.kflidScriptureBooks;
bottomInfo[3].ihvo = iBookEnd;
bottomInfo[3].hvo = bookEnd.Hvo;
fakeSelHelper.SetupResult("LevelInfo", topInfo);
fakeSelHelper.SetupResult("IchAnchor", ichStart);
fakeSelHelper.SetupResult("IchEnd", ichEnd);
fakeSelHelper.SetupResult("IsValid", true);
fakeSelHelper.SetupResult("AssocPrev", false);
fakeSelHelper.Ignore("get_IsRange");
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;
}
示例7: PressingEnterWithPictureSelected_InScrSectionContents
public void PressingEnterWithPictureSelected_InScrSectionContents()
{
CheckDisposed();
int hvoPic = CreateAndInsertPicture();
CmPicture pic = new CmPicture(Cache, hvoPic);
pic.Caption.SetVernacularDefaultWritingSystem("My Caption");
// Get the first paragraph in the first section of the first book.
IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo);
StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
ScrStyleNames.NormalParagraph);
m_scrInMemoryCache.AddRunToMockedPara(para, "This is the paragraph", null);
section.AdjustReferences();
SelectionHelper helper = PutPictureInParagraph(hvoPic, para);
helper.IchAnchor = 4;
helper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, (int)CmPicture.CmPictureTags.kflidCaption);
ReflectionHelper.SetField(m_editingHelper, "m_viewSelection", helper);
DynamicMock rootbox = new DynamicMock(typeof(IVwRootBox));
rootbox.Ignore("Close");
rootbox.Strict = true;
ReflectionHelper.SetField(m_RootSite, "m_rootb", rootbox.MockInstance);
ReflectionHelper.CallMethod(m_editingHelper, "HandleEnterKey", true, string.Empty,
0, 0, VwShiftStatus.kfssNone, null, Keys.None);
rootbox.Verify();
}
示例8: UserPromptChangeWSWhenPasting
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();
}
示例9: UserPromptChangeWSWhenTyping
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();
}
示例10: InitializeActionHandler
/// ------------------------------------------------------------------------------------
/// <summary>
/// Initializes an ActionHandler mock object
/// </summary>
/// ------------------------------------------------------------------------------------
public virtual void InitializeActionHandler()
{
CheckDisposed();
m_acth = new DynamicMock(typeof(IActionHandler));
m_acth.SetupResult("CurrentDepth", 0); // TODO: update our action handler depth to be 1.
m_acth.SetupResult("IsUndoOrRedoInProgress", false);
m_acth.SetupResult("CanUndo", false);
m_acth.SetupResult("Mark", 432);
m_acth.Ignore("AddAction");
((NewFdoCache)m_fdoCache).ActionHandler = (IActionHandler)m_acth.MockInstance;
}
示例11: Setup
public void Setup()
{
CheckDisposed();
m_ode = new DynamicMock(typeof(IOleDbEncap));
m_odde = new DynamicMock(typeof(IVwOleDbDa));
m_mdc = new DynamicMock(typeof(IFwMetaDataCache));
m_odc = new DynamicMock(typeof(IOleDbCommand));
m_odc.Ignore("ExecCommand");
m_ode.SetupResult("CreateCommand", null,
new string[] { "SIL.FieldWorks.Common.COMInterfaces.IOleDbCommand&"},
new object[] { m_odc.MockInstance });
m_cacheBase = new CacheBase((IFwMetaDataCache)m_mdc.MockInstance);
if (m_fdoCache != null)
m_fdoCache.Dispose();
m_fdoCache = new DummyFdoCache((IOleDbEncap)m_ode.MockInstance,
(IFwMetaDataCache)m_mdc.MockInstance, (IVwOleDbDa)m_odde.MockInstance,
m_cacheBase);
}