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


C# MockRepository.PartialMock方法代码示例

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


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

示例1: Setup

 public void Setup()
 {
     mock = new MockRepository();
     mockContext = mock.PartialMock<TestBasketballContext>();
     // TODO This doesn't work
     eventRepository = mock.PartialMock<EventRepository>(mockContext);
     eventService = new EventService(eventRepository);
 }
开发者ID:philjhale,项目名称:TeessideBasketballLeague,代码行数:8,代码来源:EventServiceTests.cs

示例2: Read_TwoMessages

        public void Read_TwoMessages()
        {
            var mocks = new MockRepository();
            var adapter = mocks.PartialMock<CrossPlatformUdpClient>(new UdpClient());

            // first datagram
            Expect.Call(adapter.Read())
                .Return(new List<byte>(new byte[] { 1 }));

            // second datagram
            Expect.Call(adapter.Read())
                .Return(new List<byte>(new byte[] { 2, 3, 4 }));

            mocks.ReplayAll();

            // read first datagram
            var buffer = new byte[1];
            Assert.AreEqual(1, adapter.Read(buffer, 0, 1));

            // read second datagram
            buffer = new byte[3];
            Assert.AreEqual(3, adapter.Read(buffer, 0, 3));

            Assert.AreEqual(new byte[] { 2, 3, 4 }, buffer);

            mocks.VerifyAll();
        }
开发者ID:nabrotzky,项目名称:OmniModbus,代码行数:27,代码来源:CrossPlatformUdpClientFixture.cs

示例3: UnicastMessage_AcknowlegeSlaveException

        public void UnicastMessage_AcknowlegeSlaveException()
        {
            MockRepository mocks = new MockRepository();
            ModbusTransport transport = mocks.PartialMock<ModbusTransport>();

            // set the wait to retry property to a small value so the test completes quickly
            transport.WaitToRetryMilliseconds = 5;

            transport.Write(null);
            LastCall.IgnoreArguments();

            // return a slave exception a greater number of times than number of retries to make sure we aren't just retrying
            Expect.Call(transport.ReadResponse<ReadHoldingInputRegistersResponse>())
                .Return(new SlaveExceptionResponse(1, Modbus.ReadHoldingRegisters + Modbus.ExceptionOffset,
                    Modbus.Acknowledge))
                .Repeat.Times(transport.Retries + 1);

            Expect.Call(transport.ReadResponse<ReadHoldingInputRegistersResponse>())
                .Return(new ReadHoldingInputRegistersResponse(Modbus.ReadHoldingRegisters, 1, new RegisterCollection(1)));

            transport.OnValidateResponse(null, null);
            LastCall.IgnoreArguments();

            mocks.ReplayAll();

            ReadHoldingInputRegistersRequest request = new ReadHoldingInputRegistersRequest(
                Modbus.ReadHoldingRegisters, 1, 1, 1);
            ReadHoldingInputRegistersResponse expectedResponse =
                new ReadHoldingInputRegistersResponse(Modbus.ReadHoldingRegisters, 1, new RegisterCollection(1));
            ReadHoldingInputRegistersResponse response =
                transport.UnicastMessage<ReadHoldingInputRegistersResponse>(request);
            Assert.AreEqual(expectedResponse.MessageFrame, response.MessageFrame);

            mocks.VerifyAll();
        }
开发者ID:Salman-Samian,项目名称:NModbus4,代码行数:35,代码来源:ModbusTransportFixture.cs

示例4: SetUp

 public void SetUp()
 {
     mocker = new MockRepository();
     service = mocker.PartialMock<HarvestService>();
     harvestor = mocker.CreateMock<IHarvester>();
     scripter = mocker.CreateMock<ISqlScripter>();
 }
开发者ID:TheCodeKing,项目名称:SqlHarvester.Net,代码行数:7,代码来源:HarvestServiceTestFixture.cs

