Ejemplo n.º 1
0
        public void ChecksForNullSampleList()
        {
            var stable = new Stable();

            Assert.DoesNotThrow(() => stable.AddSample(123), "Adding Sample threw an error");
            Assert.IsNotNull(stable.Samples, "Samples is still null");
        }
Ejemplo n.º 2
0
        public void DefaultThreshold()
        {
            var threshold = 0.2;

            var stable = new Stable();

            Assert.AreEqual(threshold, stable.Threshold, "Threshold default not set to " + threshold);
        }
Ejemplo n.º 3
0
        public void DefaultSampleSize()
        {
            var sampleSize = 3;

            var stable = new Stable();

            Assert.AreEqual(sampleSize, stable.SampleSize, "Sample Size default not set to " + sampleSize);
        }
Ejemplo n.º 4
0
        public void DefaultIsStable()
        {
            var isStable = false;

            var stable = new Stable();

            Assert.AreEqual(isStable, stable.IsStable, "IsStable not defaulting to " + isStable);
        }
Ejemplo n.º 5
0
        public void CanSetThreshold()
        {
            var threshold = 0.2;

            var stable = new Stable(new Stable { Threshold = threshold });

            Assert.AreEqual(threshold, stable.Threshold, "Threshold not set.");
        }
Ejemplo n.º 6
0
        public void StableAverageUpdated()
        {
            var stable = new Stable();

            stable.AddSample(123);

            Assert.AreNotEqual(0, stable.StableAverage, "The Stable Average was not set.");
        }
Ejemplo n.º 7
0
        public void SampleAddedToNew()
        {
            var sample = 45.2;
            var stable = new Stable();

            stable.AddSample(sample);

            Assert.IsTrue(stable.Samples.Count > 0, "Sample not added to List.");
            Assert.AreEqual(sample, stable.Samples[0], "Sample not added to empty list");
        }
Ejemplo n.º 8
0
        public void CanSetSampleSize()
        {
            //Arrange
            var sampleSize = 2;

            //Act
            var stable = new Stable(new Stable { SampleSize = sampleSize });

            //Assert
            Assert.AreEqual(sampleSize, stable.SampleSize, "Sample Size not set in constructor.");
        }
Ejemplo n.º 9
0
        public void SamplesDoesNotGetBiggerThanSampleSize()
        {
            var sampleSize = 2;
            var stable = new Stable(new Stable { SampleSize = sampleSize });

            stable.AddSample(23);
            stable.AddSample(65);
            stable.AddSample(123);

            Assert.AreEqual(sampleSize, stable.Samples.Count, "Samples count has exceeded sample size");
        }
Ejemplo n.º 10
0
        public void StableAverageIsCorrectWith3Values()
        {
            var average = 5;
            var diff = 2;
            var stable = new Stable();

            stable.AddSample(average + diff);
            stable.AddSample(average - diff);
            stable.AddSample(average);

            Assert.AreEqual(average, stable.StableAverage, "The Stable Average is not computing correctly with 3 values");
        }
Ejemplo n.º 11
0
        public void WillBecomeStableAndThenUnstableWithAnotherValue()
        {
            var average = 5;
            var diff = .1;
            var stable = new Stable();

            stable.AddSample(average + diff);
            stable.AddSample(average - diff);
            stable.AddSample(average);

            Assert.IsTrue(stable.IsStable, "Not marked as stable and should have.");

            stable.AddSample(average * 40);

            Assert.IsFalse(stable.IsStable, "Marked as stable and should not have.");
        }
Ejemplo n.º 12
0
 public Stable(Stable stable)
 {
     SampleSize = stable.SampleSize;
     Threshold = stable.Threshold;
 }
Ejemplo n.º 13
0
        public void WillMarkAsNotStableWithDefaultThreshold()
        {
            var average = 5;
            var diff = 2;
            var stable = new Stable();

            stable.AddSample(average + diff);
            stable.AddSample(average - diff);
            stable.AddSample(average);

            Assert.IsFalse(stable.IsStable, "Marked as stable and should not have.");
        }
Ejemplo n.º 14
0
        public void WillMarkAsStableWithDefaultThreshold()
        {
            var average = 5;
            var diff = .1;
            var stable = new Stable();

            stable.AddSample(average + diff);
            stable.AddSample(average - diff);
            stable.AddSample(average);

            Assert.IsTrue(stable.IsStable, "Not marked as stable and should have.");
        }