public UserInteractUIServiceTest()
        {
            realRedisService = new RedisService();
            userInteractUIService = new UserInteractUIService(realRedisService);
            EntityMapping.Config();
            realRedisService.FlushAll();

            configID = realRedisService.Add<PushConfig>(new PushConfig {
                AllowedPeriodFrom = DateTime.Now,
                AllowedPeriodTo = DateTime.Now.AddSeconds(10000),
                DelaySeconds = 123,
                ExecuteTimes = 2,
                FailGotoActionId = 1,
                SuccessGotoActionId =1,
                IntervalSeconds = 60
            });

            configID2 = realRedisService.Add<PushConfig>(new PushConfig
            {
                AllowedPeriodFrom = DateTime.Now,
                AllowedPeriodTo = DateTime.Now.AddSeconds(1000),
                DelaySeconds = 321,
                ExecuteTimes = 20,
                FailGotoActionId = 10,
                SuccessGotoActionId = 10,
                IntervalSeconds = 600
            });
        }
Ejemplo n.º 2
0
 public static void Start(bool shouldFlush)
 {
     if (!_hasBeenIntialized)
     {
         if (shouldFlush)
         {
             // clear data
             var svc = new RedisService();
             svc.FlushAll();
         }
         _hasBeenIntialized = true;
     }
 }
Ejemplo n.º 3
0
        public void get_sequence_num_should_work_in_concurrent_situation()
        {
            using (var redis = new RedisService())
            {
                const string key = "SEQ_key";

                Action<object> action = (object id) =>
                {
                    Console.WriteLine(redis.GetNextSequenceNum(key));
                };

                Task t1 = Task.Factory.StartNew(action, "1");
                Task t2 = Task.Factory.StartNew(action, "2");
                Task t3 = Task.Factory.StartNew(action, "3");
                Task t4 = Task.Factory.StartNew(action, "4");
                Task t5 = Task.Factory.StartNew(action, "5");
                Task t6 = Task.Factory.StartNew(action, "6");
                Task t7 = Task.Factory.StartNew(action, "7");
                Task t8 = Task.Factory.StartNew(action, "8");
                Task t9 = Task.Factory.StartNew(action, "9");
                Task t0 = Task.Factory.StartNew(action, "10");

                t1.Wait();
                t2.Wait();
                t3.Wait();
                t4.Wait();
                t5.Wait();
                t6.Wait();
                t7.Wait();
                t8.Wait();
                t9.Wait();
                t0.Wait();

                long result = redis.GetNextSequenceNum(key);
                Assert.Equal(11, result);
                redis.FlushAll();
            }
        }
Ejemplo n.º 4
0
        public void integration_test_for_user_upload_info()
        {
            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_IMSI] = TEST_IMSI;
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            var realRedisService = new RedisService();
            var realRedisLogger = new RedisLogger();
            realRedisService.FlushAll();
            realRedisLogger.Flush();

            UserInteractService userInteractService = new UserInteractService(realRedisLogger, realRedisService, new UserInteractUIService(realRedisService));
            //first time , add
            UserUploadInfo userUploadInfo = new UserUploadInfo
            {
                ActivityInfos = GetAndroidUserAppActivityInfos(),
                AppInfos = GetAppInfos(),
                AppTrafficInfos = GetAppTrafficInfos()
            };
            userInteractService.SaveUserUploadInfos(mobileParam, userUploadInfo);
            //second time , update
            namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_IMSI] = TEST_IMSI;
            namevalues[MobileParam.Key_IsTouch] = "1";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            mobileParam = new MobileParam(requestRepo);

            userInteractService.SaveUserUploadInfos(mobileParam, userUploadInfo);

            Assert.NotNull(realRedisService.GetValueFromHash<string>("U:9460002850533220", "com.packagename.app1"));
            using (var redis = RedisClientManager.GetReadOnlyClient())
            {
                Assert.Equal(2, redis.GetListCount("Queue:AndroidUserUploadInfo:Logger"));
                var secondAndroidUserUploadInfo = JsonConvert.DeserializeObject<LogModel>(redis.GetItemFromList("Queue:AndroidUserUploadInfo:Logger", 1));
                Assert.Equal(LogOperationType.Update, secondAndroidUserUploadInfo.Operation);
                Assert.Equal(6, redis.GetListCount("Queue:AndroidUserAppInfo:Logger"));
                Assert.Equal(4, redis.GetListCount("Queue:AndroidUserAppTrafficInfo:AndroidUserAppTrafficInfoLogger"));
                Assert.Equal(4, redis.GetListCount("Queue:AndroidUserAppActivityInfo:AndroidUserAppActivityInfoLogger"));
            }
        }
Ejemplo n.º 5
0
 public RedisMapperTests()
 {
     redis = new RedisService();
     redis.FlushAll();
 }