示例5: IssueToken_CalledOnFederationBinding_CallsIssueToken

        public void IssueToken_CalledOnFederationBinding_CallsIssueToken()
        {
            // Arrange
            var returnToken = MockRepository.GenerateStub<SecurityToken>();
            var mockRepository = new MockRepository();
            var securityTokenProvider = mockRepository.PartialMock<SecurityTokenProvider>();
            securityTokenProvider.Stub(x => x.IssueToken(Arg<IWSTrustChannelContract>.Is.Anything, Arg<string>.Is.Anything, Arg<SecurityToken>.Is.Anything, Arg<SecurityToken>.Is.Anything)).Return(returnToken);
            securityTokenProvider.Replay();

            var binding = MockRepository.GenerateStub<WS2007FederationHttpBinding>();
            var messageSecurityOverHttp = new FederatedMessageSecurityOverHttp
            {
                IssuerAddress = new EndpointAddress("http://localhost/issuer"),
                IssuerBinding = new WS2007HttpBinding()
            };
            binding.Security.Message = messageSecurityOverHttp;
            var actAsToken = MockRepository.GenerateStub<SecurityToken>();

            // Act
            var actual = securityTokenProvider.IssueToken(binding, "http://localhost/service", actAsToken);

            // Assert
            securityTokenProvider.AssertWasCalled(
                x => x.IssueToken(Arg<IWSTrustChannelContract>.Is.Anything, Arg<string>.Is.Anything, Arg<SecurityToken>.Is.Anything, Arg<SecurityToken>.Is.Anything));
            Assert.AreEqual(returnToken, actual);
        }
开发者ID:huoxudong125,项目名称:Wcf-2,代码行数:26,代码来源:SecurityTokenProviderTests.cs

示例6: WillInitializeAllModuleLoadersOnStart

		public void WillInitializeAllModuleLoadersOnStart()
		{

			MockRepository mocks = new MockRepository();
			IModuleLoader mockLoader1 = mocks.DynamicMock<IModuleLoader>();
			IModuleLoader mockLoader2 = mocks.DynamicMock<IModuleLoader>();
			IModuleLoader mockLoader3 = mocks.DynamicMock<IModuleLoader>();
			IShellView stubShell = mocks.Stub<IShellView>();
			DefaultApplicationContext context = mocks.PartialMock<DefaultApplicationContext>(
				stubShell, new IModuleLoader[] { mockLoader1, mockLoader2, mockLoader3 });

			using (mocks.Record())
			{
				//we may have order dependnecies, let us verify
				//that it does this in order
				using (mocks.Ordered())
				{
					mockLoader1.Initialize(context, stubShell);
					mockLoader2.Initialize(context, stubShell);
					mockLoader3.Initialize(context, stubShell);
				}

				//force context to ignore these calls
				Expect.Call(context.GetShellAsForm()).Return(null).Repeat.Once();
				Expect.Call(delegate { context.RunForm(null); }).Repeat.Once();
			}

			using (mocks.Playback())
			{
				context.Start();
			}
		}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:32,代码来源:ApplicationContextFixture.cs

示例7: FiltersOnParseAndFormat

        public void FiltersOnParseAndFormat()
        {
            MockRepository mocks = new MockRepository();
            IFormatter underlyingFormatter = mocks.StrictMock<IFormatter>();
            TestFilteringFormatter formatter = (TestFilteringFormatter) mocks.PartialMock(typeof (TestFilteringFormatter), underlyingFormatter);

            string inputText = "inputText";
            string filteredInputText = "filteredInputText";
            object outputValue = new object();
            object filteredOutputValue = new object();

            using(mocks.Ordered())
            {
                Expect.Call(formatter.DoFilterValueToParse(inputText)).Return(filteredInputText);
                Expect.Call(underlyingFormatter.Parse(filteredInputText)).Return(outputValue);

                Expect.Call(formatter.DoFilterValueToFormat(outputValue)).Return(filteredOutputValue);
                Expect.Call(underlyingFormatter.Format(filteredOutputValue)).Return(inputText);
            }
            mocks.ReplayAll();

            Assert.AreSame(outputValue, formatter.Parse(inputText));
            Assert.AreEqual(inputText, formatter.Format(outputValue));

            mocks.VerifyAll();
        }
开发者ID:spring-projects,项目名称:spring-net,代码行数:26,代码来源:FilteringFormatterTests.cs

示例8: When_application_context_is_started_it_will_initialized_all_the_module_loader

        public void When_application_context_is_started_it_will_initialized_all_the_module_loader()
		{

            MockRepository mocks = new MockRepository();
            IModuleLoader mockLoader1 = mocks.DynamicMock<IModuleLoader>();
            IModuleLoader mockLoader2 = mocks.DynamicMock<IModuleLoader>();
            IModuleLoader mockLoader3 = mocks.DynamicMock<IModuleLoader>();
            IApplicationShell stubShell = mocks.Stub<IApplicationShell>();
            DefaultApplicationContext context = mocks.PartialMock<DefaultApplicationContext>(
                stubShell, 
				mocks.DynamicMock<ILayoutRegistry>(),
				new IModuleLoader[] { mockLoader1, mockLoader2, mockLoader3 });

            //we may have order dependnecies, let us verify
            //that it does this in order
            using (mocks.Record())
            using (mocks.Ordered())
            {
                mockLoader1.Initialize(context, stubShell);
                mockLoader2.Initialize(context, stubShell);
                mockLoader3.Initialize(context, stubShell);
            }

            using (mocks.Playback())
            {
                context.Start();
            }
        }
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:28,代码来源:ApplicationContextFixture.cs

