本文整理汇总了C#中Moq.MockRepository类的典型用法代码示例。如果您正苦于以下问题:C# MockRepository类的具体用法?C# MockRepository怎么用?C# MockRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockRepository类属于Moq命名空间,在下文中一共展示了MockRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Install_should_install_if_a_package_has_not_been_installed_yet
public void Install_should_install_if_a_package_has_not_been_installed_yet()
{
// Arrange
var fixture = new Fixture().Customize(new AutoMoqCustomization());
var proj = fixture.Freeze<Project>();
var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj);
var mocks = new MockRepository(MockBehavior.Strict);
{
var m = mocks.Create<IVsPackageInstallerServices>();
m.Setup(_ => _.IsPackageInstalledEx(proj, "Prig", "2.0.0")).Returns(false);
m.Setup(_ => _.IsPackageInstalled(proj, "Prig")).Returns(false);
fixture.Inject(m);
}
{
var m = mocks.Create<IVsPackageUninstaller>();
fixture.Inject(m);
}
{
var m = mocks.Create<IVsPackageInstaller>();
m.Setup(_ => _.InstallPackage(default(string), proj, "Prig", "2.0.0", false));
fixture.Inject(m);
}
var pwInstllr = fixture.NewProjectWideInstaller();
// Act
pwInstllr.Install(pwPkg);
// Assert
mocks.VerifyAll();
}
开发者ID:umaranis,项目名称:Prig,代码行数:34,代码来源:ProjectWideInstallerTest.cs
示例2: InvokeErrorTest
public async Task InvokeErrorTest()
{
var mr = new MockRepository(MockBehavior.Strict);
var next = mr.Create<OwinMiddleware>(MockBehavior.Strict, (OwinMiddleware)null);
var ctx = mr.Create<IOwinContext>();
var logger = mr.Create<ILog>();
var exception = new Exception();
var request = mr.Create<IOwinRequest>();
ctx.SetupGet(x => x.Request).Returns(request.Object).Verifiable();
logger.Setup(x => x.Info(It.IsAny<string>())).Throws(exception);
request.SetupGet(x => x.Method).Returns("fasefaes").Verifiable();
request.SetupGet(x => x.Uri).Returns(new Uri("http://ya.ru")).Verifiable();
request.SetupGet(x => x.RemoteIpAddress).Returns("asefasergsdrg").Verifiable();
request.SetupGet(x => x.RemotePort).Returns(11).Verifiable();
var mw = new LoggerMiddleware(next.Object, logger.Object);
try
{
await mw.Invoke(ctx.Object);
}
catch (Exception e)
{
Assert.AreEqual(exception, e);
return;
}
finally
{
mr.VerifyAll();
}
Assert.Fail();
}
开发者ID:riberk,项目名称:Rib.Common,代码行数:30,代码来源:LoggerMiddlewareTests.cs
示例3: Create
public void Create(params string[] lines)
{
_textBuffer = EditorUtil.CreateTextBuffer(lines);
_factory = new MockRepository(MockBehavior.Strict);
_adapterRaw = new ResharperExternalEditAdapter();
_adapter = _adapterRaw;
}
开发者ID:GunioRobot,项目名称:VsVim,代码行数:7,代码来源:ResharperExternalEditAdapterTest.cs
示例4: HostFactoryTest
protected HostFactoryTest()
{
_globalSettings = Vim.GlobalSettings;
_protectedOperations = new TestableProtectedOperations();
_mockFactory = new MockRepository(MockBehavior.Strict);
_synchronizer = _mockFactory.Create<IEditorToSettingsSynchronizer>(MockBehavior.Strict);
_vsEditorAdaptersFactoryService = _mockFactory.Create<IVsEditorAdaptersFactoryService>();
_vimApplicationSettings = _mockFactory.Create<IVimApplicationSettings>(MockBehavior.Loose);
var vsAdapter = _mockFactory.Create<IVsAdapter>();
vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_vsEditorAdaptersFactoryService.Object);
_hostFactory = new HostFactory(
Vim,
_vsEditorAdaptersFactoryService.Object,
_mockFactory.Create<IDisplayWindowBrokerFactoryService>(MockBehavior.Loose).Object,
_mockFactory.Create<ITextManager>(MockBehavior.Loose).Object,
vsAdapter.Object,
_protectedOperations,
new VimBufferCoordinatorFactory(Vim),
_mockFactory.Create<IKeyUtil>(MockBehavior.Loose).Object,
_synchronizer.Object,
_vimApplicationSettings.Object,
new Lazy<ICommandTargetFactory, IOrderable>[] { });
}
开发者ID:aesire,项目名称:VsVim,代码行数:25,代码来源:HostFactoryTest.cs
示例5: Setup
public void Setup()
{
_candidate = ObjectMother.GetCandidate();
_mockRepository = new MockRepository(MockBehavior.Default);
_candidateRepoMock = _mockRepository.Create<ICandidateRepository>();
_service = new CandidateService(_candidateRepoMock.Object);
}
开发者ID:AprigioJoseZancheta,项目名称:TrabalhoDesenvolvimentoAprigio,代码行数:7,代码来源:ServiceCandidateTest.cs
示例6: Create
public void Create(params string[] lines)
{
_textView = CreateTextView(lines);
_textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
_textBuffer = _textView.TextBuffer;
_factory = new MockRepository(MockBehavior.Strict);
_editOpts = _factory.Create<IEditorOperations>();
_vimHost = _factory.Create<IVimHost>();
_vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false);
_operations = _factory.Create<ICommonOperations>();
_operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
_statusUtil = _factory.Create<IStatusUtil>();
_fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
_foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
_vimData = new VimData();
_vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
var localSettings = new LocalSettings(Vim.GlobalSettings);
var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
_textBuffer,
vim: _vim.Object,
localSettings: localSettings,
factory: _factory);
var vimBufferData = CreateVimBufferData(
vimTextBuffer.Object,
_textView,
statusUtil: _statusUtil.Object);
var vimBuffer = CreateVimBuffer(vimBufferData);
_interpreter = new Interpreter.VimInterpreter(
vimBuffer,
_operations.Object,
_foldManager.Object,
_fileSystem.Object,
_factory.Create<IBufferTrackingService>().Object);
}
开发者ID:wmchristie,项目名称:VsVim,代码行数:34,代码来源:CommandProcessorLegacyTest.cs
示例7: UserServiceTest
public UserServiceTest()
{
this.mockRepository = new MockRepository(MockBehavior.Strict);
this.mockErrorState = this.mockRepository.Create<IErrorState>();
this.mockUserRepository = this.mockRepository.Create<IUserRepository>();
this.userService = new UserService(this.mockErrorState.Object, this.mockUserRepository.Object);
}
开发者ID:akornatskyy,项目名称:sample-blog-api-net,代码行数:7,代码来源:UserServiceTest.cs
示例8: ReportDesignerUtilTest
protected ReportDesignerUtilTest()
{
_factory = new MockRepository(MockBehavior.Strict);
_vsEditorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
_reportDesignerUtilRaw = new ReportDesignerUtil(_vsEditorAdaptersFactoryService.Object);
_reportDesignerUtil = _reportDesignerUtilRaw;
}
开发者ID:aesire,项目名称:VsVim,代码行数:7,代码来源:ReportDesignerUtilTest.cs
示例9: Create
public void Create(params string[] lines)
{
_textBuffer = CreateTextBuffer(lines);
_factory = new MockRepository(MockBehavior.Strict);
_reSharperUtilRaw = new ReSharperUtil(isResharperInstalled: true);
_reSharperUtil = _reSharperUtilRaw;
}
开发者ID:honeyhoneywell,项目名称:VsVim,代码行数:7,代码来源:ReSharperUtilTest.cs
示例10: CreateVsTextLineMarker
public static Mock<IVsTextLineMarker> CreateVsTextLineMarker(
TextSpan span,
MARKERTYPE type,
MockRepository factory = null)
{
return CreateVsTextLineMarker(span, (int)type, factory);
}
开发者ID:kcprogrammer,项目名称:VsVim,代码行数:7,代码来源:MockObjectFactory.cs
示例11: UserBusinessLogicTests
public UserBusinessLogicTests()
{
MockFactory = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock };
MockedUserBusinessLogic = MockFactory.Create<IUserBusinessLogic>();
MockedUserRepository = MockFactory.Create<IUserRepository>();
}
开发者ID:dragana-berber,项目名称:FarmAppReborn,代码行数:7,代码来源:UserBusinessLogicTests.cs
示例12: VsCommandTargetTest
public VsCommandTargetTest()
{
_textView = CreateTextView("");
_buffer = Vim.CreateVimBuffer(_textView);
_bufferCoordinator = new VimBufferCoordinator(_buffer);
_vim = _buffer.Vim;
_factory = new MockRepository(MockBehavior.Strict);
// By default Resharper isn't loaded
_resharperUtil = _factory.Create<IResharperUtil>();
_resharperUtil.SetupGet(x => x.IsInstalled).Returns(false);
_nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
_vsAdapter = _factory.Create<IVsAdapter>();
_vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
_vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
_vsAdapter.Setup(x => x.InDebugMode).Returns(false);
_vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
_broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);
var oldCommandFilter = _nextTarget.Object;
var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose);
vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
var result = VsCommandTarget.Create(
_bufferCoordinator,
vsTextView.Object,
_vsAdapter.Object,
_broker.Object,
_resharperUtil.Object,
KeyUtil);
Assert.True(result.IsSuccess);
_targetRaw = result.Value;
_target = _targetRaw;
}
开发者ID:kcprogrammer,项目名称:VsVim,代码行数:35,代码来源:VsCommandTargetTest.cs
示例13: VimTest
public VimTest()
{
_factory = new MockRepository(MockBehavior.Strict);
_globalSettings = new GlobalSettings();
_markMap = _factory.Create<IMarkMap>(MockBehavior.Strict);
_fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
_bufferFactory = VimBufferFactory;
var map = new Dictionary<string, VariableValue>();
_keyMap = new KeyMap(_globalSettings, map);
_vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
_searchInfo = _factory.Create<ISearchService>(MockBehavior.Strict);
_vimRaw = new Vim(
_vimHost.Object,
_bufferFactory,
FSharpList<Lazy<IVimBufferCreationListener>>.Empty,
_globalSettings,
_markMap.Object,
_keyMap,
MockObjectFactory.CreateClipboardDevice().Object,
_searchInfo.Object,
_fileSystem.Object,
new VimData(),
_factory.Create<IBulkOperations>().Object,
map);
_vim = _vimRaw;
_vim.AutoLoadVimRc = false;
}
开发者ID:fpicalausa,项目名称:VsVim,代码行数:28,代码来源:VimTest.cs
示例14: Setup
public void Setup()
{
_interview = ObjectMother.GetInterview();
_mockRepository = new MockRepository(MockBehavior.Default);
_interviewRepoMoq = _mockRepository.Create<IInterviewRepository>();
_service = new InterviewService(_interviewRepoMoq.Object);
}
开发者ID:AprigioJoseZancheta,项目名称:TrabalhoDesenvolvimentoAprigio,代码行数:7,代码来源:ServiceInterviewTest.cs
示例15: InvokeTest
public async Task InvokeTest()
{
var mr = new MockRepository(MockBehavior.Strict);
var next = mr.Create<OwinMiddleware>(MockBehavior.Strict, (OwinMiddleware) null);
var ctx = mr.Create<IOwinContext>();
var logger = mr.Create<ILog>();
var exception = new Exception();
logger.Setup(x => x.Fatal(It.IsAny<object>(), exception)).Verifiable();
next.Setup(x => x.Invoke(ctx.Object)).Returns(async () =>
{
await Task.Delay(1);
throw exception;
}).Verifiable();
var mw = new ExceptionHandlerMiddleware(next.Object, logger.Object);
try
{
await mw.Invoke(ctx.Object);
}
catch (Exception e)
{
Assert.AreEqual(exception, e);
}
mr.VerifyAll();
}
开发者ID:riberk,项目名称:Rib.Common,代码行数:27,代码来源:ExceptionHandlerMiddlewareTests.cs
示例16: Create
public void Create(params string[] lines)
{
_textBuffer = CreateTextBuffer(lines);
_factory = new MockRepository(MockBehavior.Strict);
_adapterRaw = new ReSharperUtil(true);
_adapter = _adapterRaw;
}
开发者ID:kun-liu,项目名称:VsVim,代码行数:7,代码来源:ReSharperUtilTest.cs
示例17: Init
public void Init()
{
_mockRepository = new MockRepository(MockBehavior.Strict);
_fdResolver = _mockRepository.Create<IFirstDayOfWeekResolver>();
_weekPadding = _mockRepository.Create<IWeekPaddingCalculator>();
}
开发者ID:riberk,项目名称:Rib.Common,代码行数:7,代码来源:WeekHelperTests.cs
示例18: CreateMacroRecorder
public static Mock<IMacroRecorder> CreateMacroRecorder(MockRepository factory = null)
{
factory = factory ?? new MockRepository(MockBehavior.Strict);
var recorder = factory.Create<IMacroRecorder>(MockBehavior.Loose);
recorder.SetupGet(x => x.IsRecording).Returns(false);
return recorder;
}
开发者ID:Kazark,项目名称:VsVim,代码行数:7,代码来源:MockObjectFactory.cs
示例19: Setup
public void Setup()
{
_address = ObjectMother.GetAddress();
_mockRepository = new MockRepository(MockBehavior.Default);
_addressRepoMoq = _mockRepository.Create<IAddressRepository>();
_service = new AddressService(_addressRepoMoq.Object);
}
开发者ID:AprigioJoseZancheta,项目名称:TrabalhoDesenvolvimentoAprigio,代码行数:7,代码来源:ServiceAddressTest.cs
示例20: Initalize
public void Initalize()
{
_factory = new MockRepository(MockBehavior.Loose);
_container = new AutoMockContainer(_factory);
_coins = new List<Coin>();
_purchaseServiceMock = _container.GetMock<IPurchaseService>();
var product_a = new Product() { Price = 1, Title = "Apple" };
var product_b = new Product() { Price = .75m, Title = "Banana" };
var slot_a = new Slot() { Button = "A", Product = product_a, MaxNumberOfProduct = 5, Quantity = 4 };
var slot_b = new Slot() { Button = "B", Product = product_b, MaxNumberOfProduct = 5, Quantity = 0 };
_dollar = new Coin() { Title = "One Dollar", Value = 1, ShortName = "O" };
_quarter = new Coin() { Title = "Quarter", Value = .25m, ShortName = "Q" };
_dime = new Coin() { Title = "Dime", Value = .1m, ShortName = "d" };
_nickle = new Coin() { Title = "Nickle", Value = .05m, ShortName = "n" };
_penny = new Coin() { Title = "Penny", Value = .01m, ShortName = "p" };
_slots = new List<Slot>() { slot_a, slot_b };
_maxSlots = 5;
_machineService = new MachineService(_maxSlots, _purchaseServiceMock.Object);
}
开发者ID:andrewleaf,项目名称:CodeKata,代码行数:25,代码来源:MachineServiceTests.cs
注:本文中的Moq.MockRepository类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论