Пример #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");
        }
Пример #2
0
        public void DefaultThreshold()
        {
            var threshold = 0.2;

            var stable = new Stable();

            Assert.AreEqual(threshold, stable.Threshold, "Threshold default not set to " + threshold);
        }
Пример #3
0
        public void DefaultSampleSize()
        {
            var sampleSize = 3;

            var stable = new Stable();

            Assert.AreEqual(sampleSize, stable.SampleSize, "Sample Size default not set to " + sampleSize);
        }
Пример #4
0
        public void DefaultIsStable()
        {
            var isStable = false;

            var stable = new Stable();

            Assert.AreEqual(isStable, stable.IsStable, "IsStable not defaulting to " + isStable);
        }
Пример #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.");
        }
Пример #6
0
        public void StableAverageUpdated()
        {
            var stable = new Stable();

            stable.AddSample(123);

            Assert.AreNotEqual(0, stable.StableAverage, "The Stable Average was not set.");
        }
Пример #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");
        }
Пример #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.");
        }
Пример #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");
        }
Пример #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");
        }
Пример #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.");
        }
Пример #12
0
 public Stable(Stable stable)
 {
     SampleSize = stable.SampleSize;
     Threshold = stable.Threshold;
 }
Пример #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.");
        }
Пример #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.");
        }