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)));
        }
Example #3
0
        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));
        }
Example #4
0
    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);
    }
Example #5
0
        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)
                              ));
        }
Example #6
0
        public void Test_Chronological_Empty()
        {
            var empty  = Enumerable.Empty <Activity>();
            var result = ActivityTools.PartitionChronological(empty);

            Assert.IsTrue(result.IsEmpty());
        }
Example #7
0
        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));
        }
Example #8
0
        public void Test_Empty_Empty()
        {
            var source = Enumerable.Empty <Activity>();

            var result = ActivityTools.Merge(source, source).ToList();

            Assert.IsTrue(result.IsEmpty());
        }
Example #9
0
        public void Test_HasNull()
        {
            var activities = new List <Activity>();

            activities.Add(LivingLogger.GetSync());
            activities.Add(null);

            Assert.IsFalse(ActivityTools.IsValid(activities));
        }
Example #10
0
        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));
        }
Example #11
0
        public void Test_FirstIsSync()
        {
            var activities = new List <Activity>();

            activities.Add(new Activity()
            {
                Type = Categories.Keyboard_KeyDown
            });

            Assert.IsFalse(ActivityTools.IsValid(activities));
        }
Example #12
0
        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));
        }
Example #13
0
        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));
        }
Example #14
0
        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));
        }
Example #15
0
        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));
        }
Example #17
0
 public void Test_Chronological_Null()
 {
     ActivityTools.PartitionChronological(null).ToList();
 }
 public void Test_Null()
 {
     ActivityTools.RemoveDuplicates(null);
 }
Example #19
0
 public void Test_Null_Null()
 {
     ActivityTools.Merge(null, null);
 }
Example #20
0
 public void Test_Null()
 {
     ActivityTools.IsValid(null);
 }
Example #21
0
        public void Test_Empty()
        {
            var activities = new List <Activity>();

            Assert.IsTrue(ActivityTools.IsValid(activities));
        }
Example #22
0
        public void Test_Null_1()
        {
            var source = Enumerable.Empty <Activity>();

            ActivityTools.Merge(null, source);
        }
Example #23
0
 void Awake()
 {
     instance = this;
 }
Example #24
0
        public void Test_Null_2()
        {
            var source = Enumerable.Empty <Activity>();

            ActivityTools.Merge(source, null);
        }
Example #25
0
        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;
        }