public void IsPowerOf2_should_return_true_when_a_power_of_2( [Values(0, 1, 2, 4, 8, 128, 0x40000000)] int n) { var result = PowerOf2.IsPowerOf2(n); result.Should().BeTrue(); }
public void IsPowerOf2_should_throw_when_n_is_invalid( [Values(-1, 0x40000001)] int n) { Action action = () => PowerOf2.IsPowerOf2(n); action.ShouldThrow <ArgumentOutOfRangeException>().And.ParamName.Should().Be("n"); }
public void IsPowerOf2_should_return_false_when_not_a_power_of_2( [Values(3, 5, 6, 7, 9, 127, 129, 0x37ffffff)] int n) { var result = PowerOf2.IsPowerOf2(n); result.Should().BeFalse(); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="OutputBufferChunkSource"/> class. /// </summary> /// <param name="baseSource">The chunk source.</param> /// <param name="initialUnpooledChunkSize">The size of the initial unpooled chunk.</param> /// <param name="minChunkSize">The minimum size of a chunk.</param> /// <param name="maxChunkSize">The maximum size of a chunk.</param> public OutputBufferChunkSource( IBsonChunkSource baseSource, int initialUnpooledChunkSize = DefaultInitialUnpooledChunkSize, int minChunkSize = DefaultMinChunkSize, int maxChunkSize = DefaultMaxChunkSize) { if (baseSource == null) { throw new ArgumentNullException("baseSource"); } if (initialUnpooledChunkSize < 0) { throw new ArgumentOutOfRangeException("initialUnpooledChunkSize"); } if (minChunkSize <= 0) { throw new ArgumentOutOfRangeException("minChunkSize"); } if (maxChunkSize <= 0) { throw new ArgumentOutOfRangeException("maxChunkSize"); } if (!PowerOf2.IsPowerOf2(minChunkSize)) { throw new ArgumentException("minChunkSize is not a power of 2.", "minChunkSize"); } if (!PowerOf2.IsPowerOf2(maxChunkSize)) { throw new ArgumentException("maxChunkSize is not a power of 2.", "maxChunkSize"); } if (maxChunkSize < minChunkSize) { throw new ArgumentException("maxChunkSize is less than minChunkSize", "maxChunkSize"); } _baseSource = baseSource; _initialUnpooledChunkSize = initialUnpooledChunkSize; _minChunkSize = minChunkSize; _maxChunkSize = maxChunkSize; }