public async Task Remove_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await store.RemoveAsync(1);

            await store.SaveChangesAsync();

            IJsonRepository <Person, int> newStore = GetStore(_options);
            var items = await newStore.GetAllAsync();

            Assert.Empty(items);
        }
        public async Task Add_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            var person2 = Constants.GetPerson2();
            await store.AddAsync(person2);

            await store.SaveChangesAsync();

            // use another repository (without any cache) to load the saved item
            var newRepository = GetStore(_options);
            var items         = (await newRepository.GetAllAsync()).ToList();

            Assert.Contains(person2, items);
            Assert.Equal(2, items.Count);
        }
        public async Task Update_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);
            var person = Constants.GetPerson();

            person.FullName = Guid.NewGuid().ToString();

            await store.UpdateAsync(person);

            await store.SaveChangesAsync();

            // reloads the item
            IJsonRepository <Person, int> newStore = GetStore(_options);
            var newPerson = await newStore.GetByIdAsync(person.Id);

            Assert.Equal(person, newPerson);
        }
        public async Task SavingEmptyList()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await Assert.ThrowsAsync <InvalidOperationException>(async() => await store.SaveChangesAsync());
        }