예제 #1
0
        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 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 Delete_when_config_action_should_call_method_on_internal_configuration()
        {
            var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration<Order>();

            ModificationFunctionConfiguration<Order> configuration = null;

            modificationFunctionsConfiguration.Delete(c => { configuration = c; });

            Assert.Same(
                configuration.Configuration,
                modificationFunctionsConfiguration.Configuration.DeleteModificationFunctionConfiguration);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public void IsCompatible_should_check_compatibility_of_delete_configuration()
        {
            var modificationFunctionsConfiguration1 = new ModificationFunctionsConfiguration();
            var modificationFunctionsConfiguration2 = new ModificationFunctionsConfiguration();

            Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2));

            var modificationFunctionConfiguration1 = new ModificationFunctionConfiguration();
            var modificationFunctionConfiguration2 = new ModificationFunctionConfiguration();

            modificationFunctionsConfiguration1.Delete(modificationFunctionConfiguration1);

            Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2));

            modificationFunctionsConfiguration2.Delete(modificationFunctionConfiguration2);

            Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2));

            modificationFunctionConfiguration1.HasName("Foo");

            Assert.True(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2));

            modificationFunctionConfiguration2.HasName("Bar");

            Assert.False(modificationFunctionsConfiguration1.IsCompatibleWith(modificationFunctionsConfiguration2));
        }