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


C# DynamicMock.Verify方法代码示例

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


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

示例1: testStrategy

        public void testStrategy()
        {
            FastIDSet itemIDsFromUser123 = new FastIDSet();
            itemIDsFromUser123.Add(1L);

            FastIDSet itemIDsFromUser456 = new FastIDSet();
            itemIDsFromUser456.Add(1L);
            itemIDsFromUser456.Add(2L);

            List<IPreference> prefs = new List<IPreference>();
            prefs.Add(new GenericPreference(123L, 1L, 1.0f));
            prefs.Add(new GenericPreference(456L, 1L, 1.0f));
            IPreferenceArray preferencesForItem1 = new GenericItemPreferenceArray(prefs);

            var dataModelMock = new DynamicMock(typeof(IDataModel));
            dataModelMock.ExpectAndReturn("GetPreferencesForItem", preferencesForItem1,  (1L));
            dataModelMock.ExpectAndReturn("GetItemIDsFromUser", itemIDsFromUser123, (123L));
            dataModelMock.ExpectAndReturn("GetItemIDsFromUser", itemIDsFromUser456, (456L));

            IPreferenceArray prefArrayOfUser123 =
            new GenericUserPreferenceArray( new List<IPreference>() {new GenericPreference(123L, 1L, 1.0f)} );

            ICandidateItemsStrategy strategy = new PreferredItemsNeighborhoodCandidateItemsStrategy();

            //EasyMock.replay(dataModel);

            FastIDSet candidateItems = strategy.GetCandidateItems(123L, prefArrayOfUser123, (IDataModel)dataModelMock.MockInstance);
            Assert.AreEqual(1, candidateItems.Count());
            Assert.True(candidateItems.Contains(2L));

            dataModelMock.Verify(); //  EasyMock.verify(dataModel);
        }
开发者ID:techmobstudios,项目名称:Certified-Mixtapes-Recommender,代码行数:32,代码来源:PreferredItemsNeighborhoodCandidateItemsStrategyTest.cs

示例2: testStrategy

        public void testStrategy()
        {
            FastIDSet allItemIDs = new FastIDSet();
            allItemIDs.AddAll(new long[] { 1L, 2L, 3L });

            FastIDSet preferredItemIDs = new FastIDSet(1);
            preferredItemIDs.Add(2L);

            var dataModelMock = new DynamicMock( typeof( IDataModel ));
            dataModelMock.ExpectAndReturn("GetNumItems", 3);
            dataModelMock.ExpectAndReturn("GetItemIDs", allItemIDs.GetEnumerator());

            IPreferenceArray prefArrayOfUser123 = new GenericUserPreferenceArray( new List<IPreference>() {
            new GenericPreference(123L, 2L, 1.0f) } );

            ICandidateItemsStrategy strategy = new AllUnknownItemsCandidateItemsStrategy();

            //EasyMock.replay(dataModel);

            FastIDSet candidateItems = strategy.GetCandidateItems(123L, prefArrayOfUser123, (IDataModel)dataModelMock.MockInstance);
            Assert.AreEqual(2, candidateItems.Count() );
            Assert.True(candidateItems.Contains(1L));
            Assert.True(candidateItems.Contains(3L));

            dataModelMock.Verify();
            //EasyMock.verify(dataModel);
        }
开发者ID:techmobstudios,项目名称:Certified-Mixtapes-Recommender,代码行数:27,代码来源:AllUnknownItemsCandidateItemsStrategyTest.cs

示例3: IsLoginOK_WhenCalled_WritesToLog

        public void IsLoginOK_WhenCalled_WritesToLog()
        {
            DynamicMock mockLog = new DynamicMock(typeof(ILogger));
            mockLog.Expect("Write","login ok: user: u");

            var loginManager = new LoginManagerWithMock((ILogger)mockLog.MockInstance);
            loginManager.IsLoginOK("", "");

            mockLog.Verify();
        }
开发者ID:royosherove,项目名称:tddnetcoursedemos,代码行数:10,代码来源:1_LoginManagerTestsDemoNUnitMocks.cs

