当前位置: 首页>>代码示例>>C#>>正文


C# MockRepository.Verify方法代码示例

本文整理汇总了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();
        }
开发者ID:quentinproust,项目名称:Little-Problem,代码行数:15,代码来源:GlobalBootStrapperTest.cs

示例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();
        }
开发者ID:incjonya,项目名称:demos,代码行数:15,代码来源:TestMockRepository.cs

示例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()));
			}
		}
开发者ID:rajgit31,项目名称:MetroUnitTestsDemoApp,代码行数:19,代码来源:MockRepositoryFixture.cs

示例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();
        }
开发者ID:bajtos,项目名称:VsVim,代码行数:21,代码来源:TextViewUtilTest.cs

示例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();
            
        }
开发者ID:shiddamallappa,项目名称:UBSFundManagerApp,代码行数:23,代码来源:BlotterViewModelTests.cs

示例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();
            }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:24,代码来源:CustomerServiceTests.cs

示例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();

        }
开发者ID:SergeyTeplyakov,项目名称:Moq.Samples,代码行数:24,代码来源:MockRepositories.cs


注:本文中的Moq.MockRepository.Verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。