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


C# MockRepository.Record方法代码示例

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


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

示例1: CanReadFromValidStream

        public void CanReadFromValidStream()
        {
            string testString = "26/09/2008,1204.47,1215.77,1187.54,1213.27,5383610000,1213.27";
            MockRepository mocks = new MockRepository();
            TextReader sourceReader  = mocks.Stub<TextReader>();

                using (mocks.Record())
                {
                    SetupResult
                        .For(sourceReader.ReadLine())
                        .Return(testString);
                }

                IParseIntervals intervalParser = mocks.Stub<IParseIntervals>();

            using (mocks.Record())
                {
                    SetupResult
                        .For(intervalParser.Parse("qwert", 0))
                        .IgnoreArguments()
                        .Return(new OHLCVInterval()
                        {
                             Close = 1213.27f,
                             // DataSource="Stub",
                               DateTime=new DateTime(2008,09,26),
                                High=1215.77f,
                                 Index=0,
                                  Instrument="StubInstrument",
                                   //Interval="Day",
                                   Exchange="StubExchange",
                                     Low=1187.54f,
                                      Open=1204.47f,
                                       Volume=5383610000,
                                       //Id = Guid.NewGuid()//"StubInstrument" + new DateTime(2008,09,26).Ticks.ToString()
                        }
                        );
                }

            bool hasHeader = false;

              OHLCVIntervalReader reader = new OHLCVIntervalReader(sourceReader, intervalParser, hasHeader);

              foreach (var interval in reader)
              {
              Assert.AreEqual(new DateTime(2008, 09, 26), interval.DateTime);
              Assert.IsFalse(Math.Abs(1204.47f - interval.Open) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1215.77f - interval.High) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1187.54f - interval.Low) > Single.Epsilon);
              Assert.IsFalse(Math.Abs(1213.27f - interval.Close) > Single.Epsilon);
              Assert.AreEqual(5383610000, interval.Volume);
              Assert.AreEqual(0, interval.Index);
              Assert.AreEqual("StubExchange", interval.Exchange);

              //Assert.AreEqual("Stub", interval.DataSource);
              Assert.AreEqual("StubInstrument", interval.Instrument);
             // Assert.AreEqual("StubInstrument" + new DateTime(2008, 09, 26).Ticks.ToString(), interval.Id);
              break;
              }
        }
开发者ID:MattCollinge,项目名称:StrategyTester,代码行数:59,代码来源:OHLCVIntervalReaderTests.cs

示例2: Drops_database

		public void Drops_database()
		{
			var settings = new ConnectionSettings("server", "db", true, null, null);
            var taskAttributes = new TaskAttributes(settings, null);

			var mocks = new MockRepository();
			var connectionDropper = mocks.CreateMock<IDatabaseConnectionDropper>();
			var taskObserver = mocks.CreateMock<ITaskObserver>();
			var queryExecutor = mocks.CreateMock<IQueryExecutor>();
            
			using (mocks.Record())
			{
				connectionDropper.Drop(settings, taskObserver);
                
                queryExecutor.ExecuteNonQuery(settings, "ALTER DATABASE [db] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [db]", false);
			    
			}

			using (mocks.Playback())
			{
				IDatabaseActionExecutor dropper = new DatabaseDropper(connectionDropper, queryExecutor);
				dropper.Execute(taskAttributes, taskObserver);
			}

			mocks.VerifyAll();
		}
开发者ID:joaomajesus,项目名称:Tarantino,代码行数:26,代码来源:DatabaseDropperTester.cs

