public void InstanceCountDefault() { var scaler = new AutoScalerHelper(); Assert.AreEqual(1, scaler.InstanceCount.Minimum); Assert.AreEqual(2, scaler.InstanceCount.Maximum); }
public void ScaleUnit() { var scaler = new AutoScalerHelper(); var unit = scaler.ScaleUnit(null); Assert.IsNotNull(unit); Assert.AreEqual(1, unit.Count()); Assert.IsNotNull(unit.First() as AdaptiveHelper); }
public void Tasks() { var config = new object(); var scaler = new AutoScalerHelper(config); var unit = scaler.Tasks(); Assert.IsNotNull(unit); Assert.AreEqual(1, unit.Count()); Assert.IsNotNull(unit.First() as AdaptiveHelper); Assert.AreEqual(config, scaler.passed); }
public void RunOptimalShouldntScale() { var config = new object(); var s = Substitute.For <IScaler <object> >(); s.IsFirstRun(1).Returns(false); s.ShouldScale().Returns((bool?)null); var scaler = new AutoScalerHelper(s, config); scaler.Run(); s.Received().IsFirstRun(1); s.Received(0).ScaleDown(Arg.Any <string>()); s.Received(0).ScaleUp(scaler, config, Arg.Any <string>()); }
public void RunIsFirstRun() { var s = Substitute.For <IScaler <object> >(); var config = new object(); s.IsFirstRun(1).Returns(true); var scaler = new AutoScalerHelper(s, config); s.Initialize(1, scaler, config, Arg.Any <string>()); scaler.Run(); s.Received().IsFirstRun(1); s.Received().Initialize(1, scaler, config, Arg.Any <string>()); }
public void RunOptimalMax() { var config = new object(); var s = Substitute.For <IScaler <object> >(); s.IsFirstRun(1).Returns(false); s.ShouldScale().Returns(true); s.CurrentUnits.Returns(2); var scaler = new AutoScalerHelper(s, config); scaler.Run(); s.Received().IsFirstRun(1); var r = s.Received().CurrentUnits; s.Received(0).ScaleDown(Arg.Any <string>()); s.Received(0).ScaleUp(scaler, config, Arg.Any <string>()); }
public void RunScaleDown() { var s = Substitute.For <IScaler <object> >(); s.IsFirstRun(1).Returns(false); s.ShouldScale().Returns(false); s.CurrentUnits.Returns(100); s.ScaleDown(Arg.Any <string>()); var scaler = new AutoScalerHelper(s, null); scaler.Run(); s.Received().IsFirstRun(1); s.Received().ShouldScale(); var r = s.Received().CurrentUnits; s.Received().ScaleDown(Arg.Any <string>()); }
public void Maximum() { var scaler = new AutoScalerHelper(new object(), 100, 150); Assert.AreEqual(150, scaler.InstanceCount.Maximum); }