This commit is contained in:
2020-03-18 19:26:12 +00:00
parent a915d224d1
commit a02d3fee21
3 changed files with 43 additions and 44 deletions

View File

@@ -41,7 +41,7 @@ namespace raven_integration
((JArray)a.ObjectResponse["data"]).Count.Should().Be(2); ((JArray)a.ObjectResponse["data"]).Count.Should().Be(2);
//Now ensure there are at least two keys in the fetched keys array //Now ensure there are at least two keys in the fetched keys array
a = await Util.GetAsync("Translation/LocaleKeyCoverage", await Util.GetTokenAsync("CustomerLimited")); a = await Util.GetAsync("Translation/TranslationKeyCoverage", await Util.GetTokenAsync("CustomerLimited"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200); Util.ValidateHTTPStatusCode(a, 200);

View File

@@ -8,38 +8,38 @@ using System.Collections.Concurrent;
namespace raven_integration namespace raven_integration
{ {
public class Locale public class Translation
{ {
/* /*
ImportLocale(ct, ResourceFolderPath, "en"); - id 1 ImportTranslation(ct, ResourceFolderPath, "en"); - id 1
ImportLocale(ct, ResourceFolderPath, "es"); - id 2 ImportTranslation(ct, ResourceFolderPath, "es"); - id 2
ImportLocale(ct, ResourceFolderPath, "fr"); - id 3 ImportTranslation(ct, ResourceFolderPath, "fr"); - id 3
ImportLocale(ct, ResourceFolderPath, "de"); - id 4 ImportTranslation(ct, ResourceFolderPath, "de"); - id 4
*/ */
[Fact] [Fact]
public async void LocalePickListWorks() public async void TranslationPickListWorks()
{ {
//Get all //Get all
ApiResponse a = await Util.GetAsync("Translation/picklist", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated ApiResponse a = await Util.GetAsync("Translation/picklist", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200); Util.ValidateHTTPStatusCode(a, 200);
//there should be at least 4 of them as there are 4 stock locales //there should be at least 4 of them as there are 4 stock translations
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(3); ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(3);
} }
[Fact] [Fact]
public async void GetFullLocaleWorks() public async void GetFullTranslationWorks()
{ {
//Get all //Get all
ApiResponse a = await Util.GetAsync("Translation/1", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated ApiResponse a = await Util.GetAsync("Translation/1", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200); 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 //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"]["localeItems"]).Count.Should().BeGreaterThan(0); ((JArray)a.ObjectResponse["data"]["translationItems"]).Count.Should().BeGreaterThan(0);
} }
@@ -85,12 +85,12 @@ namespace raven_integration
a.ObjectResponse["data"]["stock"].Value<bool>().Should().Be(false); a.ObjectResponse["data"]["stock"].Value<bool>().Should().Be(false);
a.ObjectResponse["data"]["id"].Value<long>().Should().BeGreaterThan(4); a.ObjectResponse["data"]["id"].Value<long>().Should().BeGreaterThan(4);
a.ObjectResponse["data"]["concurrencyToken"].Value<uint>().Should().BeGreaterThan(0); a.ObjectResponse["data"]["concurrencyToken"].Value<uint>().Should().BeGreaterThan(0);
((JArray)a.ObjectResponse["data"]["localeItems"]).Count.Should().BeGreaterThan(0); ((JArray)a.ObjectResponse["data"]["translationItems"]).Count.Should().BeGreaterThan(0);
long NewId = a.ObjectResponse["data"]["id"].Value<long>(); long NewId = a.ObjectResponse["data"]["id"].Value<long>();
//UPDATE //UPDATE
//Update locale name //Update translation name
/* /*
@@ -105,7 +105,7 @@ namespace raven_integration
d2.id = NewId; d2.id = NewId;
d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALE NAME UPDATE"); d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALE NAME UPDATE");
d2.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); d2.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
ApiResponse PUTTestResponse = await Util.PutAsync("Translation/UpdateLocaleName", await Util.GetTokenAsync("BizAdminFull"), d2.ToString()); ApiResponse PUTTestResponse = await Util.PutAsync("Translation/UpdateTranslationName", await Util.GetTokenAsync("BizAdminFull"), d2.ToString());
Util.ValidateHTTPStatusCode(PUTTestResponse, 200); Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
@@ -115,28 +115,28 @@ namespace raven_integration
//uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); //uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//Update locale key //Update translation key
var FirstLocaleKey = ((JArray)a.ObjectResponse["data"]["localeItems"])[0]; var FirstTranslationKey = ((JArray)a.ObjectResponse["data"]["translationItems"])[0];
long UpdatedLocaleKeyId = FirstLocaleKey["id"].Value<long>(); long UpdatedTranslationKeyId = FirstTranslationKey["id"].Value<long>();
d2.id = UpdatedLocaleKeyId; d2.id = UpdatedTranslationKeyId;
d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALEITEM DISPLAY UPDATE"); d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALEITEM DISPLAY UPDATE");
d2.concurrencyToken = FirstLocaleKey["concurrencyToken"].Value<uint>(); d2.concurrencyToken = FirstTranslationKey["concurrencyToken"].Value<uint>();
string UpdatedLocaleKey = FirstLocaleKey["key"].Value<string>(); string UpdatedTranslationKey = FirstTranslationKey["key"].Value<string>();
PUTTestResponse = await Util.PutAsync("Translation/UpdateLocaleItemDisplayText", await Util.GetTokenAsync("BizAdminFull"), d2.ToString()); PUTTestResponse = await Util.PutAsync("Translation/UpdateTranslationItemDisplayText", await Util.GetTokenAsync("BizAdminFull"), d2.ToString());
Util.ValidateHTTPStatusCode(PUTTestResponse, 200); Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
//create user that is set to new locale so can use getSubset //create user that is set to new translation so can use getSubset
var Login = Util.Uniquify("LOGIN"); var Login = Util.Uniquify("LOGIN");
var Password = Util.Uniquify("PASSWORD"); var Password = Util.Uniquify("PASSWORD");
dynamic DUSER = new JObject(); dynamic DUSER = new JObject();
DUSER.name = Util.Uniquify("LocaleUpdateSubsetTestUser"); DUSER.name = Util.Uniquify("TranslationUpdateSubsetTestUser");
DUSER.active = true; DUSER.active = true;
DUSER.login = Login; DUSER.login = Login;
DUSER.password = Password; DUSER.password = Password;
DUSER.roles = 0;//norole (any role can get a subset of locale keys) DUSER.roles = 0;//norole (any role can get a subset of translation keys)
DUSER.translationId = NewId; DUSER.translationId = NewId;
DUSER.userType = 3;//non scheduleable DUSER.userType = 3;//non scheduleable
//Required by form custom rules //Required by form custom rules
@@ -149,7 +149,7 @@ namespace raven_integration
List<string> keys = new List<string>(); List<string> keys = new List<string>();
keys.AddRange(new string[] { UpdatedLocaleKey }); keys.AddRange(new string[] { UpdatedTranslationKey });
dynamic d3 = new JObject(); dynamic d3 = new JObject();
d3 = JToken.FromObject(keys); d3 = JToken.FromObject(keys);
@@ -158,9 +158,9 @@ namespace raven_integration
Util.ValidateDataReturnResponseOk(checkPUTWorked); Util.ValidateDataReturnResponseOk(checkPUTWorked);
Util.ValidateHTTPStatusCode(checkPUTWorked, 200); Util.ValidateHTTPStatusCode(checkPUTWorked, 200);
((JArray)checkPUTWorked.ObjectResponse["data"]).Count.Should().Be(1); ((JArray)checkPUTWorked.ObjectResponse["data"]).Count.Should().Be(1);
var FirstLocaleKeyUpdated = ((JArray)checkPUTWorked.ObjectResponse["data"])[0]; var FirstTranslationKeyUpdated = ((JArray)checkPUTWorked.ObjectResponse["data"])[0];
FirstLocaleKeyUpdated["value"].Value<string>().Should().Be(d2.newText.ToString()); FirstTranslationKeyUpdated["value"].Value<string>().Should().Be(d2.newText.ToString());
//DELETE TEMPORARY USER SO CAN DELETE LOCALE //DELETE TEMPORARY USER SO CAN DELETE LOCALE
a = await Util.DeleteAsync("User/" + DUSERID.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); a = await Util.DeleteAsync("User/" + DUSERID.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));

View File

@@ -23,10 +23,8 @@ namespace raven_integration
D1.active = true; D1.active = true;
D1.login = Util.Uniquify("LOGIN"); D1.login = Util.Uniquify("LOGIN");
D1.password = Util.Uniquify("PASSWORD"); D1.password = Util.Uniquify("PASSWORD");
D1.roles = 0;//norole D1.roles = 0;//norole
D1.translationId=1; D1.userType = 3;//non scheduleable
D1.userType = 3;//non scheduleable
//Required by form custom rules
D1.notes = "notes"; D1.notes = "notes";
D1.customFields = Util.UserRequiredCustomFieldsJsonString(); D1.customFields = Util.UserRequiredCustomFieldsJsonString();
@@ -44,15 +42,16 @@ namespace raven_integration
uint concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); uint concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//UPDATE //UPDATE
//PUT //PUT
dynamic D2 = new JObject(); dynamic D2 = new JObject();
D2.EmailAddress = "testuseroptions@helloayanova.com"; D2.translationId = 1;
D2.LanguageOverride = "de-DE"; D2.emailAddress = "testuseroptions@helloayanova.com";
D2.TimeZoneOverride = "Europe/Berlin"; D2.languageOverride = "de-DE";
D2.CurrencyName = "EUR"; D2.timeZoneOverride = "Europe/Berlin";
D2.Hour12 = false; D2.currencyName = "EUR";
D2.UiColor = -2097216;//Int value (no suffix for int literals) D2.hour12 = false;
D2.uiColor = "#ffaaff";
D2.concurrencyToken = concurrencyToken; D2.concurrencyToken = concurrencyToken;
ApiResponse PUTTestResponse = await Util.PutAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D2.ToString()); ApiResponse PUTTestResponse = await Util.PutAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D2.ToString());
Util.ValidateHTTPStatusCode(PUTTestResponse, 200); Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
@@ -64,13 +63,13 @@ namespace raven_integration
/* /*
"{\"data\":{\"id\":44,\"concurrencyToken\":7144348,\"emailAddress\":null,\"uiColor\":0,\"languageOverride\":null,\"timeZoneOverride\":null,\"currencyName\":\"USD\",\"hour12\":true,\"userId\":44}}" "{\"data\":{\"id\":44,\"concurrencyToken\":7144348,\"emailAddress\":null,\"uiColor\":0,\"languageOverride\":null,\"timeZoneOverride\":null,\"currencyName\":\"USD\",\"hour12\":true,\"userId\":44}}"
*/ */
R.ObjectResponse["data"]["emailAddress"].Value<string>().Should().Be(D2.EmailAddress.ToString()); R.ObjectResponse["data"]["emailAddress"].Value<string>().Should().Be(D2.emailAddress.ToString());
R.ObjectResponse["data"]["languageOverride"].Value<string>().Should().Be(D2.LanguageOverride.ToString()); R.ObjectResponse["data"]["languageOverride"].Value<string>().Should().Be(D2.languageOverride.ToString());
R.ObjectResponse["data"]["timeZoneOverride"].Value<string>().Should().Be(D2.TimeZoneOverride.ToString()); R.ObjectResponse["data"]["timeZoneOverride"].Value<string>().Should().Be(D2.timeZoneOverride.ToString());
R.ObjectResponse["data"]["currencyName"].Value<string>().Should().Be(D2.CurrencyName.ToString()); R.ObjectResponse["data"]["currencyName"].Value<string>().Should().Be(D2.currencyName.ToString());
R.ObjectResponse["data"]["hour12"].Value<bool>().Should().Be((bool)D2.Hour12); R.ObjectResponse["data"]["hour12"].Value<bool>().Should().Be((bool)D2.hour12);
R.ObjectResponse["data"]["uiColor"].Value<string>().Should().Be(D2.uiColor.ToString());
R.ObjectResponse["data"]["uiColor"].Value<int>().Should().Be((int)D2.UiColor); R.ObjectResponse["data"]["translationId"].Value<long>().Should().Be((long)D2.translationId);
concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();