Beispiel #1
0
        public async Task ReadItem()
        {
            var store = new ConcurrentJsonStore <Person>(_options, _semaphoreFactory);

            var person = await store.ReadAsync();

            Assert.Equal(Constants.GetPerson(), person);
        }
Beispiel #2
0
        public void ReadAndSave()
        {
            var store   = new ConcurrentJsonStore <Person>(_options, _semaphoreFactory);
            var person2 = Constants.GetPerson2();

            // use a task to change the item and other to read it
            Task.WaitAll(
                Task.Run(async() => await store.SaveAsync(person2)),
                Task.Run(async() => await store.ReadAsync())
                );
        }
Beispiel #3
0
        public async Task ChangeItem()
        {
            var store1    = new ConcurrentJsonStore <Person>(_options, _semaphoreFactory);
            var newPerson = Constants.GetPerson2();
            await store1.SaveAsync(newPerson);

            // use another store to read
            var store2 = new ConcurrentJsonStore <Person>(_options, _semaphoreFactory);
            var person = await store2.ReadAsync();

            Assert.Equal(Constants.GetPerson2(), person);
        }
Beispiel #4
0
        public async Task GetNullValue()
        {
            var person = await _store.ReadAsync();

            Assert.Null(person);
        }