public void AcquireCapacityInvalidUnitTest() { int throttleRetryCount = 0; int throttleRetryCost = 5; int throttleCost = 1; CapacityManager capacityManagerInstance = new CapacityManager(throttleRetryCount, throttleRetryCost, throttleCost); retryCapacity = capacityManagerInstance.GetRetryCapacity("AcquireCapacityInvalidUnitTest"); Assert.IsNotNull(retryCapacity); Assert.IsFalse(capacityManagerInstance.TryAcquireCapacity(retryCapacity)); Assert.AreEqual(0, retryCapacity.AvailableCapacity); var consumedCapacity = retryCapacity.MaxCapacity - retryCapacity.AvailableCapacity; Assert.AreEqual(0, consumedCapacity); }
public void ReleaseCapacityUnitTest() { int throttleRetryCount = 5; int throttleRetryCost = 5; int throttleCost = 1; CapacityManager capacityManagerInstance = new CapacityManager(throttleRetryCount, throttleRetryCost, throttleCost); retryCapacity = capacityManagerInstance.GetRetryCapacity("ReleaseCapacityUnitTest"); Assert.IsNotNull(retryCapacity); Assert.IsTrue(capacityManagerInstance.TryAcquireCapacity(retryCapacity)); capacityManagerInstance.TryReleaseCapacity(true, retryCapacity); Assert.AreEqual(throttleRetryCost * throttleRetryCount, retryCapacity.AvailableCapacity); var consumedCapacity = retryCapacity.MaxCapacity - retryCapacity.AvailableCapacity; Assert.AreEqual(0, consumedCapacity); capacityManagerInstance.TryReleaseCapacity(false, retryCapacity); Assert.AreEqual(throttleRetryCost * throttleRetryCount, retryCapacity.AvailableCapacity); consumedCapacity = retryCapacity.MaxCapacity - retryCapacity.AvailableCapacity; Assert.AreEqual(0, consumedCapacity); }