示例9: PartialMock

 public static PageDefinitionSynchronizationEngine PartialMock(MockRepository fakesRepository)
 {
     return fakesRepository.PartialMock<PageDefinitionSynchronizationEngine>(
         new PageDefinitionUpdater(new PageDefinitionRepository(), new TabDefinitionRepository(), new PageDefinitionTypeMapper(new PageDefinitionTypeRepository(), new NativePageDefinitionsMap())),
         new PageTypePropertyDefinitionLocator(),
         new PageDefinitionSpecificPropertySettingsUpdater(() => new PropertySettingsRepository(), new GlobalPropertySettingsLocator(new AppDomainAssemblyLocator()), new PageDefinitionRepository()));
 }
开发者ID:joelabrahamsson,项目名称:Page-Type-Builder,代码行数:7,代码来源:PageDefinitionSynchronizationEngineFactory.cs

示例10: PartialMock

 public static PageTypePropertyUpdater PartialMock(MockRepository fakesRepository)
 {
     return fakesRepository.PartialMock<PageTypePropertyUpdater>(
         new PageDefinitionFactory(),
         new PageDefinitionTypeFactory(),
         new TabFactory());
 }
开发者ID:osdezwart,项目名称:Page-Type-Builder,代码行数:7,代码来源:PageTypePropertyUpdaterFactory.cs

示例11: RegisterCustomFunction_FunctionAlreadyExists

        public void RegisterCustomFunction_FunctionAlreadyExists()
        {
            MockRepository mocks = new MockRepository();
            var slave = mocks.PartialMock<ModbusSlave>((byte) 1, new EmptyTransport());

            slave.RegisterCustomFunction<TestMessage>(100, (request, dataStore) => { throw new NotImplementedException(); });
            Assert.Throws<ArgumentException>(() => slave.RegisterCustomFunction<TestMessage>(100, (request, dataStore) => { throw new NotImplementedException(); }));
        }
开发者ID:qinyanggl,项目名称:nmodbus,代码行数:8,代码来源:ModbusSlaveFixture.cs

示例12: CreateMock

		protected virtual MementoEntity CreateMock( IChangeTrackingService memento, bool registerAsrTransient ) 
		{
			MockRepository mocks = new MockRepository();
			var entity = mocks.PartialMock<MementoEntity>( memento, registerAsrTransient );
			entity.Replay();

			return entity;
		}
开发者ID:nazarenomanco,项目名称:Radical,代码行数:8,代码来源:EntityMementoTests.cs

示例13: File

 public static File File(MockRepository mocks, int id)
 {
     var file = mocks.PartialMock<File>();
     SetupResult.For(file.GetHashCode()).Return(random.Next());
     SetupResult.For(file.FullName).Return(id.ToString());
     SetupResult.For(file.Name).Return(id.ToString());
     return file;
 }
开发者ID:srushti,项目名称:azazel,代码行数:8,代码来源:HistoryTest.cs

示例14: RequestBytesToReadDiagnostics

		public void RequestBytesToReadDiagnostics()
		{
			MockRepository mocks = new MockRepository();
			var mockSlave = mocks.PartialMock<ModbusSlave>((byte) 1, new EmptyTransport());

			byte[] frame = { 0x01, 0x08, 0x00, 0x00, 0xA5, 0x37, 0, 0 };
			Assert.AreEqual(1, ModbusRtuTransport.RequestBytesToRead(frame, mockSlave));
		}
开发者ID:ian588h,项目名称:nmodbus,代码行数:8,代码来源:ModbusRtuTransportFixture.cs

示例15: RequestBytesToReadCoils

		public void RequestBytesToReadCoils()
		{
			MockRepository mocks = new MockRepository();
			var mockSlave = mocks.PartialMock<ModbusSlave>((byte) 1, new EmptyTransport());

			byte[] frameStart = { 0x11, 0x01, 0x00, 0x13, 0x00, 0x25 };
			Assert.AreEqual(1, ModbusRtuTransport.RequestBytesToRead(frameStart, mockSlave));
		}
开发者ID:ian588h,项目名称:nmodbus,代码行数:8,代码来源:ModbusRtuTransportFixture.cs


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