Beispiel #1
0
        public static ProviderCollection <StorageProviderDefinition> CreateTestDomainStorageProviders()
        {
            ProviderCollection <StorageProviderDefinition> storageProviderDefinitionCollection = new ProviderCollection <StorageProviderDefinition>();
            var sqlStorageObjectFactory = new SqlStorageObjectFactory();

            storageProviderDefinitionCollection.Add(
                new RdbmsProviderDefinition(
                    DatabaseTest.c_testDomainProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.TestDomainConnectionString));

            storageProviderDefinitionCollection.Add(
                new RdbmsProviderDefinition(
                    DatabaseTest.DefaultStorageProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.TestDomainConnectionString));

            storageProviderDefinitionCollection.Add(
                new UnitTestStorageProviderStubDefinition(
                    DatabaseTest.c_unitTestStorageProviderStubID));

            storageProviderDefinitionCollection.Add(
                new RdbmsProviderDefinition(
                    TableInheritanceMappingTest.TableInheritanceTestDomainProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.TestDomainConnectionString));

            return(storageProviderDefinitionCollection);
        }
        public void SetUp()
        {
            _configuration           = new StorageConfiguration();
            _sqlStorageObjectFactory = new SqlStorageObjectFactory();

            FakeConfigurationWrapper configurationWrapper = new FakeConfigurationWrapper();

            configurationWrapper.SetUpConnectionString("Rdbms", "ConnectionString", null);
            ConfigurationWrapper.SetCurrent(configurationWrapper);
        }
Beispiel #3
0
        public SchemaGenerationConfiguration()
        {
            var sqlStorageObjectFactory             = new SqlStorageObjectFactory();
            var storageProviderDefinitionCollection = new ProviderCollection <StorageProviderDefinition>
            {
                new RdbmsProviderDefinition(
                    DatabaseTest.SchemaGenerationFirstStorageProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.SchemaGenerationConnectionString1),
                new RdbmsProviderDefinition(
                    DatabaseTest.SchemaGenerationSecondStorageProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.SchemaGenerationConnectionString2),
                new RdbmsProviderDefinition(
                    DatabaseTest.SchemaGenerationThirdStorageProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.SchemaGenerationConnectionString3),
                new RdbmsProviderDefinition(
                    DatabaseTest.SchemaGenerationInternalStorageProviderID,
                    sqlStorageObjectFactory,
                    DatabaseTest.SchemaGenerationConnectionString1)
            };

            _storageConfiguration = new StorageConfiguration(
                storageProviderDefinitionCollection,
                storageProviderDefinitionCollection[DatabaseTest.SchemaGenerationFirstStorageProviderID]);
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(
                    new FirstStorageGroupAttribute(),
                    DatabaseTest.SchemaGenerationFirstStorageProviderID));
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(
                    new SecondStorageGroupAttribute(),
                    DatabaseTest.SchemaGenerationSecondStorageProviderID));
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(
                    new ThirdStorageGroupAttribute(),
                    DatabaseTest.SchemaGenerationThirdStorageProviderID));
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(
                    new InternalStorageGroupAttribute(),
                    DatabaseTest.SchemaGenerationInternalStorageProviderID));

            _mappingLoaderConfiguration = new MappingLoaderConfiguration();
            _queryConfiguration         = new QueryConfiguration();

            var typeDiscoveryService = GetTypeDiscoveryService(GetType().Assembly);

            _mappingConfiguration = new MappingConfiguration(
                MappingReflectorObjectMother.CreateMappingReflector(typeDiscoveryService),
                new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(_storageConfiguration)));
            _domainObjectsConfiguration = new FakeDomainObjectsConfiguration(_mappingLoaderConfiguration, _storageConfiguration, _queryConfiguration);
        }
        public override void SetUp()
        {
            base.SetUp();

            _sqlStorageObjectFactory = new SqlStorageObjectFactory();
            _definition = new RdbmsProviderDefinition("StorageProviderID", _sqlStorageObjectFactory, "ConnectionString");

            FakeConfigurationWrapper configurationWrapper = new FakeConfigurationWrapper();

            configurationWrapper.SetUpConnectionString("SqlProvider", "ConnectionString", null);
            ConfigurationWrapper.SetCurrent(configurationWrapper);
        }
Beispiel #5
0
        public void Serialize()
        {
            var sqlStorageObjectFactory = new SqlStorageObjectFactory();
            var mappingSerializer       =
                new MappingSerializer(
                    d => sqlStorageObjectFactory.CreateEnumSerializer(),
                    (d, enumSerializer) => sqlStorageObjectFactory.CreateStorageProviderSerializer(enumSerializer));

            var actual   = mappingSerializer.Serialize(MappingConfiguration.Current.GetTypeDefinitions());
            var expected = XDocument.Load(new MemoryStream(ResourceManager.GetMappingExportOutput()));

            Assert.That(actual.ToString(), Is.EqualTo(expected.ToString()));
        }
Beispiel #6
0
        public void Serialize_OutputIsValid()
        {
            var sqlStorageObjectFactory = new SqlStorageObjectFactory();
            var mappingSerializer       =
                new MappingSerializer(
                    d => sqlStorageObjectFactory.CreateEnumSerializer(),
                    (d, enumSerializer) => sqlStorageObjectFactory.CreateStorageProviderSerializer(enumSerializer));

            var actual = mappingSerializer.Serialize(MappingConfiguration.Current.GetTypeDefinitions());

            var schemaSet = new XmlSchemaSet();

            schemaSet.Add(XmlSchema.Read(new MemoryStream(ResourceManager.GetRdbmsMappingSchema()), null));
            actual.Validate(schemaSet, null);
        }
Beispiel #7
0
        public void SetUp()
        {
            var mappingLoader = new MappingReflector(
                new FixedTypeDiscoveryService(GetReflectedTypes()),
                new ClassIDProvider(),
                new ReflectionBasedMemberInformationNameResolver(),
                new PropertyMetadataReflector(),
                new DomainModelConstraintProvider(),
                new ThrowingDomainObjectCreator());

            _storageObjectFactory = CreateSqlStorageObjectFactory();
            var storageProviderDefinitionFinderStub = MockRepository.GenerateStub <IStorageProviderDefinitionFinder>();

            _storageProviderDefinition = new RdbmsProviderDefinition("test", _storageObjectFactory, DatabaseTest.TestDomainConnectionString);
            storageProviderDefinitionFinderStub
            .Stub(stub => stub.GetStorageProviderDefinition(Arg <ClassDefinition> .Is.Anything, Arg <string> .Is.Anything))
            .Return(_storageProviderDefinition);
            var persistenceModelLoader = _storageObjectFactory.CreatePersistenceModelLoader(_storageProviderDefinition, storageProviderDefinitionFinderStub);

            _mappingConfiguration = new MappingConfiguration(mappingLoader, persistenceModelLoader);

            MappingConfiguration.SetCurrent(_mappingConfiguration);
        }