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


C# MockRepository.Stub方法代码示例

本文整理汇总了C#中MockRepository.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Stub方法的具体用法?C# MockRepository.Stub怎么用?C# MockRepository.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockRepository的用法示例。


在下文中一共展示了MockRepository.Stub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StubDemoTestFixture

        public StubDemoTestFixture()
        {
            _mocks = new MockRepository();

            _mockBase = _mocks.Stub<IBase>();
            _mockChild = _mocks.Stub<IChild>();

            _mocks.ReplayAll();
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:9,代码来源:FieldProblem_Nolan.cs

示例2: SetUp

        public void SetUp()
        {
            _mocks = new MockRepository();

            _mockBase = _mocks.Stub<IBase>();
            _mockChild = _mocks.Stub<IChild>();

            _mocks.ReplayAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:9,代码来源:FieldProblem_Nolan.cs

示例3: CanUseStubSyntaxOnMocksInRecordMode

 public void CanUseStubSyntaxOnMocksInRecordMode()
 {
     MockRepository mocks = new MockRepository();
     var service = mocks.Stub<IService>();
     var view = mocks.Stub<IView>();
     service.Stub(x => x.GetString()).Return("Test");
     var presenter = new Presenter(view, service);
     mocks.ReplayAll();
     presenter.OnViewLoaded();
     view.AssertWasCalled(x => x.Message = "Test");
 }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:11,代码来源:FieldProblem_Kythorn.cs

示例4: SetupResult_For_writeable_property_on_stub_should_be_ignored

 public void SetupResult_For_writeable_property_on_stub_should_be_ignored()
 {
     MockRepository mocks = new MockRepository();
     TestClass test = mocks.Stub<TestClass>();
     SetupResult.For(test.ReadOnly).Return("foo");
     SetupResult.For(test.ReadWrite).PropertyBehavior();
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:7,代码来源:FieldProblem_Chad.cs

示例5: MultiStubShouldGenerateStubWithOnlyBaseClass

        public void MultiStubShouldGenerateStubWithOnlyBaseClass()
        {
            var mockRepository = new MockRepository();
            var animal = (IAnimal)mockRepository.Stub(typeof(IAnimal), null, null);

            Assert.NotNull(animal);
            Assert.Null(animal as ICat);
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:8,代码来源:MultiStubWithAAA.cs

示例6: Stub

 public static PageTypeUpdater Stub(MockRepository fakesRepository)
 {
     return fakesRepository.Stub<PageTypeUpdater>(
         PageTypeDefinitionLocatorFactory.Stub(), 
         new PageTypeFactory(),
         new PageTypeValueExtractor(),
         new PageTypeLocator(new PageTypeFactory()));
 }
开发者ID:andreasnico,项目名称:Page-Type-Builder,代码行数:8,代码来源:PageTypeUpdaterFactory.cs

示例7: MultiStubShouldGenerateStubWithMultiInterfaces

        public void MultiStubShouldGenerateStubWithMultiInterfaces()
        {
            var mockRepository = new MockRepository();
            var animal = (IAnimal)mockRepository.Stub(typeof(IAnimal), new[] { typeof(ICat) });
            var cat = (ICat)animal;

            Assert.NotNull(cat);
            Assert.NotNull(animal);
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:9,代码来源:MultiStubWithAAA.cs

示例8: SetupPageTypeUpdaterWithFakePageTypeFactory

 private void SetupPageTypeUpdaterWithFakePageTypeFactory(PageTypeUpdater pageTypeUpdater)
 {
     MockRepository mocks = new MockRepository();
     PageTypeFactory fakePageTypeFactory = mocks.Stub<PageTypeFactory>();
     fakePageTypeFactory.Stub(factory => factory.Save(Arg<IPageType>.Is.NotNull));
     fakePageTypeFactory.Stub(factory => factory.CreateNew()).Return(new NativePageType());
     fakePageTypeFactory.Replay();
     pageTypeUpdater.PageTypeFactory = fakePageTypeFactory;
 }
开发者ID:andreasnico,项目名称:Page-Type-Builder,代码行数:9,代码来源:CreateNewPageTypeTests.cs

示例9: PropertiesWillBehaveLikeProperties

        public void PropertiesWillBehaveLikeProperties()
        {
            MockRepository mocks = new MockRepository();
            TestObject testObject = mocks.Stub<TestObject>();

            mocks.ReplayAll();

            Assert.Equal(0, testObject.IntProperty);
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:9,代码来源:FieldProblem_Christian.cs

示例10: TestInitialize

		public void TestInitialize()
		{
			mocks = new MockRepository();
			smsSender = mocks.CreateMock<ISmsSender>();

			user = new User("sally", "1234");

			userRepository = mocks.Stub<IUserRepository>();
			SetupResult.For(userRepository.GetByUserName("sally"))
				.Return(user);
		}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:11,代码来源:RhinoMocks101.cs

示例11: CannotCallLastCallConstraintsMoreThanOnce

 public void CannotCallLastCallConstraintsMoreThanOnce()
 {
     MockRepository repository = new MockRepository();
     IGetResults resultGetter = repository.Stub<IGetResults>();
     using (repository.Record())
     {
         resultGetter.GetSomeNumber("a");
         LastCall.Constraints(Text.Contains("b"));
         LastCall.Constraints(Text.Contains("a"));
     }
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:11,代码来源:FieldProblem_Roy.cs

示例12: SetupResult_For_writeable_property_on_stub_should_be_ignored

        public void SetupResult_For_writeable_property_on_stub_should_be_ignored()
        {
            MockRepository mocks = new MockRepository();
            TestClass test = mocks.Stub<TestClass>();
            SetupResult.For(test.ReadOnly).Return("foo");

            const string expected =
                @"You are trying to set an expectation on a property that was defined to use PropertyBehavior.
            Instead of writing code such as this: mockObject.Stub(x => x.SomeProperty).Return(42);
            You can use the property directly to achieve the same result: mockObject.SomeProperty = 42;";

            Assert.Throws<InvalidOperationException>(expected, () => SetupResult.For(test.ReadWrite).PropertyBehavior());
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:13,代码来源:FieldProblem_Chad.cs

示例13: StubNeverFailsTheTest

        public void StubNeverFailsTheTest()
        {
            MockRepository repository = new MockRepository();
            IGetResults resultGetter = repository.Stub<IGetResults>();
            using (repository.Record())
            {
                resultGetter.GetSomeNumber("a");
                LastCall.Return(1);
            }

            int result = resultGetter.GetSomeNumber("b");
            Assert.Equal(0, result);
            repository.VerifyAll(); //<- should not fail the test methinks
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:14,代码来源:FieldProblem_Roy.cs

示例14: CanGetSetupResultFromStub

        public void CanGetSetupResultFromStub()
        {
            MockRepository repository = new MockRepository();
            IGetResults resultGetter = repository.Stub<IGetResults>();
            using (repository.Record())
            {
                resultGetter.GetSomeNumber("a");
                LastCall.Return(1);
            }

            int result = resultGetter.GetSomeNumber("a");
            Assert.Equal(1, result);
            repository.VerifyAll();
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:14,代码来源:FieldProblem_Roy.cs

示例15: CannotCallLastCallConstraintsMoreThanOnce

 public void CannotCallLastCallConstraintsMoreThanOnce()
 {
     MockRepository repository = new MockRepository();
     IGetResults resultGetter = repository.Stub<IGetResults>();
     var ex = Assert.Throws<InvalidOperationException>(() =>
                                                       	{
                                                       		using (repository.Record())
                                                       		{
                                                       			resultGetter.GetSomeNumber("a");
                                                       			LastCall.Constraints(Text.Contains("b"));
                                                       			LastCall.Constraints(Text.Contains("a"));
                                                       		}
                                                       	});
     Assert.Equal("You have already specified constraints for this method. (IGetResults.GetSomeNumber(contains \"b\");)", ex.Message);
 }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:15,代码来源:FieldProblem_Roy.cs


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