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


C# List.Max方法代码示例

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


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

示例1: SaltSize

        public void SaltSize()
        {
            var sizes = new List<int>();

            for (int i = 0; i < 100; i++)
            {
                var salt = Current.GenerateSalt(Int32.MaxValue);

                sizes.Add(salt.Length);
            }

            Assert.IsTrue(sizes.Max() <= 33, "Max length = " + sizes.Max());
        }
开发者ID:Lacoste,项目名称:stackid,代码行数:13,代码来源:PasswordTests.cs

示例2: HashSize

        public void HashSize()
        {
            var sizes = new List<int>();

            string salt;
            for (int i = 0; i < 100; i++)
            {
                var hash = Current.SecureHash(Convert.ToBase64String(Current.Random(32)), out salt);

                sizes.Add(hash.Length);
            }

            Assert.IsTrue(sizes.Max() <= 32, "hash.Length = " + sizes.Max());
        }
开发者ID:Lacoste,项目名称:stackid,代码行数:14,代码来源:PasswordTests.cs

示例3: Should38

        public void Should38()
        {
            var times = new List<long>();

            var lines = File.ReadAllLines("C:\\tmp\\badphonenumber-clean.log");
            foreach (var line in lines)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var isValidNumber = IsValidNumber(line.Trim());
                stopwatch.Stop();
                if (isValidNumber)
                {
                    Console.WriteLine("{0}", line);
                }
                times.Add(stopwatch.ElapsedMilliseconds);
                Thread.Sleep(TimeSpan.FromMilliseconds(500));
            }

            var average = times.Average();
            var count = times.Count;
            var sum = times.Sum();
            var max = times.Max();
            Console.WriteLine("{0} ms. {1} numbers. {2} sum. {3} max", average, count, sum, max);
        }
开发者ID:lasl321,项目名称:phone-validation,代码行数:25,代码来源:Tests.cs

示例4: Can_get_lots_of_records_with_new_instantiation_every_time_test

        public void Can_get_lots_of_records_with_new_instantiation_every_time_test()
        {
            var times = new List<double>();

            for (int i = 0; i < 40; ++i)
            {
                var sw = Stopwatch.StartNew();
                var dapperDriver = new DapperDriver();
                var rows = dapperDriver.GetLotsOfRecords<TransactionHistory>();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}",
                times.Average(),
                times.Min(),
                times.Max());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
开发者ID:jeff-vera,项目名称:ef6-vs-dapper,代码行数:33,代码来源:DapperDriverTests.cs

示例5: Can_get_few_records_test

        public void Can_get_few_records_test()
        {
            var efDriver = new EFDriver();
            var times = new List<double>();

            for (int i = 0; i < 100; ++i)
            {
                var sw = Stopwatch.StartNew();
                var rows = efDriver.GetAFewRecords();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}, std dev: {3}, median: {4}",
                times.Average(),
                times.Min(),
                times.Max(),
                times.StandardDeviation(),
                times.Median());

            var timesSansMinAndMax = new List<double>();
            timesSansMinAndMax.AddRange(times);
            timesSansMinAndMax.Remove(timesSansMinAndMax.Min());
            timesSansMinAndMax.Remove(timesSansMinAndMax.Max());
            Console.WriteLine("average sans min & max: {0}",
                timesSansMinAndMax.Average());
        }
开发者ID:jeff-vera,项目名称:ef6-vs-dapper,代码行数:35,代码来源:EFDriverTests.cs

示例6: Can_get_lots_of_records_with_new_instantiation_every_time_test

        public void Can_get_lots_of_records_with_new_instantiation_every_time_test()
        {
            var times = new List<double>();

            for (int i = 0; i < 40; ++i)
            {
                var sw = Stopwatch.StartNew();
                var efDriver = new EFDriver();
                var rows = efDriver.GetLotsOfRecords();

                Assert.That(rows, Is.Not.Null);
                Assert.That(rows.Count(), Is.GreaterThan(0));

                sw.Stop();

                times.Add(sw.ElapsedMilliseconds);
                Console.WriteLine("took {0} ms to get {1} records",
                    sw.ElapsedMilliseconds,
                    rows.Count());
            }

            Console.WriteLine("average: {0}, min: {1}, max: {2}, std dev: {3}",
                times.Average(),
                times.Min(),
                times.Max(),
                times.StandardDeviation());
        }
开发者ID:jeff-vera,项目名称:ef6-vs-dapper,代码行数:27,代码来源:EFDriverTests.cs

示例7: TestNameTest

        public void TestNameTest()
        {
            var ints = new List<int> {1, 2, 3, 4, 5, 6};

            var filtered = ints.Where(x => x >= ints.Max() - 2);

            Assert.IsTrue(new[]{4,5,6}.SequenceEqual(filtered));
        }
