public void ToUnit()
        {
            var katal = CatalyticActivity.FromKatals(1);

            var katalQuantity = katal.ToUnit(CatalyticActivityUnit.Katal);

            AssertEx.EqualTolerance(KatalsInOneKatal, (double)katalQuantity.Value, KatalsTolerance);
            Assert.Equal(CatalyticActivityUnit.Katal, katalQuantity.Unit);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = CatalyticActivity.FromKatals(1);
            object b = CatalyticActivity.FromKatals(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
        public void ArithmeticOperators()
        {
            CatalyticActivity v = CatalyticActivity.FromKatals(1);

            AssertEx.EqualTolerance(-1, -v.Katals, KatalsTolerance);
            AssertEx.EqualTolerance(2, (CatalyticActivity.FromKatals(3) - v).Katals, KatalsTolerance);
            AssertEx.EqualTolerance(2, (v + v).Katals, KatalsTolerance);
            AssertEx.EqualTolerance(10, (v * 10).Katals, KatalsTolerance);
            AssertEx.EqualTolerance(10, (10 * v).Katals, KatalsTolerance);
            AssertEx.EqualTolerance(2, (CatalyticActivity.FromKatals(10) / 5).Katals, KatalsTolerance);
            AssertEx.EqualTolerance(2, CatalyticActivity.FromKatals(10) / CatalyticActivity.FromKatals(5), KatalsTolerance);
        }
        public void ComparisonOperators()
        {
            CatalyticActivity oneKatal  = CatalyticActivity.FromKatals(1);
            CatalyticActivity twoKatals = CatalyticActivity.FromKatals(2);

            Assert.True(oneKatal < twoKatals);
            Assert.True(oneKatal <= twoKatals);
            Assert.True(twoKatals > oneKatal);
            Assert.True(twoKatals >= oneKatal);

            Assert.False(oneKatal > twoKatals);
            Assert.False(oneKatal >= twoKatals);
            Assert.False(twoKatals < oneKatal);
            Assert.False(twoKatals <= oneKatal);
        }
        public void EqualityOperators()
        {
            var a = CatalyticActivity.FromKatals(1);
            var b = CatalyticActivity.FromKatals(2);

            // ReSharper disable EqualExpressionComparison

            Assert.True(a == a);
            Assert.False(a != a);

            Assert.True(a != b);
            Assert.False(a == b);

            Assert.False(a == null);
            Assert.False(null == a);

// ReSharper restore EqualExpressionComparison
        }
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = CatalyticActivity.FromKatals(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
        public void EqualsReturnsFalseOnNull()
        {
            CatalyticActivity katal = CatalyticActivity.FromKatals(1);

            Assert.False(katal.Equals(null));
        }
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            CatalyticActivity katal = CatalyticActivity.FromKatals(1);

            Assert.False(katal.Equals(new object()));
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = CatalyticActivity.FromKatals(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(CatalyticActivity.FromKatals(1), -1, ComparisonType.Relative));
        }
        public void CompareToThrowsOnNull()
        {
            CatalyticActivity katal = CatalyticActivity.FromKatals(1);

            Assert.Throws <ArgumentNullException>(() => katal.CompareTo(null));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            CatalyticActivity katal = CatalyticActivity.FromKatals(1);

            Assert.Throws <ArgumentException>(() => katal.CompareTo(new object()));
        }
        public void ConversionRoundTrip()
        {
            CatalyticActivity katal = CatalyticActivity.FromKatals(1);

            AssertEx.EqualTolerance(1, CatalyticActivity.FromKatals(katal.Katals).Katals, KatalsTolerance);
        }
        public void As()
        {
            var katal = CatalyticActivity.FromKatals(1);

            AssertEx.EqualTolerance(KatalsInOneKatal, katal.As(CatalyticActivityUnit.Katal), KatalsTolerance);
        }
 public void FromKatals_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => CatalyticActivity.FromKatals(double.NaN));
 }
 public void FromKatals_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => CatalyticActivity.FromKatals(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => CatalyticActivity.FromKatals(double.NegativeInfinity));
 }