コード例 #1
0
        public void OneTimeSetUp()
        {
            TestSetUp.DefaultEnvironmentVariablePrefix = "Billing";
            TestSetUp.SetDefaultLocalReferenceData <IReferenceData, ReferenceDataAgentProvider, IReferenceDataAgent, ReferenceDataAgent>();
            TestSetUp.DefaultExpectNoEvents = true;
            TestSetUp.RegisterSetUp(async(count, _) =>
            {
                // Setup and load cosmos once only.
                if (count == 0)
                {
                    var config      = AgentTester.BuildConfiguration <Startup>("Billing").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>("RefData.yaml").ConfigureAwait(false);
                }

                return(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()
        {
            var config = AgentTester.BuildConfiguration <Startup>("Beef");

            TestSetUp.SetDefaultLocalReferenceData <IReferenceData, ReferenceDataAgentProvider, IReferenceDataAgent, ReferenceDataAgent>();
            TestSetUp.RegisterSetUp(async(count, data) =>
            {
                return(await DatabaseExecutor.RunAsync(
                           count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData,
                           config["ConnectionStrings:BeefDemo"], useBeefDbo: true,
                           typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly(), typeof(Beef.Demo.Abc.Database.Scripts).Assembly).ConfigureAwait(false) == 0);
            });
        }
コード例 #3
0
        public void OneTimeSetUp()
        {
            TestSetUp.DefaultEnvironmentVariablePrefix = "AppName";
            TestSetUp.SetDefaultLocalReferenceData <IReferenceData, ReferenceDataAgentProvider, IReferenceDataAgent, ReferenceDataAgent>();
            TestSetUp.DefaultExpectNoEvents = true;
            var config = AgentTester.BuildConfiguration <Startup>();

            TestSetUp.RegisterSetUp(async(count, _) =>
            {
                return(await DatabaseExecutor.RunAsync(
                           count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData,
                           config["ConnectionStrings:Database"], useBeefDbo: true,
                           typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly()).ConfigureAwait(false) == 0);
            });
        }
コード例 #4
0
        public void OneTimeSetUp()
        {
            var config = AgentTester.BuildConfiguration <Startup>("Beef");

            TestSetUp.SetDefaultLocalReferenceData <IReferenceData, ReferenceDataAgentProvider, IReferenceDataAgent, ReferenceDataAgent>();
            TestSetUp.AddWebApiAgentArgsType <IDemoWebApiAgentArgs, DemoWebApiAgentArgs>();
            TestSetUp.RegisterSetUp(async(count, data) =>
            {
                var args = new DatabaseExecutorArgs(
                    count == 0 ? DatabaseExecutorCommand.ResetAndDatabase : DatabaseExecutorCommand.ResetAndData, config["ConnectionStrings:BeefDemo"],
                    typeof(Database.Program).Assembly, Assembly.GetExecutingAssembly(), typeof(Beef.Demo.Abc.Database.Scripts).Assembly)
                {
                    UseBeefDbo = true
                }.AddSchemaOrder("Sec", "Ref", "Test", "Demo");

                return(await DatabaseExecutor.RunAsync(args).ConfigureAwait(false) == 0);
            });
        }
コード例 #5
0
        public void OneTimeSetUp()
        {
            TestSetUp.DefaultEnvironmentVariablePrefix = "AppName";
            TestSetUp.SetDefaultLocalReferenceData <IReferenceData, ReferenceDataAgentProvider, IReferenceDataAgent, ReferenceDataAgent>();
            TestSetUp.DefaultExpectNoEvents = true;
            var config = AgentTester.BuildConfiguration <Startup>();

            TestSetUp.RegisterSetUp(async(count, _) =>
            {
                var cc          = config.GetSection("CosmosDb");
                _removeAfterUse = config.GetValue <bool>("RemoveAfterUse");
                _cosmosDb       = new AppNameCosmosDb(new Cosmos.CosmosClient(cc.GetValue <string>("EndPoint"), cc.GetValue <string>("AuthKey")), cc.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>("RefData.yaml").ConfigureAwait(false);

                return(true);
            });
        }