예제 #1
0
        public void TestBlobFileStore()
        {
            var testKey = new TestValue.Key(accountId: Guid.NewGuid());

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

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

            var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>(
                fileStore: new BlobFileStore(
                    GetConfig("ConnectionString"),
                    "test-kvs",
                    "application/json"),
                serializer: new JsonSerializer($"{JsonOptions.Default}"),
                keyMap: "test-values/{AccountId}",
                fileExtension: ".json");

            TestDataStore(
                dataStore,
                testKey,
                testValueA,
                testValueB);
        }
예제 #2
0
        public void TestBlobFileStore_OptimisticConcurrency()
        {
            var testKey = new TestValue.Key(accountId: Guid.NewGuid());

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

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

            var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>(
                fileStore: new BlobFileStore(
                    GetConfig("ConnectionString"),
                    "test-kvs",
                    "application/json"),
                serializer: new JsonSerializer($"{JsonOptions.Default}"),
                keyMap: "test-values/{AccountId}",
                fileExtension: ".json");

            dataStore
            .Upsert(testKey, o =>
            {
                Assert.Null(o);

                return(testValueB);
            })
            .Wait();

            dataStore
            .Upsert(testKey, o =>
            {
                Assert.Equal(testValueB.AccountId, o.AccountId);

                Assert.Equal(testValueB.Message, o.Message);

                return(testValueA);
            })
            .Wait();
        }