public async Task ExecuteAsync_InvalidMaxProcessors_Throws() { IStep step = new LoadStep() { MemoryInBytes = 5, TimeInSeconds = 2.0d, CpuPercentage = 5, MaxProcessors = -1 }; var logger = new Mock <ILogger>(MockBehavior.Loose); step = step.AsTypeModel(logger.Object); await Assert.ThrowsExceptionAsync <InvalidOperationException>( () => step.ExecuteAsync()); }
public async Task ExecuteAsync_ValidBytesMax_Throws() { IStep step = new LoadStep() { MemoryInBytes = ulong.MaxValue, TimeInSeconds = 2, CpuPercentage = 0 }; var logger = new Mock <ILogger>(MockBehavior.Loose); step = step.AsTypeModel(logger.Object); await Assert.ThrowsExceptionAsync <OutOfMemoryException>( () => step.ExecuteAsync()); }
public async Task ExecuteAsync_ValidState_ExecutesCorrectly() { IStep step = new LoadStep() { MemoryInBytes = 10, TimeInSeconds = 0.0d, CpuPercentage = 10 }; var logger = new Mock <ILogger>(MockBehavior.Loose); step = step.AsTypeModel(logger.Object); ExecutionStatus status = await step.ExecuteAsync(); Assert.AreEqual(ExecutionStatus.Success, status); }
public async Task ExecuteAsync_ValidBytesOne_ExecutesCorrectly() { var start = DateTime.UtcNow; IStep step = new LoadStep() { MemoryInBytes = 1, TimeInSeconds = 1.0d, CpuPercentage = 1 }; var logger = new Mock <ILogger>(MockBehavior.Loose); step = step.AsTypeModel(logger.Object); ExecutionStatus status = await step.ExecuteAsync(); var timeSpan = DateTime.UtcNow.Subtract(start); Assert.IsTrue(timeSpan.TotalSeconds >= 1.0d); Assert.AreEqual(ExecutionStatus.Success, status); }
public async Task ExecuteAsync_ProcessorOverrideHigherThanProcessorCount_ExecutesCorrectly() { var start = DateTime.UtcNow; IStep step = new LoadStep() { MemoryInBytes = 10, TimeInSeconds = 0.2d, CpuPercentage = 10, MaxProcessors = int.MaxValue }; var logger = new Mock <ILogger>(MockBehavior.Loose); step = step.AsTypeModel(logger.Object); ExecutionStatus status = await step.ExecuteAsync(); var timeSpan = DateTime.UtcNow.Subtract(start); Assert.IsTrue(timeSpan.TotalSeconds >= 0.2d); Assert.AreEqual(ExecutionStatus.Success, status); }