示例3: RelationsTest

        public static void RelationsTest()
        {
            MockRepository rhinoEngine = new MockRepository();
            var mockWriter = rhinoEngine.DynamicMock<TextWriter>();

            TextWriterFactory.SetTextWriter(mockWriter);

            using (rhinoEngine.Record())
            {
                mockWriter.Write("Nothing");
                LastCall.Constraints(new Rhino.Mocks.Constraints.Contains("TestCustomer") &
                                     new Rhino.Mocks.Constraints.Contains("TestMovie") &
                                     new Rhino.Mocks.Constraints.Contains("6 days") &
                                     new Rhino.Mocks.Constraints.Contains(12.ToString("C")));
                mockWriter.Flush();

            }

            Customer customer = new Customer("TestCustomer");
            customer.Rental.Add(new Rental(new Movie("TestMovie", 2), 6));

            ReportManager.CreateReport("SomePath", customer);

            rhinoEngine.VerifyAll();
        }
开发者ID:master-vk,项目名称:Tasks-ITVDN,代码行数:25,代码来源:TestClass.cs

示例4: Should_enable_load_balancing_when_requested

		public void Should_enable_load_balancing_when_requested()
		{
			ApplicationInstance instance = new ApplicationInstance();
			instance.AvailableForLoadBalancing = false;

			MockRepository mocks = new MockRepository();
			IApplicationInstanceContext instanceContext = mocks.CreateMock<IApplicationInstanceContext>();
			IWebContext context = mocks.CreateMock<IWebContext>();
			ISecureAvailabilityStatusUpdater updater = mocks.CreateMock<ISecureAvailabilityStatusUpdater>();			

			using (mocks.Record())
			{
				Expect.Call(instanceContext.GetCurrent()).Return(instance);
				Expect.Call(context.GetRequestItem(LoadBalanceStatusManager.ENABLED_PARAM)).Return("True");
				Expect.Call(updater.SetStatus(true)).Return("My error message");
			}

			using (mocks.Playback())
			{
				ILoadBalanceStatusManager manager = new LoadBalanceStatusManager(instanceContext, context, updater);
				string errorMessage = manager.HandleLoadBalanceRequest();

				Assert.That(errorMessage, Is.EqualTo("My error message"));
			}
		}
开发者ID:joaomajesus,项目名称:Tarantino,代码行数:25,代码来源:LoadBalanceStatusManagerTester.cs

示例5: Select_Finds_FirstToSatisfyAllConstraints

        public void Select_Finds_FirstToSatisfyAllConstraints()
        {
            var mockery = new MockRepository();
            var constraint1 = mockery.StrictMock<IResidentConstraint>();
            var constraint2 = mockery.StrictMock<IResidentConstraint>();
            var selector = new ResidentSelector();
            selector.Constraints.Clear();
            selector.Constraints.Add(constraint1);
            selector.Constraints.Add(constraint2);

            var residents = new List<Resident> { new Resident(), new Resident(), new Resident() };
            var shift = new Shift(DateTime.Today, DateTime.Today, DateTime.Today);
            using (mockery.Record()) {
                SetupResult.For(constraint1.Assignable(residents.First(), shift)).Return(false);
                SetupResult.For(constraint2.Assignable(residents.First(), shift)).Return(true);

                SetupResult.For(constraint1.Assignable(residents.Skip(1).First(), shift)).Return(true);
                SetupResult.For(constraint2.Assignable(residents.Skip(1).First(), shift)).Return(false);

                SetupResult.For(constraint1.Assignable(residents.Skip(2).First(), shift)).Return(true);
                SetupResult.For(constraint2.Assignable(residents.Skip(2).First(), shift)).Return(true);
            }
            using (mockery.Playback()) {
                Assert.AreEqual(residents.Skip(2).First(), selector.Select(residents, shift));
            }
        }
开发者ID:BobHemphill,项目名称:Scheduling-App,代码行数:26,代码来源:ResidentSelectorTest.cs

