예제 #1
0
        public void InstanceCountDefault()
        {
            var scaler = new AutoScalerHelper();

            Assert.AreEqual(1, scaler.InstanceCount.Minimum);
            Assert.AreEqual(2, scaler.InstanceCount.Maximum);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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>());
        }
예제 #5
0
        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>());
        }
예제 #6
0
        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>());
        }
예제 #7
0
        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>());
        }
예제 #8
0
        public void Maximum()
        {
            var scaler = new AutoScalerHelper(new object(), 100, 150);

            Assert.AreEqual(150, scaler.InstanceCount.Maximum);
        }