Esempio n. 1
0
        public void ExecuteTranslated()
        {
            // arrange
            var shadowBlueId    = 1357;
            var translatedNames = new Dictionary <LanguageCode, string>()
            {
                { LanguageCode.DE, "Schatten-Blau" },
                { LanguageCode.EN, "Shadow Blue" },
                { LanguageCode.ES, "Azul sombrío" },
                { LanguageCode.FR, "Bleu de l'ombre" },
            };

            foreach (var pair in translatedNames)
            {
                // act
                var response = new ColorsRequest(pair.Key).Execute();

                // assert
                Assert.IsTrue(response.Colors.Count > 0);
                Assert.IsTrue(response.Colors.ContainsKey(shadowBlueId));

                var dye = response.Colors[shadowBlueId];

                Assert.AreEqual(pair.Value, dye.Name);
            }
        }
Esempio n. 2
0
        public async Task <IDataTransferCollection <Color> > GetColors()
        {
            var request = new ColorsRequest();

            using var response = await _http.SendAsync(request).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var context = response.Headers.GetCollectionContext();
            var list    = new List <Color>(context.ResultCount);

            JsonConvert.PopulateObject(json, list, Json.DefaultJsonSerializerSettings);
            return(new DataTransferCollection <Color>(list, context));
        }
Esempio n. 3
0
        public async Task <List <string> > GetAllJsonColors(bool indented)
        {
            var request = new ColorsRequest();

            using var response = await _http.SendAsync(request);

            using var responseReader = new StreamReader(await response.Content.ReadAsStreamAsync());
            using var jsonReader     = new JsonTextReader(responseReader);
            response.EnsureSuccessStatusCode();

            // API returns a JSON array but we want a List of JSON objects instead
            var array = await JToken.ReadFromAsync(jsonReader);

            return(array.Children <JObject>().Select(obj => obj.ToString(indented ? Formatting.Indented : Formatting.None)).ToList());
        }
Esempio n. 4
0
        public void Execute()
        {
            // act
            var response = new ColorsRequest().Execute();

            // assert
            Assert.IsTrue(response.Colors.Count > 0);

            foreach (var dye in response.Colors.Values)
            {
                Assert.IsNotNull(dye.Name);

                AssertRgbArray(dye.BaseRgb);

                AssertMaterialColor(dye.Cloth);
                AssertMaterialColor(dye.Leather);
                AssertMaterialColor(dye.Metal);
            }
        }