コード例 #1
0
ファイル: CheckpointStoreTest.cs プロジェクト: nlcamp/iotedge
        public async Task CheckpointStoreBasicTest()
        {
            ICheckpointStore checkpointStore = CheckpointStore.Create(new StoreProvider(new InMemoryDbStoreProvider()));

            for (long i = 0; i < 10; i++)
            {
                var checkpointData = new CheckpointData(i);
                await checkpointStore.SetCheckpointDataAsync($"Endpoint{i}", checkpointData, CancellationToken.None);
            }

            IDictionary <string, CheckpointData> allCheckpointData = await checkpointStore.GetAllCheckpointDataAsync(CancellationToken.None);

            Assert.Equal(10, allCheckpointData.Count);
            long counter = 0;

            foreach (KeyValuePair <string, CheckpointData> checkpointValue in allCheckpointData)
            {
                Assert.Equal(counter, checkpointValue.Value.Offset);
                Assert.Equal($"Endpoint{counter}", checkpointValue.Key);
                counter++;
            }

            for (long i = 0; i < 10; i++)
            {
                CheckpointData checkpointData = await checkpointStore.GetCheckpointDataAsync($"Endpoint{i}", CancellationToken.None);

                Assert.NotNull(checkpointData);
                Assert.Equal(i, checkpointData.Offset);
            }
        }