Пример #1
0
        public void use_a_type_alias()
        {
            var variables  = new StubMethodVariables();
            var basketball = Variable.For <Basketball>();

            variables.Store(basketball);

            var @call = MethodCall.For <MethodCallTarget>(x => x.Throw(null));

            @call.IsLocal = true;

            @call.Aliases[typeof(Ball)] = typeof(Basketball);

            @call.FindVariables(variables)
            .Single()
            .ShouldBeOfType <CastVariable>()
            .Inner
            .ShouldBeSameAs(basketball);
        }
Пример #2
0
        public void find_simple_variable_by_name_and_type()
        {
            var age   = Variable.For <int>("age");
            var count = Variable.For <int>("count");

            var name = Variable.For <string>();

            var variables = new StubMethodVariables();

            variables.Store(age);
            variables.Store(count);
            variables.Store(name);

            var @call = MethodCall.For <MethodCallTarget>(x => x.DoSomething(0, 0, null));

            @call.IsLocal = true;

            var found = @call.FindVariables(variables).ToArray();

            @call.Arguments[0].ShouldBe(age);
            @call.Arguments[1].ShouldBe(count);
            @call.Arguments[2].ShouldBe(name);
        }
Пример #3
0
        public void find_variables_returns_all_the_set_arguments_too()
        {
            var age   = Variable.For <int>("age");
            var count = Variable.For <int>("count");

            var name = Variable.For <string>();

            var variables = new StubMethodVariables();

            //variables.Store(age);
            variables.Store(count);
            variables.Store(name);

            var @call = MethodCall.For <MethodCallTarget>(x => x.DoSomething(0, 0, null));

            @call.IsLocal = true;
            @call.TrySetArgument("age", age).ShouldBeTrue();

            var found = @call.FindVariables(variables).ToArray();

            found.ShouldContain(age);
            found.ShouldContain(count);
            found.ShouldContain(name);
        }