Exemplo n.º 1
0
        private void EntityTests()
        {
            Debug.WriteLine("==== START ENTITY TESTS====");

            var entityManager = new EntityManager();

            InputEntity inputEntity = new InputEntity();
            //entity.Id = new Guid("C5050AC8-5967-4CE1-95E7-A79B054F9D14");
            inputEntity.Id = Guid.NewGuid();
            inputEntity.Name = "goro_test";
            inputEntity.Label = "Goro Test";
            inputEntity.LabelPlural = "Goro Tests";
            inputEntity.System = true;

            List<Guid> allowedRoles = new List<Guid>();
            allowedRoles.Add(new Guid("F42EBA3B-6433-752B-6C34-B322A7B4CE7D"));
            inputEntity.RecordPermissions = new RecordPermissions();
            inputEntity.RecordPermissions.CanRead = allowedRoles;
            inputEntity.RecordPermissions.CanCreate = allowedRoles;
            inputEntity.RecordPermissions.CanUpdate = allowedRoles;
            inputEntity.RecordPermissions.CanDelete = allowedRoles;

            try
            {
                Entity entity = inputEntity.MapTo<Entity>();

                EntityResponse response = entityManager.CreateEntity(inputEntity);

                InputTextField field = new InputTextField();
                field.Id = Guid.NewGuid();
                field.Name = "text_field";
                field.Label = "Text field";
                field.PlaceholderText = "Text field placeholder text";
                field.Description = "Text field description";
                field.HelpText = "Text field help text";
                field.Required = true;
                field.Unique = true;
                field.Searchable = true;
                field.Auditable = true;
                field.System = true;
                field.DefaultValue = "";

                field.MaxLength = 200;

                FieldResponse fieldResponse = entityManager.CreateField(entity.Id, field, false);

                //inputEntity.Label = "GoroTest_edited";
                //inputEntity.PluralLabel = "Goro Tests - edited";

                //Expando obj = new Expando();
                //obj["Label"] = "GoroTest_edited";
                //obj["PluralLabel"] = "Goro Tests - edited";

                //response = entityManager.PartialUpdateEntity(entity.Id.Value, obj);

                //field.Label = "TextField_edited";

                InputField fieldObj = new InputTextField();
                fieldObj.Label = "TextField_edited";

                //fieldResponse = entityManager.PartialUpdateField(entity.Id, field.Id.Value, fieldObj);

                //fieldResponse = entityManager.DeleteField(entity.Id.Value, field.Id.Value);

                //List<Field> fields = CreateTestFieldCollection(entity);
                ////FieldResponse fieldResponse = entityManager.CreateField(entity.Id.Value, fields[0]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[1]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[2]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[3]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[4]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[5]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[6]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[7]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[8]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[9]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[10]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[11]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[12]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[13]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[14]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[15]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[16]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[17]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[18]);
                //fieldResponse = entityManager.CreateField(entity.Id.Value, fields[19]);

                //EntityResponse entityResponse = entityManager.ReadEntity(entity.Id.Value);
                //entity = entityResponse.Object;

                //List<RecordsList> recordsLists = CreateTestViewCollection(entity);

                //RecordsListResponse recordsListsResponse = entityManager.CreateRecordsList(entity.Id.Value, recordsLists[0]);

                //recordsLists[0].Label = "Edited View";

                //recordsListsResponse = entityManager.UpdateRecordsList(entity.Id.Value, recordsLists[0]);

                //List<RecordView> recordViewList = CreateTestFormCollection(entity);

                //RecordViewResponse recordViewResponse = entityManager.CreateRecordView(entity.Id.Value, recordViewList[0]);

                //recordViewList[0].Label = "Edited Form";

                //recordViewResponse = entityManager.CreateRecordView(entity.Id.Value, recordViewList[0]);

                EntityListResponse entityListResponse = entityManager.ReadEntities();

                EntityResponse resultEntity = entityManager.ReadEntity(entity.Id);

                response = entityManager.DeleteEntity(entity.Id);

            }
            catch (StorageException e)
            {
                Debug.WriteLine(e);
            }

            Debug.WriteLine("==== END ENTITY TESTS====");
        }