Ejemplo n.º 1
0
        public void ItShouldReturnItselfForKilowattHours()
        {
            var original = new KilowattHoursEnergy(0);
            var conversion = original.KilowattHours;

            Assert.That(original, Is.SameAs(conversion));
        }
Ejemplo n.º 2
0
        public void ToStringShouldWork(double value, string expected)
        {
            var original = new KilowattHoursEnergy(value);
            var actual = original.ToString();

            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 3
0
        public void ItShouldConvertToJoulesProperly(double before, double after)
        {
            var original = new KilowattHoursEnergy(before);
            var conversion = original.Joules;

            Assert.That(conversion.Value, Is.EqualTo(after).Within(0.001));
        }
Ejemplo n.º 4
0
        public static IEnergy Parse(double value, string type)
        {
            IEnergy result;

            switch (type.ToLower())
            {
            case "j":
            case "joule":
            case "joules":
                result = new JoulesEnergy(value);
                break;

            case "kwh":
            case "kilowatt hour":
            case "kilowatt hours":
                result = new KilowattHoursEnergy(value);
                break;

            default:
                throw new Exception("Could not determine type " + type);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public static IEnergy Parse(double value, string type)
        {
            IEnergy result;

            switch (type.ToLower())
            {
                case "j":
                case "joule":
                case "joules":
                    result = new JoulesEnergy(value);
                    break;

                case "kwh":
                case "kilowatt hour":
                case "kilowatt hours":
                    result = new KilowattHoursEnergy(value);
                    break;

                default:
                    throw new Exception("Could not determine type " + type);
            }

            return result;
        }