Ejemplo n.º 1
0
 public void Gate_toJSONObject()
 {
     {
         var gate = new RecordGate("Test_RecordGate_Id", "Test_Score_Id", 100.0);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_RecordGate_Id"",
     ""className"":""RecordGate"",
     ""associatedScoreId"":""Test_Score_Id"",
     ""desiredBalance"":100
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         List<Schedule.DateTimeRange> timeRanges = new List<Schedule.DateTimeRange>();
         timeRanges.Add(new Schedule.DateTimeRange(DateTime.Parse("01/01/2010"), DateTime.Parse("01/01/2011")));
         timeRanges.Add(new Schedule.DateTimeRange(DateTime.Parse("01/01/2011"), DateTime.Parse("01/01/2012")));
         var schedule = new Schedule(timeRanges, Schedule.Recurrence.EVERY_HOUR, 1);
         var gate = new ScheduleGate("Test_ScheduleGate_Id", schedule);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_ScheduleGate_Id"",
     ""className"":""ScheduleGate"",
     ""schedule"":{
     ""className"":""Schedule"",
     ""schedRecurrence"":3,
     ""schedApprovals"":1,
     ""schedTimeRanges"":[
     {
         ""className"":""DateTimeRange"",
         ""schedTimeRangeStart"":63397899010048,
         ""schedTimeRangeEnd"":63429435981824
     },
     {
         ""className"":""DateTimeRange"",
         ""schedTimeRangeStart"":63429435981824,
         ""schedTimeRangeEnd"":63460972953600
     }
     ]
     }
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new WorldCompletionGate("Test_WorldCompletionGate_Id", "Test_World_Id");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_WorldCompletionGate_Id"",
     ""className"":""WorldCompletionGate"",
     ""associatedWorldId"":""Test_World_Id""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new BalanceGate("Test_BalanceGate_Id", "Test_Item_Id", 100);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_BalanceGate_Id"",
     ""className"":""BalanceGate"",
     ""associatedItemId"":""Test_Item_Id"",
     ""desiredBalance"":100
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new PurchasableGate("Test_PurchasableGate_Id", "Test_Item_Id");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_PurchasableGate_Id"",
     ""className"":""PurchasableGate"",
     ""associatedItemId"":""Test_Item_Id""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new SocialLikeGate("Test_SocialLikeGate_Id", Provider.FACEBOOK, "Test_PageName");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_SocialLikeGate_Id"",
     ""className"":""SocialLikeGate"",
     ""provider"":""facebook"",
     ""pageName"":""Test_PageName""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new SocialStatusGate("Test_SocialStatusGate_Id", Provider.GOOGLE, "Test_Status");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_SocialStatusGate_Id"",
     ""className"":""SocialStatusGate"",
     ""provider"":""google"",
     ""status"":""Test_Status""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
 }