本文整理汇总了C#中Moq.MockRepository.Create方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Create方法的具体用法?C# MockRepository.Create怎么用?C# MockRepository.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moq.MockRepository
的用法示例。
在下文中一共展示了MockRepository.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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.Interpreter(
vimBuffer,
_operations.Object,
_foldManager.Object,
_fileSystem.Object,
_factory.Create<IBufferTrackingService>().Object);
}
示例3: SutDoesNotEqualOtherWithDifferentNodes
public void SutDoesNotEqualOtherWithDifferentNodes()
{
// Arrange
var moqRepo = new MockRepository(MockBehavior.Default);
var sut = new CompositeMortgageApplicationProcessor
{
Nodes = new[]
{
moqRepo.Create<IMortgageApplicationProcessor>().Object,
moqRepo.Create<IMortgageApplicationProcessor>().Object,
moqRepo.Create<IMortgageApplicationProcessor>().Object
}
};
var other = new CompositeMortgageApplicationProcessor
{
Nodes = new[]
{
moqRepo.Create<IMortgageApplicationProcessor>().Object,
moqRepo.Create<IMortgageApplicationProcessor>().Object,
moqRepo.Create<IMortgageApplicationProcessor>().Object
}
};
// Act
var actual = sut.Equals(other);
// Assert
Assert.False(actual);
}
示例4: VimTest
protected VimTest()
{
_factory = new MockRepository(MockBehavior.Strict);
_globalSettings = new GlobalSettings();
_fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
_bufferFactory = VimBufferFactory;
_simpleListener = new SimpleListener();
var creationListeners = new [] { new Lazy<IVimBufferCreationListener>(() => _simpleListener) };
var map = new Dictionary<string, VariableValue>();
_keyMap = new KeyMap(_globalSettings, map);
_vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
_vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());
_vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true);
_vimRaw = new Vim(
_vimHost.Object,
_bufferFactory,
CompositionContainer.GetExportedValue<IVimInterpreterFactory>(),
creationListeners.ToFSharpList(),
_globalSettings,
_factory.Create<IMarkMap>().Object,
_keyMap,
MockObjectFactory.CreateClipboardDevice().Object,
_factory.Create<ISearchService>().Object,
_fileSystem.Object,
new VimData(_globalSettings),
_factory.Create<IBulkOperations>().Object,
map,
new EditorToSettingSynchronizer());
_vim = _vimRaw;
_vim.AutoLoadVimRc = false;
}
示例5: testProsesNotaPengeluaran
public void testProsesNotaPengeluaran()
{
var transactionDate = new DateTime(2015, 10, 26);
var periodId = new PeriodeId(new DateTime(2015, 11, 1), new DateTime(2015, 11, 6));
var listAkun = new string[] { "Ayam" };
var listSummaryAkun = new List<SummaryAkunDto>()
{
new SummaryAkunDto(){ PeriodId = "20151104",Akun ="Ayam", Nominal=600000.0}
};
var factory = new MockRepository(MockBehavior.Loose);
var mockRepository = factory.Create<IRepository>();
var mockCashFlow = factory.Create<ICashFlow>();
var mockPengeluaran = factory.Create<INotaPengeluaran>();
var mockCurrentPeriod = factory.Create<IPeriod>();
mockRepository.Setup(t => t.FindPeriodForDate(transactionDate)).Returns(mockCurrentPeriod.Object);
mockCurrentPeriod.SetupGet(t => t.PeriodId).Returns(periodId);
mockRepository.Setup(t => t.FindCashFlowByPeriod(periodId)).Returns(mockCashFlow.Object);
mockPengeluaran.SetupGet(t => t.Date).Returns(transactionDate);
mockPengeluaran.Setup(t => t.ListAkun()).Returns(listAkun);
mockRepository.Setup(t => t.ListSummaryAkunIn(mockCurrentPeriod.Object, listAkun)).Returns(listSummaryAkun);
mockCashFlow.Setup(t => t.ChangePengeluaran(It.IsAny<string>(), It.IsAny<double>(),It.IsAny<int>()));
mockRepository.Setup(t => t.Save(mockCashFlow.Object));
var service = new ProcessNotaPengeluaran();
service.Repository = mockRepository.Object;
service.Process(mockPengeluaran.Object);
factory.VerifyAll();
}
示例6: SerializeTest
public void SerializeTest()
{
var mockRepository = new MockRepository(MockBehavior.Strict);
var mockTimeSpan = mockRepository.Create<IStringSerializer<TimeSpan>>();
var mockDaysOfWeek = mockRepository.Create<IStringSerializer<DaysOfWeek>>();
var mockIEnumerableDateTime = mockRepository.Create<IStringSerializer<IEnumerable<DateTime>>>();
var timeSpanRuleInfoSerializer = new TimeSpanRuleInfoSerializer(mockTimeSpan.Object, mockDaysOfWeek.Object,
mockIEnumerableDateTime.Object);
var expMin = new TimeSpan(150);
var expMax = new TimeSpan(250);
var expDaysOfWeek = new DaysOfWeek(DayOfWeek.Monday, DayOfWeek.Thursday);
var expDateTimes = new[] {new DateTime(1), new DateTime(100), new DateTime(500)};
var exp = new TimeSpanRuleInfo(expMin, expMax, expDaysOfWeek, expDateTimes);
mockTimeSpan.Setup(x => x.Serialize(expMin)).Returns("150").Verifiable();
mockTimeSpan.Setup(x => x.Serialize(expMax)).Returns("250").Verifiable();
mockDaysOfWeek.Setup(x => x.Serialize(expDaysOfWeek)).Returns("1,4").Verifiable();
mockIEnumerableDateTime.Setup(x => x.Serialize(expDateTimes)).Returns("datetimes").Verifiable();
Assert.AreEqual("150\x001E250\x001E1,4\x001Edatetimes", timeSpanRuleInfoSerializer.Serialize(exp));
mockRepository.VerifyAll();
}
示例7: Create
public void Create(bool haveHistory = true)
{
_factory = new MockRepository(MockBehavior.Strict);
_statusUtil = _factory.Create<IStatusUtil>();
var editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>();
if (haveHistory)
{
_textUndoHistory = _factory.Create<ITextUndoHistory>();
_textUndoHistory.Setup(x => x.Undo(It.IsAny<int>())).Callback<int>(count => { _undoCount += count; });
_textUndoHistory.Setup(x => x.Redo(It.IsAny<int>())).Callback<int>(count => { _redoCount += count; });
_undoRedoOperationsRaw = new UndoRedoOperations(
_statusUtil.Object,
FSharpOption.Create(_textUndoHistory.Object),
editorOperationsFactoryService.Object);
}
else
{
_undoRedoOperationsRaw = new UndoRedoOperations(
_statusUtil.Object,
FSharpOption<ITextUndoHistory>.None,
editorOperationsFactoryService.Object);
}
_undoRedoOperations = _undoRedoOperationsRaw;
}
示例8: SelectionChangeTrackerTest
public SelectionChangeTrackerTest()
{
_factory = new MockRepository(MockBehavior.Loose);
_selection = _factory.Create<ITextSelection>();
_textView = MockObjectFactory.CreateTextView(
selection: _selection.Object,
factory: _factory);
_vimHost = _factory.Create<IVimHost>();
_vimHost.Setup(x => x.IsFocused(_textView.Object)).Returns(true);
_vimBuffer = MockObjectFactory.CreateVimBuffer(
textView: _textView.Object,
vim: MockObjectFactory.CreateVim(host: _vimHost.Object).Object,
factory: _factory);
_vimBuffer.SetupGet(x => x.IsClosed).Returns(false);
_mouseDevice = _factory.Create<IMouseDevice>();
_selectionOverride = _factory.Create<IVisualModeSelectionOverride>();
_selectionOverride.Setup(x => x.IsInsertModePreferred(It.IsAny<ITextView>())).Returns(false);
var selectionList = new List<IVisualModeSelectionOverride>();
selectionList.Add(_selectionOverride.Object);
_context = new TestableSynchronizationContext();
_context.Install();
_tracker = new SelectionChangeTracker(_vimBuffer.Object, _factory.Create<ICommonOperations>(MockBehavior.Loose).Object, selectionList.ToFSharpList(), _mouseDevice.Object);
}
示例9: 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;
}
示例10: Init
public void Init()
{
_mockRepository = new MockRepository(MockBehavior.Strict);
_fdResolver = _mockRepository.Create<IFirstDayOfWeekResolver>();
_weekPadding = _mockRepository.Create<IWeekPaddingCalculator>();
}
示例11: WhenDataReaderIsDBNullReturnsTrue_ThenTheFieldIsNotSetInTheRow
public void WhenDataReaderIsDBNullReturnsTrue_ThenTheFieldIsNotSetInTheRow()
{
List<string> columns = new List<string>();
MockRepository mockRepository = new MockRepository(MockBehavior.Strict);
Mock<IDataReader> dataReaderMock = mockRepository.Create<IDataReader>();
dataReaderMock.SetupSequence(x => x.Read()).Returns(true).Returns(false);
dataReaderMock.SetupGet(x => x.FieldCount).Returns(2);
dataReaderMock.Setup(x => x.IsDBNull(0)).Returns(false);
dataReaderMock.Setup(x => x.IsDBNull(1)).Returns(true);
dataReaderMock.Setup(x => x.GetValue(0)).Returns(0);
dataReaderMock.Setup(x => x.GetName(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns<int>(n => "Col" + n);
Mock<IDataRow> rowMock = mockRepository.Create<IDataRow>();
rowMock.SetupSet(x => x[0] = 0);
Mock<ISimpleDataTable> dataTableMock = mockRepository.Create<ISimpleDataTable>();
dataTableMock.SetupGet(x => x.ColumnNames).Returns(columns);
dataTableMock.Setup(x => x.NewRow()).Returns(rowMock.Object);
DataReaderAdapter target = new DataReaderAdapter();
target.Fill(dataTableMock.Object, dataReaderMock.Object);
dataTableMock.Verify(x => x.NewRow(), Times.Once());
dataReaderMock.Verify(x => x.GetValue(0), Times.Once());
dataReaderMock.Verify(x => x.GetValue(1), Times.Never());
rowMock.VerifySet(x => x[0] = It.IsAny<int>(), Times.Once());
rowMock.VerifySet(x => x[1] = It.IsAny<int>(), Times.Never());
}
示例12: UserBusinessLogicTests
public UserBusinessLogicTests()
{
MockFactory = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock };
MockedUserBusinessLogic = MockFactory.Create<IUserBusinessLogic>();
MockedUserRepository = MockFactory.Create<IUserRepository>();
}
示例13: CommandMarginControllerTest
protected CommandMarginControllerTest()
{
_factory = new MockRepository(MockBehavior.Strict);
_marginControl = new CommandMarginControl();
_marginControl.CommandLineTextBox.Text = String.Empty;
_search = _factory.Create<IIncrementalSearch>();
_search.SetupGet(x => x.InSearch).Returns(false);
_search.SetupGet(x => x.InPasteWait).Returns(false);
_vimBuffer = new MockVimBuffer();
_vimBuffer.IncrementalSearchImpl = _search.Object;
_vimBuffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
_vimBuffer.CommandModeImpl = _factory.Create<ICommandMode>(MockBehavior.Loose).Object;
var textBuffer = CreateTextBuffer(new []{""});
_vimBuffer.TextViewImpl = TextEditorFactoryService.CreateTextView(textBuffer);
Mock<IVimGlobalSettings> globalSettings = new Mock<IVimGlobalSettings>();
_vimBuffer.GlobalSettingsImpl = globalSettings.Object;
var editorFormatMap = _factory.Create<IEditorFormatMap>(MockBehavior.Loose);
editorFormatMap.Setup(x => x.GetProperties(It.IsAny<string>())).Returns(new ResourceDictionary());
var parentVisualElement = _factory.Create<FrameworkElement>();
_controller = new CommandMarginController(
_vimBuffer,
parentVisualElement.Object,
_marginControl,
VimEditorHost.EditorFormatMapService.GetEditorFormatMap(_vimBuffer.TextView),
VimEditorHost.ClassificationFormatMapService.GetClassificationFormatMap(_vimBuffer.TextView));
}
示例14: WhenDataReaderGetNameReturnsNull_ThenTheColumnIndexIsUsedAsColumnName
public void WhenDataReaderGetNameReturnsNull_ThenTheColumnIndexIsUsedAsColumnName()
{
List<string> columns = new List<string>();
MockRepository mockRepository = new MockRepository(MockBehavior.Strict);
Mock<IDataReader> dataReaderMock = mockRepository.Create<IDataReader>();
dataReaderMock.SetupSequence(x => x.Read()).Returns(true).Returns(false);
dataReaderMock.SetupGet(x => x.FieldCount).Returns(2);
dataReaderMock.Setup(x => x.IsDBNull(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns(false);
dataReaderMock.Setup(x => x.GetValue(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns<int>(n => n);
dataReaderMock.Setup(x => x.GetName(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns((string)null);
Mock<IDataRow> rowMock = mockRepository.Create<IDataRow>();
rowMock.SetupSet(x => x[0] = 0);
rowMock.SetupSet(x => x[1] = 1);
Mock<ISimpleDataTable> dataTableMock = mockRepository.Create<ISimpleDataTable>();
dataTableMock.SetupGet(x => x.ColumnNames).Returns(columns);
dataTableMock.Setup(x => x.NewRow()).Returns(rowMock.Object);
DataReaderAdapter target = new DataReaderAdapter();
target.Fill(dataTableMock.Object, dataReaderMock.Object);
dataTableMock.Verify(x => x.NewRow(), Times.Once());
dataReaderMock.Verify(x => x.GetName(It.IsAny<int>()), Times.Exactly(2));
Assert.Equal(2, columns.Count);
Assert.Equal("0", columns[0]);
Assert.Equal("1", columns[1]);
}
示例15: Init
public void Init()
{
_mockFactory = new MockRepository(MockBehavior.Strict);
_helper = _mockFactory.Create<IConfigurationItemsHelper>();
_resolver = _mockFactory.Create<IConfigurationTypeResolver>();
_reader = new ConfigurationItemsReader(_resolver.Object, _helper.Object);
}