Exemplo n.º 1
0
        public void AddArgument_DoublePassedIntExpected_TypeConverted()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Round"));

            function.AddArgument(21.21d);
            function.AddArgument(0d);

            Assert.That(function.Arguments.Last(), Is.InstanceOf <int>());
        }
Exemplo n.º 2
0
        public void AddArgument_TooMuchArguments_Throws()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Double"));

            function.AddArgument(1);

            var ex = Assert.Throws <InvalidOperationException>(() => function.AddArgument(2));

            Assert.That(ex.Message, Does.Contain("parameter count mismatch"));
        }
Exemplo n.º 3
0
        public void Invoke_DoublePassedIntExpected_InvokeSucceeds()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Round"));

            function.AddArgument(21.21d);
            function.AddArgument(0d);

            var result = function.Invoke();

            Assert.That(result, Is.EqualTo(21));
        }
Exemplo n.º 4
0
        public void AddArgument_Null_Accepted()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Count"));

            function.AddArgument(null);

            Assert.That(function.Arguments.Last(), Is.Null);
        }
Exemplo n.º 5
0
        public void AddArgument_ImplementedInterfaceExpected_ArgumentExpected()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Count"));

            function.AddArgument(FigureSeries.Empty);

            Assert.That(function.Arguments.Last(), Is.InstanceOf <FigureSeries>());
        }
Exemplo n.º 6
0
        public void AddArgument_IntPassedDoubleExpected_TypeConverted()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Double"));

            function.AddArgument(21);

            Assert.That(function.Arguments.First(), Is.InstanceOf <double>());
        }
Exemplo n.º 7
0
        public void Invoke_IntPassedDoubleExpected_InvokeSucceeds()
        {
            var function = new FunctionCall(typeof(FakeFunctions).GetMethod("Double"));

            function.AddArgument(21);

            var result = function.Invoke();

            Assert.That(result, Is.EqualTo(42));
        }