protected JsonResult GetListByParamTest(OnixSaveController createCtrl, OnixGetListController getListCtrl, FormSubmitParam param)
        {
            FormSubmitParam prm = new FormSubmitParam();

            BaseModel createdObj = (BaseModel)Activator.CreateInstance(createCtrl.ModelType);

            TestUtils.PopulateDummyPropValues(createdObj, createCtrl.PkFieldName);
            prm.JsonContent = JsonConvert.SerializeObject(createdObj, Formatting.Indented);

            createCtrl.CreateWithParam(prm);

            JsonResult getResult = getListCtrl.GetWithParam(param);

            return(getResult);
        }
        public void GetMasterListParamTest(string content)
        {
            FormSubmitParam param = new FormSubmitParam();

            param.JsonContent = content;

            JsonResult returnObj = GetListByParamTest(new SaveMasterController(Context), new GetMasterListController(Context), param);
            var        value     = returnObj.Value;

            Assert.IsInstanceOf(typeof(QueryResponseParam), value);

            int total = (value as QueryResponseParam).TotalRecord;

            Assert.AreEqual(1, total, "Expected number of item returned to be NOT zero!!!");
        }
コード例 #3
0
        protected void DeleteWithFoundTest(OnixSaveController createCtrl, OnixDeleteController delCtrl)
        {
            FormSubmitParam prm = new FormSubmitParam();

            BaseModel createdObj = (BaseModel)Activator.CreateInstance(createCtrl.ModelType);

            TestUtils.PopulateDummyPropValues(createdObj, createCtrl.PkFieldName);
            prm.JsonContent = JsonConvert.SerializeObject(createdObj, Formatting.Indented);

            JsonResult result = createCtrl.CreateWithParam(prm);

            createdObj = (BaseModel)result.Value;
            int newID = (int)TestUtils.GetPropertyValue(createdObj, createCtrl.PkFieldName);

            delCtrl.SetModel(createdObj);
            delCtrl.Delete(-1); //Not use the ID
        }
コード例 #4
0
        public virtual JsonResult Update(int id, [FromForm] FormSubmitParam prm = null)
        {
            var opr = (ManipulationOperation)FactoryBusinessOperation.CreateBusinessOperationObject(ApiName);

            string content = "";

            if ((prm != null) && (!String.IsNullOrEmpty(prm.JsonContent)))
            {
                content = prm.JsonContent;
            }

            BaseModel m        = GetModel(id, content);
            var       response = opr.Apply(m);
            var       result   = new JsonResult(response);

            return(result);
        }
コード例 #5
0
        protected BaseModel GetInfoWithFoundTest(OnixSaveController createCtrl, OnixGetInfoController getInfoCtrl)
        {
            FormSubmitParam prm = new FormSubmitParam();

            BaseModel createdObj = (BaseModel)Activator.CreateInstance(createCtrl.ModelType);

            TestUtils.PopulateDummyPropValues(createdObj, createCtrl.PkFieldName);
            prm.JsonContent = JsonConvert.SerializeObject(createdObj, Formatting.Indented);

            JsonResult result = createCtrl.CreateWithParam(prm);

            createdObj = (BaseModel)result.Value;
            int newID = (int)TestUtils.GetPropertyValue(createdObj, createCtrl.PkFieldName);

            JsonResult getResult = getInfoCtrl.GetInfo(newID);
            BaseModel  returnObj = (BaseModel)getResult.Value;

            return(returnObj);
        }
        public void SaveMasterWithNotFoundTest(int id, string content)
        {
            try
            {
                FormSubmitParam prm = new FormSubmitParam();
                prm.JsonContent = content;

                if (content == null)
                {
                    prm = null;
                }

                SaveWithNotFoundTest(id, new SaveMasterController(Context), prm);
                Assert.Fail("Exception should be thrown due to no data to delete!!!");
            }
            catch (Exception e)
            {
                Assert.Pass(e.Message);
            }
        }
コード例 #7
0
        //Use POST method with the Get* operations with parameters to prevent the issue when deploy to Google Cloud Run
        //This is an example of issue - HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
        public virtual JsonResult CreateWithParam([FromForm] FormSubmitParam prm = null)
        {
            object response = null;

            string content = "";

            if ((prm != null) && (!String.IsNullOrEmpty(prm.JsonContent)))
            {
                content = prm.JsonContent;
            }

            var opr = FactoryBusinessOperation.CreateBusinessOperationObject(ApiName);

            BaseModel m = GetModel(null, content);

            response = (opr as ManipulationOperation).Apply(m);

            var result = new JsonResult(response);

            return(result);
        }
        //Use POST method with the Get* operations with parameters to prevent the issue when deploy to Google Cloud Run
        //This is an example of issue - HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
        public virtual JsonResult GetWithParam([FromForm] FormSubmitParam prm = null)
        {
            object response = null;

            string content = "";

            if ((prm != null) && (!String.IsNullOrEmpty(prm.JsonContent)))
            {
                content = prm.JsonContent;
            }

            var opr = FactoryBusinessOperation.CreateBusinessOperationObject(ApiName);

            var qrp = new QueryRequestParam();

            qrp      = JsonConvert.DeserializeObject <QueryRequestParam>(content);
            response = (opr as GetListOperation).Apply(qrp);

            var result = new JsonResult(response);

            return(result);
        }
コード例 #9
0
        protected BaseModel SaveWithNotFoundTest(int id, OnixSaveController saveCtrl, FormSubmitParam prm)
        {
            JsonResult getResult = saveCtrl.Update(id, prm);
            BaseModel  returnObj = (BaseModel)getResult.Value;

            return(returnObj);
        }