public void RequestTypeServiceScalarTest() { IncrementTestCount(); var prop1 = new ScalarShape("string", null, null, null, null, null, null, null, null, null, null, null, null, "3", "prop", null, null, null, null, null, null); var props = new List <PropertyShape>() { new PropertyShape("/", prop1, null, 0, null) }; var payload = new Payload("application/json", new NodeShape(null, null, null, null, null, null, props, null, null, null, null, "foo", "bar", "", "", null, null, new List <Shape>(), null)); var schemaObjs = new Dictionary <string, ApiObject>() { { "baz", new ApiObject() { AmfId = null, Name = "Node", Type = "Node" } } }; var objs = new Dictionary <string, ApiObject>(); var links = new Dictionary <string, string>(); var enums = new Dictionary <string, ApiEnum>(); var payloads = new List <Payload>() { payload }; var request = new Request(null, null, payloads, null); var service = new RequestTypesService(schemaObjs, objs, links, enums); var method = new Operation("GET", "test", "", false, "", new Documentation("www.doc.com", "docs", "docs"), new string[] { "HTTP" }, null, new string[] { "application/json" }, request, null, null); var operations = new List <Operation>() { method }; var resource = new EndPoint("Key", "", "", operations, null, null); var fullUrl = "/"; var key = "Key"; var result = service.GetRequestParameter(key, method, resource, fullUrl, new string[] { "application/json" }); Assert.AreEqual("string", result.Type); }
private void OnSaveMethod(bool IsAlive) { string requestNameTemp = ContentPanel.GetFormControlFromPanel <TextBox>(RequestNameTextBox).Text; string descriptionTemp = ContentPanel.GetFormControlFromPanel <TextBox>(DescriptionTextBox).Text; RequestTypeModel NewModel = new RequestTypeModel { RequestName = requestNameTemp, Description = descriptionTemp }; RequestTypeDataContract changes = new RequestTypeDataContract(); int selectedModel = baseControl.Models.IndexOf(OldModel); if (OldModel.IsNull()) { NewModel.ID = Guid.NewGuid(); changes = RequestTypesService.InsertRequestType(mapper.Map <RequestTypeModel, RequestTypeDataContract>(NewModel)).Result; baseControl.Models.Add(mapper.Map <RequestTypeDataContract, RequestTypeModel>(changes)); } else { NewModel.ID = baseControl.Models[selectedModel].ID; changes = RequestTypesService.UpdateRequestType(mapper.Map <RequestTypeModel, RequestTypeDataContract>(NewModel)).Result; baseControl.Models[selectedModel] = mapper.Map <RequestTypeDataContract, RequestTypeModel>(changes); baseControl.CollectionView.Items[selectedModel].Selected = true; } if (IsAlive) { OldModel = selectedModel.Equals(-1) ? baseControl.Models[baseControl.Models.Count - 1] : baseControl.Models[selectedModel]; } else { CloseViewButton.PerformClick(); } }