Beispiel #1
0
        public static async Task Main()
        {
            /// \todo https://open-api.bser.io/v1/data/ItemWeapon get all item weapon datas
            /// and list all types programatically
            string apiKey = Environment.GetEnvironmentVariable("BSER_APIKEY");
            // Set up (called once per test)
            var client = new BserHttpClient(apiKey);

            var gameMetaData = await client.GetData();

            Console.WriteLine(gameMetaData);
            var  gameData = gameMetaData.data;
            Type type     = gameData.GetType();

            PropertyInfo[] properties = type.GetProperties();

            foreach (PropertyInfo property in properties)
            {
                if (property.Name != "/")
                {
                    var dynamicDataToSave = await client.GetData(property.Name);

                    string file_name = "data/" + property.Name + ".json";
                    string json      = JsonSerializer.Serialize(dynamicDataToSave);

                    File.WriteAllText(file_name, json);
                }
            }
        }
Beispiel #2
0
        public async Task TestGetData()
        {
            BserMetaData bserData = await client.GetData();

            string debugMessage = String.Format("{0} - {1}", bserData.code, bserData.message);

            _testOutputHelper.WriteLine(debugMessage);
            int    code    = bserData.code;
            string message = bserData.message;

            Assert.Equal(200, code);
            Assert.Equal("Success", message);
            Assert.IsType <GameDataObj>(bserData.data);
        }