public void OneTimeSetUp() { TestSetUp.RegisterSetUp(async(count, _) => { // Setup and load cosmos once only. if (count == 0) { var config = AgentTester.Configuration.GetSection("CosmosDb"); _removeAfterUse = config.GetValue <bool>("RemoveAfterUse"); _cosmosDb = new CosmosDb(new Cosmos.CosmosClient(config.GetValue <string>("EndPoint"), config.GetValue <string>("AuthKey")), config.GetValue <string>("Database"), createDatabaseIfNotExists: true); var ac = await _cosmosDb.ReplaceOrCreateContainerAsync( new Cosmos.ContainerProperties { Id = "Account", PartitionKeyPath = "/_partitionKey" }, 400).ConfigureAwait(false); await ac.ImportBatchAsync <AccountTest, Business.Data.Model.Account>("Account.yaml", "Account").ConfigureAwait(false); var tc = await _cosmosDb.ReplaceOrCreateContainerAsync( new Cosmos.ContainerProperties { Id = "Transaction", PartitionKeyPath = "/accountId" }, 400).ConfigureAwait(false); await tc.ImportBatchAsync <AccountTest, Business.Data.Model.Transaction>("Transaction.yaml", "Transaction").ConfigureAwait(false); var rdc = await _cosmosDb.ReplaceOrCreateContainerAsync( new Cosmos.ContainerProperties { Id = "RefData", PartitionKeyPath = "/_partitionKey", UniqueKeyPolicy = new Cosmos.UniqueKeyPolicy { UniqueKeys = { new Cosmos.UniqueKey { Paths = { "/type","/value/code" } } } } }, 400).ConfigureAwait(false); await rdc.ImportValueRefDataBatchAsync <AccountTest>(ReferenceData.Current, "RefData.yaml").ConfigureAwait(false); } return(true); }); AgentTester.TestServerStart <Startup>("Banking"); AgentTester.DefaultExpectNoEvents = true; // TODO: Passing the username as an http header for all requests; this would be replaced with OAuth integration, etc. AgentTester.RegisterBeforeRequest(r => r.Headers.Add("cdr-user", Beef.ExecutionContext.Current.Username)); // Set "page" and "page-size" as the supported paging query string parameters as defined by the CDR specification. WebApiPagingArgsArg.PagingArgsPageQueryStringName = "page"; WebApiPagingArgsArg.PagingArgsSizeQueryStringName = "page-size"; }
public void OneTimeSetUp() { TestSetUp.RegisterSetUp(async(count, data) => { return(await DatabaseExecutor.RunAsync( count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData, AgentTester.Configuration["ConnectionStrings:BeefDemo"], useBeefDbo: true, typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly(), typeof(Beef.Demo.Abc.Database.Scripts).Assembly).ConfigureAwait(false) == 0); }); AgentTester.TestServerStart <Startup>("Beef"); }
public void OneTimeSetUp() { TestSetUp.RegisterSetUp(async(count, _) => { return(await DatabaseExecutor.RunAsync( count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData, AgentTester.Configuration["ConnectionStrings:Database"], useBeefDbo: true, typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly()).ConfigureAwait(false) == 0); }); AgentTester.TestServerStart <Startup>("AppName"); AgentTester.DefaultExpectNoEvents = true; }
public void OneTimeSetUp() { TestSetUp.RegisterSetUp(async(count, _) => { var config = AgentTester.Configuration.GetSection("CosmosDb"); _removeAfterUse = config.GetValue <bool>("RemoveAfterUse"); _cosmosDb = new AppNameCosmosDb(new Cosmos.CosmosClient(config.GetValue <string>("EndPoint"), config.GetValue <string>("AuthKey")), config.GetValue <string>("Database"), createDatabaseIfNotExists: true); var rc = await _cosmosDb.ReplaceOrCreateContainerAsync( new Cosmos.ContainerProperties { Id = "Person", PartitionKeyPath = "/_partitionKey" }, 400).ConfigureAwait(false); await rc.ImportBatchAsync <PersonTest, Person>("Person.yaml", "Person").ConfigureAwait(false); var rdc = await _cosmosDb.ReplaceOrCreateContainerAsync( new Cosmos.ContainerProperties { Id = "RefData", PartitionKeyPath = "/_partitionKey", UniqueKeyPolicy = new Cosmos.UniqueKeyPolicy { UniqueKeys = { new Cosmos.UniqueKey { Paths = { "/type","/value/code" } } } } }, 400).ConfigureAwait(false); await rdc.ImportValueRefDataBatchAsync <PersonTest>(ReferenceData.Current, "RefData.yaml").ConfigureAwait(false); return(true); }); AgentTester.TestServerStart <Startup>("AppName"); AgentTester.DefaultExpectNoEvents = true; }