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


C# List.ConvertAll方法代码示例

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


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

示例1: SmoothPursuitPositiveQuadrant

        public void SmoothPursuitPositiveQuadrant()
        {
            var results = new List<PanTiltTime>();
            var sut = GetSystemUnderTest();
            var resolution = 100;

            var tickEveryMs = Convert.ToInt32(sut.TimeSpan.TotalMilliseconds/resolution);
            var time = TimeSpan.FromSeconds(0);
            var tick = TimeSpan.FromMilliseconds(tickEveryMs);

            for (var timeMs = 0; timeMs <= sut.TimeSpan.TotalMilliseconds; timeMs += tickEveryMs)
            {
                var result = new PanTiltTime();
                time += tick;
                _mockStopwatch.Set(time);
                result.TimeSpan = time;
                result.Setting = sut.GetNextPosition();

                results.Add(result);
            }

            var panPoints = results.ConvertAll(p => p.ToCsv(PanTiltAxis.Horizontal));
            var tiltPoints = results.ConvertAll(p => p.ToCsv(PanTiltAxis.Vertical));

            var csvPan = string.Join("\r\n", panPoints);
            var csvTilt = string.Join("\r\n", tiltPoints);

            Console.WriteLine($"Pan:\r\n{csvPan}");

            Console.WriteLine($"Tilt:\r\n{csvTilt}");
        }
开发者ID:neutmute,项目名称:PiCamCV,代码行数:31,代码来源:TimeTargetFixture.cs

示例2: AssertSequencePattern

        public void AssertSequencePattern()
        {
            var dummy = new DummySequencer();
            var goalDistance = 3;
            var lastTrainingDistance = 2;
            var lastRestituteDistance = 0;
            var repeat = 1;
            var e = new SimpleGoaledSequencer<int>(goalDistance, lastTrainingDistance, lastRestituteDistance, repeat, Comparer<int>.Default, dummy);
            var distances = new List<int>();
            while (e.MoveNext())
            {
                var next = e.Current;
                distances.Add(next);
            }

            var expected = "1,2,3";
            var actual = string.Join(",", distances.ConvertAll(x => x.ToString()).ToArray());
            Assert.AreEqual(expected, actual);

            goalDistance = 5;
            repeat = 3;
            lastTrainingDistance = 4;
            expected = "1,2,3,4,4,4,5";
            distances.Clear();
            e = new SimpleGoaledSequencer<int>(goalDistance, lastTrainingDistance, lastRestituteDistance, repeat, Comparer<int>.Default, dummy);
            while (e.MoveNext())
            {
                var next = Convert.ToInt32(e.Current);
                distances.Add(next);
            }
            actual = string.Join(",", distances.ConvertAll(x => x.ToString()).ToArray());
            Assert.AreEqual(expected, actual);
        }
开发者ID:1pindsvin,项目名称:yagni,代码行数:33,代码来源:SimpleGoaledSequenceTester.cs

示例3: TestClassifyPeptideHit

    public void TestClassifyPeptideHit()
    {
      List<IIdentifiedSpectrum> spectra = new List<IIdentifiedSpectrum>();
      spectra.Add(new IdentifiedSpectrum() { Rank = 1 });
      spectra.Add(new IdentifiedSpectrum() { Rank = 1 });
      spectra.Add(new IdentifiedSpectrum() { Rank = 2 });
      spectra.Add(new IdentifiedSpectrum() { Rank = 2 });

      new IdentifiedPeptide(spectra[0]) { Sequence = "SE*Q" };
      new IdentifiedPeptide(spectra[1]) { Sequence = "SEQ" };
      new IdentifiedPeptide(spectra[2]) { Sequence = "SEQSEQ" };
      new IdentifiedPeptide(spectra[3]) { Sequence = "SEQSEQSEQ" };

      CalculationItem item = new CalculationItem()
      {
        Peptides = spectra.ConvertAll(m => m.Peptide).ToList()
      };


      item.ClassifyPeptideHit(m => m.Spectrum.Rank.ToString(), new string[] { "1", "2" });

      Assert.AreEqual(2, item.Classifications.Count);
      Assert.AreEqual(2, item.Classifications["1"].PeptideCount);
      Assert.AreEqual(1, item.Classifications["1"].UniquePeptideCount);
      Assert.AreEqual(2, item.Classifications["2"].PeptideCount);
      Assert.AreEqual(2, item.Classifications["2"].UniquePeptideCount);
    }
