コード例 #1
0
        public void ChangingSetpointWorksRepeatably()
        {
            // this is to check for a bug that manifested when 
            // ShiftSubsequentData() was called several times with
            // various values

            IRandomGenerator randomGenerator = new RandomGeneratorStub(0.95);

            var sampleData = new SampleDataGenerator(10, 20, randomGenerator);

            sampleData.GetNextValue();

            sampleData.ShiftSubsequentData(200);
            
            sampleData.GetNextValue();

            sampleData.ShiftSubsequentData(2000);

            // this one will just be 2000
            sampleData.GetNextValue();

            // this one will likely be different
            var result1 = sampleData.GetNextValue();

            Assert.GreaterOrEqual(result1, 1995);
            Assert.LessOrEqual(result1, 2005);

            sampleData.ShiftSubsequentData(-2000);

            // this one will just be -2000
            sampleData.GetNextValue();

            // this one will likely be different
            var result2 = sampleData.GetNextValue();

            Assert.GreaterOrEqual(result2, -2005);
            Assert.LessOrEqual(result2, -1995);
        }