示例6: SubmitAdRequestsAsync

        public void SubmitAdRequestsAsync()
        {
            var mockery = new MockRepository();
              var taskFactory = mockery.StrictMock<IVistarTaskFactory>();
              var adRequestor = mockery.StrictMock<IAdRequestor>();

              var adRequests = new List<AdRequest> {
            new AdRequest(),
            new AdRequest(),
            new AdRequest()
              };

              var expectedTasks = new List<Task<List<Advertisement>>> {
            new Task<List<Advertisement>>(null),
            new Task<List<Advertisement>>(null),
            new Task<List<Advertisement>>(null)
              };

              using (mockery.Record()) {
            Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[0])).Return(expectedTasks[0]);
            Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[1])).Return(expectedTasks[1]);
            Expect.Call(taskFactory.StartNew(adRequestor.RunSubmitAdRequest, adRequests[2])).Return(expectedTasks[2]);
              }

              using (mockery.Playback()) {
            var client = new ApiClientAsync(adRequestor, taskFactory);
            var tasks = client.SubmitAdRequestsAsync(adRequests);
            Assert.AreEqual(expectedTasks, tasks);
              }
        }
开发者ID:vistarmedia,项目名称:net-client,代码行数:30,代码来源:ApiClientAsyncTest.cs

示例7: NavigateTo

        public void NavigateTo(bool simulateSuccess)
        {
            MockRepository mocks = new MockRepository();

            IGallioNavigator navigator = mocks.StrictMock<IGallioNavigator>();
            using (mocks.Record())
            {
                Expect.Call(navigator.NavigateTo(
                        @"C:\Source\MbUnit\v3\src\Gallio\Gallio.Tests\Reflection\Impl\CecilReflectionPolicyTest.cs", 5, 11))
                    .Return(simulateSuccess);
            }

            using (mocks.Playback())
            {
                InstrumentedProgram program = new InstrumentedProgram();
                program.Engine = navigator;
                int returnCode = program.Run(new string[]
                {
                    @"gallio:navigateTo?path=C:\Source\MbUnit\v3\src\Gallio\Gallio.Tests\Reflection\Impl\CecilReflectionPolicyTest.cs&line=5&column=11"
                });

                Assert.IsFalse(program.HelpCalled);
                Assert.AreEqual(simulateSuccess ? 0 : 1, returnCode);

                mocks.VerifyAll();
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:27,代码来源:ProgramTest.cs

示例8: Correctly_constructs_action_executors

        public void Correctly_constructs_action_executors()
        {
            DatabaseAction[] actions = new DatabaseAction[] { DatabaseAction.Create, DatabaseAction.Update };

            MockRepository mocks = new MockRepository();
            IDatabaseActionResolver resolver = mocks.StrictMock<IDatabaseActionResolver>();
            IDataBaseActionLocator locator = mocks.StrictMock<IDataBaseActionLocator>();

            IDatabaseActionExecutor creator = mocks.StrictMock<IDatabaseActionExecutor>();
            IDatabaseActionExecutor updater = mocks.StrictMock<IDatabaseActionExecutor>();

            using (mocks.Record())
            {
                Expect.Call(resolver.GetActions(RequestedDatabaseAction.Create)).Return(actions);
                Expect.Call(locator.CreateInstance(DatabaseAction.Create)).Return(creator);
                Expect.Call(locator.CreateInstance(DatabaseAction.Update)).Return(updater);
            }

            using (mocks.Playback())
            {
                IDatabaseActionExecutorFactory factory = new DatabaseActionExecutorFactory(resolver, locator);
                IEnumerable<IDatabaseActionExecutor> executors = factory.GetExecutors(RequestedDatabaseAction.Create);
                IList<IDatabaseActionExecutor> executorList = new List<IDatabaseActionExecutor>(executors);

                Assert.That(executorList, Is.EqualTo(new IDatabaseActionExecutor[]{ creator, updater }));
            }

            mocks.VerifyAll();
        }
开发者ID:psantiago,项目名称:AliaSQL,代码行数:29,代码来源:DatabaseActionExecutorFactoryTester.cs

示例9: CompleteTest

        public void CompleteTest()
        {
            InstallController target = null;
            // Arrange
            MockRepository mocks = new MockRepository();
            IInstallerService installerService = mocks.StrictMock<IInstallerService>();
            ActionResult actual;

            using (mocks.Record())
            {

            }

            try
            {
                target = new InstallController(installerService);
                using (mocks.Playback())
                {
                    actual = target.Complete();
                }

                ControllerTestHelper.TestForEmptyViewAndModel(actual, target);

            }
            finally
            {
                if (target != null)
                {
                    target.Dispose();
                }
            }
        }
开发者ID:PascalPiche,项目名称:SymNet,代码行数:32,代码来源:InstallControllerTest.cs

示例10: 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

示例11: FormatPhoneNumber_PhoneNumberInDresdenGermany_ReturnsFormattedNumber

        public void FormatPhoneNumber_PhoneNumberInDresdenGermany_ReturnsFormattedNumber(
            [Values(DISTANCE_RULE.CANONICAL, DISTANCE_RULE.InternationalRule, DISTANCE_RULE.LongDistanceRule,
                DISTANCE_RULE.SameAreaRule)] DISTANCE_RULE distanceRule,
            [Values("+49 (351) 1234567", "00493511234567", "03511234567", "1234567")] string expected)
        {
            MockRepository mocks = new MockRepository();
            IPhoneNumberDataXml xmlDataProvider = mocks.Stub<IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>();

            string number = "+493511234567";

            using (mocks.Record())
            {
                registryDataProvider.GetUserCountryID();
                LastCall.Return("49");
                registryDataProvider.GetUserAreaCode();
                LastCall.Return("351");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.InternationalRule);
                LastCall.Return("00EFG");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.LongDistanceRule);
                LastCall.Return("0FG");
                registryDataProvider.GetPhoneFormat(49, DISTANCE_RULE.SameAreaRule);
                LastCall.Return("G");

                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
            string actual = phoneNumberConverter.FormatPhoneNumber(number, distanceRule);

            Assert.AreEqual(expected, actual);
        }
开发者ID:HomeSen,项目名称:Helpers,代码行数:35,代码来源:PhoneNumbersTests.cs

示例12: Certifies_deployment

		public void Certifies_deployment()
		{
			var deployment = new Deployment();

			var mocks = new MockRepository();
			var clock = mocks.CreateMock<ISystemClock>();
			var securityContext = mocks.CreateMock<ISecurityContext>();
			var repository = mocks.CreateMock<IDeploymentRepository>();

			using (mocks.Record())
			{
				Expect.Call(clock.GetCurrentDateTime()).Return(new DateTime(2007, 4, 15));
				Expect.Call(securityContext.GetCurrentUsername()).Return("khurwitz");
				repository.Save(deployment);
			}

			using (mocks.Playback())
			{
				IVersionCertifier certifier = new VersionCertifier(clock, securityContext, repository);
				certifier.Certify(deployment);
				
				Assert.That(deployment.CertifiedBy, Is.EqualTo("khurwitz"));
				Assert.That(deployment.CertifiedOn, Is.EqualTo(new DateTime(2007, 4, 15)));
			}

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

示例13: List_getValidNumberAndReferencesOfBeautifulGirls

 public void List_getValidNumberAndReferencesOfBeautifulGirls()
 {
     const int countOfBeautifulGirls= 50;
     var girls = Builder<Girl>.CreateListOfSize(2 * countOfBeautifulGirls)
                .All()
                     .With(x => x.Height = 175).With(x => x.Weight = 55).With(x => x.BirthDate = new DateTime(1990, 2, 2))
                .TheLast(countOfBeautifulGirls)
                     .With(x => x.Height = 180).With(x => x.Weight = 105).With(x => x.BirthDate = new DateTime(1990, 2, 2))
                .Build();
     for (int page = 1; page < 10; page++)
     {
         Mockery = new MockRepository();
         var girlService = Mockery.Stub<IGirlService>();
         UnitOfWorkFactory = Mockery.DynamicMock<IUnitOfWorkFactory>();
         UnitOfWork = Mockery.DynamicMock<IUnitOfWork>();
         using (Mockery.Record())
         {
             Expect.Call(UnitOfWorkFactory.Create()).Return(UnitOfWork);
             Expect.Call(girlService.GetBeautifulGirls()).Return(girls.Take(countOfBeautifulGirls).ToList());
         }
         IEnumerable<GirlModel> resultGirls;
         using (Mockery.Playback())
         {
             var controller = new GirlsController(girlService, UnitOfWorkFactory);
             var result = controller.List(page, true);
             resultGirls = (IEnumerable<GirlModel>) result.Data;
         }
         var girlModels = resultGirls as GirlModel[] ?? resultGirls.ToArray();
         Assert.AreEqual(girls.Take(countOfBeautifulGirls).Skip((page - 1) * Constants.GIRLS_PAGER_LINKS_PER_PAGE).
             Take(Constants.GIRLS_PAGER_LINKS_PER_PAGE).Count(), girlModels.Count());
         if (girlModels.Count() != 0)
             Assert.AreEqual(girls.Take(countOfBeautifulGirls).Skip((page - 1) * Constants.GIRLS_PAGER_LINKS_PER_PAGE).
                 Take(Constants.GIRLS_PAGER_LINKS_PER_PAGE).First().Id, girlModels.First().Id);
     }
 }
开发者ID:AndreyB1990,项目名称:Task1,代码行数:35,代码来源:GirlsControllerTests.cs

示例14: TestWindow

        /// <summary>
        ///     The test window.
        /// </summary>
        public void TestWindow()
        {
            var mocks = new MockRepository();
            var mockHttpReq = mocks.Stub<IHttpSonarConnector>();
            var mockVsHelpers = mocks.Stub<IVsEnvironmentHelper>();
            var config = new ConnectionConfiguration("serveraddr", "login", "password");

            // set expectations
            using (mocks.Record())
            {
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/issues/search?components=resource"))
                    .Return(File.ReadAllText("TestData/issuessearchbycomponent.txt"));
                SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/users/search")).Return(File.ReadAllText("TestData/userList.txt"));
            }

            ISonarRestService service = new SonarRestService(mockHttpReq);
            var issues = service.GetIssuesInResource(config, "resource");
            var associatedProject = new Resource { Key = "core:Common" };

            this.model = new ExtensionDataModel(service, mockVsHelpers, associatedProject);
            var t = new Thread(this.Threadprc);
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
开发者ID:NMarouschek,项目名称:VSSonarQubeExtension,代码行数:28,代码来源:TestMainWindow.cs

示例15: Should_not_fail_if_datebase_does_not_exist

		public void Should_not_fail_if_datebase_does_not_exist()
		{
			var settings = new ConnectionSettings("server", "db", true, null, null);
            var taskAttributes = new TaskAttributes(settings, null);

			var mocks = new MockRepository();
			var connectionDropper = mocks.DynamicMock<IDatabaseConnectionDropper>();
			var taskObserver = mocks.CreateMock<ITaskObserver>();
			var queryExecutor = mocks.CreateMock<IQueryExecutor>();

			using (mocks.Record())
			{
                Expect.Call(() => queryExecutor.ExecuteNonQuery(settings, "ALTER DATABASE [db] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [db]", false))
					.Throw(new Exception("foo message"));
				Expect.Call(() => taskObserver.Log("Database 'db' could not be dropped."));
			}

			using (mocks.Playback())
			{
				IDatabaseActionExecutor dropper = new DatabaseDropper(connectionDropper, queryExecutor);
                dropper.Execute(taskAttributes, taskObserver);
			}

			mocks.VerifyAll();
		}
开发者ID:joaomajesus,项目名称:Tarantino,代码行数:25,代码来源:DatabaseDropperTester.cs


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