Esempio n. 1
0
        private static void PowerConsumptionTest(Camera camera, PowerSupplyDevice powerSupply)
        {
            msg = "Input acceptable range in Watts separated by comma ex. min,max: ";
            WriteToScreen(msg);
            var range = Console.ReadLine();

            if (range == null)
            {
                throw new ArgumentNullException(range, "Range cannot be null");
            }

            var lstRange = range.Split(',');

            if (lstRange.Length != 2)
            {
                _consoleLogger.LogError("Invalid Range");
                throw new ArgumentException("Invalid acceptable power consumption range");
            }


            IPowerConsumption powerConsumption = new PowerConsumption(new ConsoleLogger());

//            IPowerConsumption powerConsumption = new PowerConsumption(new FileLogger("C:\\Users\\chimm\\Desktop\\log.txt"));

            camera.PowerConsumption = powerConsumption.PowerConsumptionInWatts(powerSupply);

            var passed = powerConsumption.IsPowerConsumptionWithinRange(Convert.ToDouble(lstRange[0]),
                                                                        Convert.ToDouble(lstRange[1]), camera);

            msg = passed ? "Test Passed!" : "Test Failed";

            WriteToScreen(msg);
        }
Esempio n. 2
0
        public void IsPowerConsumptionWithinRange_WhenCalled_ReturnIsWithinRange(double minWatts, double maxWatts,
                                                                                 double powerConsumption, bool expectedResult)
        {
            var camera = new Camera
            {
                PowerConsumption = powerConsumption
            };

            var result = _powerConsumption.IsPowerConsumptionWithinRange(minWatts, maxWatts, camera);

            Assert.That(result, Is.EqualTo(expectedResult));
        }