public void SerializeToJsonFileTest()
        {
            var temp = new Data.DataBase.Config();

            temp.Host = "Vladislav";
            ProviderJson.SerializeToJsonFile <Data.DataBase.Config>(temp, $@"./temp.json");

            var temp_2 = ProviderJson.DeserializeJsonFile <Data.DataBase.Config>($@"./temp.json");

            Assert.Equal("Vladislav", temp_2.Host);

            File.Delete($@"./temp.json");
        }
Пример #2
0
        public ApiDb(string configPath)
        {
            if (string.IsNullOrEmpty(configPath) || !File.Exists(configPath))
            {
                throw new ArgumentException("Указан некорректный путь до файла настроек БД");
            }

            _config = ProviderJson.DeserializeJsonFile <Config>(configPath);

            if (_config == null)
            {
                throw new DataException("Не удалось считать файл настроект БД");
            }

            using var ctx = new PostgresContext(_config);
            ctx.SaveChanges();
        }
        public void DeserializeJsonFileTest()
        {
            var temp = ProviderJson.DeserializeJsonFile <Data.DataBase.Config>(@$ "../../../../db_example.json");

            Assert.NotNull(temp);
        }