using System; using Xunit; using Newtonsoft.Json.Linq; using FluentAssertions; using System.Collections.Generic; using System.Threading.Tasks; using System.Collections.Concurrent; namespace raven_integration { public class RequestedLocaleKeys { [Fact] public async void RequestedLocaleKeysWorks() { //First determine if there is a requested key route because it's debug build dependent //And doesn't exists if server was not debug built ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("CustomerLimited")); Util.ValidateDataReturnResponseOk(a); var BuildMode = a.ObjectResponse["data"]["buildMode"].Value(); BuildMode.Should().BeOneOf((new string[] { "DEBUG", "RELEASE" })); if (BuildMode == "DEBUG") { //Make a "list" of keys to fetch the values for List keys = new List(); keys.AddRange(new string[] { "HelpLicense", "CustomerName" }); dynamic d = new JObject(); d = JToken.FromObject(keys); //Fetch the values to force RAVEN to track at least these two a = await Util.PostAsync("translation/subset", await Util.GetTokenAsync("CustomerLimited"), d.ToString()); Util.ValidateDataReturnResponseOk(a); Util.ValidateHTTPStatusCode(a, 200); //there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one ((JArray)a.ObjectResponse["data"]).Count.Should().Be(2); //Now ensure there are at least two keys in the fetched keys array a = await Util.GetAsync("translation/TranslationKeyCoverage", await Util.GetTokenAsync("CustomerLimited")); Util.ValidateDataReturnResponseOk(a); Util.ValidateHTTPStatusCode(a, 200); var RequestedKeyCount = a.ObjectResponse["data"]["requestedKeyCount"].Value(); RequestedKeyCount.Should().BeGreaterOrEqualTo(2); var NotRequestedKeyCount = a.ObjectResponse["data"]["notRequestedKeyCount"].Value(); NotRequestedKeyCount.Should().BeGreaterThan(1);//For now at least, once we have this dialed in it will be zero ultimately //there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one ((JArray)a.ObjectResponse["data"]["requestedKeys"]).Count.Should().Be(RequestedKeyCount); ((JArray)a.ObjectResponse["data"]["notRequestedKeys"]).Count.Should().Be(NotRequestedKeyCount); } } //================================================== }//eoc }//eons