Пример #1
0
        public virtual void Use_provider_method_is_generated_correctly()
        {
            var codeGenerator = new SpannerCodeGenerator(
                new ProviderCodeGeneratorDependencies(Enumerable.Empty <IProviderCodeGeneratorPlugin>()));

            var result = codeGenerator.GenerateUseProvider("Source=projects/p1/instances/i1/databases/d1", providerOptions: null);

            Assert.Equal("UseSpanner", result.Method);
            Assert.Collection(
                result.Arguments,
                a => Assert.Equal("Source=projects/p1/instances/i1/databases/d1", a));
            Assert.Null(result.ChainedCall);
        }
Пример #2
0
        public virtual void Use_provider_method_is_generated_correctly_with_options()
        {
            var codeGenerator = new SpannerCodeGenerator(
                new ProviderCodeGeneratorDependencies(Enumerable.Empty <IProviderCodeGeneratorPlugin>()));

            var providerOptions = new MethodCallCodeFragment("SetProviderOption");

            var result = codeGenerator.GenerateUseProvider("Source=projects/p1/instances/i1/databases/d1", providerOptions);

            Assert.Equal("UseSpanner", result.Method);
            Assert.Collection(
                result.Arguments,
                a => Assert.Equal("Source=projects/p1/instances/i1/databases/d1", a),
                a =>
            {
                var nestedClosure = Assert.IsType <NestedClosureCodeFragment>(a);

                Assert.Equal("x", nestedClosure.Parameter);
                Assert.Same(providerOptions, nestedClosure.MethodCall);
            });
            Assert.Null(result.ChainedCall);
        }