예제 #1
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");
        }
예제 #2
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");
        }
예제 #3
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.");
        }
예제 #4
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");
        }
예제 #5
0
        public void StableAverageUpdated()
        {
            var stable = new Stable();

            stable.AddSample(123);

            Assert.AreNotEqual(0, stable.StableAverage, "The Stable Average was not set.");
        }
예제 #6
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");
        }
예제 #7
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.");
        }
예제 #8
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.");
        }