本文整理汇总了C#中Pool.DecreaseAvailablePoolSizeAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Pool.DecreaseAvailablePoolSizeAsync方法的具体用法?C# Pool.DecreaseAvailablePoolSizeAsync怎么用?C# Pool.DecreaseAvailablePoolSizeAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pool
的用法示例。
在下文中一共展示了Pool.DecreaseAvailablePoolSizeAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PoolCannotDecreaseAvailableInstancesBelow0Test
public void PoolCannotDecreaseAvailableInstancesBelow0Test()
{
// given
var emptyPool = new Pool<string>((token) => Guid.NewGuid().ToString());
var nonEmptyPool = new Pool<string>((token) => Guid.NewGuid().ToString(), 10);
// when
Func<Task> invalidDecreaseOnEmptyPool = async () => await emptyPool.DecreaseAvailablePoolSizeAsync(1);
Func<Task> invalidDecreaseOnNonEmptyPool = async () => await nonEmptyPool.DecreaseAvailablePoolSizeAsync(11);
// then
invalidDecreaseOnEmptyPool.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("decreaseBy");
invalidDecreaseOnNonEmptyPool.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("decreaseBy");
}
示例2: PoolCanDecreaseAvailableInstancesTest
public async Task PoolCanDecreaseAvailableInstancesTest(int initialInstanceCount, int instancesToDecreaseBy)
{
// given
var pool = new Pool<string>((token) => Guid.NewGuid().ToString(), initialInstanceCount);
pool.TotalInstancesCount.Should().Be(initialInstanceCount);
// when
await pool.DecreaseAvailablePoolSizeAsync(instancesToDecreaseBy);
pool.TotalInstancesCount.Should().Be(initialInstanceCount - instancesToDecreaseBy);
// then
pool.AvailableInstancesCount.Should().Be(initialInstanceCount - instancesToDecreaseBy);
}