Esempio n. 1
0
        public void TestCosmosDbJObject()
        {
            var testKey = new JObjectTestKey(
                partitionId: Guid.NewGuid(),
                accountId: Guid.NewGuid());

            var testValueA = JObject.FromObject(new PartitionedTestValue(
                                                    partitionId: testKey.PartitionId.Value,
                                                    accountId: testKey.AccountId.Value,
                                                    message: "Hello, world!"));

            var testValueB = JObject.FromObject(new PartitionedTestValue(
                                                    partitionId: testKey.PartitionId.Value,
                                                    accountId: testKey.AccountId.Value,
                                                    message: "Kthx, world!"));

            var dataStore = new CosmosDbDataStore <JObjectTestKey, JObject>(
                connectionString: GetConfig("ConnectionString"),
                databaseId: GetConfig("DatabaseId"),
                containerId: GetConfig("CollectionId"),
                keyMap: "{PartitionId}|test-jobject-values/{AccountId}");

            ClearDataStore(dataStore);

            TestDataStore(
                dataStore,
                testKey,
                testValueA,
                testValueB);

            ClearDataStore(dataStore);
        }
        //[Fact, Trait("Type", "Integration")]
        public void TestCosmosDbFixed()
        {
            var testKey = new FixedTestValue.Key(accountId: Guid.NewGuid());

            var testValueA = new FixedTestValue(
                accountId: testKey.AccountId.Value,
                message: "Hello, world!");

            var testValueB = new FixedTestValue(
                accountId: testKey.AccountId.Value,
                message: "Kthx, world!");

            var dataStore = new CosmosDbDataStore <FixedTestValue.Key, FixedTestValue>(
                connectionString: GetConfig("ConnectionString"),
                databaseId: GetConfig("DatabaseId"),
                containerId: GetConfig("CollectionId"),
                keyMap: "test-values/{AccountId}");

            ClearDataStore(dataStore);

            TestDataStore(
                dataStore,
                testKey,
                testValueA,
                testValueB);

            TestQuery(dataStore);
        }
Esempio n. 3
0
        public async Task RunBulkApiTests()
        {
            var ds = new CosmosDbDataStore <EnumPartitionedTestValue.Key, EnumPartitionedTestValue>(
                connectionString: GetConfig("ConnectionString"),
                databaseId: GetConfig("DatabaseId"),
                containerId: GetConfig("CollectionId"),
                keyMap: "{PartitionId}|test-values/{AccountId}");

            ClearDataStore(ds);

            await TestBulkApi(ds,
                              (keyGen, dataGen) =>
            {
                var partitionId = (EnumPartitionedTestValue.PartitionEnum)(keyGen / 3);
                var accountId   = keyGen.ToGuid();

                return(new KeyValuePair <EnumPartitionedTestValue.Key, EnumPartitionedTestValue>(new EnumPartitionedTestValue.Key(partitionId, accountId),
                                                                                                 new EnumPartitionedTestValue(partitionId, accountId, $"Test: {dataGen}")));
            });
        }
Esempio n. 4
0
        public async Task TestCosmosDbPartitioned()
        {
            var testKey = new EnumPartitionedTestValue.Key(
                partitionId: EnumPartitionedTestValue.PartitionEnum.Bravo,
                accountId: Guid.NewGuid());

            var testValueA = new EnumPartitionedTestValue(
                partitionId: testKey.PartitionId,
                accountId: testKey.AccountId.Value,
                message: "Hello, world!");

            var testValueB = new EnumPartitionedTestValue(
                partitionId: testKey.PartitionId,
                accountId: testKey.AccountId.Value,
                message: "Kthx, world!");

            var dataStore = new CosmosDbDataStore <EnumPartitionedTestValue.Key, EnumPartitionedTestValue>(
                connectionString: GetConfig("ConnectionString"),
                databaseId: GetConfig("DatabaseId"),
                containerId: GetConfig("CollectionId"),
                keyMap: "{PartitionId}|enum-test-values/{AccountId}");

            ClearDataStore(dataStore);

            TestDataStore(
                dataStore,
                testKey,
                testValueA,
                testValueB);

            TestQuery(dataStore);

            ClearDataStore(dataStore);

            await TestBatch(dataStore);
        }