Example #1
0
        public void NegativeFibonacciNumberTest()
        {
            var firstIn = -8;
            var res     = ReadifyFactory.GetFibonacciNumber(firstIn);

            Assert.AreEqual(-21, res);
        }
Example #2
0
        public void GetFibonacciNumberArgExceptionTest()
        {
            var firstIn = 100;
            var res     = ReadifyFactory.GetFibonacciNumber(firstIn);

            Assert.AreEqual(93, res);
        }
Example #3
0
        public void ReverseWords2Test()
        {
            var firstIn = "abc cba/123";
            var res     = ReadifyFactory.ReverseWords(firstIn);

            Assert.AreEqual("cba abc/123", res);
        }
Example #4
0
        public void PositiveFibonacciNumberTest()
        {
            var firstIn = 9;
            var res     = ReadifyFactory.GetFibonacciNumber(firstIn);

            Assert.AreEqual(34, res);
        }
Example #5
0
 /// <summary>
 /// Reverse word's letters ignoring any symbols, whitespace, delimiters and digits
 /// </summary>
 /// <param name="s">The list of workds</param>
 /// <returns>String with reversed words</returns>
 public string ReverseWords(string s)
 {
     try
     {
         return(ReadifyFactory.ReverseWords(s));
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error invoking ReverseWords. a: {0}, Error: {1}", s, ex);
         throw new FaultException("Sorry, there happened something unexpected!!!");
     }
 }
Example #6
0
 /// <summary>
 /// Checking list of digits that they are really the dimensions of sides of triangle
 /// </summary>
 /// <param name="a">The first size of side</param>
 /// <param name="b">The second size of side</param>
 /// <param name="c">The third size of side</param>
 /// <returns>The triangle type</returns>
 public TriangleType WhatShapeIsThis(int a, int b, int c)
 {
     try
     {
         return(ReadifyFactory.WhatShapeIsThis(a, b, c));
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error invoking WhatShapeIsThis. a: {0}, b: {1}, c: {2}, Error: {3}", a, b, c, ex);
         throw new FaultException("Sorry, there happened something unexpected!!!");
     }
 }
Example #7
0
 /// <summary>
 /// Calculating fibonacci number by received negative or positive index
 /// </summary>
 /// <param name="n">Negative or positive index</param>
 /// <exception cref="ArgumentOutOfRangeException">The incoming parameter should be between -92..92</exception>
 /// <returns>The fibonacci number</returns>
 public long FibonacciNumber(long n)
 {
     try
     {
         return(ReadifyFactory.GetFibonacciNumber(n));
     }
     catch (ArgumentOutOfRangeException ex)
     {
         Trace.TraceWarning("Argument was out or range while invoking FibonacciNumber. n: {0}, Error: {1}", n, ex);
         throw new FaultException <ArgumentOutOfRangeException>(ex, ex.Message);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error invoking FibonacciNumber. n: {0}, Error: {1}", n, ex);
         throw new FaultException("Sorry, there happened something unexpected!!!");
     }
 }
Example #8
0
        public void ShapeBordersNotConnect()
        {
            var res = ReadifyFactory.WhatShapeIsThis(3, 4, 10);

            Assert.AreEqual(TriangleType.Error, res);
        }
Example #9
0
        public void ShapeSideIsNegative()
        {
            var res = ReadifyFactory.WhatShapeIsThis(-1, 3, 7);

            Assert.AreEqual(TriangleType.Error, res);
        }
Example #10
0
        public void ShapeIsScalene()
        {
            var res = ReadifyFactory.WhatShapeIsThis(5, 3, 7);

            Assert.AreEqual(TriangleType.Scalene, res);
        }
Example #11
0
        public void ShapeIsIsosceles()
        {
            var res = ReadifyFactory.WhatShapeIsThis(2, 1, 2);

            Assert.AreEqual(TriangleType.Isosceles, res);
        }
Example #12
0
        public void ShapeIsEquilateral()
        {
            var res = ReadifyFactory.WhatShapeIsThis(1, 1, 1);

            Assert.AreEqual(TriangleType.Equilateral, res);
        }