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


C# MockRepository.DynamicMock方法代码示例

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


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

示例1: CannotUseRepeatAny

 public void CannotUseRepeatAny()
 {
     MockRepository mocks = new MockRepository();
     IFoo54 demo = mocks.DynamicMock<IFoo54>();
     mocks.ReplayAll();
     demo.AssertWasCalled(x => x.Bar("a"), o => o.Repeat.Any());
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:7,代码来源:RecordingMocks.cs

示例2: DslFactoryFixture

        public DslFactoryFixture()
        {
            factory = new DslFactory();
            mocks = new MockRepository();
            mockedDslEngine = mocks.DynamicMock<DslEngine>();
            mockCache = mocks.DynamicMock<IDslEngineCache>();
        	
			mockCache.WriteLock(null);
        	LastCall.Repeat.Any()
        		.IgnoreArguments()
        		.Do((Action<CacheAction>) ExecuteCachedAction);
			
			mockCache.ReadLock(null);
			LastCall.Repeat.Any()
				.IgnoreArguments()
				.Do((Action<CacheAction>)ExecuteCachedAction);
            
			IDslEngineStorage mockStorage = mocks.DynamicMock<IDslEngineStorage>();
            Assembly assembly = Assembly.GetCallingAssembly();
            context = new CompilerContext();
            context.GeneratedAssembly = assembly;
            mockedDslEngine.Storage = mockStorage;
            mockedDslEngine.Cache = mockCache;

            SetupResult.For(mockStorage.GetMatchingUrlsIn("", ref testUrl)).Return(new string[] { testUrl });
            SetupResult.For(mockStorage.IsUrlIncludeIn(null, null, null))
                .IgnoreArguments()
                .Return(true);
        }
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:29,代码来源:DslFactoryFixture.cs

示例3: setup

 public void setup()
 {
     mocks = new MockRepository();
     builder = new TestControllerBuilder();
     session = mocks.DynamicMock<ISession>();
     todoRepository = mocks.StrictMock<TodoRepository>(session);
     todoController = new TodoController(todoRepository);
     builder.InitializeController(todoController);
 }
开发者ID:gkeary,项目名称:myGetOrg,代码行数:9,代码来源:TodoControllerTest.cs

示例4: FieldProblem_leftend

        public FieldProblem_leftend()
        {
            mocks = new MockRepository();
            viewMock =
                (IAddAlbumPresenter) mocks.DynamicMock(typeof (IAddAlbumPresenter));
            albumMock = mocks.StrictMock<IAlbum>();

            viewMock.Save += null;
            LastCall.IgnoreArguments().Constraints(Is.NotNull());
            saveRaiser = LastCall.GetEventRaiser();
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:11,代码来源:FieldProblem_leftend.cs

示例5: TestSampleMatrixChanged

        public void TestSampleMatrixChanged()
        {
            var repository = new MockRepository();
            var mockTestClass = repository.DynamicMock<ClassToMock>();
            mockTestClass.ChangeTestProperty += null;
            var fireChangeTestProperty = LastCall.IgnoreArguments().GetEventRaiser();
            new ClassRaisingException(mockTestClass);

            repository.ReplayAll();
            fireChangeTestProperty.Raise(true);
            repository.VerifyAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:12,代码来源:FieldProblem_Harley.cs

示例6: GoodExplanationForUsingReturnAndRepeatNever

        public void GoodExplanationForUsingReturnAndRepeatNever()
        {
            MockRepository mocks = new MockRepository();
            ILogWriter eventLogMock = (ILogWriter)mocks.DynamicMock(typeof(ILogWriter));
            Log log = new Log(null, eventLogMock, "MOCK", true, false);

            Expect.Call(eventLogMock.WriteLog(EventLogEntryType.SuccessAudit, "MOCK", null, null, 0)).Return(true);
            Assert.Throws<InvalidOperationException>(
                "After specifying Repeat.Never(), you cannot specify a return value, exception to throw or an action to execute",
                () => Expect.Call(eventLogMock.WriteLog(EventLogEntryType.FailureAudit, "MOCK", null, null, 0))
                .Return(true).Repeat.Never());
        }
开发者ID:medmondson,项目名称:RhinoMocks,代码行数:12,代码来源:FieldProblem_Mark.cs

示例7: Can_mix_assert_was_call_with_verify_all

        public void Can_mix_assert_was_call_with_verify_all()
        {
            MockRepository mocks = new MockRepository();
            var errorHandler = mocks.DynamicMock<IErrorHandler>();
            mocks.ReplayAll();

            var ex = new Exception("Take this");
            errorHandler.HandleError(ex);

            errorHandler.AssertWasCalled(eh => eh.HandleError(ex));

            mocks.ReplayAll();
            mocks.VerifyAll(); // Can I still keep this somehow?
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:14,代码来源:FieldProblem_Libardo.cs

示例8: CanSetExpectationOnReadWritePropertyUsingRecordPlaybackSyntax

        public void CanSetExpectationOnReadWritePropertyUsingRecordPlaybackSyntax()
        {
            var mocks = new MockRepository();
            var demo = mocks.DynamicMock<IDemo>();

            using (mocks.Record())
            {
                demo.Expect(x => x.Prop).SetPropertyWithArgument("Eduardo");
            }

            using (mocks.Playback())
            {
                demo.Prop = "Eduardo";
            }
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:15,代码来源:FieldProblem_Eduardo.cs

示例9: CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock

        public void CanUseSetupResultAndIgnoreArguments_WhenUsingUnorderedBlock()
        {
            MockRepository mocks = new MockRepository();
            IFetcher fetcher = mocks.DynamicMock<IFetcher>();

            using (mocks.Unordered())
            {
                SetupResult.For(fetcher.GetUsersWithCriteriaLike(null)).IgnoreArguments().Return(
                    new Student[] {new Student(), new Student()});
            }

            mocks.ReplayAll();

            Assert.Equal(2, fetcher.GetUsersWithCriteriaLike("foo").Length);
        }
开发者ID:ChuangYang,项目名称:RhinoMocks,代码行数:15,代码来源:SetupResultAndIgnoreArguments.cs

示例10: GoodExplanationForUsingReturnAndRepeatNever

        public void GoodExplanationForUsingReturnAndRepeatNever()
        {
            MockRepository mocks = new MockRepository();
            ILogWriter eventLogMock = (ILogWriter)mocks.DynamicMock(typeof(ILogWriter));
            Log log = new Log(null, eventLogMock, "MOCK", true, false);

            Expect.Call(eventLogMock.WriteLog(EventLogEntryType.SuccessAudit, "MOCK", null, null, 0)).Return(true);
            //Actually I don't expect this one. But Repeat.Never() doesn't work.
            Expect.Call(eventLogMock.WriteLog(EventLogEntryType.FailureAudit, "MOCK", null, null, 0))
                .Return(true).Repeat.Never();
            mocks.ReplayAll();

            log.Audit(AuditOptions.Succes, null, null, null, 0);
            mocks.VerifyAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:15,代码来源:FieldProblem_Mark.cs

示例11: IgnoreArgumentsAfterDo

        public void IgnoreArgumentsAfterDo()
        {
            MockRepository mocks = new MockRepository();
            IDemo demo = mocks.DynamicMock<IDemo>();
            bool didDo = false;
            demo.VoidNoArgs();
            LastCall
                .Do(SetToTrue(out didDo))
                .IgnoreArguments();

            mocks.ReplayAll();

            demo.VoidNoArgs();
            Assert.True(didDo, "Do has not been executed!");

            mocks.VerifyAll();
        }
开发者ID:bjornbouetsmith,项目名称:mammock,代码行数:17,代码来源:FieldProblem_Stephan.cs

示例12: WillDisposeInternalEnumeratorAndEnumerableWhenDisposed

 public void WillDisposeInternalEnumeratorAndEnumerableWhenDisposed()
 {
     MockRepository mocks = new MockRepository();
     IEnumerable<Row> enumerable = mocks.DynamicMultiMock<IEnumerable<Row>>(typeof(IDisposable));
     IEnumerator<Row> enumerator = mocks.DynamicMock<IEnumerator<Row>>();
     using(mocks.Record())
     {
         SetupResult.For(enumerable.GetEnumerator()).Return(enumerator);
         enumerator.Dispose();
         ((IDisposable)enumerable).Dispose();
     }
     using (mocks.Playback())
     {
         DictionaryEnumeratorDataReader reader =
             new DictionaryEnumeratorDataReader(new Dictionary<string, Type>(), enumerable);
         reader.Dispose();
     }
 }
开发者ID:nkmajeti,项目名称:rhino-tools,代码行数:18,代码来源:DictionaryEnumeratorDataReaderFixture.cs

示例13: BackToRecordOnADynamicMock

        public void BackToRecordOnADynamicMock()
        {
            MockRepository repository = new MockRepository();
            ITest test = (ITest)repository.DynamicMock(typeof(ITest));

            test.DoSomething(1);

            repository.BackToRecord(test);

            test.DoSomething(2);

            repository.ReplayAll();

            test.DoSomething(2);
            test.DoSomething(3);

            repository.VerifyAll();
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:18,代码来源:FieldProblem_BackToRecordWithDynamicMocks.cs

示例14: WillFailVerificationsOfMethod_IfWereNotCalled_OnVoidMethod

        public void WillFailVerificationsOfMethod_IfWereNotCalled_OnVoidMethod()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();

            mocks.ReplayAll();
            demo.AssertWasCalled(x => x.DoSomethingElse());
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:8,代码来源:RecordingMocks.cs

示例15: WhenNoExpectationIsSetup_WillReturnDefaultValues

        public void WhenNoExpectationIsSetup_WillReturnDefaultValues()
        {
            MockRepository mocks = new MockRepository();
            IFoo54 demo = mocks.DynamicMock<IFoo54>();

            Assert.AreEqual(0, demo.DoSomething());
        }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:7,代码来源:RecordingMocks.cs


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