public async Task Using_batch_multithreaded_should_work() { using (var store = NewRemoteCountersStore(DefaultCounterStorageName)) { using (var otherStore = await store.Admin.CreateCounterStorageAsync(MultiDatabase.CreateCounterStorageDocument(OtherCounterStorageName), OtherCounterStorageName)) { otherStore.Initialize(); var t1 = Task.Run(() => { for (int i = 0; i < 500; i++) { store.Batch[OtherCounterStorageName].ScheduleIncrement("G", "C"); } }); var t2 = Task.Run(() => { for (int i = 0; i < 500; i++) { store.Batch[OtherCounterStorageName].ScheduleIncrement("G", "C"); } }); await Task.WhenAll(t1, t2); await store.Batch[OtherCounterStorageName].FlushAsync(); var total = await otherStore.GetOverallTotalAsync("G", "C"); Assert.Equal(1000, total.Total); } } }
public async Task Should_be_able_to_delete_counter_storages() { var expectedClientNames = new ReadOnlyCollection <string>(new List <string>() { CounterStorageName + "A", CounterStorageName + "C" }); using (var store = NewRemoteCountersStore(DefaultCounterStorageName, createDefaultCounter: false)) { await store.Admin.CreateCounterStorageAsync(MultiDatabase.CreateCounterStorageDocument(expectedClientNames[0]), expectedClientNames[0]); await store.Admin.CreateCounterStorageAsync(MultiDatabase.CreateCounterStorageDocument("CounterThatWillBeDeleted"), "CounterThatWillBeDeleted"); await store.Admin.CreateCounterStorageAsync(MultiDatabase.CreateCounterStorageDocument(expectedClientNames[1]), expectedClientNames[1]); await store.Admin.DeleteCounterStorageAsync("CounterThatWillBeDeleted", true); var counterStorageNames = await store.Admin.GetCounterStoragesNamesAsync(); Assert.Equal(counterStorageNames, expectedClientNames); } }