本文整理汇总了C#中Moq.MockRepository.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Verify方法的具体用法?C# MockRepository.Verify怎么用?C# MockRepository.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moq.MockRepository
的用法示例。
在下文中一共展示了MockRepository.Verify方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeBootStrappers
public void InitializeBootStrappers()
{
var mockRepository = new MockRepository(MockBehavior.Default);
var globalBoot = new GlobalBootStrapper();
for (int i = 0; i < 10; i++)
{
var bootStrap = mockRepository.Create<IBootStrap>();
bootStrap.Setup(x => x.Initialize()).Verifiable();
globalBoot.Register(bootStrap.Object);
}
globalBoot.Initialize();
mockRepository.Verify();
}
示例2: RepoTestMethod1
public void RepoTestMethod1()
{
var repo = new MockRepository(MockBehavior.Strict);
var logWriterMock = repo.Create<ILogSaver>();
logWriterMock.Setup(lw => lw.Write(It.IsAny<string>()));
var logMailerMock = repo.Create<ILogMailer>();
logMailerMock.Setup(lm => lm.Send(It.IsAny<MailMessage>()));
var WizzLogger = new WizzLogger(logWriterMock.Object, logMailerMock.Object);
WizzLogger.WriteLine("Hello, Logger");
repo.Verify();
}
示例3: ShouldVerifyVerifiables
public void ShouldVerifyVerifiables()
{
try
{
var repository = new MockRepository(MockBehavior.Default);
var mock = repository.Create<IFoo>();
mock.Setup(foo => foo.Do());
mock.Setup(foo => foo.Undo()).Verifiable();
repository.Verify();
}
catch (MockException mex)
{
Assert.AreEqual(MockException.ExceptionReason.VerificationFailed, mex.Reason);
Expression<Action<IFoo>> doExpr = foo => foo.Do();
Assert.IsFalse(mex.Message.Contains(doExpr.ToString()));
}
}
示例4: MoveCaretToVirtualPoint
public void MoveCaretToVirtualPoint()
{
var buffer = CreateTextBuffer("foo","bar");
var factory = new MockRepository(MockBehavior.Strict);
var caret = MockObjectFactory.CreateCaret(factory: factory);
caret.Setup(x => x.EnsureVisible()).Verifiable();
var selection = MockObjectFactory.CreateSelection(factory: factory);
selection.Setup(x => x.Clear()).Verifiable();
var textView = MockObjectFactory.CreateTextView(
textBuffer: buffer,
selection: selection.Object,
caret: caret.Object,
factory: factory);
var point = new VirtualSnapshotPoint(buffer.GetLine(0), 2);
caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable();
TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
factory.Verify();
}
示例5: BlotterViewModel_Loading
public void BlotterViewModel_Loading()
{
var factory = new MockRepository(MockBehavior.Loose);
int userId = 1;
Mock<IEventAggregator> mockEventAggtr = new Mock<IEventAggregator>();
Mock<IFundsDataService> mockFundService = new Mock<IFundsDataService>();
var mockStockUpdatedEventEvent = new Mock<StockUpdatedEvent>();
var mockCancelStockSelectedEventEvent = new Mock<CancelStockSelectedEvent>();
mockEventAggtr.Setup(e => e.GetEvent<StockUpdatedEvent>()).Returns(mockStockUpdatedEventEvent.Object);
mockEventAggtr.Setup(e => e.GetEvent<CancelStockSelectedEvent>()).Returns(mockCancelStockSelectedEventEvent.Object);
var stockobject = new StockDetail(){StockId=1,Type="Equity",Price=25,Quantity=10,StockName="Equity1"};
mockFundService.Setup(t => t.GetAllStocks(userId)).Returns(new List<StockDetail>() {stockobject });
var viewModel = new BlotterViewModel(mockFundService.Object, mockEventAggtr.Object);
Assert.IsNotNull(viewModel.Stocks);
Assert.IsTrue(viewModel.Stocks.Contains(stockobject));
mockFundService.Verify(s => s.GetAllStocks(It.IsAny<int>()), Times.Once);
mockEventAggtr.Verify(s => s.GetEvent<StockUpdatedEvent>(), Times.Once);
mockEventAggtr.Verify(s => s.GetEvent<CancelStockSelectedEvent>(), Times.Once);
factory.Verify();
}
示例6: the_address_should_be_formatted
public void the_address_should_be_formatted()
{
//Arrange
var mockFactory = new MockRepository(MockBehavior.Loose)
{DefaultValue = DefaultValue.Mock};
var mockCustomerRepository =
mockFactory.Create<ICustomerRepository>();
var mockCustomerAddressFormatter =
mockFactory.Create<ICustomerAddressFormatter>();
mockCustomerAddressFormatter.Setup(
x => x.For(It.IsAny<CustomerToCreateDto>()))
.Returns(new Address());
var customerService = new CustomerService(
mockCustomerRepository.Object,
mockCustomerAddressFormatter.Object);
//Act
customerService.Create(new CustomerToCreateDto());
//Assert
mockFactory.Verify();
}
示例7: Test_WriteLine_Calls_LogWriter_And_LogMailer
public void Test_WriteLine_Calls_LogWriter_And_LogMailer()
{
// Creating different mocks from MockRepository simplifies
// future verification by calling one verification method
// on mock repository instead of calling different methods
// on different mock objects
// Arrange
var repo = new MockRepository(MockBehavior.Default);
var logWriterMock = repo.Create<ILogWriter>();
logWriterMock.Setup(lw => lw.Write(It.IsAny<string>()));
var logMailerMock = repo.Create<ILogMailer>();
logMailerMock.Setup(lm => lm.Send(It.IsAny<MailMessage>()));
var smartLogger = new SmartLogger(logWriterMock.Object, logMailerMock.Object);
// Act
smartLogger.WriteLine("Hello, Logger");
// Assert
repo.Verify();
}