public void Configure_should_ensure_consistency_of_function_configuration_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var functionConfiguration = new ModificationStoredProcedureConfiguration(); functionConfiguration.HasName("Bar"); var functionsConfiguration = new ModificationStoredProceduresConfiguration(); functionsConfiguration.Insert(functionConfiguration); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")); associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { ModificationStoredProceduresConfiguration = functionsConfiguration }; navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object))); Assert.Equal(functionsConfiguration, navigationPropertyConfigurationA.ModificationStoredProceduresConfiguration); }
public void IsCompatible_should_check_compatibility_of_insert_configuration() { var modificationFunctionsConfiguration1 = new ModificationStoredProceduresConfiguration(); var modificationFunctionsConfiguration2 = new ModificationStoredProceduresConfiguration(); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); var modificationFunctionConfiguration1 = new ModificationStoredProcedureConfiguration(); var modificationFunctionConfiguration2 = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfiguration1.Insert(modificationFunctionConfiguration1); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionsConfiguration2.Insert(modificationFunctionConfiguration2); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionConfiguration1.HasName("Foo"); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionConfiguration2.HasName("Bar"); Assert.False(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); }
public void Configure_association_set_should_call_configure_function_configurations() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration(); var mockModificationFunctionConfiguration = new Mock <ModificationStoredProcedureConfiguration>(); modificationFunctionsConfiguration.Insert(mockModificationFunctionConfiguration.Object); modificationFunctionsConfiguration.Delete(mockModificationFunctionConfiguration.Object); var entitySet = new EntitySet(); entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace)); var storageModificationFunctionMapping = new ModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new ModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new AssociationSetModificationFunctionMapping( new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)), storageModificationFunctionMapping, storageModificationFunctionMapping), ProviderRegistry.Sql2008_ProviderManifest); mockModificationFunctionConfiguration .Verify( m => m.Configure(storageModificationFunctionMapping, It.IsAny <DbProviderManifest>()), Times.Exactly(2)); }
public void Configure_should_call_configure_function_configurations() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration(); var mockModificationFunctionConfiguration = new Mock<ModificationStoredProcedureConfiguration>(); modificationFunctionsConfiguration.Insert(mockModificationFunctionConfiguration.Object); modificationFunctionsConfiguration.Update(mockModificationFunctionConfiguration.Object); modificationFunctionsConfiguration.Delete(mockModificationFunctionConfiguration.Object); var entitySet = new EntitySet(); entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace)); var storageModificationFunctionMapping = new ModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new ModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new EntityTypeModificationFunctionMapping( new EntityType("E", "N", DataSpace.CSpace), storageModificationFunctionMapping, storageModificationFunctionMapping, storageModificationFunctionMapping), ProviderRegistry.Sql2008_ProviderManifest); mockModificationFunctionConfiguration .Verify( m => m.Configure(storageModificationFunctionMapping, It.IsAny<DbProviderManifest>()), Times.Exactly(3)); }
public void Insert_when_config_action_should_call_method_on_internal_configuration() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration<Order>(); ModificationStoredProcedureConfigurationBase configuration = null; modificationFunctionsConfiguration.Insert(c => { configuration = c; }); Assert.Same( configuration.Configuration, modificationFunctionsConfiguration.Configuration.InsertModificationStoredProcedureConfiguration); }
public void Insert_when_config_action_should_call_method_on_internal_configuration() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration <Order>(); ModificationStoredProcedureConfigurationBase configuration = null; modificationFunctionsConfiguration.Insert(c => { configuration = c; }); Assert.Same( configuration.Configuration, modificationFunctionsConfiguration.Configuration.InsertModificationStoredProcedureConfiguration); }
public void Configure_should_configure_function_mapping() { var functionsConfiguration = new ModificationStoredProceduresConfiguration(); var functionConfiguration = new ModificationStoredProcedureConfiguration(); functionConfiguration.HasName("Func"); functionsConfiguration.Insert(functionConfiguration); var mockPropertyInfo = new MockPropertyInfo(typeof(AType1), "N"); var navigationPropertyConfiguration = new NavigationPropertyConfiguration(mockPropertyInfo) { ModificationStoredProceduresConfiguration = functionsConfiguration }; var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace) { SourceEnd = new AssociationEndMember( "S", new EntityType( "E1", "N", DataSpace.CSpace)), TargetEnd = new AssociationEndMember( "T", new EntityType( "E2", "N", DataSpace.CSpace)) }; associationType.SourceEnd.SetClrPropertyInfo(mockPropertyInfo); var associationSetMapping = databaseMapping.AddAssociationSetMapping(new AssociationSet("AS", associationType), new EntitySet()); var dependentTable = databaseMapping.Database.AddTable("T"); associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable); associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration); associationSetMapping.SourceEndMapping.AssociationEnd = associationType.SourceEnd; navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); Assert.Equal("Func", associationSetMapping.ModificationFunctionMapping.InsertFunctionMapping.Function.StoreFunctionNameAttribute); }
public void Configure_should_validate_consistency_of_function_configuration_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var functionConfiguration1 = new ModificationStoredProcedureConfiguration(); functionConfiguration1.HasName("Foo"); var functionConfiguration2 = new ModificationStoredProcedureConfiguration(); functionConfiguration2.HasName("Bar"); var functionsConfiguration1 = new ModificationStoredProceduresConfiguration(); functionsConfiguration1.Insert(functionConfiguration1); var functionsConfiguration2 = new ModificationStoredProceduresConfiguration(); functionsConfiguration2.Insert(functionConfiguration2); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")) { ModificationStoredProceduresConfiguration = functionsConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { ModificationStoredProceduresConfiguration = functionsConfiguration2 }; Assert.Equal( Strings.ConflictingFunctionsMapping("N2", typeof(object)), Assert.Throws <InvalidOperationException>( () => navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)))).Message); }
public void Can_clone_configuration() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration(); var modificationFunctionConfiguration = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration); modificationFunctionsConfiguration.Update(modificationFunctionConfiguration); modificationFunctionsConfiguration.Delete(modificationFunctionConfiguration); var clone = modificationFunctionsConfiguration.Clone(); Assert.NotSame(modificationFunctionsConfiguration, clone); Assert.NotSame(modificationFunctionConfiguration, clone.InsertModificationStoredProcedureConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.UpdateModificationStoredProcedureConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.DeleteModificationStoredProcedureConfiguration); }
public void Can_merge_configurations() { var modificationFunctionsConfigurationA = new ModificationStoredProceduresConfiguration(); var modificationFunctionConfiguration = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfigurationA.Insert(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Update(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Delete(modificationFunctionConfiguration); var modificationFunctionsConfigurationB = new ModificationStoredProceduresConfiguration(); modificationFunctionsConfigurationB.Merge(modificationFunctionsConfigurationA, true); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.InsertModificationStoredProcedureConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.UpdateModificationStoredProcedureConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.DeleteModificationStoredProcedureConfiguration); }
public void Can_clone_configuration() { var modificationFunctionsConfiguration = new ModificationStoredProceduresConfiguration(); var modificationFunctionConfiguration = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration); modificationFunctionsConfiguration.Update(modificationFunctionConfiguration); modificationFunctionsConfiguration.Delete(modificationFunctionConfiguration); var clone = modificationFunctionsConfiguration.Clone(); Assert.NotSame(modificationFunctionsConfiguration, clone); Assert.NotSame(modificationFunctionConfiguration, clone.InsertModificationStoredProcedureConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.UpdateModificationStoredProcedureConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.DeleteModificationStoredProcedureConfiguration); }
public void Can_merge_configurations() { var modificationFunctionsConfigurationA = new ModificationStoredProceduresConfiguration(); var modificationFunctionConfiguration = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfigurationA.Insert(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Update(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Delete(modificationFunctionConfiguration); var modificationFunctionsConfigurationB = new ModificationStoredProceduresConfiguration(); modificationFunctionsConfigurationB.Merge(modificationFunctionsConfigurationA, true); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.InsertModificationStoredProcedureConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.UpdateModificationStoredProcedureConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.DeleteModificationStoredProcedureConfiguration); }
public void Configure_should_ensure_consistency_of_function_configuration_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var functionConfiguration = new ModificationStoredProcedureConfiguration(); functionConfiguration.HasName("Bar"); var functionsConfiguration = new ModificationStoredProceduresConfiguration(); functionsConfiguration.Insert(functionConfiguration); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")); associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { ModificationStoredProceduresConfiguration = functionsConfiguration }; navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object))); Assert.Equal(functionsConfiguration, navigationPropertyConfigurationA.ModificationStoredProceduresConfiguration); }
public void Configure_should_validate_consistency_of_function_configuration_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); var functionConfiguration1 = new ModificationStoredProcedureConfiguration(); functionConfiguration1.HasName("Foo"); var functionConfiguration2 = new ModificationStoredProcedureConfiguration(); functionConfiguration2.HasName("Bar"); var functionsConfiguration1 = new ModificationStoredProceduresConfiguration(); functionsConfiguration1.Insert(functionConfiguration1); var functionsConfiguration2 = new ModificationStoredProceduresConfiguration(); functionsConfiguration2.Insert(functionConfiguration2); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")) { ModificationStoredProceduresConfiguration = functionsConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { ModificationStoredProceduresConfiguration = functionsConfiguration2 }; Assert.Equal( Strings.ConflictingFunctionsMapping("N2", typeof(object)), Assert.Throws<InvalidOperationException>( () => navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_configure_function_mapping() { var functionsConfiguration = new ModificationStoredProceduresConfiguration(); var functionConfiguration = new ModificationStoredProcedureConfiguration(); functionConfiguration.HasName("Func"); functionsConfiguration.Insert(functionConfiguration); var mockPropertyInfo = new MockPropertyInfo(typeof(AType1), "N"); var navigationPropertyConfiguration = new NavigationPropertyConfiguration(mockPropertyInfo) { ModificationStoredProceduresConfiguration = functionsConfiguration }; var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace) { SourceEnd = new AssociationEndMember( "S", new EntityType( "E1", "N", DataSpace.CSpace)), TargetEnd = new AssociationEndMember( "T", new EntityType( "E2", "N", DataSpace.CSpace)) }; associationType.SourceEnd.SetClrPropertyInfo(mockPropertyInfo); var associationSetMapping = databaseMapping.AddAssociationSetMapping(new AssociationSet("AS", associationType), new EntitySet()); var dependentTable = databaseMapping.Database.AddTable("T"); associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable); associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration); associationSetMapping.SourceEndMapping.AssociationEnd = associationType.SourceEnd; navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); Assert.Equal("Func", associationSetMapping.ModificationFunctionMapping.InsertFunctionMapping.Function.StoreFunctionNameAttribute); }
public void IsCompatible_should_check_compatibility_of_insert_configuration() { var modificationFunctionsConfiguration1 = new ModificationStoredProceduresConfiguration(); var modificationFunctionsConfiguration2 = new ModificationStoredProceduresConfiguration(); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); var modificationFunctionConfiguration1 = new ModificationStoredProcedureConfiguration(); var modificationFunctionConfiguration2 = new ModificationStoredProcedureConfiguration(); modificationFunctionsConfiguration1.Insert(modificationFunctionConfiguration1); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionsConfiguration2.Insert(modificationFunctionConfiguration2); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionConfiguration1.HasName("Foo"); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); modificationFunctionConfiguration2.HasName("Bar"); Assert.False(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); }