Esempio n. 1
0
        public void NumeratorAndDenominatorToHumanRepresentationTest(long inputNumerator, long inputDenominator, string expectedOutput)
        {
            var f1 = new Fractional(inputNumerator, inputDenominator);

            Assert.False(f1.IsNaN);

            Assert.True(f1.HumanRepresentation == expectedOutput);
        }
        public void ConstructionOfFractionObjectFromString(string value, long expectedNumerator, long expectedDenominator)
        {
            var fractional = new Fractional(value);

            Assert.False(fractional.IsNaN);
            Assert.Equal(expectedDenominator, fractional.Denominator);
            Assert.Equal(expectedNumerator, fractional.Numerator);
        }
Esempio n. 3
0
        public void DecimalToHumanRepresentationTest(decimal d, string expectedOutput)
        {
            var f1 = new Fractional(d, keepExcat: false);

            Assert.False(f1.IsNaN);

            Assert.True(f1.HumanRepresentation == expectedOutput);
        }
        public void ConstructionOfFractionObjectFromInteger(long numerator, long denominator)
        {
            var fractional = new Fractional(numerator, denominator);

            Assert.False(fractional.IsNaN);
            Assert.Equal(denominator, fractional.Denominator);
            Assert.Equal(numerator, fractional.Numerator);
        }
        public void ConstructionOfFractionObjectFromExcactDecimal(decimal value, long expectedNumerator, long expectedDenominator)
        {
            var fractional = new Fractional(value: value, keepExcat: true);

            Assert.False(fractional.IsNaN);
            Assert.Equal(expectedDenominator, fractional.Denominator);
            Assert.Equal(expectedNumerator, fractional.Numerator);
        }
        public void TwoFractionalsAreNotEqual(string input1, string input2)
        {
            var f1 = new Fractional(input1);
            var f2 = new Fractional(input2);

            Assert.False(f1.IsNaN);
            Assert.False(f2.IsNaN);
            Assert.True(f1 != f2);
        }
        public void IsLowerThan(string input1, string input2)
        {
            var f1 = new Fractional(input1);
            var f2 = new Fractional(input2);

            Assert.False(f1.IsNaN);
            Assert.False(f2.IsNaN);
            Assert.True(f1 < f2);
        }
        public void TwoFractionalsAreEqual(string input)
        {
            var f1 = new Fractional(input);
            var f2 = new Fractional(input);

            Assert.False(f1.IsNaN);
            Assert.False(f2.IsNaN);
            Assert.True(f1 == f2);
        }
        public void FractionalToDecimalDivision(string input1, decimal input2, long expectedNumerator, long expectedDenominator)
        {
            var f1 = new Fractional(input1);

            var result = f1 / input2;

            Assert.False(result.IsNaN);
            Assert.Equal(expectedDenominator, result.Denominator);
            Assert.Equal(expectedNumerator, result.Numerator);
        }
        public void FractionalToStringSubtraction(string input1, string input2, long expectedNumerator, long expectedDenominator)
        {
            var f1 = new Fractional(input1);

            var result = f1 - input2;

            Assert.False(result.IsNaN);
            Assert.Equal(expectedDenominator, result.Denominator);
            Assert.Equal(expectedNumerator, result.Numerator);
        }
Esempio n. 11
0
        public override string ToString()
        {
            switch (Type)
            {
            case PropertyType.Null:                 return("null");

            case PropertyType.Calculated:           return("calculated");

            case PropertyType.Bool:                 return(Bool.ToString());

            case PropertyType.String:               return("string: " + StringHandle.ToString());

            case PropertyType.MultiValue:           return("multi: " + MultiValueHandle.ToString());

            case PropertyType.Enum:                 return("enum: " + Enum.ToString());

            case PropertyType.Color:                return("color: " + Color.ToString());

            case PropertyType.Integer:              return(Integer.ToString() + " (integer)");

            case PropertyType.Fractional:           return(Fractional.ToString() + " (fractional)");

            case PropertyType.Percentage:           return(Percentage.ToString() + "%");

            case PropertyType.AbsLength:            return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (abs)");

            case PropertyType.RelLength:            return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (rel)");

            case PropertyType.HtmlFontUnits:        return(HtmlFontUnits.ToString() + " (html font units)");

            case PropertyType.RelHtmlFontUnits:     return(RelativeHtmlFontUnits.ToString() + " (relative html font units)");

            case PropertyType.Multiple:             return(Integer.ToString() + "*");

            case PropertyType.Pixels:               return(Pixels.ToString() + "px");

            case PropertyType.Ems:                  return(Ems.ToString() + "em");

            case PropertyType.Exs:                  return(Exs.ToString() + "ex");

            case PropertyType.Milliseconds:         return(Milliseconds.ToString() + "ms");

            case PropertyType.kHz:                  return(kHz.ToString() + "kHz");

            case PropertyType.Degrees:              return(Degrees.ToString() + "deg");
            }

            return("unknown value type");
        }
