This commit is contained in:
2020-02-10 18:25:10 +00:00
parent 33b747697b
commit 51f185f07b

View File

@@ -6,27 +6,27 @@ using FluentAssertions;
namespace raven_integration
{
public class UserOptionsRu
public class UserOptions
{
/// <summary>
/// Test all CRUD routes for a UserOptions object
/// </summary>
[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<uint>();
//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<string>().Should().Be(D2.emailaddress.ToString());
R.ObjectResponse["data"]["timeZoneOffset"].Value<decimal>().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<string>().Should().Be(D2.EmailAddress.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"]["currencyName"].Value<string>().Should().Be(D2.CurrencyName.ToString());
R.ObjectResponse["data"]["hour12"].Value<bool>().Should().Be((bool)D2.Hour12);
R.ObjectResponse["data"]["uiColor"].Value<int>().Should().Be((int)D2.UiColor);
concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//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<string>().Should().Be(newEmail);
R.ObjectResponse["data"]["timeZoneOffset"].Value<decimal>().Should().Be((decimal)D2.TimeZoneOffset);
R.ObjectResponse["data"]["uiColor"].Value<int>().Should().Be((int)D2.UiColor);
// concurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//DELETE USER
ApiResponse DELETETestResponse = await Util.DeleteAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);