Exemplo n.º 1
0
        public void TestStrategySet()           // TODO: Make this a unit test by mocking out the IModuleStrategy. I can show you how to use a cool library called Moq to do this.
        {
            BloodPressureStrategy blood_pressure_strat = new BloodPressureStrategy();
            int test = blood_pressure_strat.GetCurrentReading(1, 10);

            Console.WriteLine(test);
        }
Exemplo n.º 2
0
        public void OnConstruction_WhenMinValueIsGreaterThanMaxValue_Throws()
        {
            const int             initialMinValue = 3;
            const int             initialMaxValue = 2;
            BloodPressureStrategy strat           = new BloodPressureStrategy();

            Assert.Throws <ArgumentOutOfRangeException>(() => new Module(strat, "", initialMinValue, initialMaxValue));
        }
Exemplo n.º 3
0
        public void OnConstruction_WhenMinValueIsNegative_DoesNotThrow()
        {
            const int             initialMinValue = -1;
            const int             initialMaxValue = 4;
            BloodPressureStrategy strat           = new BloodPressureStrategy();

            Assert.DoesNotThrow(() => new Module(strat, "", initialMinValue, initialMaxValue));
        }
Exemplo n.º 4
0
        public void OnMinValueSet_WhenMinValueIsSetGreaterThanMaxValue_Throws()
        {
            const int initialMinValue = 1;
            const int initialMaxValue = 2;
            const int newMinValue     = 3;

            BloodPressureStrategy strat = new BloodPressureStrategy();
            var module = new Module(strat, "", initialMinValue, initialMaxValue);

            Assert.Throws <ArgumentOutOfRangeException>(() => module.MinValue = newMinValue);
        }
Exemplo n.º 5
0
        public void OnConstruction_WhenMinValueAndinitialMaxValueAreValid_DoesNotThrow()
        {
            const int initialMinValue = 2;
            const int initialMaxValue = 4;

            BloodPressureStrategy strat = new BloodPressureStrategy();
            Module module = null;

            Assert.DoesNotThrow(() => module = new Module(strat, "", initialMinValue, initialMaxValue));

            Assert.That(module.MinValue, Is.EqualTo(initialMinValue));
            Assert.That(module.MaxValue, Is.EqualTo(initialMaxValue));
        }
Exemplo n.º 6
0
        public void OnMinValueSet_WhenMinValueIsSetNegative_DoesNotThrow()
        {
            const int initialMinValue = 1;
            const int initialMaxValue = 2;
            const int newMinValue     = 0;

            BloodPressureStrategy strat = new BloodPressureStrategy();
            var module = new Module(strat, "", initialMinValue, initialMaxValue);

            Assert.DoesNotThrow(() => module.MinValue = newMinValue);

            Assert.That(module.MinValue, Is.EqualTo(newMinValue));
            Assert.That(module.MaxValue, Is.EqualTo(initialMaxValue));
        }
Exemplo n.º 7
0
        [Test, Explicit]         // The behaviour is non-deterministic, hence why this test should only be run manually.
        public void GetCurrentReading_ReturnsRandomValues()
        {
            const int initialMinValue = 2;
            const int initialMaxValue = 4;
            const int numberOfRuns    = 1000;

            BloodPressureStrategy strat = new BloodPressureStrategy();
            var module = new Module(strat, "", initialMinValue, initialMaxValue);

            var valuesReceived = new List <int>();

            for (var run = 1; run <= numberOfRuns; run++)
            {
                var valueReceived = module.GetCurrentReading();

                valuesReceived.Add(valueReceived);
            }

            for (var expectedValue = initialMinValue - 1; expectedValue <= initialMaxValue + 1; expectedValue++)
            {
                Assert.That(valuesReceived.Contains(expectedValue));
            }
        }