Esempio n. 12
0
        private List <string> FractionalNumber(Treatment treatment)
        {
            Number integerNumber = new IntegerNumber("Fractional");
            Number fractional    = new Fractional("Fractional");

            try
            {
                integerNumber.Translate(treatment);
                fractional.Translate(treatment);
            }
            catch (InvalidNumber ex)
            {
                return(new List <string> {
                    "Error", ex.Message
                });
            }
            return(CheckNegativeNumber(integerNumber, fractional));
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            /*   Hello msg = new Hello();
             * msg.Message();
             * ComputerText txt = new ComputerText();
             * txt.Text();
             * ConsoleSquere squr = new ConsoleSquere();
             * squr.Squere();
             * ArraySort ar = new ArraySort(); // object init
             * ar.Sort();                 // object call
             * Functions fun = new Functions();
             * fun.Operations();
             * Calculator calc = new Calculator();
             * calc.Calculations();
             * Crypton cry = new Crypton();
             * cry.Ceasar();
             * FigureCheck fgr = new FigureCheck();
             * fgr.FigureChecking();
             * Fibonachi fbn = new Fibonachi();
             * fbn.FibCount();*/
            /*   First rev = new First();
             * rev.Revers();
             * Second pal = new Second();
             * pal.palindrome();
             * Third rwo = new Third();
             * rwo.revwordord();
             * Forth rew = new Forth();
             * rew.revEachWord();
             * Fifth cC = new Fifth();
             * cC.charCount();
             * Six rD = new Six();
             * rD.remDouple();
             *    Seven ss = new Seven();
             * ss.substring();*/
            //3.1 Fractional
            Fractional fr = new Fractional();

            Console.WriteLine(fr.Add(12.3, 11.1));
            Console.WriteLine(fr.Sub(12.3, 11.1));
            Console.WriteLine(fr.Mul(12.3, 11.1));
            Console.WriteLine(fr.Check(12.3, 11.1));
            //3.2_Money
            Money bal = new Money();

            bal.UAH  = 534;
            bal.COIN = 345;
            CalcMoney c   = new CalcMoney();
            double    sum = c.Conc(bal.UAH, bal.COIN);

            Console.WriteLine(c.Add(sum, 4));
            Console.WriteLine(c.Sub(sum, 4));
            Console.WriteLine(c.Mul(sum, 4));
            Console.WriteLine(c.Div(sum, 4));
            Console.WriteLine(c.Check(sum, 4));
            //3.3 Equal trapezoid
            Console.WriteLine("a,c sides, b-smaller basis, d-lagger basis");
            int N = Convert.ToInt32(Console.ReadLine());

            Trapezoid  [] T = new Trapezoid[N];
            for (int i = 0; i < N; i++)
            {
                T[i] = new Trapezoid();
            }
        }
        public void ZeroDenominator(string zeroDenominator)
        {
            var fractional = new Fractional(zeroDenominator);

            Assert.True(fractional.IsNaN);
        }
        public void InvalidExpression(string invalidExpression)
        {
            var fractional = new Fractional(invalidExpression);

            Assert.True(fractional.IsNaN);
        }