示例4: CanAddDecorator

        public void CanAddDecorator()
        {
            DynamicMock mock = new DynamicMock( typeof(ITestDecorator) );
            mock.Expect( "Decorate" );

            IExtensionPoint ep = host.GetExtensionPoint("TestDecorators");
            ep.Install( mock.MockInstance );
            host.TestDecorators.Decorate( null, null );

            mock.Verify();
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:11,代码来源:CoreExtensionsTests.cs

示例5: CanAddTestCaseBuilder

        public void CanAddTestCaseBuilder()
        {
            DynamicMock mock = new DynamicMock( typeof(ITestCaseBuilder) );
            mock.ExpectAndReturn( "CanBuildFrom", true, null );
            mock.Expect( "BuildFrom" );

            IExtensionPoint ep = host.GetExtensionPoint("TestCaseBuilders");
            ep.Install( mock.MockInstance );
            host.TestBuilders.BuildFrom( null );

            mock.Verify();
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:12,代码来源:CoreExtensionsTests.cs

示例6: Analyze_TooShortFileName_CallsWebService

        public void Analyze_TooShortFileName_CallsWebService()
        {
            DynamicMock mockController = new DynamicMock(typeof (IWebService));
            mockController.Expect("LogError", "Filename too short:abc.ext");

            IWebService mockService = mockController.MockInstance as IWebService;

            LogAnalyzer log = new LogAnalyzer(mockService);
            string tooShortFileName="abc.ext";
            log.Analyze(tooShortFileName);

            mockController.Verify();
        }
开发者ID:johnlim,项目名称:aout1,代码行数:13,代码来源:LogAnalyzerTestsUsingRhinoMocks.cs

示例7: CanAddEventListener

        public void CanAddEventListener()
        {
            DynamicMock mock = new DynamicMock( typeof(EventListener) );
            mock.Expect( "RunStarted" );
            mock.Expect( "RunFinished" );

            IExtensionPoint ep = host.GetExtensionPoint("EventListeners");
            ep.Install( mock.MockInstance );
            host.Listeners.RunStarted( "test", 0 );
            host.Listeners.RunFinished( new TestSuiteResult(null, "test") );

            mock.Verify();
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:13,代码来源:CoreExtensionsTests.cs

示例8: Install_Successful

		public void Install_Successful()
		{
			DynamicMock extensionPointMock = new DynamicMock(typeof(IExtensionPoint));
			IExtensionPoint extensionPoint = (IExtensionPoint) extensionPointMock.MockInstance;

			extensionHostMock.ExpectAndReturn("GetExtensionPoint", extensionPoint, "ParameterProviders");
			extensionPointMock.Expect("Install");

			bool installed = addIn.Install(extensionHost);
			
			extensionHostMock.Verify();
			extensionPointMock.Verify();
			Assert.That(installed, Is.True);
		}
开发者ID:kobida,项目名称:nunitv2,代码行数:14,代码来源:RowTestAddInTest.cs

示例9: IsLoginOK_LoggerThrowsException_WritesToWebService

        public void IsLoginOK_LoggerThrowsException_WritesToWebService()
        {
            DynamicMock stubLog = new DynamicMock(typeof(ILogger));
            DynamicMock mockService = new DynamicMock(typeof(IWebService));

            stubLog.ExpectAndThrow("Write",new LoggerException("fake exception"),"yo" );
            mockService.Expect("Write","got exception");

            var loginManager =
                new LoginManagerWithMockAndStub((ILogger)stubLog.MockInstance,
                                                (IWebService) mockService.MockInstance);
            loginManager.IsLoginOK("", "");

            mockService.Verify();
        }
开发者ID:royosherove,项目名称:tddnetcoursedemos,代码行数:15,代码来源:1_LoginManagerTestsDemoNUnitMocks.cs

示例10: TestLoad

        public void TestLoad()
        {
            Document dm = new Document();

            dm.FileName = @"c:\abc.wordo";

            DynamicMock fs = new DynamicMock(typeof (IFileSystem));

            fs.ExpectAndReturn("ReadAllText", "abc", @"c:\abc.wordo");

            dm.Load((IFileSystem)fs.MockInstance);

            fs.Verify();

            Assert.AreEqual("abc", dm.Text);
        }
开发者ID:alfar,项目名称:WordBuilder,代码行数:16,代码来源:DocumentTest.cs

示例11: estimatePreference

        public void estimatePreference()
        {
            var dataModelMock = new DynamicMock( typeof( IDataModel) );
            var factorizerMock = new DynamicMock( typeof(IFactorizer) );
            var factorization = new Factorization_estimatePreference_TestMock();

            factorizerMock.ExpectAndReturn("Factorize", factorization);

             //EasyMock.replay(dataModel, factorizer, factorization);

            SVDRecommender svdRecommender = new SVDRecommender( (IDataModel)dataModelMock.MockInstance, (IFactorizer)factorizerMock.MockInstance);

            float estimate = svdRecommender.EstimatePreference(1L, 5L);
            Assert.AreEqual(1, estimate, EPSILON);

            factorizerMock.Verify();
            Assert.AreEqual(1, factorization.getItemFeaturesCallCount );
            Assert.AreEqual(1, factorization.getUserFeaturesCallCount);
            //EasyMock.verify(dataModel, factorizer, factorization);
        }
开发者ID:techmobstudios,项目名称:Certified-Mixtapes-Recommender,代码行数:20,代码来源:SVDRecommenderTest.cs

示例12: TestPersist

        public void TestPersist()
        {
            //Gateway
            DynamicMock mockGateway = new DynamicMock(typeof(IUserGateway));
            IUserGateway gateway = (IUserGateway) mockGateway.MockInstance;

            //Validator
            DynamicMock mockValidator = new DynamicMock(typeof(IUserValidator));
            IUserValidator validator = (IUserValidator)mockValidator.MockInstance;

            //User
            User user = new User(gateway);

            //Expectations
            mockValidator.ExpectAndReturn("Validate", true, user);
            mockGateway.ExpectAndReturn("Persist", true, user);

            Assert.AreEqual(true, user.Persist(validator));
            mockValidator.Verify();
            mockGateway.Verify();
        }
开发者ID:pweibel,项目名称:DotNetMockingFrameworksDemo,代码行数:21,代码来源:NUnitMockTest.cs

示例13: preferencesFetchedOnlyOnce

        public void preferencesFetchedOnlyOnce()
        {
            var dataModelMock = new DynamicMock( typeof( IDataModel) );

            var itemSimilarityMock = new DynamicMock( typeof(IItemSimilarity) );
            var candidateItemsStrategyMock = new DynamicMock( typeof (ICandidateItemsStrategy) );
            var mostSimilarItemsCandidateItemsStrategyMock =
            new DynamicMock( typeof(IMostSimilarItemsCandidateItemsStrategy) );

            IPreferenceArray preferencesFromUser = new GenericUserPreferenceArray(
            new List<IPreference>() {new GenericPreference(1L, 1L, 5.0f), new GenericPreference(1L, 2L, 4.0f)});

            dataModelMock.ExpectAndReturn("GetMinPreference", float.NaN);
            dataModelMock.ExpectAndReturn("GetMaxPreference", float.NaN);
            dataModelMock.ExpectAndReturn("GetPreferencesFromUser", preferencesFromUser, 1L);
            var dataModel = (IDataModel)dataModelMock.MockInstance;

            candidateItemsStrategyMock.ExpectAndReturn("GetCandidateItems", new FastIDSet(new long[] { 3L, 4L }),
            1L, preferencesFromUser, dataModel);

            itemSimilarityMock.ExpectAndReturn("ItemSimilarities", new double[] { 0.5, 0.3 },
            3L, preferencesFromUser.GetIDs());
            itemSimilarityMock.ExpectAndReturn("ItemSimilarities", new double[] { 0.4, 0.1 },
            4L, preferencesFromUser.GetIDs());

            //EasyMock.replay(dataModel, itemSimilarity, candidateItemsStrategy, mostSimilarItemsCandidateItemsStrategy);

            IRecommender recommender = new GenericItemBasedRecommender((IDataModel)dataModel,
            (IItemSimilarity)itemSimilarityMock.MockInstance,
            (ICandidateItemsStrategy)candidateItemsStrategyMock.MockInstance,
            (IMostSimilarItemsCandidateItemsStrategy)mostSimilarItemsCandidateItemsStrategyMock.MockInstance);

            recommender.Recommend(1L, 3);

            dataModelMock.Verify();
            itemSimilarityMock.Verify();
            candidateItemsStrategyMock.Verify();
            mostSimilarItemsCandidateItemsStrategyMock.Verify();
            //EasyMock.verify(dataModel, itemSimilarity, candidateItemsStrategy, mostSimilarItemsCandidateItemsStrategy);
        }
开发者ID:techmobstudios,项目名称:Certified-Mixtapes-Recommender,代码行数:40,代码来源:GenericItemBasedRecommenderTest.cs

示例14: TestExport

        public void TestExport()
        {
            m_FileSystem = new DynamicMock(typeof(IFileSystem));

            List<Context> selected = new List<Context>();

            Context result = new Context();
            result.Tokens.Add("a");
            result.Tokens.Add("b");
            result.Tokens.Add("c");

            Context branch = result.Branch("b1");
            branch.Tokens.Add("d");

            selected.Add(result);

            IExporter exporter = new CsvExporter();

            m_FileSystem.Expect("WriteAllText", @"c:\abc.csv", string.Format(".Word.;b1{0}abc;abcd{0}", Environment.NewLine));

            exporter.Export(selected, @"c:\abc.csv", (IFileSystem)m_FileSystem.MockInstance);

            m_FileSystem.Verify();
        }
开发者ID:alfar,项目名称:WordBuilder,代码行数:24,代码来源:CsvExporterTest.cs

示例15: testCommitTransactionCalled

        public void testCommitTransactionCalled()
        {
            //STOP -- check with instructor before beginning this test~
            //now go break your code -- don't call the 'commit transaction' or the 'update account' methods.  Does the test above fail?
            //use dynamic mocks to verify that these methods are called.

            //here's an example of creating the credit card service.  You'll need another thing just like this for
            //the account update.  These mocks will replace the stub code from the happyPathTest
            DynamicMock mockCreditCardService = new DynamicMock(typeof (ICreditCardService));
            //some expectations
            int token = 42;
            String ccNum = "4324 3924 4382 3888";
            Decimal amount = 199.99M;
            mockCreditCardService.ExpectAndReturn("ReserveFunds", token, new Object[2] { ccNum, amount });
            mockCreditCardService.Expect("CommitTransaction", new Object[1] { token });
            ICreditCardService creditCardServiceInstance = (ICreditCardService) mockCreditCardService.MockInstance;

            //calls to the actual class under test goes here
            AccountUpdater au = new AccountUpdater(new StubBalanceService(), creditCardServiceInstance);
            au.UpdateAccount(ccNum, amount, 3982834);

            //this should be the last line.
            mockCreditCardService.Verify();
        }
开发者ID:Davisbase,项目名称:DavisbaseAgileEngineering,代码行数:24,代码来源:AccountUpdaterTest.cs


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