Beispiel #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>());
        }
Beispiel #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"));
        }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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>());
        }
Beispiel #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>());
        }
Beispiel #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));
        }