Esempio n. 16
0
        /// <summary>
        /// Returns true if SymbolInfoArrays instances are equal
        /// </summary>
        /// <param name="other">Instance of SymbolInfoArrays to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SymbolInfoArrays other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Symbol == other.Symbol ||
                     Symbol != null &&
                     Symbol.SequenceEqual(other.Symbol)
                     ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.SequenceEqual(other.Description)
                 ) &&
                 (
                     ExchangeListed == other.ExchangeListed ||
                     ExchangeListed != null &&
                     ExchangeListed.SequenceEqual(other.ExchangeListed)
                 ) &&
                 (
                     ExchangeTraded == other.ExchangeTraded ||
                     ExchangeTraded != null &&
                     ExchangeTraded.SequenceEqual(other.ExchangeTraded)
                 ) &&
                 (
                     Minmovement == other.Minmovement ||
                     Minmovement != null &&
                     Minmovement.SequenceEqual(other.Minmovement)
                 ) &&
                 (
                     Minmov2 == other.Minmov2 ||
                     Minmov2 != null &&
                     Minmov2.SequenceEqual(other.Minmov2)
                 ) &&
                 (
                     Fractional == other.Fractional ||
                     Fractional != null &&
                     Fractional.SequenceEqual(other.Fractional)
                 ) &&
                 (
                     Pricescale == other.Pricescale ||
                     Pricescale != null &&
                     Pricescale.SequenceEqual(other.Pricescale)
                 ) &&
                 (
                     HasIntraday == other.HasIntraday ||
                     HasIntraday != null &&
                     HasIntraday.SequenceEqual(other.HasIntraday)
                 ) &&
                 (
                     HasNoVolume == other.HasNoVolume ||
                     HasNoVolume != null &&
                     HasNoVolume.SequenceEqual(other.HasNoVolume)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.SequenceEqual(other.Type)
                 ) &&
                 (
                     Ticker == other.Ticker ||
                     Ticker != null &&
                     Ticker.SequenceEqual(other.Ticker)
                 ) &&
                 (
                     Timezone == other.Timezone ||
                     Timezone != null &&
                     Timezone.SequenceEqual(other.Timezone)
                 ) &&
                 (
                     SessionRegular == other.SessionRegular ||
                     SessionRegular != null &&
                     SessionRegular.SequenceEqual(other.SessionRegular)
                 ) &&
                 (
                     SupportedResolutions == other.SupportedResolutions ||
                     SupportedResolutions != null &&
                     SupportedResolutions.SequenceEqual(other.SupportedResolutions)
                 ) &&
                 (
                     HasDaily == other.HasDaily ||
                     HasDaily != null &&
                     HasDaily.SequenceEqual(other.HasDaily)
                 ) &&
                 (
                     IntradayMultipliers == other.IntradayMultipliers ||
                     IntradayMultipliers != null &&
                     IntradayMultipliers.SequenceEqual(other.IntradayMultipliers)
                 ) &&
                 (
                     HasWeeklyAndMonthly == other.HasWeeklyAndMonthly ||
                     HasWeeklyAndMonthly != null &&
                     HasWeeklyAndMonthly.SequenceEqual(other.HasWeeklyAndMonthly)
                 ));
        }
Esempio n. 17
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Symbol != null)
         {
             hashCode = hashCode * 59 + Symbol.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (ExchangeListed != null)
         {
             hashCode = hashCode * 59 + ExchangeListed.GetHashCode();
         }
         if (ExchangeTraded != null)
         {
             hashCode = hashCode * 59 + ExchangeTraded.GetHashCode();
         }
         if (Minmovement != null)
         {
             hashCode = hashCode * 59 + Minmovement.GetHashCode();
         }
         if (Minmov2 != null)
         {
             hashCode = hashCode * 59 + Minmov2.GetHashCode();
         }
         if (Fractional != null)
         {
             hashCode = hashCode * 59 + Fractional.GetHashCode();
         }
         if (Pricescale != null)
         {
             hashCode = hashCode * 59 + Pricescale.GetHashCode();
         }
         if (HasIntraday != null)
         {
             hashCode = hashCode * 59 + HasIntraday.GetHashCode();
         }
         if (HasNoVolume != null)
         {
             hashCode = hashCode * 59 + HasNoVolume.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Ticker != null)
         {
             hashCode = hashCode * 59 + Ticker.GetHashCode();
         }
         if (Timezone != null)
         {
             hashCode = hashCode * 59 + Timezone.GetHashCode();
         }
         if (SessionRegular != null)
         {
             hashCode = hashCode * 59 + SessionRegular.GetHashCode();
         }
         if (SupportedResolutions != null)
         {
             hashCode = hashCode * 59 + SupportedResolutions.GetHashCode();
         }
         if (HasDaily != null)
         {
             hashCode = hashCode * 59 + HasDaily.GetHashCode();
         }
         if (IntradayMultipliers != null)
         {
             hashCode = hashCode * 59 + IntradayMultipliers.GetHashCode();
         }
         if (HasWeeklyAndMonthly != null)
         {
             hashCode = hashCode * 59 + HasWeeklyAndMonthly.GetHashCode();
         }
         return(hashCode);
     }
 }