Exemplo n.º 1
0
        public void CreateRangeWithTwoParameters()
        {
            RangeFunction function = new RangeFunction();

            var result = function.Apply(null, new object[] { 1, 2 }, null);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Range));

            var range = (Range)result;

            Assert.AreEqual(1, range.From);
            Assert.AreEqual(2, range.To);
            Assert.AreEqual(1, range.Step);
        }
Exemplo n.º 2
0
        public void RaiseIfSomeParameterIsFloat()
        {
            RangeFunction function = new RangeFunction();

            try
            {
                function.Apply(null, new object[] { 1.0, 2, 3 }, null);
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(TypeError));
                Assert.AreEqual("'float' object cannot be interpreted as an integer", ex.Message);
            }
        }
Exemplo n.º 3
0
        public void RaiseMoreThanThreeParameters()
        {
            RangeFunction function = new RangeFunction();

            try
            {
                function.Apply(null, new object[] { 1, 2, 3, 4 }, null);
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(TypeError));
                Assert.AreEqual("range expected at most 3 arguments, got 4", ex.Message);
            }
        }
Exemplo n.º 4
0
        public void RaiseWhenNoParameters()
        {
            RangeFunction function = new RangeFunction();

            try
            {
                function.Apply(null, new object[] { }, null);
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(TypeError));
                Assert.AreEqual("range expected 1 arguments, got 0", ex.Message);
            }
        }