开发者ID:CCInc,项目名称:TestWPF,代码行数:8,代码来源:LinqTests.cs

示例8: GetMaxPrimeFactorFor

        private static ulong GetMaxPrimeFactorFor(ulong number)
        {
            var primeFactors = new List<ulong>(0);

            for (ulong i = number; i * i < number; i++)
            {
                if (!IsPrime(i)) continue;

                if (number % i != 0) continue;

                primeFactors.Add(i);
            }

            return primeFactors.Max();
        }
开发者ID:jbtherasse,项目名称:euler-project,代码行数:15,代码来源:Problem3.cs

示例9: AggregatesTicksIntoSecondBars

        public void AggregatesTicksIntoSecondBars()
        {
            var timeProvider = new ManualTimeProvider(TimeZones.NewYork);
            var enumerator = new TradeBarBuilderEnumerator(Time.OneSecond, TimeZones.NewYork, timeProvider);

            // noon new york time
            var currentTime = new DateTime(2015, 10, 08, 12, 0, 0);
            timeProvider.SetCurrentTime(currentTime);

            // add some ticks
            var ticks = new List<Tick>
            {
                new Tick(currentTime, "SPY", 199.55m, 199, 200) {Quantity = 10},
                new Tick(currentTime, "SPY", 199.56m, 199.21m, 200.02m) {Quantity = 5},
                new Tick(currentTime, "SPY", 199.53m, 198.77m, 199.75m) {Quantity = 20},
                new Tick(currentTime, "SPY", 198.77m, 199.75m) {Quantity = 0},
                new Tick(currentTime, "SPY", 199.73m, 198.77m, 199.75m) {Quantity = 20},
                new Tick(currentTime, "SPY", 198.77m, 199.75m) {Quantity = 0},
            };

            foreach (var tick in ticks)
            {
                enumerator.ProcessData(tick);
            }

            // even though no data is here, it will still return true
            Assert.IsTrue(enumerator.MoveNext());
            Assert.IsNull(enumerator.Current);

            // advance a second
            currentTime = currentTime.AddSeconds(1);
            timeProvider.SetCurrentTime(currentTime);

            Assert.IsTrue(enumerator.MoveNext());
            Assert.IsNotNull(enumerator.Current);

            // in the spirit of not duplicating the above code 5 times (OHLCV, we'll assert these ere as well)
            var bar = (TradeBar)enumerator.Current;
            Assert.AreEqual(currentTime.AddSeconds(-1), bar.Time);
            Assert.AreEqual(currentTime, bar.EndTime);
            Assert.AreEqual("SPY", bar.Symbol.Value);
            Assert.AreEqual(ticks.First().LastPrice, bar.Open);
            Assert.AreEqual(ticks.Max(x => x.LastPrice), bar.High);
            Assert.AreEqual(ticks.Min(x => x.LastPrice), bar.Low);
            Assert.AreEqual(ticks.Last().LastPrice, bar.Close);
            Assert.AreEqual(ticks.Sum(x => x.Quantity), bar.Volume);
        }
开发者ID:hittudiv,项目名称:Lean,代码行数:47,代码来源:TradeBarBuilderEnumeratorTests.cs

示例10: MergePrsm

        private List<ProteinSpectrumMatch> MergePrsm(List<ProteinSpectrumMatch> targetList)
        {
            //var sortedList = targetList.OrderBy(prsm => prsm.ScanNum).ToList();
            //var minScan = sortedList.First().ScanNum;
            var maxScan = targetList.Max(prsm => prsm.ScanNum);

            var ret = new ProteinSpectrumMatch[maxScan + 1];
            foreach (var prsm in targetList)
            {
                var scan = prsm.ScanNum;

                if (ret[scan] == null)
                {
                    ret[scan] = prsm;
                }
                else
                {
                    if (prsm.SpectralEvalue < ret[scan].SpectralEvalue)
                        ret[scan] = prsm;
                }
            }

            return ret.Where(prsm => prsm != null).ToList();
        }
开发者ID:javamng,项目名称:GitHUB,代码行数:24,代码来源:AnalysisLewy.cs

示例11: maximum_inflight_is_respected

        public void maximum_inflight_is_respected(int limit)
        {
            var counts = new List<int>();
            long completed = 0;
            var _lock = new object();

            // ReSharper disable AccessToModifiedClosure
            _subject.AddConsumer(s => {
                Thread.Sleep(15);
                lock (_lock) { counts.Add(_subject.CurrentInflight()); }
                Interlocked.Increment(ref completed);
                Thread.Sleep(15);
            });
            // ReSharper restore AccessToModifiedClosure

            _subject.SetMaximumInflight(limit);
            _subject.Start();

            const int runs = 100;
            for (int i = 0; i < runs; i++) { _subject.AddWork(""); }

            while (Interlocked.Read(ref completed) < runs)
            {
                Thread.Sleep(500);
            }
            _subject.Stop();

            Assert.That(counts.Count(), Is.GreaterThan(0), "No actions ran");
            Assert.That(counts.Min(), Is.GreaterThan(0), "Inflight count is invalid");
            Assert.That(counts.Max(), Is.LessThanOrEqualTo(limit), "More workers run in parallel than limit");
        }
