本文整理汇总了C#中Range.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Contains方法的具体用法?C# Range.Contains怎么用?C# Range.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsValue
public void ContainsValue()
{
var target = new Range<int>(10, 20);
Assert.IsTrue(target.Contains(10));
Assert.IsTrue(target.Contains(20));
Assert.IsTrue(target.Contains(14));
}
示例2: DefaultComparerExcludingStart
public void DefaultComparerExcludingStart()
{
var subject = new Range<int>(0, 5).ExcludeStart();
Assert.IsFalse(subject.IncludesStart);
Assert.IsTrue(subject.IncludesEnd);
Assert.IsFalse(subject.Contains(0));
Assert.IsTrue(subject.Contains(1));
Assert.IsTrue(subject.Contains(5));
}
示例3: ExcludeBothEnds
public void ExcludeBothEnds()
{
var subject = new Range<int>(0, 5).ExcludeStart().ExcludeEnd();
Assert.IsFalse(subject.IncludesStart);
Assert.IsFalse(subject.IncludesEnd);
Assert.IsFalse(subject.Contains(0));
Assert.IsTrue(subject.Contains(1));
Assert.IsFalse(subject.Contains(5));
}
示例4: CheckContainment
public void CheckContainment()
{
var range = new Range<int>(3, 10);
Assert.IsTrue(range.Contains(5));
Assert.IsTrue(range.Contains(3));
Assert.IsTrue(range.Contains(10));
Assert.IsFalse(range.Contains(-3));
Assert.IsFalse(range.Contains(20));
}
示例5: CustomComparer
public void CustomComparer()
{
var subject = new Range<string>("a", "e", StringComparer.Ordinal);
Assert.IsFalse(subject.Contains("B"));
Assert.IsTrue(subject.Contains("b"));
subject = new Range<string>("a", "e", StringComparer.OrdinalIgnoreCase);
Assert.IsTrue(subject.Contains("B"));
Assert.IsTrue(subject.Contains("A"));
Assert.IsTrue(subject.Contains("E"));
Assert.IsFalse(subject.Contains("F"));
}
示例6: ContainsShouldFailIfItIsNotInRange
public void ContainsShouldFailIfItIsNotInRange()
{
var range = new Range<int>(1, 3);
Assert.False(range.Contains(0));
Assert.False(range.Contains(4));
range = new Range<int>(null, 3);
Assert.False(range.Contains(4));
range = new Range<int>(1);
Assert.False(range.Contains(0));
}
示例7: ContainsShouldSuccessIfItIsAtLimit
public void ContainsShouldSuccessIfItIsAtLimit()
{
var range = new Range<int>(1, 3);
Assert.True(range.Contains(1));
Assert.True(range.Contains(2));
Assert.True(range.Contains(3));
range = new Range<int>(null, 3);
Assert.True(range.Contains(int.MinValue));
Assert.True(range.Contains(3));
range = new Range<int>(1);
Assert.True(range.Contains(1));
Assert.True(range.Contains(int.MaxValue));
}
示例8: Contains
public void Contains(string range, double value, bool expected)
{
// Parse
var minmax = range.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim())
.ToArray();
var minIsInclusive = minmax[0][0] == '[';
var maxIsInclusive = minmax[1][minmax[1].Length - 1] == ']';
var minStr = minmax[0].Substring(1);
var maxStr = minmax[1].Substring(0, minmax[1].Length - 1);
double? min = null, max = null;
if (minStr != "-∞")
{
min = double.Parse(minStr, NumberStyles.Float, CultureInfo.InvariantCulture);
}
if (maxStr != "+∞")
{
max = double.Parse(maxStr, NumberStyles.Float, CultureInfo.InvariantCulture);
}
// Test
var target = new Range(min, max) {MinIsInclusive = minIsInclusive, MaxIsInclusive = maxIsInclusive};
var actual = target.Contains(value);
Assert.AreEqual(expected, actual);
}
示例9: LogDetailsPageModel
protected LogDetailsPageModel(BatNodeLog batLog)
{
EditLogCommand = new RelayCommand(() => _navigationService.EditLog(BatLog));
BatLog = batLog;
_batCalls = new List<BatCall>();
FrequencyRange = new Range<uint>(0, 100);
FrequencyRange.PropertyChanged += async (s, e) => await UpdateBins();
IntensityRange = new Range<uint>(0, 1024);
IntensityRange.PropertyChanged += async (s, e) => await UpdateBins();
DurationRange = new Range<uint>(0, 100);
DurationRange.PropertyChanged += async (s, e) => await UpdateBins();
TimeRange = new Range<uint>(0, 100);
TimeRange.PropertyChanged += async (s, e) => await UpdateBins();
//BUG!
Func<BatCall, bool> filter = c => IntensityRange.Contains(c.MaxPower) && FrequencyRange.Contains(c.MaxFrequency) && DurationRange.Contains(c.Duration / 1000) && TimeRange.Contains(c.StartTimeMs);
FreqBins = new UintBinCollection(100, b => (uint)b.MaxFrequency, filter);
IntensityBins = new UintBinCollection(200, b => (uint)b.MaxPower, filter);
CallDurationBins = new UintBinCollection(100, b => b.Duration / 1000, filter);
TimeBins = new TimeCallBinCollection(200, batLog.LogStart, filter);
}
示例10: Contains_should_return_true
public void Contains_should_return_true()
{
// Arrange
var a = new Range<int>(1, 6);
// Act
var actual = a.Contains(4);
// Assert
actual.Should().BeTrue();
}
示例11: Element_should_not_be_in_range_when_its_equal_to_upper_bound_and_its_not_inclusive
public void Element_should_not_be_in_range_when_its_equal_to_upper_bound_and_its_not_inclusive()
{
var expectedLowerBound = 0;
var expectedUpperBound = 1;
var expectedElement = 1;
var target = new Range<int>(expectedLowerBound, false, expectedUpperBound, false);
var actual = target.Contains(expectedElement);
Assert.That(actual, Is.False);
}
示例12: Element_should_not_be_in_range_when_its_not_between_lower_and_upper_bound
public void Element_should_not_be_in_range_when_its_not_between_lower_and_upper_bound()
{
var expectedLowerBound = 0;
var expectedUpperBound = 1;
var expectedElement = 2;
var target = new Range<int>(expectedLowerBound, expectedUpperBound);
var actual = target.Contains(expectedElement);
Assert.That(actual, Is.False);
}
示例13: RangeDoesContainItemUpperBounds
public void RangeDoesContainItemUpperBounds()
{
var range1 = new Range<int>(3, 10);
Assert.IsTrue(range1.Contains(10));
}
示例14: contains_range
public void contains_range() {
var a = new Range(1, 5);
var b = new Range(1, 3);
var c = new Range(2, 5);
var d = new Range(2, 4);
var e = new Range(2, 6);
var f = new Range(7, 9);
Assert.True(a.Contains(a));
Assert.True(a.Contains(b));
Assert.False(b.Contains(a));
Assert.True(a.Contains(c));
Assert.False(c.Contains(a));
Assert.True(a.Contains(d));
Assert.False(d.Contains(a));
Assert.False(a.Contains(e));
Assert.False(e.Contains(a));
Assert.False(a.Contains(f));
Assert.False(f.Contains(a));
}
示例15: CheckFloatRange
//--------------------------------------------------------------------
private void CheckFloatRange(Range<float> range)
{
Assert.AreEqual(float.MinValue, range.Min);
Assert.AreEqual(float.MaxValue, range.Max);
Assert.AreEqual(range.MinIncluded, range.Contains(float.MinValue));
Assert.AreEqual(range.MaxIncluded, range.Contains(float.MaxValue));
}