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


C# MockRepository.VerifyAll方法代码示例

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


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

示例1: Executes_all_the_scripts_within_a_folder

		public void Executes_all_the_scripts_within_a_folder()
		{
			var settings = new ConnectionSettings("server", "db", true, null, null);
            var sqlFiles = new[] { "c:\\scripts\\Update\\001.sql", "c:\\scripts\\Update\\002_data_.sql", "c:\\scripts\\Update\\003.sql" };
            var taskAttributes = new TaskAttributes(settings, "c:\\scripts")
                                     {
                                         RequestedDatabaseAction = RequestedDatabaseAction.Update,
                                     };

			var mocks = new MockRepository();
            var initializer = mocks.StrictMock<ISchemaInitializer>();
            var fileLocator = mocks.StrictMock<ISqlFileLocator>();
            var executor = mocks.StrictMock<IChangeScriptExecutor>();
            var testdataexecutor = mocks.StrictMock<ITestDataScriptExecutor>();
            var versioner = mocks.StrictMock<IDatabaseVersioner>();
            var taskObserver = mocks.StrictMock<ITaskObserver>();

			using (mocks.Record())
			{
				initializer.EnsureSchemaCreated(settings);
				Expect.Call(fileLocator.GetSqlFilenames("c:\\scripts", "Update")).Return(sqlFiles);
				executor.Execute("c:\\scripts\\Update\\001.sql", settings, taskObserver);
				executor.Execute("c:\\scripts\\Update\\002_data_.sql", settings, taskObserver);
				executor.Execute("c:\\scripts\\Update\\003.sql", settings, taskObserver);
				versioner.VersionDatabase(settings, taskObserver);
			}

			using (mocks.Playback())
			{
                IScriptFolderExecutor folderExecutor = new ScriptFolderExecutor(initializer, fileLocator, executor, testdataexecutor, versioner);
				folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Update", taskObserver);
			}

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

示例2: GetMatchNonMatchTest

        public static void GetMatchNonMatchTest(
			string headerName, 
			string[] values, 
			bool existsInStore,
			bool expectReturnNull,
			HttpStatusCode expectedStatus = HttpStatusCode.Unused)
        {
            // setup
            var mocks = new MockRepository();
            var entityTagStore = mocks.StrictMock<IEntityTagStore>();
            var entityTagHandler = new CachingHandler(entityTagStore);
            var request = new HttpRequestMessage(HttpMethod.Get, TestUrl);
            request.Headers.Add(headerName, values);
            TimedEntityTagHeaderValue entityTagHeaderValue = new TimedEntityTagHeaderValue("\"12345678\"");

            if(values.Length>0) // if
                entityTagStore.Expect(x => x.TryGetValue(Arg<CacheKey>.Matches(etg => etg.ResourceUri == entityTagHandler.UriTrimmer(new Uri(TestUrl))),
                    out Arg<TimedEntityTagHeaderValue>.Out(entityTagHeaderValue).Dummy)).Return(existsInStore);

            mocks.ReplayAll();

            // run
            var matchNoneMatch = entityTagHandler.GetIfMatchNoneMatch();
            // verify
            Task<HttpResponseMessage> resultTask = matchNoneMatch(request);
            Assert.That(expectReturnNull ^ resultTask != null, "result was not as expected");
            if(resultTask!=null && expectedStatus != HttpStatusCode.Unused)
            {
                Assert.AreEqual(expectedStatus, resultTask.Result.StatusCode, "Status code");
            }
            mocks.VerifyAll();
        }
开发者ID:sayedihashimi,项目名称:CacheCow,代码行数:32,代码来源:CachingHandlerRulesTests.cs

示例3: Do3Classic

        public void Do3Classic()
        {
            var mockRepository = new MockRepository();
            var view = mockRepository.StrictMock<IButtonView>();
            var model = mockRepository.StrictMock<IToggleModel>();

            model.VisibilityStateChanged += null;
            IEventRaiser visibilityChanged = LastCall.GetEventRaiser();

            view.Clicked += null;
            IEventRaiser clicked = LastCall.GetEventRaiser();

            var presenter = new ButtonPresenter(model);
            presenter.ConnectView(view);

            mockRepository.BackToRecordAll();
            //mockRepository.Playback();

            Expect.Call(model.ToggleVisibility);
            Expect.Call(() => model.VisibilityStateChanged += null).IgnoreArguments();
            Expect.Call(() => view.SetCheckedState(CheckedState.Checked));

            mockRepository.ReplayAll();

            clicked.Raise();
            visibilityChanged.Raise(VisibilityState.Visible);

            mockRepository.VerifyAll();
        }
开发者ID:baens,项目名称:Esri2011,代码行数:29,代码来源:ButtonPresenterFixture.cs

示例4: ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct

        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            MockRepository mocks = new MockRepository();
            ISomeService m_SomeServiceMock = mocks.StrictMock<ISomeService>();
            SomeClient sut = new SomeClient(m_SomeServiceMock);

            using (mocks.Ordered())
            {
                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<string>(null, null);
                });
                LastCall.IgnoreArguments();

                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<DateTime>(null, default(DateTime));  // can't use null here, because it's a value type!
                });
                LastCall.IgnoreArguments();

            }
            mocks.ReplayAll();

            // test
            sut.DoSomething();

            // verification
            mocks.VerifyAll();

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
开发者ID:guesshoo,项目名称:rhino-mocks,代码行数:34,代码来源:FieldProblem_Stephan.cs