开发者ID:kalotay,项目名称:DispatchSharp,代码行数:31,代码来源:Threaded_InMemory_tests.cs

示例12: WriteCommandList_should_include_all_commands_and_descriptions

        public void WriteCommandList_should_include_all_commands_and_descriptions()
        {
            //  arrange
            var commandList = new List<ICommand> {
                new MockCommand1(),
                new MockCommand1()
            };
            int maxCommandNameLength = commandList.Max(x => x.CommandName.Length);

            //  act
            _helpWriter.WriteCommandList(commandList);

            //  assert
            string expectedOutput = "\r\nAvailable commands:\r\n" +
                                    "  " + commandList[0].CommandName.PadRight(maxCommandNameLength + 4) + commandList[0].Description + "\r\n" +
                                    "  " + commandList[1].CommandName.PadRight(maxCommandNameLength + 4) + commandList[1].Description + "\r\n";
            Assert.AreEqual(expectedOutput, _logger.Output);
        }
开发者ID:jpoehls,项目名称:dotnetmigrations,代码行数:18,代码来源:CommandHelpWriterUnitTests.cs

示例13: BenchSingleAdd

		public void BenchSingleAdd()
		{
			Database.RegisterDataObject(typeof(TestTable));
			Database.RegisterDataObject(typeof(TestTableRelations));
			Database.RegisterDataObject(typeof(TestTableRelationsEntries));

			Database.DeleteObject(Database.SelectAllObjects<TestTable>());
			Database.DeleteObject(Database.SelectAllObjects<TestTableRelations>());
			Database.DeleteObject(Database.SelectAllObjects<TestTableRelationsEntries>());
			
			Assert.IsEmpty(Database.SelectAllObjects<TestTable>(), "Database shouldn't have any record For TestTable.");
			Assert.IsEmpty(Database.SelectAllObjects<TestTableRelations>(), "Database shouldn't have any record For TestTable.");
			Assert.IsEmpty(Database.SelectAllObjects<TestTableRelationsEntries>(), "Database shouldn't have any record For TestTable.");
			
			var objs = Enumerable.Range(0, 100).Select(i => new TestTable { TestField = string.Format("Bench Single Add '{0}'", i) }).ToArray();

			var times = new List<long>();
			foreach (var obj in objs)
			{
				var stopWatch = Stopwatch.StartNew();
				Database.AddObject(obj);
				stopWatch.Stop();
				times.Add(stopWatch.ElapsedMilliseconds);
			}
						
			var relationObjs = Enumerable.Range(0, 100).Select(i => new TestTableRelations { TestField = string.Format("Bench Single Relations Add '{0}'", i) }).ToArray();
			foreach (var obj in relationObjs)
				obj.Entries = Enumerable.Range(0, 5).Select(i => new TestTableRelationsEntries { ForeignTestField = obj.ObjectId }).ToArray();
			
			var timesRelations =  new List<long>();
			foreach (var obj in relationObjs)
			{
				var stopWatch = Stopwatch.StartNew();
				Database.AddObject(obj);
				stopWatch.Stop();
				timesRelations.Add(stopWatch.ElapsedMilliseconds);
			}

			Console.WriteLine("Bench Single TestTable Add Total Elapse {3}ms, Average {0}ms, Min {1}ms, Max {2}ms", times.Average(), times.Min(), times.Max(), times.Sum());
			Console.WriteLine("Bench Single TestTableRelations Add Total Elapse {3}ms, Average {0}ms, Min {1}ms, Max {2}ms", timesRelations.Average(), timesRelations.Min(), timesRelations.Max(), timesRelations.Sum());
		}
开发者ID:dol-leodagan,项目名称:DOLSharp,代码行数:41,代码来源:InterfaceTests.cs

示例14: ListExtensions_Max_ThrowsExceptionIfListIsEmpty

        public void ListExtensions_Max_ThrowsExceptionIfListIsEmpty()
        {
            var list = new List<Int32>();

            Assert.That(() => list.Max(),
                Throws.TypeOf<InvalidOperationException>());
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:7,代码来源:ListExtensionsTest.cs

示例15: ListExtensions_Max_ReturnsMaxValue

        public void ListExtensions_Max_ReturnsMaxValue()
        {
            var list = new List<Int32>() { 4, 5, 6, 99, 10, 1, 12, 45 };

            var result = list.Max();

            TheResultingValue(result).ShouldBe(99);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:ListExtensionsTest.cs


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