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


C# MockRepository.Create方法代码示例

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


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

示例1: ShouldCreateMockWithConstructorArgs

		public void ShouldCreateMockWithConstructorArgs()
		{
			var repository = new MockRepository(MockBehavior.Loose);

			var mock = repository.Create<BaseClass>("foo");

			Assert.Equal("foo", mock.Object.Value);
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:8,代码来源:MockRepositoryFixture.cs

示例2: ShouldCreateMocksWithFactoryBehavior

		public void ShouldCreateMocksWithFactoryBehavior()
		{
			var repository = new MockRepository(MockBehavior.Loose);

			var mock = repository.Create<IFormatProvider>();

			Assert.Equal(MockBehavior.Loose, mock.Behavior);
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:8,代码来源:MockRepositoryFixture.cs

示例3: ShouldAggregateFailures

		public void ShouldAggregateFailures()
		{
			try
			{
				var repository = new MockRepository(MockBehavior.Loose);
				var foo = repository.Create<IFoo>();
				var bar = repository.Create<IBar>();

				foo.Setup(f => f.Do());
				bar.Setup(b => b.Redo());

				repository.VerifyAll();
			}
			catch (MockException mex)
			{
				Expression<Action<IFoo>> fooExpect = f => f.Do();
				Assert.True(mex.Message.Contains(fooExpect.ToString()));

				Expression<Action<IBar>> barExpect = b => b.Redo();
				Assert.True(mex.Message.Contains(barExpect.ToString()));
			}
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:22,代码来源:MockRepositoryFixture.cs

示例4: ShouldAssignNullCallSequenceToCreatedMocksByDefault

        public void ShouldAssignNullCallSequenceToCreatedMocksByDefault()
        {
            var repository = new MockRepository(MockBehavior.Default);

            var mock = repository.Create<IFoo>();

            Assert.Throws<NoSequenceAssignedException>(
                () => mock.CallSequence.Verify(
                    mock.CallTo(m => m.Do()),
                    mock.CallTo(m => m.Undo())
                )
            );
        }
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:13,代码来源:MockRepositoryFixture.cs

示例5: ShouldVerifyAll

		public void ShouldVerifyAll()
		{
			try
			{
				var repository = new MockRepository(MockBehavior.Default);
				var mock = repository.Create<IFoo>();

				mock.Setup(foo => foo.Do());

				repository.VerifyAll();
			}
			catch (MockException mex)
			{
				Assert.Equal(MockException.ExceptionReason.VerificationFailed, mex.Reason);
			}
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:16,代码来源:MockRepositoryFixture.cs

示例6: ShouldCreateMocksWithFactoryCallBase

        public void ShouldCreateMocksWithFactoryCallBase()
        {
            var repository = new MockRepository(MockBehavior.Loose);

            var mock = repository.Create<BaseClass>();

            mock.Object.BaseMethod();

            Assert.False(mock.Object.BaseCalled);

            repository.CallBase = true;

            mock = repository.Create<BaseClass>();

            mock.Object.BaseMethod();

            Assert.True(mock.Object.BaseCalled);
        }
开发者ID:RajOpteamix,项目名称:moq,代码行数:18,代码来源:MockRepositoryFixture.cs

示例7: 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.Equal(MockException.ExceptionReason.VerificationFailed, mex.Reason);
				Expression<Action<IFoo>> doExpr = foo => foo.Do();
				Assert.False(mex.Message.Contains(doExpr.ToString()));
			}
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:19,代码来源:MockRepositoryFixture.cs

示例8: ShouldCreateMocksWithFactoryDefaultValue

		public void ShouldCreateMocksWithFactoryDefaultValue()
		{
			var repository = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock };

			var mock = repository.Create<IFoo>();

			Assert.NotNull(mock.Object.Bar());
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:8,代码来源:MockRepositoryFixture.cs

示例9: ShouldOverrideDefaultBehaviorWithCtorArgs

		public void ShouldOverrideDefaultBehaviorWithCtorArgs()
		{
			var repository = new MockRepository(MockBehavior.Loose);
			var mock = repository.Create<BaseClass>(MockBehavior.Strict, "Foo");

			Assert.Equal(MockBehavior.Strict, mock.Behavior);
			Assert.Equal("Foo", mock.Object.Value);
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:8,代码来源:MockRepositoryFixture.cs

示例10: ShouldOverrideDefaultBehavior

		public void ShouldOverrideDefaultBehavior()
		{
			var repository = new MockRepository(MockBehavior.Loose);
			var mock = repository.Create<IFoo>(MockBehavior.Strict);

			Assert.Equal(MockBehavior.Strict, mock.Behavior);
		}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:7,代码来源:MockRepositoryFixture.cs

示例11: ShouldAssignTheSameCallSequenceToCreatedMocksThatWasAssignedToIt

        public void ShouldAssignTheSameCallSequenceToCreatedMocksThatWasAssignedToIt()
        {
            var callSequence = new CallSequence(MockBehavior.Strict);
            var repository = new MockRepository(MockBehavior.Default)
            {
                CallSequence = callSequence
            };

            var mock = repository.Create<IFoo>();

            Assert.Equal(callSequence, mock.CallSequence);
        }
开发者ID:grzesiek-galezowski,项目名称:moq4,代码行数:12,代码来源:MockRepositoryFixture.cs


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