public void Test_NoDuplicates() { var t0 = new DateTime(2000, 01, 01); var a0 = new Activity() { Timestamp = new Timestamp(t0), Type = Categories.LivingLog_Startup, Info = LivingLogger.SyncData.At(t0) }; var t1 = new DateTime(2015, 05, 06); var a1 = new Activity() { Timestamp = new Timestamp(t1), Type = Categories.LivingLog_Exit, Info = LivingLogger.SyncData.At(t1) }; var source = new List <Activity>() { a0, a1 }; var result = ActivityTools.RemoveDuplicates(source); Assert.IsTrue(result.SequenceEqual(source)); }
public void Test_Duplicate_Value() { var t0 = new DateTime(2000, 01, 01); var a0 = new Activity() { Timestamp = new Timestamp(t0), Type = Categories.LivingLog_Startup, Info = LivingLogger.SyncData.At(t0) }; var a1 = new Activity() { Timestamp = a0.Timestamp, Type = a0.Type, Info = a0.Info }; var source = new List <Activity>() { a0, a1 }; var result = ActivityTools.RemoveDuplicates(source); Assert.IsTrue(result.SequenceEqual(source.Take(1))); Assert.IsTrue(result.SequenceEqual(source.Skip(1))); }
public void Test_Chronological_Dual() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var a0 = LivingLogger.GetSync(new Timestamp(t0)); var a1 = LivingLogger.GetSync(new Timestamp(t1)); var a2 = LivingLogger.GetSync(new Timestamp(t2)); var a3 = LivingLogger.GetSync(new Timestamp(t3)); var actA = new List <Activity>() { a0, a2 }; var actB = new List <Activity>() { a1, a3 }; var activities = actA.Concat(actB); var result = ActivityTools.PartitionChronological(activities); var expected = new List <List <Activity> >() { actA, actB }; Assert.IsTrue(PartitionEqual(expected, result)); }
private string GetBattleSceneMapName() { string curLevelId = LevelManager.CurLevelId; if (string.IsNullOrEmpty(curLevelId)) { UnityEngine.Debug.LogError("GetBattleSceneMapName empty or null, leevelId: " + LevelManager.CurLevelId); return(string.Empty); } SysBattleSceneVo dataById = BaseDataMgr.instance.GetDataById <SysBattleSceneVo>(curLevelId); Dictionary <string, object> dicByType = BaseDataMgr.instance.GetDicByType <SysMapChangeVo>(); string scene_map_id = dataById.scene_map_id; foreach (KeyValuePair <string, object> current in dicByType) { SysMapChangeVo sysMapChangeVo = current.Value as SysMapChangeVo; if (!(sysMapChangeVo.id != dataById.scene_map_id)) { DateTime dateTime = ActivityTools.GetDateTime(sysMapChangeVo.start_time, true); DateTime dateTime2 = ActivityTools.GetDateTime(sysMapChangeVo.end_time, true); if (ToolsFacade.Instance.IsInTimeInterval(dateTime, dateTime2)) { return(sysMapChangeVo.id2); } } } return(dataById.scene_map_id); }
public void Test_Ordering() { var t0 = DateTime.Now; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var sourceA = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t0)) }; var sourceB = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t1)) }; var sourceC = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t2)) }; var sourceD = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t3)) }; var result = ActivityTools.Merge( sourceA.Concat(sourceC), sourceB.Concat(sourceD) ).ToList(); Assert.IsTrue(result.SequenceEqual( sourceA.Concat(sourceB).Concat(sourceC).Concat(sourceD) )); }
public void Test_Chronological_Empty() { var empty = Enumerable.Empty <Activity>(); var result = ActivityTools.PartitionChronological(empty); Assert.IsTrue(result.IsEmpty()); }
public void Test_Chronological_AntiChrono() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var t2 = t1 + TimeSpan.FromSeconds(1); var t3 = t2 + TimeSpan.FromSeconds(1); var a0 = LivingLogger.GetSync(new Timestamp(t0)); var a1 = LivingLogger.GetSync(new Timestamp(t1)); var a2 = LivingLogger.GetSync(new Timestamp(t2)); var a3 = LivingLogger.GetSync(new Timestamp(t3)); var act0 = Enumerable.Repeat(a0, 1); var act1 = Enumerable.Repeat(a1, 1); var act2 = Enumerable.Repeat(a2, 1); var act3 = Enumerable.Repeat(a3, 1); var activities = act3.Concat(act2).Concat(act1).Concat(act0); var result = ActivityTools.PartitionChronological(activities); var expected = new List <IEnumerable <Activity> >() { act3, act2, act1, act0 }; Assert.IsTrue(PartitionEqual(expected, result)); }
public void Test_Empty_Empty() { var source = Enumerable.Empty <Activity>(); var result = ActivityTools.Merge(source, source).ToList(); Assert.IsTrue(result.IsEmpty()); }
public void Test_HasNull() { var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync()); activities.Add(null); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_Chronological_Single() { var a = LivingLogger.GetSync(); var activities = Enumerable.Repeat(a, 1); var result = ActivityTools.PartitionChronological(activities); var expected = Enumerable.Repeat(activities, 1); Assert.IsTrue(PartitionEqual(expected, result)); }
public void Test_FirstIsSync() { var activities = new List <Activity>(); activities.Add(new Activity() { Type = Categories.Keyboard_KeyDown }); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_Empty_2() { var sourceA = new List <Activity>() { LivingLogger.GetSync() }; var sourceB = Enumerable.Empty <Activity>(); var result = ActivityTools.Merge(sourceA, sourceB).ToList(); Assert.IsTrue(result.SequenceEqual(sourceA)); }
public void Test_NonChronological() { var t0 = DateTime.UtcNow; var t1 = t0 - TimeSpan.FromSeconds(1); var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync(new Timestamp(t0))); activities.Add(LivingLogger.GetSync(new Timestamp(t1))); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_Unknown() { var t0 = DateTime.UtcNow; var t1 = t0 + TimeSpan.FromSeconds(1); var activities = new List <Activity>(); activities.Add(LivingLogger.GetSync(new Timestamp(t0))); activities.Add(new Activity() { Timestamp = new Timestamp(t1), Type = Category.Unknown, }); Assert.IsFalse(ActivityTools.IsValid(activities)); }
public void Test_First_2() { var t0 = DateTime.Now; var t1 = t0 + TimeSpan.FromSeconds(1); var sourceA = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t1)) }; var sourceB = new List <Activity>() { LivingLogger.GetSync(new Timestamp(t0)) }; var result = ActivityTools.Merge(sourceA, sourceB).ToList(); Assert.IsTrue(result.SequenceEqual(sourceB.Concat(sourceA))); }
public void Test_Duplicate_Reference() { var t0 = new DateTime(2000, 01, 01); var a0 = new Activity() { Timestamp = new Timestamp(t0), Type = Categories.LivingLog_Startup, Info = LivingLogger.SyncData.At(t0) }; var source = new List <Activity>() { a0, a0 }; var result = ActivityTools.RemoveDuplicates(source); var expected = source.Take(1); Assert.IsTrue(result.SequenceEqual(expected)); }
public void Test_Chronological_Null() { ActivityTools.PartitionChronological(null).ToList(); }
public void Test_Null() { ActivityTools.RemoveDuplicates(null); }
public void Test_Null_Null() { ActivityTools.Merge(null, null); }
public void Test_Null() { ActivityTools.IsValid(null); }
public void Test_Empty() { var activities = new List <Activity>(); Assert.IsTrue(ActivityTools.IsValid(activities)); }
public void Test_Null_1() { var source = Enumerable.Empty <Activity>(); ActivityTools.Merge(null, source); }
void Awake() { instance = this; }
public void Test_Null_2() { var source = Enumerable.Empty <Activity>(); ActivityTools.Merge(source, null); }
private void InitActivityNewState() { ActivityData activityData = base.Data as ActivityData; if (activityData.dicActivityNewState == null) { activityData.dicActivityNewState = new Dictionary <int, ActivityData.ActivityNewState>(); } Dictionary <string, object> dicByType = BaseDataMgr.instance.GetDicByType <SysActivityVo>(); DateTime serverCurrentTime = ToolsFacade.ServerCurrentTime; foreach (KeyValuePair <string, object> current in dicByType) { SysActivityVo sysActivityVo = current.Value as SysActivityVo; if (sysActivityVo != null) { DateTime dateTime = ActivityTools.GetDateTime(sysActivityVo.show_start_time, true); DateTime dateTime2 = ActivityTools.GetDateTime(sysActivityVo.show_end_time, false); if (string.IsNullOrEmpty(sysActivityVo.show_start_time) || !(serverCurrentTime < dateTime)) { if (string.IsNullOrEmpty(sysActivityVo.show_end_time) || !(serverCurrentTime > dateTime2)) { int key = int.Parse(current.Key); if (!activityData.dicActivityNewState.ContainsKey(key)) { ActivityData.ActivityNewState activityNewState = new ActivityData.ActivityNewState { activityVo = sysActivityVo, type = sysActivityVo.activity_type_id, dicTaskState = new Dictionary <int, ActivityData.TaskState>() }; activityData.dicActivityNewState.Add(key, activityNewState); string[] array = sysActivityVo.module.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { SysActivityModuleVo dataById = BaseDataMgr.instance.GetDataById <SysActivityModuleVo>(array[i]); if (dataById != null && dataById.type == 4) { if (string.IsNullOrEmpty(dataById.content_first)) { ClientLogger.Error("配置错误, 模块ID=" + dataById.id); } else { string[] array2 = dataById.content_first.Split(new char[] { ',' }); for (int j = 0; j < array2.Length; j++) { SysActivityTaskVo dataById2 = BaseDataMgr.instance.GetDataById <SysActivityTaskVo>(array2[j]); if (dataById2 == null) { ClientLogger.Error("配置错误,找不到SysActivityTaskVo id=" + array2[j]); } else { ActivityData.TaskState value = new ActivityData.TaskState { taskID = dataById2.id, taskVo = dataById2 }; activityNewState.dicTaskState.Add(dataById2.id, value); } } } } } } } } } } this.init = true; }