Beispiel #1
0
        public virtual void Finds_dbFunctions_on_dbContext()
        {
            var modelBuilder = GetModelBuilder();

            var customizer = new RelationalModelCustomizer(new ModelCustomizerDependencies(new DbSetFinder()));

            customizer.Customize(modelBuilder, new MyDerivedContext());

            foreach (var function in MyBaseContext.FunctionNames)
            {
                Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                                   typeof(MyBaseContext).GetMethod(function, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)));
            }

            foreach (var function in MyDerivedContext.FunctionNames)
            {
                Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                                   typeof(MyDerivedContext).GetMethod(function, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)));
            }
        }
        public virtual void Finds_dbFunctions_on_dbContext()
        {
            var modelBuilder = GetModelBuilder();

            var customizer = new RelationalModelCustomizer(new ModelCustomizerDependencies(new DbSetFinder()));

            customizer.Customize(modelBuilder, new MyDerivedContext());

            Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                               typeof(MyDerivedContext)
                               .GetRuntimeMethod(nameof(MyBaseContext.NonStaticBase), new Type[] { })));

            Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                               typeof(MyBaseContext)
                               .GetRuntimeMethod(nameof(MyBaseContext.StaticBase), new Type[] { })));

            Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                               typeof(MyDerivedContext)
                               .GetRuntimeMethod(nameof(MyDerivedContext.NonStaticDerived), new Type[] { })));

            Assert.NotNull(modelBuilder.Model.Relational().FindDbFunction(
                               typeof(MyDerivedContext)
                               .GetRuntimeMethod(nameof(MyDerivedContext.NonStaticDerived), new Type[] { })));
        }