Exemplo n.º 1
0
            public void ShouldReturnTheCorrectValue()
            {
                var rational = new SignedRational(0, 1);

                Assert.Equal("0", rational.ToString());

                rational = new SignedRational(-2, 1);
                Assert.Equal("-2", rational.ToString());

                rational = new SignedRational(-1, 2);
                Assert.Equal("-1/2", rational.ToString());
            }
Exemplo n.º 2
0
        public void ExifSignedRationalTests(ExifTag tag)
        {
            var       expected = new SignedRational(21, 42);
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifSignedRational)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 3
0
        public void Test_ToString()
        {
            SignedRational rational = new SignedRational(0, 0);

            Assert.AreEqual("Indeterminate", rational.ToString());

            rational = new SignedRational(double.PositiveInfinity);
            Assert.AreEqual("PositiveInfinity", rational.ToString());

            rational = new SignedRational(double.NegativeInfinity);
            Assert.AreEqual("NegativeInfinity", rational.ToString());

            rational = new SignedRational(0, 1);
            Assert.AreEqual("0", rational.ToString());

            rational = new SignedRational(2, 1);
            Assert.AreEqual("2", rational.ToString());

            rational = new SignedRational(1, 2);
            Assert.AreEqual("1/2", rational.ToString());
        }
Exemplo n.º 4
0
        public void ToStringRepresention()
        {
            SignedRational rational = new SignedRational(0, 0);

            Assert.Equal("[ Indeterminate ]", rational.ToString());

            rational = new SignedRational(double.PositiveInfinity);
            Assert.Equal("[ PositiveInfinity ]", rational.ToString());

            rational = new SignedRational(double.NegativeInfinity);
            Assert.Equal("[ NegativeInfinity ]", rational.ToString());

            rational = new SignedRational(0, 1);
            Assert.Equal("0", rational.ToString());

            rational = new SignedRational(2, 1);
            Assert.Equal("2", rational.ToString());

            rational = new SignedRational(1, 2);
            Assert.Equal("1/2", rational.ToString());
        }
Exemplo n.º 5
0
        public void ToString_ReturnsReadableString(int numerator, int denominator, string str)
        {
            var rational = new SignedRational(numerator, denominator);

            Assert.Equal(str, rational.ToString());
        }
Exemplo n.º 6
0
            public void ShouldReturnNegativeInfinityWhenValueIsNegativeInfinity()
            {
                var rational = new SignedRational(double.NegativeInfinity);

                Assert.Equal("NegativeInfinity", rational.ToString());
            }
Exemplo n.º 7
0
            public void ShouldReturnPositiveInfinityWhenValueIsNan()
            {
                var rational = new SignedRational(double.NaN);

                Assert.Equal("Indeterminate", rational.ToString());
            }
Exemplo n.º 8
0
    public void Test_ToString()
    {
      SignedRational rational = new SignedRational(0, 0);
      Assert.AreEqual("Indeterminate", rational.ToString());

      rational = new SignedRational(double.PositiveInfinity);
      Assert.AreEqual("PositiveInfinity", rational.ToString());

      rational = new SignedRational(double.NegativeInfinity);
      Assert.AreEqual("NegativeInfinity", rational.ToString());

      rational = new SignedRational(0, 1);
      Assert.AreEqual("0", rational.ToString());

      rational = new SignedRational(2, 1);
      Assert.AreEqual("2", rational.ToString());

      rational = new SignedRational(1, 2);
      Assert.AreEqual("1/2", rational.ToString());
    }
Exemplo n.º 9
0
            public void ShouldReturnPositiveInfinityWhenValueIsPositiveInfinity()
            {
                var rational = new SignedRational(double.PositiveInfinity);

                Assert.AreEqual("PositiveInfinity", rational.ToString());
            }