当前位置: 首页>>代码示例>>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;未经允许,请勿转载。