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