示例#1
0
        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.StartupTestServer <Startup>(environmentVariablesPrefix: "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";
        }
示例#2
0
        public void OneTimeSetUp()
        {
            TestSetUp.RegisterSetUp((count, data) =>
            {
                return(DatabaseExecutor.Run(
                           count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData,
                           AgentTester.Configuration["ConnectionStrings:Database"],
                           typeof(DatabaseExecutor).Assembly, typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly()) == 0);
            });

            AgentTester.StartupTestServer <Startup>(environmentVariablesPrefix: "AppName_");
        }
示例#3
0
        public void OneTimeSetUp()
        {
            TestSetUp.RegisterSetUp(async(count, data) =>
            {
                return(await DatabaseExecutor.RunAsync(
                           count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData,
                           AgentTester.Configuration["ConnectionStrings:BeefDemo"],
                           typeof(DatabaseExecutor).Assembly, typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly()).ConfigureAwait(false) == 0);
            });

            AgentTester.StartupTestServer <Startup>(environmentVariablesPrefix: "Beef_");
        }
示例#4
0
        public void OneTimeSetUp()
        {
            TestSetUp.RegisterSetUp(async(count, _) =>
            {
                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 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.StartupTestServer <Startup>(environmentVariablesPrefix: "AppName_");
            AgentTester.DefaultExpectNoEvents = true;
        }