Exemplo n.º 1
0
        public void Should_not_throw_exception_on_division_by_zero(double value, double expectedValue)
        {
            var instance = new Millilitre(value);
            var actual   = instance / 0d;

            Assert.AreEqual(expectedValue, actual.Value);
        }
Exemplo n.º 2
0
        public void Should_initialize_instance(double value)
        {
            var actual = new Millilitre(value);

            Assert.IsAssignableFrom <Millilitre>(actual);
            Assert.AreEqual(value, actual.Value, nameof(actual.Value));
        }
Exemplo n.º 3
0
        public void Should_compare_with_null_instance(double value)
        {
            var instance = new Millilitre(value);

            Assert.IsFalse(instance.Equals(null), "Equals");
            Assert.AreEqual(1, instance.CompareTo(null), "CompareTo");
        }
Exemplo n.º 4
0
        public void Should_compare_with_another_type_of_instance(double value)
        {
            var    instance1 = new Millilitre(value);
            object instance2 = value;

            Assert.IsFalse(instance1.Equals(instance2), "Equals");
            Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo");
        }
Exemplo n.º 5
0
        public void Should_cast_to_double(double value)
        {
            var instance = new Millilitre(value);

            var actual = (double)instance;

            Assert.AreEqual(value, actual);
        }
Exemplo n.º 6
0
        public void Should_cast_from_double(double value)
        {
            var expected = new Millilitre(value);

            var actual = (Millilitre)value;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void Should_divide_instance_by_double(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var instance = new Millilitre(leftValue);
            var actual   = instance / rightValue;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void Should_floor_value(double value, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var instance = new Millilitre(value);
            var actual   = instance.Floor();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
0
        public void Should_format_string(string format, string mask)
        {
            var expected = string.Format(Consts.CultureEnUS, mask, 1.757899e2);

            var instance = new Millilitre(1.757899e2);
            var actual   = instance.ToString(format, Consts.CultureEnUS);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 10
0
        public void Should_own_a_HashCode(double value)
        {
            var expected = value.GetHashCode();

            var instance = new Millilitre(value);
            var actual   = instance.GetHashCode();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void Should_round_value_withDigit(double value, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var instance = new Millilitre(value);
            var actual   = instance.Round(1);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 12
0
        public void Should_convert_to_string(double value)
        {
            var expected = $"{value:e} ml";

            var instance = new Millilitre(value);
            var actual   = instance.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 13
0
        public void Should_roundvalue_withMode(MidpointRounding mode, double value, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var instance = new Millilitre(value);
            var actual   = instance.Round(mode);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 14
0
        public void Should_subtract_two_instances(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var leftInstance  = new Millilitre(leftValue);
            var rightInstance = new Millilitre(rightValue);
            var actual        = leftInstance - rightInstance;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 15
0
        public void Should_multiply_double_by_instance(double leftValue, double rightValue, double expectedValue)
        {
            var expected = new Millilitre(expectedValue);

            var instance = new Millilitre(rightValue);

            var actual = leftValue * instance;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 16
0
        public void Should_cast_from_Decilitre(double decilitreValue, double expectedValue)
        {
            var decilitreInstance = new SystemOfUnits.Volume.Litre.Decilitre(decilitreValue);

            Millilitre actual = decilitreInstance;

            Assert.IsAssignableFrom <Millilitre>(actual);

            var actualValue = actual.Value;

            Assert.AreEqual(expectedValue.ToString("E"), actualValue.ToString("E"));
        }
Exemplo n.º 17
0
        public void Should_compare_with_same_value(double value)
        {
            var baseInstance  = new Millilitre(value);
            var otherInstance = new Millilitre(value);

            Assert.IsTrue(baseInstance.Equals(otherInstance), "Equals");
            Assert.IsTrue(baseInstance.Equals((object)otherInstance), "Equals object");

            Assert.IsTrue(baseInstance == otherInstance, "==");
            Assert.IsFalse(baseInstance != otherInstance, "!=");

            Assert.AreEqual(0, baseInstance.CompareTo(otherInstance), "CompareTo");
            Assert.AreEqual(0, baseInstance.CompareTo((object)otherInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < otherInstance, "<");
            Assert.IsFalse(baseInstance > otherInstance, ">");

            Assert.IsTrue(baseInstance <= otherInstance, "<=");
            Assert.IsTrue(baseInstance >= otherInstance, ">=");
        }
Exemplo n.º 18
0
        public void Should_compare_with_smaller_value(double baseValue, double smallerValue)
        {
            var baseInstance    = new Millilitre(baseValue);
            var smallerInstance = new Millilitre(smallerValue);

            Assert.IsFalse(baseInstance.Equals(smallerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)smallerInstance), "Equals object");

            Assert.IsFalse(baseInstance == smallerInstance, "==");
            Assert.IsTrue(baseInstance != smallerInstance, "!=");

            Assert.AreEqual(+1, baseInstance.CompareTo(smallerInstance), "CompareTo");
            Assert.AreEqual(+1, baseInstance.CompareTo((object)smallerInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < smallerInstance, "<");
            Assert.IsTrue(baseInstance > smallerInstance, ">");

            Assert.IsFalse(baseInstance <= smallerInstance, "<=");
            Assert.IsTrue(baseInstance >= smallerInstance, ">=");
        }
Exemplo n.º 19
0
        public void Should_compare_with_bigger_value(double baseValue, double biggerValue)
        {
            var baseInstance   = new Millilitre(baseValue);
            var biggerInstance = new Millilitre(biggerValue);

            Assert.IsFalse(baseInstance.Equals(biggerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)biggerInstance), "Equals object");

            Assert.IsFalse(baseInstance == biggerInstance, "==");
            Assert.IsTrue(baseInstance != biggerInstance, "!=");

            Assert.AreEqual(-1, baseInstance.CompareTo(biggerInstance), "CompareTo");
            Assert.AreEqual(-1, baseInstance.CompareTo((object)biggerInstance), "CompareTo object");

            Assert.IsTrue(baseInstance < biggerInstance, "<");
            Assert.IsFalse(baseInstance > biggerInstance, ">");

            Assert.IsTrue(baseInstance <= biggerInstance, "<=");
            Assert.IsFalse(baseInstance >= biggerInstance, ">=");
        }
Exemplo n.º 20
0
 public InsulineInjection(Millilitre millilitre, DateTime dateTime, string remark)
 {
     this.Remark   = remark;
     this.DateTime = dateTime;
     _millilitre   = millilitre;
 }
Exemplo n.º 21
0
 public override double ConvertFrom(Millilitre fromUnit, double amount)
 {
     return(amount / ML_OZUS);
 }
Exemplo n.º 22
0
 public virtual double ConvertFrom(Millilitre fromUnit, double amount)
 {
     return(0);
 }
Exemplo n.º 23
0
        public void Should_have_a_symbol(double value)
        {
            IUnit actual = new Millilitre(value);

            Assert.AreEqual(Millilitre.Symbol, actual.Symbol);
        }