本文整理汇总了C#中Rhino.Mocks.MockRepository.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Stub方法的具体用法?C# MockRepository.Stub怎么用?C# MockRepository.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.Mocks.MockRepository
的用法示例。
在下文中一共展示了MockRepository.Stub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle_WrongStatementType_ThrowsException
public void Handle_WrongStatementType_ThrowsException()
{
MockRepository mocks = new MockRepository();
IBlacklistManager blacklistManager = mocks.Stub<IBlacklistManager>();
BlockParserContext blockParserContext = new BlockParserContext (
new ProblemPipeStub(),
Fragment.CreateNamed ("returnFragmentType"),
new List<ReturnCondition>(),
blacklistManager,
delegate { });
StatementHandlerBase<AssignmentStatement> handler = new AssignmentStatementHandlerController (blockParserContext);
Method sampleMethod = IntrospectionUtility.MethodFactory<StatementHandlerBaseSample> ("ContainsReturnStatement");
Block sampleBlock = (Block) sampleMethod.Body.Statements[1];
Statement sample = sampleBlock.Statements[0];
ISymbolTable symbolTable = mocks.Stub<ISymbolTable>();
HandleContext context = new HandleContext (
sample,
symbolTable,
new List<IPreCondition>(),
new List<string>(),
new List<BlockAssignment>(),
new List<int>(),
new Dictionary<string, bool>(),
new Dictionary<string, bool>());
handler.Handle (context);
}
示例2: AcksOnDelivery
public void AcksOnDelivery()
{
var mockRepository = new MockRepository();
var rabbitModel = mockRepository.DynamicMock<IModel>();
var messageSerializer = mockRepository.DynamicMock<IMessageSerializer>();
var registeredConsumer = mockRepository.DynamicMock<IRegisteredConsumer>();
var properties = mockRepository.Stub<IBasicProperties>();
var config = mockRepository.DynamicMock<IBrokerConfiguration>();
using (mockRepository.Record())
{
SetupResult.For(registeredConsumer.MessageType).Return(typeof (TestMessage));
SetupResult.For(registeredConsumer.Queue).Return("q");
SetupResult.For(registeredConsumer.ConsumerType).Return(typeof (TestConsumer));
SetupResult.For(messageSerializer.DeserializeMessage(null)).IgnoreArguments().Return(
mockRepository.Stub<IMessageEnvelope<TestMessage>>());
SetupResult.For(config.PipelineEvents).Return(new PipelineEvents());
Expect.Call(() => rabbitModel.BasicAck(1, false));
}
using (mockRepository.Playback())
{
var callbackConsumer = new GroupedCallbackConsumer(rabbitModel, messageSerializer, config);
callbackConsumer.ConsumeQueue(registeredConsumer);
callbackConsumer.QueueConsumers["q"].Consumer.HandleBasicDeliver("ct1", 1, false, "ex", typeof(TestMessage).ToRoutingKey(), properties, new byte[0]);
callbackConsumer.Close();
callbackConsumer.Dispose();
}
}
示例3: ShouldQuoteAndHtmlEncodeCsvItemsContainingComma
public void ShouldQuoteAndHtmlEncodeCsvItemsContainingComma()
{
var mocks = new MockRepository();
var httpRequestFactoryStub = mocks.Stub<IHttpRequestFactory>();
var requestStub = mocks.Stub<IHttpRequest>();
var responseStub = mocks.Stub<IHttpResponse>();
var stream = new MemoryStream();
using(mocks.Record())
{
SetupResult.For(httpRequestFactoryStub.Create(null)).IgnoreArguments().Return(requestStub);
SetupResult.For(requestStub.GetRequestStream()).Return(stream);
SetupResult.For(requestStub.GetResponse()).Return(responseStub);
}
var comm = new WebCommunication(httpRequestFactoryStub);
comm.PostCsv("http://test.com",WorkItem.New("1","/").UpdateProperty("title","title,with,comma"));
using(var reader = new StreamReader(new MemoryStream(stream.ToArray())))
{
var actual = reader.ReadToEnd();
Assert.AreEqual("id=1,\"title=title,with,comma\"",actual);
}
}
示例4: Setup
public void Setup()
{
this.mr = new MockRepository();
this.fsSvc = mr.StrictMock<IFileSystemService>();
this.tllSvc = mr.Stub<ITypeLibraryLoaderService>();
this.services = mr.StrictMock<IServiceProvider>();
var cfgSvc = mr.Stub<IConfigurationService>();
var env = mr.Stub<OperatingEnvironment>();
this.arch = new M68kArchitecture();
this.rtls = new List<RtlInstruction>();
this.m = new RtlEmitter(rtls);
cfgSvc.Stub(c => c.GetEnvironment("amigaOS")).Return(env);
env.Stub(e => e.TypeLibraries).Return(new List<ITypeLibraryElement>());
env.Stub(e => e.CharacteristicsLibraries).Return(new List<ITypeLibraryElement>());
env.Stub(e => e.Options).Return(new Dictionary<string, object>
{
{ "versionDependentLibraries", new Dictionary<string,object>
{
{ "33", new List<object> { "exec_v33", "dos_v33" } },
{ "34", new List<object> { "exec_v34", "dos_v34" } },
}
}
});
this.services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(cfgSvc);
this.services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(fsSvc);
this.services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tllSvc);
this.frame = new Frame(arch.FramePointerType);
}
示例5: ReturnsRow
public void ReturnsRow()
{
MockRepository mockRepository = new MockRepository();
IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>();
IHBaseRowData rowData = mockRepository.Stub<IHBaseRowData>();
byte[] rowName = Encoding.UTF8.GetBytes("r");
byte[] tableName = Encoding.UTF8.GetBytes("t");
using (mockRepository.Record())
{
SetupResult.For(
connection
.GetRow(
tableName,
rowName))
.Return(rowData);
SetupResult.For(rowData.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>());
SetupResult.For(rowData.Key).Return(rowName);
}
using (mockRepository.Playback())
{
HBaseDatabase db = new HBaseDatabase(connection);
HBaseTable table = new HBaseTable(tableName, db);
var row = table.GetRow(rowName);
Assert.Equal(rowName, row.Key);
}
}
示例6: Setup
public void Setup()
{
this.tabCtrl = new TabControl();
this.mr = new MockRepository();
this.pane = mr.Stub<IWindowPane>();
this.services = mr.Stub<IServiceProvider>();
}
示例7: FormatPhoneNumber_PhoneNumberInDresdenGermany_ReturnsFormattedNumber
public void FormatPhoneNumber_PhoneNumberInDresdenGermany_ReturnsFormattedNumber(
[Values(DISTANCE_RULE.CANONICAL, DISTANCE_RULE.InternationalRule, DISTANCE_RULE.LongDistanceRule,
DISTANCE_RULE.SameAreaRule)] DISTANCE_RULE distanceRule,
[Values("+49 (351) 1234567", "00493511234567", "03511234567", "1234567")] string expected)
{
MockRepository mocks = new MockRepository();
IPhoneNumberDataXml xmlDataProvider = mocks.Stub<IPhoneNumberDataXml>();
IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>();
string number = "+493511234567";
using (mocks.Record())
{
registryDataProvider.GetUserCountryID();
LastCall.Return("49");
registryDataProvider.GetUserAreaCode();
LastCall.Return("351");
registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.InternationalRule);
LastCall.Return("00EFG");
registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.LongDistanceRule);
LastCall.Return("0FG");
registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.SameAreaRule);
LastCall.Return("G");
xmlDataProvider.GetCountryCode("4935");
LastCall.Return("49");
xmlDataProvider.GetAreaCode("+493511234567");
LastCall.Return("+49351");
}
PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
string actual = phoneNumberConverter.FormatPhoneNumber(number, distanceRule);
Assert.AreEqual(expected, actual);
}
示例8: SetUp
public void SetUp()
{
mock=new MockRepository();
dataWriter = mock.DynamicMock<IDataWriter>();
dataReader = mock.Stub<IDataReader>();
randomSecret = mock.Stub<IRandomSecret>();
}
示例9: Setup
public void Setup()
{
mr = new MockRepository();
program = new Program();
proc = new Procedure("testProc", new Frame(PrimitiveType.Word32));
block = proc.AddBlock("l00100000");
trace = new RtlTrace(0x00100000);
r0 = new Identifier("r0", PrimitiveType.Word32, new RegisterStorage("r0", 0, 0, PrimitiveType.Word32));
r1 = new Identifier("r1", PrimitiveType.Word32, new RegisterStorage("r1", 1, 0, PrimitiveType.Word32));
r2 = new Identifier("r2", PrimitiveType.Word32, new RegisterStorage("r2", 2, 0, PrimitiveType.Word32));
sp = new Identifier("sp", PrimitiveType.Word32, new RegisterStorage("sp", 15, 0, PrimitiveType.Word32));
grf = proc.Frame.EnsureFlagGroup(Registers.eflags, 3, "SCZ", PrimitiveType.Byte);
var sc = new ServiceContainer();
var listener = mr.Stub<DecompilerEventListener>();
scanner = mr.StrictMock<IScanner>();
arch = mr.Stub<IProcessorArchitecture>();
program.Architecture = arch;
program.SegmentMap = new SegmentMap(
Address.Ptr32(0x00100000),
new ImageSegment(
".text",
new MemoryArea(Address.Ptr32(0x00100000), new byte[0x20000]),
AccessMode.ReadExecute));
arch.Replay();
program.Platform = new DefaultPlatform(null, arch);
arch.BackToRecord();
arch.Stub(s => s.StackRegister).Return((RegisterStorage)sp.Storage);
arch.Stub(s => s.PointerType).Return(PrimitiveType.Pointer32);
scanner.Stub(s => s.Services).Return(sc);
sc.AddService<DecompilerEventListener>(listener);
}
示例10: Setup
public void Setup()
{
MockRepository mock = new MockRepository();
IDataModel stubDb = mock.Stub<IDataModel>();
IDataQueryRepository stubReposit = mock.Stub<IDataQueryRepository>();
MyInfoController = new myInfoController(stubDb, stubReposit);
}
示例11: SetUp
protected void SetUp()
{
var mocks = new MockRepository();
var azienda = new Azienda("PROV", "Azienda di prova");
var condominio = new Condominio("Condominio di prova", 31, 12, 2012, azienda);
var stabile = new Palazzina(condominio, "Stabile di prova", false);
condominio.Palazzine.Add(stabile);
var scala = new GruppoStabile(stabile, "Scala di prova");
var tipoUnitaImmobiliare = new TipoUnitaImmobiliare("Abitazione");
var unitaImmobiliare = new UnitaImmobiliare(scala, tipoUnitaImmobiliare);
var annoGestionale = new AnnoGestionale(condominio, 2012, 2012);
_esercizio = new Esercizio(condominio, new DateTime(2012, 1, 1), new DateTime(2012, 12, 31), annoGestionale, GestioneEsercizioEnum.Ordinario);
_subentroRepository = mocks.Stub<ISubentroUnitaImmobiliareDao>();
var subentro1 = mocks.Stub<SubentroUnitaImmobiliare>();
subentro1.SoggettoEntrante = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Giorgio", "Parmeggiani", 1, true));
subentro1.SoggettoUscente = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Daniele", "Vaccari", 1, true));
var subentro2 = mocks.Stub<SubentroUnitaImmobiliare>();
subentro1.SoggettoEntrante = new SoggettoCondominio(unitaImmobiliare, subentro1.SoggettoUscente.Persona);
subentro1.SoggettoUscente = new SoggettoCondominio(unitaImmobiliare, new Persona(TipoPersonaEnum.Fisica, "Luigi", "Cacciatori", 1, true));
using (mocks.Record())
{
SetupResult.For(_subentroRepository.GetByDataCondominio(_esercizio.CondominioRiferimento.ID, _esercizio.DataApertura.GetValueOrDefault(), _esercizio.DataChiusura.GetValueOrDefault(), false)).Return(new List<SubentroUnitaImmobiliare> { subentro1, subentro2 });
}
}
示例12: CreateHookObject
private StandardHookInTension CreateHookObject(double ConcStrength, double RebarDiameter, bool IsEpoxyCoated,
ConcreteTypeByWeight typeByWeight, double ExcessFlexureReinforcementRatio)
{
MockRepository mocks = new MockRepository();
IRebarMaterial rebarMat = mocks.Stub<IRebarMaterial>();
Expect.Call(rebarMat.YieldStress).Return(60000);
Rebar rebar = new Rebar(RebarDiameter,IsEpoxyCoated, rebarMat);
ICalcLogEntry entryStub = mocks.Stub<ICalcLogEntry>();
ICalcLog logStub = mocks.Stub<ICalcLog>();
//IConcreteMaterial ConcStub = mocks.Stub<IConcreteMaterial>();
IConcreteMaterial ConcStub = new ConcreteMaterial(ConcStrength, typeByWeight, logStub) as IConcreteMaterial;
ConcStub.SpecifiedCompressiveStrength = ConcStrength;
ConcStub.TypeByWeight = typeByWeight;
using (mocks.Record())
{
logStub.CreateNewEntry();
LastCall.Return(entryStub);
}
StandardHookInTension tensHook = new StandardHookInTension(ConcStub, rebar, logStub, ExcessFlexureReinforcementRatio);
return tensHook;
}
示例13: LoadsOnLoad
public void LoadsOnLoad()
{
MockRepository mockRepository = new MockRepository();
IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>();
IHBaseRowData rowData = mockRepository.Stub<IHBaseRowData>();
IHBaseCellData cellData = mockRepository.Stub<IHBaseCellData>();
byte[] tableName = Encoding.UTF8.GetBytes("t");
byte[] rowKey = Encoding.UTF8.GetBytes("r");
byte[] columnName = Encoding.UTF8.GetBytes("c");
using (mockRepository.Record())
{
SetupResult.For(rowData.Key).Return(rowKey);
SetupResult.For(rowData.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>> { { columnName, new List<IHBaseCellData> { cellData } } });
SetupResult.For(connection.GetRow(tableName, rowKey)).Return(rowData);
}
using (mockRepository.Playback())
{
HBaseDatabase db = new HBaseDatabase(connection);
HBaseRow row = new HBaseRow(Encoding.UTF8.GetBytes("r"), new HBaseTable(Encoding.UTF8.GetBytes("t"), db));
row.Load();
Assert.Equal(1, row.Columns.Keys.Count);
}
}
示例14: Setup
public void Setup()
{
mr = new MockRepository();
mockFactory = new MockFactory(mr);
var platform = mockFactory.CreatePlatform();
var imageMap = new SegmentMap(Address32.Ptr32(0x05));
program = new Program(imageMap, platform.Architecture, platform);
interactor = new CombinedCodeViewInteractor();
var uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
var uiSvc = mr.Stub<IDecompilerShellUiService>();
var styles = new Dictionary<string, UiStyle>()
{
{
UiStyles.CodeWindow,
new UiStyle
{
Background = new SolidBrush(Color.White),
}
}
};
uiPreferencesSvc.Stub(u => u.Styles).Return(styles);
var sc = new ServiceContainer();
sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
sc.AddService<IDecompilerShellUiService>(uiSvc);
interactor.SetSite(sc);
}
示例15: Setup
public void Setup()
{
this.mr = new MockRepository();
this.sc = new ServiceContainer();
loader = mr.Stub<ILoader>();
arch = mr.StrictMock<IProcessorArchitecture>();
Address dummy;
arch.Stub(a => a.TryParseAddress(null, out dummy)).IgnoreArguments().WhenCalled(m =>
{
Address addr;
var sAddr = (string)m.Arguments[0];
var iColon = sAddr.IndexOf(':');
if (iColon > 0)
{
addr = Address.SegPtr(
Convert.ToUInt16(sAddr.Remove(iColon)),
Convert.ToUInt16(sAddr.Substring(iColon+1)));
m.ReturnValue = true;
}
else
{
m.ReturnValue = Address32.TryParse32((string)m.Arguments[0], out addr);
}
m.Arguments[1] = addr;
}).Return(false);
this.cfgSvc = mr.Stub<IConfigurationService>();
this.sc.AddService<IConfigurationService>(cfgSvc);
}