示例5: GetById_Calls_GigDAO_Method_GetById_Once_And_Returns_A_Gig

        public void GetById_Calls_GigDAO_Method_GetById_Once_And_Returns_A_Gig()
        {
            MockRepository mocks = new MockRepository();

            Guid gigId = Guid.NewGuid();
            Gig gig = new Gig();
            gig.ID = gigId;

            IGigDAO gigDAO = mocks.DynamicMock<IGigDAO>();
            GigManager gigManager = new GigManager();
            gigManager.GigDAO = gigDAO;

            Expect.Call(gigDAO.GetById(gigId))
               .Constraints(Is.Equal(gigId))
               .Repeat.Once()
               .Return(gig);

            mocks.ReplayAll();

            Gig result = gigManager.GetByID(gigId);

            mocks.VerifyAll();

            Assert.AreEqual(gig.ID, result.ID);
        }
开发者ID:listentorick,项目名称:ListenTo,代码行数:25,代码来源:GigManagerTests.cs

示例6: BidirectionalConverter_Should_Convert_All_Items

        public void BidirectionalConverter_Should_Convert_All_Items()
        {
            var mocks = new MockRepository();
            var converter1 = mocks.StrictMock<IBidirectionalConverter<int, string>>();

            Expect.Call(converter1.Convert(5)).Return("5");
            Expect.Call(converter1.Convert(3)).Return("3");
            Expect.Call(converter1.Convert(7)).Return("7");

            var converter2 = mocks.StrictMock<IBidirectionalConverter<string, int>>();

            Expect.Call(converter2.Convert("5")).Return(5);
            Expect.Call(converter2.Convert("3")).Return(3);
            Expect.Call(converter2.Convert("7")).Return(7);

            mocks.ReplayAll();

            // Convert one way
            IList<int> input1 = new List<int> { 5, 3, 7 };
            var output1 = converter1.ConvertAll(input1);

            Assert.IsTrue(output1.Contains("5"));
            Assert.IsTrue(output1.Contains("3"));
            Assert.IsTrue(output1.Contains("7"));

            // Convert the other way
            IList<string> input2 = new List<string> { "5", "3", "7" };
            var output2 = converter2.ConvertAll(input2);

            Assert.IsTrue(output2.Contains(5));
            Assert.IsTrue(output2.Contains(3));
            Assert.IsTrue(output2.Contains(7));

            mocks.VerifyAll();
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:35,代码来源:ConvertAll.cs

示例7: ShouldBeAbleToAddNewOrder

        public void ShouldBeAbleToAddNewOrder()
        {
            // arrange
            var mock = new MockRepository();
            var repository = mock.DynamicMock<IOrderRepository>();
            const string IdentityToken = "[email protected]";
            const string RetailerUrl = "amazon.com";
            Expect.Call(repository.AddOrder(IdentityToken, new Order { Retailer = new Retailer(RetailerUrl) }))
                .Return(new Order(OrderStatus.New) { Retailer = new Retailer(RetailerUrl), CreatedDate = DateTime.UtcNow });
            var service = new OrderService(repository, new FakeEmailService(), this.logger);
            var request = new AddOrderRequest
                {
                    IdentityToken = IdentityToken,
                    RetailerUrl = RetailerUrl,
                    CreatedDate = DateTime.UtcNow
                };

            // act
            mock.ReplayAll();
            var actual = service.AddOrder(request);
            mock.VerifyAll();

            // assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.CreatedDate, Is.EqualTo(request.CreatedDate).Within(1).Minutes);
            Assert.That(actual.RetailerUrl, Is.EqualTo(request.RetailerUrl));
        }
开发者ID:Naviam,项目名称:Shop-Any-Ware,代码行数:27,代码来源:OrderServiceTests.cs

示例8: Search

        public void Search()
        {
            // Basic integration test: search algorithms are already extensively tested with InMemoryIndexBase

            MockRepository mocks = new MockRepository();

            IIndexConnector conn = mocks.StrictMock<IIndexConnector>();
            ScrewTurn.Wiki.SearchEngine.IWordFetcher fetcher = mocks.StrictMock<ScrewTurn.Wiki.SearchEngine.IWordFetcher>();

            ScrewTurn.Wiki.SearchEngine.Word dummy = null;
            Expect.Call(fetcher.TryGetWord("test", out dummy)).Return(false);
            Expect.Call(fetcher.TryGetWord("query", out dummy)).Return(false);
            fetcher.Dispose();
            LastCall.On(fetcher);

            Expect.Call(conn.GetWordFetcher()).Return(fetcher);

            mocks.ReplayAll();

            SqlIndex index = new SqlIndex(conn);

            Assert.AreEqual(0, index.Search(new ScrewTurn.Wiki.SearchEngine.SearchParameters("test query")).Count, "Wrong search result count");

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

示例9: SetPort_three_locations

		public void SetPort_three_locations()
		{
			var expectedPort = 1234;
			var mockRepository = new MockRepository();

			// Arrange
			var fileManipulation = mockRepository.StrictMock<IFileManipulation>();
			var paths = mockRepository.StrictMock<IPaths>();

			var neo4JServerConfigSettings = mockRepository.StrictMock<INeo4jServerConfigSettings>();
			neo4JServerConfigSettings.Expect(n => n.Port).Return("org.neo4j.server.webserver.port");
			neo4JServerConfigSettings.Expect(n => n.WebAdminDataUri).Return("webadmindatauri");
			neo4JServerConfigSettings.Expect(n => n.WebAdminManagementUri).Return("webadminmanagementuri");

			var neo4JManager = new Neo4jManager(fileManipulation, null);

			paths.Expect(p => p.Neo4jServerConfigSettings).Return(neo4JServerConfigSettings);

			paths.Expect(p => p.Neo4jAdminDataUri).Return("Neo4jAdminDataUri");
			paths.Expect(p => p.Neo4jAdminManagementUri).Return("Neo4jAdminManagementUri");
			paths.Expect(p => p.Neo4jServerConfigPath).Return("Neo4jServerConfigPath");

			fileManipulation.Expect(fm => fm.ReplaceConfigLine(null, null)).IgnoreArguments();

			mockRepository.ReplayAll();

			// Act
			neo4JManager.SetServerPortAndUrlConfig(paths, expectedPort);

			// Assert
			mockRepository.VerifyAll();
		}
开发者ID:jonbgallant,项目名称:Neo4j.Azure.Server,代码行数:32,代码来源:Neo4jManagerTests.cs

示例10: GigController_Should_Contain_Index_Method_Which_Accepts_GigID_And_Returns_A_Gig

        public void GigController_Should_Contain_Index_Method_Which_Accepts_GigID_And_Returns_A_Gig()
        {
            MockRepository mocks = new MockRepository();

            Guid gigId = Guid.NewGuid();
            Gig gig = new Gig();
            gig.ID = gigId;

            //Mock the GigManager
            IGigManager gigManager = mocks.DynamicMock<IGigManager>();
            GigController gigController = new GigController();
            gigController.GigManager = gigManager;

            Expect.Call(gigManager.GetByID(gigId))
                .Constraints(Is.Equal(gigId))
                .Repeat.Once()
                .Return(gig);

            mocks.ReplayAll();

            ViewResult result = (ViewResult)gigController.Index(gigId);
            Gig returnedData = (Gig)(result.ViewData.Model);

            mocks.VerifyAll();

            Assert.IsNotNull(returnedData);
            Assert.AreEqual(gig.ID, returnedData.ID);
        }
开发者ID:listentorick,项目名称:ListenTo,代码行数:28,代码来源:GigControllerTests.cs

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

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

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

示例14: CanCreateNewSite

        public void CanCreateNewSite()
        {
            Site site = DomainTestHelper.GetTestSite();

             Theme theme = MockRepository.GenerateStub<Theme>();
             theme.BasePath = "~/themes/default";
             theme.Name = "default";
             site.Theme = theme;

             MockRepository mocks = new MockRepository();
             sessionFactory = MockRepository.GenerateMock<Arashi.Core.NHibernate.ISessionFactory>();
             session = MockRepository.GenerateMock<ISession>();
             Site createdSite;

             using (mocks.Record())
             {
            sessionFactory.Expect(x => x.GetSession()).Return(session /*MockRepository.GenerateStub<ISession>()*/);
            session.Expect(x => x.BeginTransaction()).Return(MockRepository.GenerateStub <ITransaction>());
             }
             using (mocks.Playback())
             {
            ISiteService siteService = new SiteService( sessionFactory, // this.AutoMockingContainer().Resolve<Arashi.Core.NHibernate.ISessionFactory>(),
                                                         this.AutoMockingContainer().Resolve<ILog>(),
                                                         this.AutoMockingContainer().Resolve<IUserService>(),
                                                         this.AutoMockingContainer().Resolve<IFileService>());

            createdSite = siteService.CreateNewSite("Test", "test", "[email protected]", "localhost", theme);
             }

             mocks.VerifyAll();

             createdSite.Should().Not.Be.Null();
             createdSite.Name.Should().Be.EqualTo(site.Name);
             createdSite.Hosts.Count.Should().Be.GreaterThanOrEqualTo(1);
             createdSite.Hosts[0].Should().Not.Be.Null();
             createdSite.Theme.Should().Be.EqualTo(theme);

             //NHibernate.ISession session = mocks.StrictMock<NHibernate.ISession>();
             //NHibernate.ITransaction transaction = mocks.Stub<NHibernate.ITransaction>();
             //Student expected = new Student();
             //Student actual;
             //using (mocks.Record())
             //{
             //   Rhino.Mocks.Expect.Call(session.Transaction)
             //       .Return(transaction)
             //       .Repeat.Any();
             //   Rhino.Mocks.Expect.Call(transaction.IsActive)
             //       .Return(true);
             //   Rhino.Mocks.Expect.Call(session.Get<Student>(Guid.Empty))
             //       .Return(expected);
             //}
             //using (mocks.Playback())
             //{
             //   IReadStudent StudentDao = new StudentDAOImpl(session);
             //   actual = StudentDao.GetById(Guid.Empty);
             //}
             //mocks.VerifyAll();
             //Assert.IsNotNull(actual);
             //Assert.AreSame(expected, actual);
        }
开发者ID:aozora,项目名称:arashi,代码行数:60,代码来源:SiteServiceTest.cs

示例15: Updates_database

        public void Updates_database()
        {
            var settings = new ConnectionSettings("server", "db", true, null, null);
            var taskAttributes = new TaskAttributes(settings, "c:\\scripts");
            taskAttributes.RequestedDatabaseAction = RequestedDatabaseAction.Update;
            var mocks = new MockRepository();
            var scriptfolderexecutor = mocks.StrictMock<IScriptFolderExecutor>();
            var queryexecutor = mocks.StrictMock<IQueryExecutor>();
            queryexecutor.Stub(x => x.CheckDatabaseExists(taskAttributes.ConnectionSettings)).Return(true);

            var taskObserver = mocks.StrictMock<ITaskObserver>();
            using (mocks.Record())
            {
                taskObserver.Log(string.Format("Run scripts in Update folder."));
                scriptfolderexecutor.ExecuteScriptsInFolder(taskAttributes, "Update", taskObserver);

                taskObserver.Log(string.Format("Run scripts in Everytime folder."));
                scriptfolderexecutor.ExecuteChangedScriptsInFolder(taskAttributes, "Everytime", taskObserver);

                taskObserver.Log(string.Format("Run scripts in RunAlways folder."));
                scriptfolderexecutor.ExecuteRunAlwaysScriptsInFolder(taskAttributes, "RunAlways", taskObserver);
            }

            using (mocks.Playback())
            {
                IDatabaseActionExecutor updater = new DatabaseUpdater(scriptfolderexecutor, queryexecutor);
                updater.Execute(taskAttributes, taskObserver);
            }

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


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