public void TestParseResponceCode() { string rawResponse = VALID_RESPONSE; ScCreateEntityResponse response = ScCreateEntityParser.Parse(rawResponse, 444, CancellationToken.None); Assert.AreEqual(444, response.StatusCode); }
public void TestParseValidResponse() { string rawResponse = VALID_RESPONSE; ScCreateEntityResponse response = ScCreateEntityParser.Parse(rawResponse, 202, CancellationToken.None); ISitecoreEntity entity = response.CreatedEntity; Assert.AreEqual("First Task", entity["Title"].RawValue); Assert.AreEqual("False", entity["Completed"].RawValue); Assert.AreEqual("4", entity["Index"].RawValue); Assert.IsTrue(response.Created); }
private async void SendCreateRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { var request = EntitySSCRequestBuilder.CreateEntityRequest(this.EntityIdTextField.Text) .Namespace("aggregate") .Controller("admin") .Action("Todo") .AddFieldsRawValuesByNameToSet("Title", this.EntityTitleTextField.Text) .AddFieldsRawValuesByNameToSet("Url", null) .Build(); this.ShowLoader(); ScCreateEntityResponse response = await session.CreateEntityAsync(request); string entityId = response.CreatedEntity.Id; string entityTitle = response.CreatedEntity["Title"].RawValue; if (response.Created) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity created successfully, Id is " + entityId + " Title: " + entityTitle); } else { string responseCode = "Unknown"; if (response != null) { responseCode = response.StatusCode.ToString(); } AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity was not created, response code: " + responseCode); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity was not created: " + e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }