當前位置: 首頁>>代碼示例>>C#>>正文


C# List.FindAll方法代碼示例

本文整理匯總了C#中NUnit.Framework.List.FindAll方法的典型用法代碼示例。如果您正苦於以下問題:C# List.FindAll方法的具體用法?C# List.FindAll怎麽用?C# List.FindAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NUnit.Framework.List的用法示例。


在下文中一共展示了List.FindAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ShouldInstrumentInnerclassesCorrectly

 public void ShouldInstrumentInnerclassesCorrectly()
 {
     TypeDefinition type = assembly.Type(typeof (OuterClass.InnerClass));
     MethodDefinition instrumentedMethod = type.Methods[0];
     var instructions = new List<Instruction>(instrumentedMethod.Body.Instructions.Cast<Instruction>());
     List<Instruction> instructionsCallingOtherMethods =
         instructions.FindAll(instruction => instruction.OpCode == OpCodes.Call);
     instructionsCallingOtherMethods.ShouldBeOfSize(2);
     instructionsCallingOtherMethods[0].Operand.ToString().ShouldContain("EnteringMethod");
     instructionsCallingOtherMethods[1].Operand.ToString().ShouldContain("ExitingMethod");
 }
開發者ID:LSudarshan,項目名稱:SilverlightProfiler,代碼行數:11,代碼來源:SilverlightProfilerTest.cs

示例2: Can_create_a_drive_system_containing_same_manual_more_than_once

        public void Can_create_a_drive_system_containing_same_manual_more_than_once()
        {
            var ds = new DriveSystem {Name = "Drive System 1"};
            var englishManual = new Manual {Title = "Operation Manual", Language = "English"};
            ds.Manuals.Add(englishManual);
            ds.Manuals.Add(englishManual);
            ds.Manuals.Add(new Manual {Title = "Operation Manual", Language = "German"});

            Session.Save(ds);
            Session.Flush();
            Session.Clear();

            // Assertions
            var fromDb = Session.Get<DriveSystem>(ds.Id);
            Assert.AreEqual(ds.Manuals.Count, fromDb.Manuals.Count);
            // Assert that bag can really contain same equipment multiple times
            var temp = new List<Manual>(fromDb.Manuals);
            Assert.AreEqual(2, temp.FindAll(m => m.Title == englishManual.Title && 
                                                 m.Language == englishManual.Language).Count);
        }
開發者ID:tasluk,項目名稱:hibernatingrhinos,代碼行數:20,代碼來源:DriveSystem_Fixture.cs

示例3: Can_create_a_drive_system_containing_same_equipment_more_than_once

        public void Can_create_a_drive_system_containing_same_equipment_more_than_once()
        {
            var ds = new DriveSystem { Name = "Drive System 1" };
            ds.Equipments.Add("Motor");
            ds.Equipments.Add("Motor");
            ds.Equipments.Add("Motor");
            ds.Equipments.Add("Filter");
            ds.Equipments.Add("Transformer");
            ds.Equipments.Add("Starter");

            Session.Save(ds);
            Session.Flush();
            Session.Clear();

            // Assertions
            var fromDb = Session.Get<DriveSystem>(ds.Id);
            Assert.AreNotSame(ds, fromDb);
            Assert.AreEqual(ds.Name, fromDb.Name);
            Assert.AreEqual(ds.Equipments.Count, fromDb.Equipments.Count);
            // Assert that bag can really contain same equipment multiple times
            var temp = new List<string>(fromDb.Equipments);
            Assert.AreEqual(3, temp.FindAll(e => e == "Motor").Count);
        }
開發者ID:tasluk,項目名稱:hibernatingrhinos,代碼行數:23,代碼來源:DriveSystem_Fixture.cs

示例4: GivenBankAccount_WhenValidatingIban_ThenWrongStuctureForCountryResultsInValidationError

        public void GivenBankAccount_WhenValidatingIban_ThenWrongStuctureForCountryResultsInValidationError()
        {
            var expectedErrorMessage = ErrorMessages.IbanStructuralFailure;

            new BankAccountBuilder(this.DatabaseSession).WithIban("LV80B12K0000435195001").Build();

            List<IDerivationError> errors = new List<IDerivationError>(this.DatabaseSession.Derive().Errors);
            Assert.AreEqual(1, errors.FindAll(e => e.Message.Equals(expectedErrorMessage)).Count);
        }
開發者ID:Allors,項目名稱:apps,代碼行數:9,代碼來源:BankAccountTests.cs

示例5: GivenBankAccount_WhenValidatingIban_ThenWronglengthResultsInValidationError

        public void GivenBankAccount_WhenValidatingIban_ThenWronglengthResultsInValidationError()
        {
            var expectedErrorMessage = ErrorMessages.IbanLengthFailure;

            new BankAccountBuilder(this.DatabaseSession).WithIban("TR3300061005196457841326").Build();

            List<IDerivationError> errors = new List<IDerivationError>(this.DatabaseSession.Derive().Errors);
            Assert.AreEqual(1, errors.FindAll(e => e.Message.Equals(expectedErrorMessage)).Count);

            this.DatabaseSession.Rollback();

            new BankAccountBuilder(this.DatabaseSession).WithIban("TR3300061005197864578413268").Build();

            errors = new List<IDerivationError>(this.DatabaseSession.Derive().Errors);
            Assert.AreEqual(1, errors.FindAll(e => e.Message.Equals(expectedErrorMessage)).Count);
        }
開發者ID:Allors,項目名稱:apps,代碼行數:16,代碼來源:BankAccountTests.cs

示例6: GivenBankAccount_WhenValidatingIban_ThenInvalidIbanResultsInValidationError

        public void GivenBankAccount_WhenValidatingIban_ThenInvalidIbanResultsInValidationError()
        {
            var expectedErrorMessage = ErrorMessages.IbanIncorrect;

            new BankAccountBuilder(this.DatabaseSession).WithIban("TR330006100519716457841326").Build();

            List<IDerivationError> errors = new List<IDerivationError>(this.DatabaseSession.Derive().Errors);
            Assert.AreEqual(1, errors.FindAll(e => e.Message.Equals(expectedErrorMessage)).Count);
        }
開發者ID:Allors,項目名稱:apps,代碼行數:9,代碼來源:BankAccountTests.cs

示例7: GetFolderMappingFoldersRecursive_Returns_All_The_Folders_In_Folder_Tree

        public void GetFolderMappingFoldersRecursive_Returns_All_The_Folders_In_Folder_Tree()
        {
            var mockCache = MockComponentProvider.CreateNew<CachingProvider>();
            mockCache.Setup(c => c.GetItem(It.IsAny<string>())).Returns(null);

            var settings = new Hashtable();
            settings["SyncAllSubFolders"] = "true";

            _folderMappingController.Setup(c => c.GetFolderMappingSettings(It.IsAny<int>())).Returns(settings);

            var hostSettingsTable = new DataTable("HostSettings");
            var nameCol = hostSettingsTable.Columns.Add("SettingName");
            hostSettingsTable.Columns.Add("SettingValue");
            hostSettingsTable.Columns.Add("SettingIsSecure");
            hostSettingsTable.PrimaryKey = new[] { nameCol };

            _mockData.Setup(c => c.GetHostSettings()).Returns(hostSettingsTable.CreateDataReader());
            _mockData.Setup(c => c.GetProviderPath()).Returns(String.Empty);

            var folderMapping = new FolderMappingInfo { FolderMappingID = Constants.FOLDER_ValidFolderMappingID, FolderProviderType = Constants.FOLDER_ValidFolderProviderType };

            var subfolders = new List<string> { "folder/subfolder", "folder/subfolder2", "folder/subfolder2/subsubfolder", "folder/subfolder2/subsubfolder2" };

            _mockFolder.Setup(mf => mf.GetSubFolders(It.IsAny<string>(), folderMapping))
                .Returns<string, FolderMappingInfo>((parent, fm) => subfolders.FindAll(sub =>
                    sub.StartsWith(parent) &&
                    sub.Length > parent.Length &&
                    sub.Substring(parent.Length).IndexOf("/") == sub.Substring(parent.Length).LastIndexOf("/")));

            var result = _mockFolderManager.Object.GetFolderMappingFoldersRecursive(folderMapping, "folder/");

            Assert.AreEqual(5, result.Count);
        }
開發者ID:biganth,項目名稱:Curt,代碼行數:33,代碼來源:FolderManagerTests.cs

示例8: GetFileSystemFoldersRecursive_Sets_ExistsInFileSystem_For_All_Items

        public void GetFileSystemFoldersRecursive_Sets_ExistsInFileSystem_For_All_Items()
        {
            var relativePaths = new Dictionary<string, string>
                                    {
                                        {@"C:\folder", "folder/"},
                                        {@"C:\folder\subfolder", "folder/subfolder/"},
                                        {@"C:\folder\subfolder2", "folder/subfolder2/"},
                                        {@"C:\folder\subfolder2\subsubfolder", "folder/subfolder2/subsubfolder/"},
                                        {@"C:\folder\subfolder2\subsubfolder2", "folder/subfolder2/subsubfolder2/"}
                                    };

            _pathUtils.Setup(pu => pu.GetRelativePath(Constants.CONTENT_ValidPortalId, It.IsAny<string>()))
                .Returns<int, string>((portalID, physicalPath) => relativePaths[physicalPath]);

            var directories = new List<string> { @"C:\folder", @"C:\folder\subfolder", @"C:\folder\subfolder2", @"C:\folder\subfolder2\subsubfolder", @"C:\folder\subfolder2\subsubfolder2" };

            _directory.Setup(d => d.GetDirectories(It.IsAny<string>()))
                .Returns<string>(path => directories.FindAll(sub => sub.StartsWith(path + "\\") && sub.LastIndexOf("\\") == path.Length).ToArray());

            var result = _mockFolderManager.Object.GetFileSystemFoldersRecursive(Constants.CONTENT_ValidPortalId, @"C:\folder");

            foreach (var mergedTreeItem in result.Values)
            {
                Assert.True(mergedTreeItem.ExistsInFileSystem);
            }
        }
開發者ID:revellado,項目名稱:privateSocialGroups,代碼行數:26,代碼來源:FolderManagerTests.cs

示例9: GetDatabaseFoldersRecursive_Sets_ExistsInDatabase_For_All_Items

        public void GetDatabaseFoldersRecursive_Sets_ExistsInDatabase_For_All_Items()
        {
            _folderInfo.Setup(fi => fi.FolderPath).Returns("folder/");
            _folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);

            var subfolders = new List<IFolderInfo>
                                 {
                                     new FolderInfo() {FolderPath = "folder/subfolder/", FolderMappingID = Constants.FOLDER_ValidFolderMappingID},
                                     new FolderInfo() {FolderPath = "folder/subfolder2/", FolderMappingID = Constants.FOLDER_ValidFolderMappingID},
                                     new FolderInfo() {FolderPath = "folder/subfolder2/subsubfolder/", FolderMappingID = Constants.FOLDER_ValidFolderMappingID},
                                     new FolderInfo() {FolderPath = "folder/subfolder2/subsubfolder2/", FolderMappingID = Constants.FOLDER_ValidFolderMappingID}
                                 };

            _mockFolderManager.Setup(mfm => mfm.GetFolders(It.IsAny<IFolderInfo>()))
                .Returns<IFolderInfo>(parent => subfolders.FindAll(sub =>
                    sub.FolderPath.StartsWith(parent.FolderPath) &&
                    sub.FolderPath.Length > parent.FolderPath.Length &&
                    sub.FolderPath.Substring(parent.FolderPath.Length).IndexOf("/") == sub.FolderPath.Substring(parent.FolderPath.Length).LastIndexOf("/")));

            var result = _mockFolderManager.Object.GetDatabaseFoldersRecursive(_folderInfo.Object);

            foreach (var mergedTreeItem in result.Values)
            {
                Assert.True(mergedTreeItem.ExistsInDatabase);
            }
        }
開發者ID:revellado,項目名稱:privateSocialGroups,代碼行數:26,代碼來源:FolderManagerTests.cs

示例10: AssertValidResponse

        private static void AssertValidResponse(Response resp)
        {
            Assert.IsNotNull(resp);
            Assert.IsNotNull(resp.Contents);
            Assert.IsNotNull(resp.Properties);

            List<CustomProperty> props = new List<CustomProperty>(resp.Properties);

            List<CustomProperty> blackList = props.FindAll(delegate(CustomProperty cp)
            {
                return cp.Name.Contains("Error.");
            });

            Assert.AreEqual(0, blackList.Count);
        }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:15,代碼來源:PerfTestHelp.cs

示例11: CountItems

 private static int CountItems(List<DictionaryEntry> collection, string option)
 {
     return collection.FindAll(item => (string)item.Value == option).Count();
 }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:4,代碼來源:StaticShared.cs

示例12: TestSequence

        private void TestSequence(int eventId, List<EventRegType> regTypes, Dictionary<int, SortedDictionary<int, int>> bibsPerGroup, Dictionary<int, List<int>> groupsPerType)
        {
            //S.BibNumbersService svcBibs = new S.BibNumbersService();//this table is separate from regtypes, with 1-0 FK
            //E.TList<E.BibNumbers> bibNumbersAll = svcBibs.GetByEventId(eventId);

            //E.BibNumbers bibNumberEvent = bibNumbersAll.Find(b => b.RegTypeId == 0);
            List<BibNumber> bibNumbersAll = new List<BibNumber>();

            ClientDataContext db = new ClientDataContext();
            bibNumbersAll = (from b in db.BibNumbers where b.EventId == eventId select b).ToList();

            BibNumber bibNumberEvent = bibNumbersAll.Find(b => b.RegTypeId == 0);

            List<EventRegType> regTypesWithStartingNumbers = regTypes.FindAll(r =>
                (bibNumbersAll.Find(b => b.RegTypeId == r.Id) != null));

            List<EventRegType> regTypesWithDefaultStartingNumber = regTypes.FindAll(r =>
                (bibNumbersAll.Find(b => b.RegTypeId == r.Id) == null));

            foreach (EventRegType regType in regTypesWithStartingNumbers)
            {
                BibNumber bibNumbers = bibNumbersAll.Find(b => b.RegTypeId == regType.Id);
                int startingNumberPerRegType = bibNumbers.StartingNumber;
                IEnumerable<int> groups = groupsPerType[regType.Id];
                int[] bibs = CollectBibsOverGroups(bibsPerGroup, groups);

                //all the types grouped together?
                Array.Sort<int>(bibs);

                if (bibs[0] != startingNumberPerRegType)
                {
                    Assert.Fail(" starts with wrong value");
                }

                VerifyBibsAreGroupedTogether(bibs);
            }

            //now, the bibs which aren't in a special-numbered regtype
            int startingNumber = bibNumberEvent.StartingNumber;
            int[] bibsForEvent;
            List<int[]> bibCollection = new List<int[]>();
            int tally = 0;

            foreach (EventRegType regType in regTypesWithDefaultStartingNumber)
            {
                IEnumerable<int> groups = groupsPerType[regType.Id];
                int[] bibsPerType = CollectBibsOverGroups(bibsPerGroup, groups);
                tally += bibsPerType.Length;
                bibCollection.Add(bibsPerType);
            }

            //all the types grouped together?
            bibsForEvent = new int[tally];
            tally = 0;

            foreach (int[] bibsPerType in bibCollection)
            {
                bibsPerType.CopyTo(bibsForEvent, tally);
                tally += bibsPerType.Length;
            }

            Array.Sort<int>(bibsForEvent);

            if (bibsForEvent[0] != startingNumber)
            {
                Assert.Fail(" starts with wrong value");
            }

            VerifyBibsAreGroupedTogether(bibsForEvent);
        }
開發者ID:aliaksandr-trush,項目名稱:csharp-automaton,代碼行數:70,代碼來源:ReportManager.cs

示例13: OccurrencesInPara

		private List<int> OccurrencesInPara(int hvoPara, List<int> allOccurrences)
		{
			List<int> result = allOccurrences.FindAll(
				delegate(int hvoCba) { return Cache.GetObjProperty(hvoCba, kflidBeginObject) == hvoPara; });
			result.Sort(
				delegate(int left, int right)
				{ return Cache.GetIntProperty(left, kflidBeginOffset).CompareTo(
					Cache.GetIntProperty(right, kflidBeginOffset)); });
			return result;
		}
開發者ID:sillsdev,項目名稱:WorldPad,代碼行數:10,代碼來源:RespellingTests.cs

示例14: GetDatabaseFoldersRecursive_Sets_ExistsInFolderMappings_For_All_Items

        public void GetDatabaseFoldersRecursive_Sets_ExistsInFolderMappings_For_All_Items()
        {
            var folderMapping = new FolderMappingInfo { FolderMappingID = Constants.FOLDER_ValidFolderMappingID, FolderProviderType = Constants.FOLDER_ValidFolderProviderType };

            var subfolders = new List<string> { "folder/subfolder", "folder/subfolder2", "folder/subfolder2/subsubfolder", "folder/subfolder2/subsubfolder2" };

            _mockFolder.Setup(mf => mf.GetSubFolders(It.IsAny<string>(), folderMapping))
                .Returns<string, FolderMappingInfo>((parent, fm) => subfolders.FindAll(sub =>
                    sub.StartsWith(parent) &&
                    sub.Length > parent.Length &&
                    sub.Substring(parent.Length).IndexOf("/") == sub.Substring(parent.Length).LastIndexOf("/")));

            var result = _mockFolderManager.Object.GetFolderMappingFoldersRecursive(folderMapping, "folder/");

            foreach (var mergedTreeItem in result.Values)
            {
                Assert.True(mergedTreeItem.ExistsInFolderMappings.Contains(Constants.FOLDER_ValidFolderMappingID));
            }
        }
開發者ID:biganth,項目名稱:Curt,代碼行數:19,代碼來源:FolderManagerTests.cs

示例15: CompareOneWay

        static int CompareOneWay(IVersionComparer comparer, string version1, string version2)
        {
            // Arrange
            var a = SemanticVersion.Parse(version1);
            var b = SemanticVersion.Parse(version2);
            var c = StrictSemanticVersion.Parse(version1);
            var d = StrictSemanticVersion.Parse(version2);

            // Act
            var results = new List<int>();
            results.Add(comparer.Compare(a, b));
            results.Add(comparer.Compare(a, d));
            results.Add(comparer.Compare(c, b));
            results.Add(comparer.Compare(c, d));

            // Assert
            Assert.True(results.FindAll(x => x == results[0]).Count == results.Count);

            return results[0];
        }
開發者ID:OctopusDeploy,項目名稱:Octo.exe,代碼行數:20,代碼來源:VersionComparerFixture.cs


注:本文中的NUnit.Framework.List.FindAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。