本文整理汇总了C#中NUnit.Framework.List.Min方法的典型用法代码示例。如果您正苦于以下问题:C# List.Min方法的具体用法?C# List.Min怎么用?C# List.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Min方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateEquityCurve
public void CalculateEquityCurve()
{
var deals = new List<MarketOrder>();
var dealsOpen = TestDataGenerator.GetOpenPosition().Select(LinqToEntity.DecorateOrder).ToList();
var dealsClose = TestDataGenerator.GetClosePosition().Select(LinqToEntity.DecorateOrder).ToList();
deals.AddRange(dealsOpen);
deals.AddRange(dealsClose);
var transfers = TestDataGenerator.GetBalanceChange().Select(LinqToEntity.DecorateBalanceChange).ToList();
var firstDealOpenedTime = deals.Min(d => d.TimeEnter);
transfers.Insert(0, new BalanceChange
{
AccountID = deals[0].AccountID,
ValueDate = firstDealOpenedTime.AddHours(-1),
CurrencyToDepoRate = 1,
ChangeType = BalanceChangeType.Deposit,
Amount = 500000
});
var dicQuote = new Dictionary<string, List<QuoteData>>();
foreach (var smb in DalSpot.Instance.GetTickerNames())
dicQuote.Add(smb, dailyQuoteStorage.GetQuotes(smb).Select(q => new QuoteData(q.b, q.b, q.a)).ToList());
var quoteArc = new QuoteArchive(dicQuote);
var res = curveCalculator.CalculateEquityCurve(deals, DepoCurrency, quoteArc, transfers);
// сверить точку кривой доходности
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 0);
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 10);
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 40);
}
示例2: 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());
}
示例3: 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());
}
示例4: 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());
}
示例5: 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);
}
示例6: Can_GetSetCountByScores
public void Can_GetSetCountByScores()
{
var scores = new List<double>();
storeMembers.ForEach(x =>
{
Redis.AddItemToSortedSet(SetId, x);
scores.Add(RedisClient.GetLexicalScore(x));
});
Assert.That(Redis.GetSortedSetCount(SetId, scores.Min(), scores.Max()), Is.EqualTo(storeMembers.Count()));
Assert.That(Redis.GetSortedSetCount(SetId, scores.Min(), scores.Min()), Is.EqualTo(1));
}
示例7: IntersectBox
public static double IntersectBox(Box box, Ray ray)
{
Ball ball = GetExternalSphere(box);
if (double.IsPositiveInfinity(IntersectBall(ball, ray)))
return double.PositiveInfinity;
else
{
var points = new List<Point3D>();
var vertex = GetVertex(box);
int[][] order = new int[12][];
order[0] = new[] {0, 2, 1};
order[1] = new[] {1, 2, 4};
order[2] = new[] {0, 5, 2};
order[3] = new[] {0, 3, 5};
order[4] = new[] {0, 3, 1};
order[5] = new[] {1, 3, 6};
order[6] = new[] {3, 5, 6};
order[7] = new[] {6, 5, 7};
order[8] = new[] {1, 6, 7};
order[9] = new[] {1, 7, 4};
order[10] = new[] {2, 5, 7};
order[11] = new[] {2, 7, 4};
for (int i = 0; i < 12; i++)
{
Point3D? point = TriangleIntersection.IntersectTriangle(vertex[order[i][0]], vertex[order[i][1]],
vertex[order[i][2]], ray);
if (point != null)
points.Add(point.Value);
else
{
point = TriangleIntersection.IntersectTriangle(vertex[order[i][0]], vertex[order[i][2]],
vertex[order[i][1]], ray);
if (point != null)
points.Add(point.Value);
}
}
if (points.Capacity == 0)
{
return double.PositiveInfinity;
}
return points.Min(a => ray.Origin.Hypot(a));
}
}
示例8: 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());
}
示例9: ListExtensions_Min_ThrowsExceptionIfListIsEmpty
public void ListExtensions_Min_ThrowsExceptionIfListIsEmpty()
{
var list = new List<Int32>();
Assert.That(() => list.Min(),
Throws.TypeOf<InvalidOperationException>());
}
示例10: ListExtensions_Min_ReturnsMinValue
public void ListExtensions_Min_ReturnsMinValue()
{
var list = new List<Int32>() { 4, 5, 6, 99, 10, 1, 12, 45 };
var result = list.Min();
TheResultingValue(result).ShouldBe(1);
}
示例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");
}