Esempio n. 1
0
        public void Caches_model_by_context_type()
        {
            var modelSource = new DefaultModelSource(new DbSetFinder());

            var model1 = modelSource.GetModel(new Context1(), new ModelBuilderFactory());
            var model2 = modelSource.GetModel(new Context2(), new ModelBuilderFactory());

            Assert.NotSame(model1, model2);
            Assert.Same(model1, modelSource.GetModel(new Context1(), new ModelBuilderFactory()));
            Assert.Same(model2, modelSource.GetModel(new Context2(), new ModelBuilderFactory()));
        }
Esempio n. 2
0
        public void Members_check_arguments()
        {
            Assert.Equal(
                "setFinder",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() => new DefaultModelSource(null)).ParamName);

            var modelSource = new DefaultModelSource(new Mock <DbSetFinder>().Object);

            Assert.Equal(
                "context",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws <ArgumentNullException>(() => modelSource.GetModel(null, new ModelBuilderFactory())).ParamName);
        }