public void Configure_association_set_should_call_configure_function_configurations() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration(); var mockModificationFunctionConfiguration = new Mock <ModificationFunctionConfiguration>(); modificationFunctionsConfiguration.Insert(mockModificationFunctionConfiguration.Object); modificationFunctionsConfiguration.Delete(mockModificationFunctionConfiguration.Object); var entitySet = new EntitySet(); entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace)); var storageModificationFunctionMapping = new StorageModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new StorageModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new StorageAssociationSetModificationFunctionMapping( 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 ModificationFunctionsConfiguration(); var mockModificationFunctionConfiguration = new Mock<ModificationFunctionConfiguration>(); 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 StorageModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new StorageModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new StorageEntityTypeModificationFunctionMapping( 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 IsCompatible_should_check_compatibility_of_insert_configuration() { var modificationFunctionsConfiguration1 = new ModificationFunctionsConfiguration(); var modificationFunctionsConfiguration2 = new ModificationFunctionsConfiguration(); Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2)); var modificationFunctionConfiguration1 = new ModificationFunctionConfiguration(); var modificationFunctionConfiguration2 = new ModificationFunctionConfiguration(); 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_should_call_configure_function_configurations() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration(); var mockModificationFunctionConfiguration = new Mock <ModificationFunctionConfiguration>(); 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 StorageModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new StorageModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new StorageEntityTypeModificationFunctionMapping( new EntityType("E", "N", DataSpace.CSpace), storageModificationFunctionMapping, storageModificationFunctionMapping, storageModificationFunctionMapping)); mockModificationFunctionConfiguration .Verify(m => m.Configure(storageModificationFunctionMapping), Times.Exactly(3)); }
public void Configure_association_set_should_call_configure_function_configurations() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration(); var mockModificationFunctionConfiguration = new Mock<ModificationFunctionConfiguration>(); modificationFunctionsConfiguration.Insert(mockModificationFunctionConfiguration.Object); modificationFunctionsConfiguration.Delete(mockModificationFunctionConfiguration.Object); var entitySet = new EntitySet(); entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace)); var storageModificationFunctionMapping = new StorageModificationFunctionMapping( entitySet, new EntityType("E", "N", DataSpace.CSpace), new EdmFunction("F", "N", DataSpace.SSpace), new StorageModificationFunctionParameterBinding[0], null, null); modificationFunctionsConfiguration.Configure( new StorageAssociationSetModificationFunctionMapping( new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)), storageModificationFunctionMapping, storageModificationFunctionMapping)); mockModificationFunctionConfiguration .Verify(m => m.Configure(storageModificationFunctionMapping), Times.Exactly(2)); }
public void Configure_should_configure_function_mapping() { var functionsConfiguration = new ModificationFunctionsConfiguration(); var functionConfiguration = new ModificationFunctionConfiguration(); functionConfiguration.HasName("Func"); functionsConfiguration.Insert(functionConfiguration); var mockPropertyInfo = new MockPropertyInfo(); var navigationPropertyConfiguration = new NavigationPropertyConfiguration(mockPropertyInfo) { ModificationFunctionsConfiguration = functionsConfiguration }; var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var associationSetMapping = databaseMapping.AddAssociationSetMapping( new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)), new EntitySet()); var dependentTable = databaseMapping.Database.AddTable("T"); associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable); associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration); associationSetMapping.SourceEndMapping.EndMember = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)); associationSetMapping.SourceEndMapping.EndMember.SetClrPropertyInfo(mockPropertyInfo); navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); Assert.Equal("Func", associationSetMapping.ModificationFunctionMapping.InsertFunctionMapping.Function.Name); }
public void Insert_when_config_action_should_call_method_on_internal_configuration() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration<Order>(); ModificationFunctionConfiguration<Order> configuration = null; modificationFunctionsConfiguration.Insert(c => { configuration = c; }); Assert.Same( configuration.Configuration, modificationFunctionsConfiguration.Configuration.InsertModificationFunctionConfiguration); }
public void Insert_when_config_action_should_call_method_on_internal_configuration() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration <Order>(); ModificationFunctionConfiguration <Order> configuration = null; modificationFunctionsConfiguration.Insert(c => { configuration = c; }); Assert.Same( configuration.Configuration, modificationFunctionsConfiguration.Configuration.InsertModificationFunctionConfiguration); }
public void Can_clone_configuration() { var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration(); var modificationFunctionConfiguration = new ModificationFunctionConfiguration(); modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration); modificationFunctionsConfiguration.Update(modificationFunctionConfiguration); modificationFunctionsConfiguration.Delete(modificationFunctionConfiguration); var clone = modificationFunctionsConfiguration.Clone(); Assert.NotSame(modificationFunctionsConfiguration, clone); Assert.NotSame(modificationFunctionConfiguration, clone.InsertModificationFunctionConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.UpdateModificationFunctionConfiguration); Assert.NotSame(modificationFunctionConfiguration, clone.DeleteModificationFunctionConfiguration); }
public void Can_merge_configurations() { var modificationFunctionsConfigurationA = new ModificationFunctionsConfiguration(); var modificationFunctionConfiguration = new ModificationFunctionConfiguration(); modificationFunctionsConfigurationA.Insert(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Update(modificationFunctionConfiguration); modificationFunctionsConfigurationA.Delete(modificationFunctionConfiguration); var modificationFunctionsConfigurationB = new ModificationFunctionsConfiguration(); modificationFunctionsConfigurationB.Merge(modificationFunctionsConfigurationA, true); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.InsertModificationFunctionConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.UpdateModificationFunctionConfiguration); Assert.Same(modificationFunctionConfiguration, modificationFunctionsConfigurationB.DeleteModificationFunctionConfiguration); }
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 ModificationFunctionConfiguration(); functionConfiguration1.HasName("Foo"); var functionConfiguration2 = new ModificationFunctionConfiguration(); functionConfiguration2.HasName("Bar"); var functionsConfiguration1 = new ModificationFunctionsConfiguration(); functionsConfiguration1.Insert(functionConfiguration1); var functionsConfiguration2 = new ModificationFunctionsConfiguration(); functionsConfiguration2.Insert(functionConfiguration2); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N1")) { ModificationFunctionsConfiguration = functionsConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(new MockType(), "N2")) { ModificationFunctionsConfiguration = 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_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 ModificationFunctionConfiguration(); functionConfiguration1.HasName("Foo"); var functionConfiguration2 = new ModificationFunctionConfiguration(); functionConfiguration2.HasName("Bar"); var functionsConfiguration1 = new ModificationFunctionsConfiguration(); functionsConfiguration1.Insert(functionConfiguration1); var functionsConfiguration2 = new ModificationFunctionsConfiguration(); functionsConfiguration2.Insert(functionConfiguration2); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()) { ModificationFunctionsConfiguration = functionsConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { ModificationFunctionsConfiguration = functionsConfiguration2 }; Assert.Equal( Strings.ConflictingFunctionsMapping("P", 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); }