public void GetSchema_InvokedUsingType_WillGenerateSchema() { var schemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); var schema = schemas.GetSchema(typeof(X)); Assert.IsNotNull(schema); }
public void GetSchemas_WhenContainingASchema_YieldsOneSchema() { var schemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); var schema = schemas.GetSchema<X>(); var fetchedSchema = schemas.GetSchemas().First(); Assert.AreEqual(schema, fetchedSchema); }
public void GetSchemas_WhenContainingASchema_YieldsOneSchema() { var schemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); var schema = schemas.GetSchema <X>(); var fetchedSchema = schemas.GetSchemas().First(); Assert.AreEqual(schema, fetchedSchema); }
public void GetSchema_WhenCustomConfigurationExists_ViaLambdas_ReturnsSchemaWithCorrectIndexAccessor() { var structureTypeFactory = new StructureTypeFactory(); var schemaBuilder = new AutoStructureSchemaBuilder(); var schemas = new StructureSchemas(structureTypeFactory, schemaBuilder); schemas.StructureTypeFactory.Configurations.Configure<FooCustomer>(cfg => cfg.OnlyIndexThis(c => c.CustomerNo)); var schema = schemas.GetSchema<FooCustomer>(); Assert.AreEqual("CustomerNo", schema.IndexAccessors.Single().Path); }
public void GetSchema_WhenCustomConfigurationExists_ViaNonGenericConfig_ReturnsSchemaWithCorrectIndexAccessor() { var structureTypeFactory = new StructureTypeFactory(); var schemaBuilder = new AutoStructureSchemaBuilder(); var schemas = new StructureSchemas(structureTypeFactory, schemaBuilder); schemas.StructureTypeFactory.Configurations.Configure(typeof(FooCustomer), cfg => cfg.OnlyIndexThis("CustomerNo")); var schema = schemas.GetSchema <FooCustomer>(); Assert.AreEqual("CustomerNo", schema.IndexAccessors.Single().Path); }
protected virtual void OnDropStructureSets(Type[] types) { using (var dbClient = ProviderFactory.GetTransactionalDbClient(_connectionInfo)) { foreach (var type in types) { CacheProvider.ClearByType(type); var structureSchema = StructureSchemas.GetSchema(type); DbSchemas.Drop(structureSchema, dbClient); StructureSchemas.RemoveSchema(type); } } }
public void Build() { var structureSchemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); structureSchemas.GetSchema<MyDummy>(); var dbFake = new Mock<ISisoDatabase>(); dbFake.SetupGet(f => f.Name).Returns("UnitTestDb"); dbFake.Setup(f => f.ConnectionInfo).Returns(new Sql2012ConnectionInfo("data source=.;initial catalog=foo;integrated security=true;")); dbFake.Setup(f => f.Settings).Returns(DbSettings.CreateDefault()); dbFake.Setup(f => f.Serializer).Returns(new ServiceStackSisoSerializer()); dbFake.Setup(f => f.StructureSchemas).Returns(structureSchemas); var dbDiagnostics = new DbDiagnosticsBuilder(dbFake.Object); var info = dbDiagnostics.Build(); JsonApprovals.VerifyAsJson(info); }
public void GetData() { var structureSchemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); structureSchemas.GetSchema<MyDummy>(); var dbFake = new Mock<ISisoDatabase>(); dbFake.SetupGet(f => f.Name).Returns("UnitTestDb"); dbFake.Setup(f => f.ConnectionInfo).Returns(new Sql2012ConnectionInfo("data source=.;initial catalog=foo;integrated security=true;")); dbFake.Setup(f => f.Settings).Returns(DbSettings.CreateDefault()); dbFake.Setup(f => f.Serializer).Returns(new ServiceStackSisoSerializer()); dbFake.Setup(f => f.StructureSchemas).Returns(structureSchemas); SisoDbGlimpsePlugin.ResolveDatabasesUsing = () => new[] { dbFake.Object }; var plugin = new SisoDbGlimpsePlugin(); var data = plugin.GetData(Mock.Of<ITabContext>()); JsonApprovals.VerifyAsJson(data); }
protected virtual void OnUpsertStructureSets(Type[] types) { if (!Settings.AllowsAnyDynamicSchemaChanges()) { return; } using (var dbClient = ProviderFactory.GetTransactionalDbClient(_connectionInfo)) { foreach (var type in types) { CacheProvider.ClearByType(type); var structureSchema = StructureSchemas.GetSchema(type); DbSchemas.Upsert(structureSchema, dbClient); } } }
public void Build() { var structureSchemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); structureSchemas.GetSchema <MyDummy>(); var dbFake = new Mock <ISisoDatabase>(); dbFake.SetupGet(f => f.Name).Returns("UnitTestDb"); dbFake.Setup(f => f.ConnectionInfo).Returns(new Sql2012ConnectionInfo("data source=.;initial catalog=foo;integrated security=true;")); dbFake.Setup(f => f.Settings).Returns(DbSettings.CreateDefault()); dbFake.Setup(f => f.Serializer).Returns(new ServiceStackSisoSerializer()); dbFake.Setup(f => f.StructureSchemas).Returns(structureSchemas); var dbDiagnostics = new DbDiagnosticsBuilder(dbFake.Object); var info = dbDiagnostics.Build(); JsonApprovals.VerifyAsJson(info); }
public void GetData() { var structureSchemas = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder()); structureSchemas.GetSchema <MyDummy>(); var dbFake = new Mock <ISisoDatabase>(); dbFake.SetupGet(f => f.Name).Returns("UnitTestDb"); dbFake.Setup(f => f.ConnectionInfo).Returns(new Sql2012ConnectionInfo("data source=.;initial catalog=foo;integrated security=true;")); dbFake.Setup(f => f.Settings).Returns(DbSettings.CreateDefault()); dbFake.Setup(f => f.Serializer).Returns(new ServiceStackSisoSerializer()); dbFake.Setup(f => f.StructureSchemas).Returns(structureSchemas); SisoDbGlimpsePlugin.ResolveDatabasesUsing = () => new[] { dbFake.Object }; var plugin = new SisoDbGlimpsePlugin(); var data = plugin.GetData(Mock.Of <ITabContext>()); JsonApprovals.VerifyAsJson(data); }