public async Task ReadItem() { var store = new ConcurrentJsonStore <Person>(_options, _semaphoreFactory); var person = await store.ReadAsync(); Assert.Equal(Constants.GetPerson(), person); }
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()) ); }
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); }
public async Task GetNullValue() { var person = await _store.ReadAsync(); Assert.Null(person); }