开发者ID:shengqh,项目名称:RCPA.Test,代码行数:27,代码来源:TestCalculationItem.cs

示例4: Can_Delete_from_basic_persistence_provider

        public void Can_Delete_from_basic_persistence_provider()
        {
            using (var db = ConnectionString.OpenDbConnection())
            using (var dbCmd = db.CreateCommand())
            {
                dbCmd.CreateTable<ModelWithFieldsOfDifferentTypes>(true);

                var basicProvider = new OrmLitePersistenceProvider(db);

                var rowIds = new List<int> { 1, 2, 3, 4, 5 };

                var rows = rowIds.ConvertAll(x => ModelWithFieldsOfDifferentTypes.Create(x));

                rows.ForEach(x => dbCmd.Insert(x));

                var deleteRowIds = new List<int> { 2, 4 };

                foreach (var row in rows)
                {
                    if (deleteRowIds.Contains(row.Id))
                    {
                        basicProvider.Delete(row);
                    }
                }

                var providerRows = basicProvider.GetByIds<ModelWithFieldsOfDifferentTypes>(rowIds).ToList();
                var providerRowIds = providerRows.ConvertAll(x => x.Id);

                var remainingIds = new List<int>(rowIds);
                deleteRowIds.ForEach(x => remainingIds.Remove(x));

                Assert.That(providerRowIds, Is.EquivalentTo(remainingIds));
            }
        }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:34,代码来源:OrmLiteBasicPersistenceProviderTests.cs

示例5: Can_support_64_threads_using_the_client_simultaneously

        public void Can_support_64_threads_using_the_client_simultaneously()
        {
            var before = Stopwatch.GetTimestamp();

            const int noOfConcurrentClients = 64; //WaitHandle.WaitAll limit is <= 64

#if NETCORE
            List<Task> tasks = new List<Task>();
#else
            var clientAsyncResults = new List<IAsyncResult>();
#endif             
            using (var redisClient = new RedisClient(TestConfig.SingleHost))
            {
                for (var i = 0; i < noOfConcurrentClients; i++)
                {
                    var clientNo = i;
                    var action = (Action)(() => UseClientAsync(redisClient, clientNo));
#if NETCORE
                    tasks.Add(Task.Run(action));
#else                                       
                    clientAsyncResults.Add(action.BeginInvoke(null, null));
#endif
                }
            }
#if NETCORE
            Task.WaitAll(tasks.ToArray());
#else            
            WaitHandle.WaitAll(clientAsyncResults.ConvertAll(x => x.AsyncWaitHandle).ToArray());
#endif
            Debug.WriteLine(String.Format("Time Taken: {0}", (Stopwatch.GetTimestamp() - before) / 1000));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Redis,代码行数:31,代码来源:MultiThreadedRedisClientIntegrationTests.cs

示例6: Can_support_64_threads_using_the_client_simultaneously

		public void Can_support_64_threads_using_the_client_simultaneously()
		{
			var before = Stopwatch.GetTimestamp();

			const int noOfConcurrentClients = 64; //WaitHandle.WaitAll limit is <= 64

			var clientAsyncResults = new List<IAsyncResult>();
			using (var manager = new PooledRedisClientManager(TestConfig.MasterHosts, TestConfig.SlaveHosts))
			{
				manager.GetClient().Run(x => x.FlushAll());

				for (var i = 0; i < noOfConcurrentClients; i++)
				{
					var clientNo = i;
					var action = (Action)(() => UseClientAsync(manager, clientNo));
					clientAsyncResults.Add(action.BeginInvoke(null, null));
				}
			}

			WaitHandle.WaitAll(clientAsyncResults.ConvertAll(x => x.AsyncWaitHandle).ToArray());

			Debug.WriteLine(string.Format("Completed in {0} ticks", (Stopwatch.GetTimestamp() - before)));

            RedisStats.ToDictionary().PrintDump();
		}
开发者ID:hucm90,项目名称:ServiceStack.Redis,代码行数:25,代码来源:RedisRegressionTestRun.cs

示例7: RunSimultaneously

        protected void RunSimultaneously(
            Func<string[], string[], IRedisClientsManager> clientManagerFactory,
            Action<IRedisClientsManager, int> useClientFn)
        {
            var before = Stopwatch.GetTimestamp();

            const int noOfConcurrentClients = 64; //WaitHandle.WaitAll limit is <= 64

#if NETCORE
            List<Task> tasks = new List<Task>();
#else
            var clientAsyncResults = new List<IAsyncResult>();
#endif             
            using (var manager = clientManagerFactory(TestConfig.MasterHosts, TestConfig.SlaveHosts))
            {
                for (var i = 0; i < noOfConcurrentClients; i++)
                {
                    var clientNo = i;
                    var action = (Action)(() => useClientFn(manager, clientNo));
#if NETCORE
                    tasks.Add(Task.Run(action));
#else                                       
                    clientAsyncResults.Add(action.BeginInvoke(null, null));
#endif
                }
            }

#if NETCORE
            Task.WaitAll(tasks.ToArray());
#else            
            WaitHandle.WaitAll(clientAsyncResults.ConvertAll(x => x.AsyncWaitHandle).ToArray());
#endif

            Debug.WriteLine(String.Format("Time Taken: {0}", (Stopwatch.GetTimestamp() - before) / 1000));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Redis,代码行数:35,代码来源:IntegrationTestBase.cs

示例8: AssertRepetitionProgressionPattern

        public void AssertRepetitionProgressionPattern()
        {
            const int pauseAfter = 20;
            const int start = 1;

            Func<int, int> progression = x => x + 1;

            var repetitionExpectedResultPair = new Dictionary<int, string>
                                                   {
                                                       {1, "1,2,3,4,5,6,7,8,9,10,11,12"},
                                                       {2, "1,1,2,2,3,3,4,4,5,5,6,6"},
                                                       {4, "1,1,1,1,2,2,2,2,3,3,3,3"}
                                                   };

            foreach (var pair in repetitionExpectedResultPair)
            {
                var repititions = pair.Key;
                var expected = pair.Value;

                var e = new Sequencer<int>(start, repititions, pauseAfter, progression);
                var results = new List<int>();
                const int noOfElements = 12;

                for (var i = 0; i < noOfElements; i++)
                {
                    e.MoveNext();
                    var next = e.Current;
                    results.Add(next);
                }
                var distances = string.Join(",", results.ConvertAll(x => x.ToString()).ToArray());
                Assert.AreEqual(expected, distances);
            }
        }
开发者ID:1pindsvin,项目名称:yagni,代码行数:33,代码来源:SequencerTester.cs

示例9: GetAllAssemblies

 private List<Assembly> GetAllAssemblies(string path)
 {
     var files = new List<FileInfo>();
     var directoryToSearch = new DirectoryInfo(path);
     files.AddRange(directoryToSearch.GetFiles("*.dll", SearchOption.AllDirectories));
     files.AddRange(directoryToSearch.GetFiles("*.exe", SearchOption.AllDirectories));
     return files.ConvertAll(file => Assembly.LoadFile(file.FullName));
 }
开发者ID:jduar005,项目名称:FizzBuzz,代码行数:8,代码来源:UtilityTest.cs

示例10: ConvertAll_LinqExt

		public void ConvertAll_LinqExt ()
		{
			// Convert list of ints into list of doubles.
			var sampleObjNumbers = new List<int> (){ 1,2,3,4,5,6,7,8,9,10};
			var sampleIntNumbers = sampleObjNumbers.ConvertAll<double> (x => Convert.ToDouble (x));

			Assert.AreEqual (10, sampleIntNumbers.Count ());
			Assert.IsInstanceOfType (typeof(List<double>), sampleIntNumbers);
			Assert.IsInstanceOfType (typeof(double), sampleIntNumbers.First ());
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:10,代码来源:Conversions.cs

示例11: CalculatePopulateWithHiddenObject

        /// <summary>
        /// Calculates the nodes that should be visible in the main window tree view when the specified xen object is hidden.
        /// </summary>
        /// <param name="hiddenObject">The hidden object.</param>
        private ComparableList<IXenObject> CalculatePopulateWithHiddenObject(IXenObject hiddenObject)
        {
            VirtualTreeNode rootNode = MW(() => new MainWindowTreeBuilder(new FlickerFreeTreeView()).CreateNewRootNode(new NavigationPane().Search, NavigationPane.NavigationMode.Infrastructure));

            List<VirtualTreeNode> nodes = new List<VirtualTreeNode>(rootNode.Descendants);

            nodes.RemoveAll(n => hiddenObject.Equals(n.Tag));
            nodes.RemoveAll(n => new List<VirtualTreeNode>(n.Ancestors).Find(nn => hiddenObject.Equals(nn.Tag)) != null);
            return new ComparableList<IXenObject>(nodes.ConvertAll(n => (IXenObject)n.Tag));
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:14,代码来源:ShowHideTests.cs

示例12: Can_Get_UrlHostName

        public void Can_Get_UrlHostName()
        {
            var urls = new List<string> { "http://localhost/a", "https://localhost/a",
                "http://localhost:81", "http://localhost:81/", "http://localhost" };

            var httpReqs = urls.ConvertAll(x => new MockUrlHttpRequest { AbsoluteUri = x });
            var hostNames = httpReqs.ConvertAll(x => x.GetUrlHostName());

            Console.WriteLine(hostNames.Dump());

            Assert.That(hostNames.All(x => x == "localhost"));
        }
开发者ID:nuxleus,项目名称:ServiceStack,代码行数:12,代码来源:ServiceStackHandlerUrlTests.cs

示例13: ScaledInput

        public void ScaledInput(List<object> samples, List<double> labels)
        {
            var people = samples.ConvertAll(x => (Person)x);
            var age = new { Mean = people.Select(x => x.Age).Average(), Deviation = Math.Sqrt( ((double)1/(people.Count - 1)) * people.Select(x => Math.Pow(x.Age - people.Select(xx => xx.Age).Average(), 2)).Sum() ) };
            var height = new { Mean = people.Select(x => x.Height).Average(), Deviation = Math.Sqrt(((double)1 / (people.Count - 1)) * people.Select(x => Math.Pow(x.Height - people.Select(xx => xx.Height).Average(), 2)).Sum()) };

            var algorithm = new FakeAlgorithm(people, labels, new Settings {InputSplitRatio = InputSplitRatio.No});

            Assert.That(algorithm.MyTrainingSetX[0, 0], Is.EqualTo(1), "A column of ones should be added to the input matrix.");
            Assert.That(algorithm.MyTrainingSetX[0, 1], Is.EqualTo(  (people[0].Age - age.Mean) / age.Deviation ));
            Assert.That(algorithm.MyTrainingSetX[0, 2], Is.EqualTo(  (people[0].Height - height.Mean) / height.Deviation ));
            Assert.That(algorithm.MyTrainingSetY[0], Is.EqualTo(labels[0]));
        }
开发者ID:andreister,项目名称:NMachine,代码行数:13,代码来源:AbstractAlgorithmTests.cs

示例14: DefaultInputSplit

        public void DefaultInputSplit(List<object> samples, List<double> labels)
        {
            var people = samples.ConvertAll(x => (Person)x);
            var trainingSetSize = (int)Math.Ceiling(((double)2 / 3) * people.Count);
            var crossValidationSetSize = (int)Math.Ceiling(((double)2 / 3) * people.Count);

            var algorithm = new FakeAlgorithm(people, labels, new Settings {ScaleAndNormalize = false});

            AssertInput(algorithm.MyTrainingSetX, algorithm.MyTrainingSetY, people, labels, 0, trainingSetSize);
            AssertInput(algorithm.MyCrossValidationSetX, algorithm.MyCrossValidationSetY, people, labels, trainingSetSize, crossValidationSetSize);
            Assert.That(algorithm.MyTestSetX, Is.Null);
            Assert.That(algorithm.MyTestSetY, Is.Null);
        }
开发者ID:andreister,项目名称:NMachine,代码行数:13,代码来源:AbstractAlgorithmTests.cs

示例15: AssertSequence

        public void AssertSequence()
        {
            var dummy = new DummySequencer();
            var e = new GoaledSequencer<int>(10, 8, 7, 3, Comparer<int>.Default, dummy);
            var numbers = new List<int>();
            e.Reset();
            while (e.MoveNext())
            {
                numbers.Add(e.Current);
            }

            const string expected = "1,2,3,4,5,6,7,8,8,8,7,7,7,10";
            var actual = string.Join(",", numbers.ConvertAll(x => x.ToString()).ToArray());
            Assert.AreEqual(expected,actual);
        }
开发者ID:1pindsvin,项目名称:yagni,代码行数:15,代码来源:GoaledSequenceTester.cs


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