Example #1
0
        public void Dispose()
        {
            GC.SuppressFinalize(this);

            if (_fileName != null)
            {
                File.Delete(FilePathEvaluator.GetFilePath(_fileName));
            }
        }
Example #2
0
        public async Task ClassName()
        {
            var options = new JsonStoreOptions();

            _path = FilePathEvaluator.GetFilePath(nameof(Person));
            var store = new JsonStore <Person>(options);

            await store.SaveAsync(_person);

            Assert.True(File.Exists(_path));
        }
Example #3
0
        public async Task ClassName_WithGenerics()
        {
            var options = new JsonStoreOptions();

            _path = FilePathEvaluator.GetFilePath(nameof(Person));
            var store = new JsonRepository <Person, int>(options);

            await store.AddAsync(_person);

            await store.SaveChangesAsync();

            Assert.True(File.Exists(_path));
        }
Example #4
0
        public async Task StaticName()
        {
            var options = new JsonStoreOptions {
                NamingStrategy = new StaticNamingStrategy("static-file-name")
            };

            _path = FilePathEvaluator.GetFilePath("static-file-name");
            var store = new JsonStore <Person>(options);

            await store.SaveAsync(_person);

            Assert.True(File.Exists(_path));
        }
Example #5
0
        public async Task Generated()
        {
            var extension = Guid.NewGuid().ToString("N");
            var options   = new JsonStoreOptions {
                FileExtension = extension
            };

            _path = FilePathEvaluator.GetFilePath(nameof(Person), extension);
            var store = new JsonStore <Person>(options);

            await store.SaveAsync(_person);

            Assert.True(File.Exists(_path));
        }
Example #6
0
        public async Task JsonExtension()
        {
            var fileName = Guid.NewGuid().ToString();
            var options  = new JsonStoreOptions {
                NamingStrategy = new StaticNamingStrategy(fileName)
            };

            _path = FilePathEvaluator.GetFilePath(fileName, "json");
            var store = new JsonStore <Person>(options);

            await store.SaveAsync(_person);

            Assert.True(File.Exists(_path));
        }