Beispiel #1
0
        public void Code_first_built_complex_types_matches_som_loaded_complex_types()
        {
            var context       = new ShopContext_v1();
            var compiledModel = context.InternalContext.CodeFirstModel;

            var builder = compiledModel.CachedModelBuilder.Clone();

            var databaseMapping
                = builder.Build(ProviderRegistry.Sql2008_ProviderInfo).DatabaseMapping;

            var itemCollection = new EdmItemCollection(databaseMapping.Model);

            var complexTypes    = databaseMapping.Model.ComplexTypes.ToList();
            var somComplexTypes = itemCollection.GetItems <ComplexType>();

            Assert.Equal(complexTypes.Count(), somComplexTypes.Count());

            foreach (var complexType in complexTypes)
            {
                var somComplexType = somComplexTypes.Single(e => e.Name == complexType.Name);

                Assert.Equal(complexType.NamespaceName, somComplexType.NamespaceName);
                Assert.Equal(complexType.Identity, somComplexType.Identity);
                Assert.Equal(complexType.Abstract, somComplexType.Abstract);
                Assert.Equal(complexType.FullName, somComplexType.FullName);
                Assert.Equal(complexType.Members.Count, somComplexType.Members.Count);
            }
        }
        public void Should_be_able_to_get_model_from_context()
        {
            var context = new ShopContext_v1();

            var edmX = context.GetModel();

            Assert.NotNull(edmX);
        }
        public void GetStoreItemCollection_should_return_collection()
        {
            DbProviderInfo providerInfo;
            var            storeItemCollection = new ShopContext_v1().GetModel().GetStoreItemCollection(out providerInfo);

            Assert.NotNull(storeItemCollection);
            Assert.NotNull(providerInfo);
            Assert.Equal("System.Data.SqlClient", providerInfo.ProviderInvariantName);
            Assert.True(providerInfo.ProviderManifestToken == "2008");
        }
        public void GetDynamicUpdateModel_should_build_model_mapped_to_tables()
        {
            var context = new ShopContext_v1();

            var model = context.GetDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);

            Assert.NotNull(model);

            var entityContainerMapping = model.DatabaseMapping.EntityContainerMappings.Single();

            Assert.False(entityContainerMapping.EntitySetMappings.SelectMany(esm => esm.ModificationFunctionMappings).Any());
            Assert.False(entityContainerMapping.AssociationSetMappings.Any(asm => asm.ModificationFunctionMapping != null));
        }
Beispiel #5
0
        public void GetStorageMappingItemCollection_should_return_collection()
        {
            DbProviderInfo providerInfo;

            using (var context = new ShopContext_v1())
            {
                var storageMappingItemCollection = context.GetModel().GetStorageMappingItemCollection(out providerInfo);
                Assert.NotNull(storageMappingItemCollection);
                Assert.NotNull(providerInfo);
                Assert.Equal("System.Data.SqlClient", providerInfo.ProviderInvariantName);

                if (DatabaseTestHelpers.IsSqlAzure(context.Database.Connection.ConnectionString))
                {
                    Assert.True(providerInfo.ProviderManifestToken == "2012.Azure");
                }
            }
        }
Beispiel #6
0
        public void Can_initialize_from_edm_model_and_items_set_read_only_and_added_to_collection()
        {
            var context       = new ShopContext_v1();
            var compiledModel = context.InternalContext.CodeFirstModel;

            var builder = compiledModel.CachedModelBuilder.Clone();

            var databaseMapping
                = builder.Build(ProviderRegistry.Sql2008_ProviderInfo).DatabaseMapping;

            var itemCollection = new EdmItemCollection(databaseMapping.Model);

            Assert.Equal(3.0, itemCollection.EdmVersion);

            foreach (var globalItem in databaseMapping.Model.GlobalItems)
            {
                Assert.True(itemCollection.Contains(globalItem));
                Assert.True(globalItem.IsReadOnly);
            }
        }