Advertisement
Guest User

ModelTest

a guest
May 16th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.59 KB | None | 0 0
  1. using System.Net;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Assertions;
  5. using System.Collections;
  6.  
  7. class ModelTest : MonoBehaviour
  8. {
  9.     public Text tquest;
  10.     public Text tuser;
  11.  
  12.     public IEnumerator Start()
  13.     {
  14.         Creator c = new Creator
  15.         {
  16.             Id = "0@bob",
  17.             Username = "bob",
  18.             Mail = "aemil@cdi.fkr",
  19.             Password = "pass",
  20.             LastName = "fdibs",
  21.             FirstName = "bob",
  22.             Xp = 0L,
  23.             Role = RoleAccount.CREATOR
  24.         };
  25.  
  26.         CheckPoint cp1 = new CheckPoint
  27.         {
  28.             Picture = "/pic",
  29.             Text = "Text of checkpoint",
  30.             Choices = { "choix 1", "choix2", "choix3" },
  31.             Answer = "choix1"
  32.         };
  33.         CheckPoint cp2 = new CheckPoint
  34.         {
  35.             Picture = "/pic",
  36.             Text = "Text of checkpoint",
  37.             Choices = { "choix 1", "choix2", "choix3" },
  38.             Answer = "choix2"
  39.         };
  40.         CheckPoint cp3 = new CheckPoint
  41.         {
  42.             Picture = "/pic",
  43.             Text = "Text of checkpoint",
  44.             Choices = { "choix 1", "choix2", "choix3" },
  45.             Answer = "choix3"
  46.         };
  47.  
  48.         Quest q1 = new Quest
  49.         {
  50.             Title = "quete1",
  51.             Description = "Super quete cool",
  52.             Geolocalisation = { x = 10, y = 45 },
  53.             Open = true,
  54.             IdCreator = c.Id,
  55.             Checkpoints = { cp1, cp2, cp3 },
  56.         };
  57.  
  58.         //HTTPHelper.Send(c);
  59.         Cookie auth = null;
  60.         yield return HTTPHelper.Instance.AuthLogin("autremil@cndi.fkr", "pass", value => auth = value);
  61.         Debug.Log(auth.Value);
  62.         string decoded = JWTHelper.DecodePayload(auth.Value);
  63.         Debug.Log(decoded);
  64.  
  65.         Account pasAccount = null;
  66.         yield return HTTPHelper.Instance.GetAccount(auth, value => pasAccount = value);
  67.  
  68.  
  69.         //HTTPHelper.Persist(c);
  70.         bool result;
  71.         yield return HTTPHelper.Instance.Persist(q1, auth, value => result = value);
  72.  
  73.         //tuser.text = JSONHelper.ToJsonString(q1);
  74.  
  75.         string questJson =
  76.             "{" +
  77.                 "\"_idCreator\": \"0@bob\"," +
  78.                 "\"geolocalisation\": {" +
  79.                     "\"x\": 10.0," +
  80.                     "\"y\": 45.0" +
  81.                 "}," +
  82.                 "\"title\": \"quete1\"," +
  83.                 "\"description\": \"Super quête cool\"," +
  84.                 "\"checkpoints\": [" +
  85.                 "{" +
  86.                   "\"text\": \"Text of checkpoint 1\"," +
  87.                   "\"choices\": [" +
  88.                     "\"choix 1\"," +
  89.                     "\"choix 2\"," +
  90.                     "\"choix 3\"" +
  91.                   "]," +
  92.                   "\"answer\": \"choix 1\"," +
  93.                   "\"difficulty\": 0" +
  94.                 "}," +
  95.                 "{" +
  96.                   "\"text\": \"Text of checkpoint 2\"," +
  97.                   "\"choices\": [" +
  98.                     "\"choix 1\"," +
  99.                     "\"choix 2\"," +
  100.                     "\"choix 3\"" +
  101.                   "]," +
  102.                   "\"answer\": \"choix 3\"," +
  103.                   "\"difficulty\": 0" +
  104.                 "}" +
  105.               "]," +
  106.               "\"value\": 0" + //complètement random
  107.             "}";
  108.            
  109.         string accountJson = "{" +
  110.             "\"connection\": {" +
  111.                 "\"email\": \"test@mail.com\"," +
  112.                 "\"password\": \"test\"" +
  113.             "}," +
  114.             "\"userInformation\": {" +
  115.                 "\"lastname\": \"test\"," +
  116.                 "\"firstname\": \"test\"," +
  117.                 "\"username\": \"test\"," +
  118.                 "\"accountType\": \"CREATOR\"" +
  119.             "}," +
  120.             "\"createdAt\": \"2018-04-30T15:52:28\"," +
  121.             "\"updatedAt\": \"2018-04-30T15:52:28\"," +
  122.             "\"game\": {" +
  123.                 "\"badges\": [0, 1, 2]," +
  124.                 "\"quests\": [{" +
  125.                     "\"_idQuest\": 0," +
  126.                     "\"state\": \"IN_PROGRESS\"," +
  127.                     "\"stats\": { \"earnedXP\": 42 }" +
  128.                 "}]," +
  129.                 "\"xp\": 42," +
  130.                 "\"elapsedTime\": 42" +
  131.             "}" +
  132.             "}";
  133.  
  134.         string badgeJson = "{" +
  135.             "\"name\": \"test\"," +
  136.             "\"description\": \"description du badge\"," +
  137.             "\"iconPath\": \"path de l'icône\"," +
  138.             "\"require\": {" +
  139.                 "\"xp\": 42," +
  140.                 "\"totalElapsedTime\": 42" +
  141.             "}," +
  142.             "\"earn\": 42" +
  143.             "}";
  144.     }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement