本文整理汇总了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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
示例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();
}
示例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);
}
示例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();
}
示例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");
}
示例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);
}
示例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());
}
示例14: ListExtensions_Max_ThrowsExceptionIfListIsEmpty
public void ListExtensions_Max_ThrowsExceptionIfListIsEmpty()
{
var list = new List<Int32>();
Assert.That(() => list.Max(),
Throws.TypeOf<InvalidOperationException>());
}
示例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);
}