diff --git a/User/UserOptionsRu.cs b/User/UserOptions.cs similarity index 70% rename from User/UserOptionsRu.cs rename to User/UserOptions.cs index 28d5f63..71b20f4 100644 --- a/User/UserOptionsRu.cs +++ b/User/UserOptions.cs @@ -6,27 +6,27 @@ using FluentAssertions; namespace raven_integration { - public class UserOptionsRu + public class UserOptions { /// /// Test all CRUD routes for a UserOptions object /// [Fact] - public async void RU() + public async void CRUD() { //CREATE a user dynamic D1 = new JObject(); D1.name = Util.Uniquify("Test UserOptions User"); - + D1.active = true; D1.login = Util.Uniquify("LOGIN"); D1.password = Util.Uniquify("PASSWORD"); D1.roles = 0;//norole D1.localeId = 1;//random locale D1.userType = 3;//non scheduleable - //Required by form custom rules + //Required by form custom rules D1.notes = "notes"; D1.customFields = Util.UserRequiredCustomFieldsJsonString(); @@ -36,10 +36,7 @@ namespace raven_integration //Now there should be a user options available for this user - //RETRIEVE companion USEROPTIONS object - - //Get it R = await Util.GetAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); Util.ValidateDataReturnResponseOk(R); //ensure the default value is set @@ -47,10 +44,14 @@ namespace raven_integration uint concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value(); //UPDATE + //PUT dynamic D2 = new JObject(); - D2.emailaddress = "testuseroptions@helloayanova.com"; - D2.TimeZoneOffset = -7.5M;//Decimal value + D2.EmailAddress = "testuseroptions@helloayanova.com"; + D2.LanguageOverride = "de-DE"; + D2.TimeZoneOverride = "Europe/Berlin"; + D2.CurrencyName = "EUR"; + D2.Hour12 = false; D2.UiColor = -2097216;//Int value (no suffix for int literals) D2.concurrencyToken = concurrencyToken; ApiResponse PUTTestResponse = await Util.PutAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D2.ToString()); @@ -60,27 +61,19 @@ namespace raven_integration R = await Util.GetAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); Util.ValidateDataReturnResponseOk(R); //ensure the default value is set - R.ObjectResponse["data"]["emailAddress"].Value().Should().Be(D2.emailaddress.ToString()); - R.ObjectResponse["data"]["timeZoneOffset"].Value().Should().Be((decimal)D2.TimeZoneOffset); + /* + "{\"data\":{\"id\":44,\"concurrencyToken\":7144348,\"emailAddress\":null,\"uiColor\":0,\"languageOverride\":null,\"timeZoneOverride\":null,\"currencyName\":\"USD\",\"hour12\":true,\"userId\":44}}" + */ + R.ObjectResponse["data"]["emailAddress"].Value().Should().Be(D2.EmailAddress.ToString()); + R.ObjectResponse["data"]["languageOverride"].Value().Should().Be(D2.LanguageOverride.ToString()); + R.ObjectResponse["data"]["timeZoneOverride"].Value().Should().Be(D2.TimeZoneOverride.ToString()); + R.ObjectResponse["data"]["currencyName"].Value().Should().Be(D2.CurrencyName.ToString()); + R.ObjectResponse["data"]["hour12"].Value().Should().Be((bool)D2.Hour12); + R.ObjectResponse["data"]["uiColor"].Value().Should().Be((int)D2.UiColor); concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value(); - //PATCH - string newEmail = "patchtestuseroptions@helloayanova.com"; - string patchJson = "[{\"value\": \"" + newEmail + "\",\"path\": \"/emailAddress\",\"op\": \"replace\"}]"; - ApiResponse PATCHTestResponse = await Util.PatchAsync("UserOptions/" + UserId.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson); - Util.ValidateHTTPStatusCode(PATCHTestResponse, 200); - - //check PATCH worked - R = await Util.GetAsync("UserOptions/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); - Util.ValidateDataReturnResponseOk(R); - //ensure the default value is set - R.ObjectResponse["data"]["emailAddress"].Value().Should().Be(newEmail); - R.ObjectResponse["data"]["timeZoneOffset"].Value().Should().Be((decimal)D2.TimeZoneOffset); - R.ObjectResponse["data"]["uiColor"].Value().Should().Be((int)D2.UiColor); - // concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value(); - //DELETE USER ApiResponse DELETETestResponse = await Util.DeleteAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); Util.ValidateHTTPStatusCode(DELETETestResponse, 204);