コード例 #1
0
        public virtual void UseProviderMethodIsGeneratedCorrectly()
        {
            var codeGenerator = new MySQLCodeGenerator(
                new ProviderCodeGeneratorDependencies(
                    Enumerable.Empty <IProviderCodeGeneratorPlugin>()));

            var result = codeGenerator.GenerateUseProvider("Data Source=Test", providerOptions: null);

            Assert.AreEqual("UseMySQL", result.Method);
            Assert.That(result.Arguments, Has.Exactly(1).EqualTo("Data Source=Test"));
            Assert.Null(result.ChainedCall);
        }
コード例 #2
0
        public virtual void UseProviderMethodIsGeneratedCorrectlyWithOptions()
        {
            var codeGenerator = new MySQLCodeGenerator(
                new ProviderCodeGeneratorDependencies(
                    Enumerable.Empty <IProviderCodeGeneratorPlugin>()));

            var providerOptions = new MethodCallCodeFragment("SetProviderOption");

            var result = codeGenerator.GenerateUseProvider("Data Source=Test", providerOptions);

            Assert.AreEqual("UseMySQL", result.Method);
            Assert.That(result.Arguments, Has.Exactly(1).EqualTo("Data Source=Test"));
            Assert.IsInstanceOf <NestedClosureCodeFragment>(result.Arguments[1]);
            NestedClosureCodeFragment nestedClosure = (NestedClosureCodeFragment)result.Arguments[1];

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