public AppStoresWapUIServiceTest()
        {
            _redisServiceMock = new Mock<IRedisService>();
            redisService = _redisServiceMock.Object;

            _redisServiceMock2 = new Mock<IRedisService2>();
            redisService2 = _redisServiceMock2.Object;

            _redisClientMock = new Mock<IRedisClient>();
            redisClient = _redisClientMock.Object;

            _appStoreUIServiceMock = new Mock<IAppStoreUIService>();
            appStoreUIService = _appStoreUIServiceMock.Object;

            _logServiceMock = new Mock<ILogger>();
            logService = _logServiceMock.Object;

            _fileServiceMock = new Mock<IFileService>();
            fileService = _fileServiceMock.Object;

            _fullTextSearchServiceMock = new Mock<IFullTextSearchService>();
            fullTextSearchService = _fullTextSearchServiceMock.Object;

            _requestRepoMock = new Mock<IRequestRepository>();
            requestRepo = _requestRepoMock.Object;

            appStoreUIRealService = new AppStoreUIService(fs, redisReal);

            sesionRepository = new Mock<ISessionRepository>();
            sesionRepositoryReal = new SessionRepository();

            cookieServiceReal =new CookieService();
            cookieService = new Mock<ICookieService>();

            appStoreServiceReal = new AppStoreService(fs, redisReal, appStoreUIRealService, new FullTextSearchService(redisReal),new IMEICacheService(redisReal));
            appStoreServiceReal.RedisService2 = new RedisService2();
            appStoreService = new AppStoreService(fs, redisService, appStoreUIRealService, new FullTextSearchService(redisService), new IMEICacheService(redisReal));
            appStoreService.RedisService2 = redisService2;

            appStoresWapUIServiceReal = new AppStoresWapUISerivces(appStoreUIRealService, redisReal, appStoreServiceReal, sesionRepositoryReal, cookieServiceReal, new FullTextSearchService(redisReal));
            appStoresWapUIServiceReal.RedisService2 = new RedisService2();
            appStoresWapUIService = new AppStoresWapUISerivces(appStoreUIService, redisService, appStoreService, sesionRepository.Object, cookieService.Object, fullTextSearchService);

            appStoresWapUIService.RedisService2 = redisService2;
            Bootstrapper.Start();
            redisReal.FlushAll();
        }
        public void HasGreaterVersionTest()
        {
            var mockLogger = new Mock<ILogger>();
            var svc = new AppStoreService(null, null, null, new FullTextSearchService(redisService), new IMEICacheService(redisService));

            Assert.True(svc.HasGreaterVersion("i10003", "i10002"));
            Assert.True(svc.HasGreaterVersion("i10010", "i10008"));
            Assert.True(svc.HasGreaterVersion("1.2.3", "1.2.2"));
            Assert.True(svc.HasGreaterVersion("2.2.1", "1.2.20"));
            Assert.True(svc.HasGreaterVersion("2.02.01", "1.02.20"));
            Assert.True(svc.HasGreaterVersion("12", "10"));
            Assert.True(svc.HasGreaterVersion("i1.0.20.5.4version", "i1.0.20.5.3ver"));
            Assert.True(svc.HasGreaterVersion("def", "abc"));

            Assert.False(svc.HasGreaterVersion(null, "i1.0.20.5.4version"));
            Assert.False(svc.HasGreaterVersion("i1.0.20.5.4version", null));
            Assert.False(svc.HasGreaterVersion("i10001", "i10002"));
            Assert.False(svc.HasGreaterVersion("abc", "def"));
            Assert.False(svc.HasGreaterVersion("i1.0.20.5.4version", "i10002"));
            Assert.False(svc.HasGreaterVersion("1.0.0", "1.0.0"));
            Assert.False(svc.HasGreaterVersion("12", "12"));
            Assert.False(svc.HasGreaterVersion("35", "123"));
        }
        public void Market31()
        {
            var redis = new RedisService();
            var appstoreService = new AppStoreService(MockFileService.Object, redis, MockAppStoreUIService.Object, MockFullTextSearchService.Object,MockIMEICacheService.Object);
            _processor = new StatisticDataProcessor(redis);
            _processor.oracleRepo = MockOracleRepo.Object;

            var globalKey = _processor.GetKey(StatisticConsts.Market31.GLOBAL_IMEI);
            redis.AddItemToSet(globalKey, "0");
            //var globalIMEIList = new List<string> { "0" };

            // the exist imei is 0 only
            appstoreService.MarketStatistic(MarketStatisticType.Market31, DateTime.Now.AddDays(-1), GetMobileParam("N1", "F1", "0"));
            appstoreService.MarketStatistic(MarketStatisticType.Market31, DateTime.Now.AddDays(-1), GetMobileParam("N1", "F1", "1"));
            appstoreService.MarketStatistic(MarketStatisticType.Market31, DateTime.Now.AddDays(-1), GetMobileParam("N2", "F1", "2"));
            appstoreService.MarketStatistic(MarketStatisticType.Market31, DateTime.Now.AddDays(-1), GetMobileParam("N1", "F2", "3"));
            appstoreService.MarketStatistic(MarketStatisticType.Market31, DateTime.Now.AddDays(-1), GetMobileParam("N2", "F2", "4"));

            //setup oracle
            MockOracleRepo.Setup(x => x.Find<Market31StatisticSummary>(It.IsAny<Expression<Func<Market31StatisticSummary, bool>>>())).Returns(default(IList<Market31StatisticSummary>));
            MockOracleRepo.Setup(x => x.Find<Market31ActiveUserUVStatistic>(It.IsAny<Expression<Func<Market31ActiveUserUVStatistic, bool>>>())).Returns(default(IList<Market31ActiveUserUVStatistic>));
            MockOracleRepo.Setup(x => x.Find<Market31AddUserUVStatistic>(It.IsAny<Expression<Func<Market31AddUserUVStatistic, bool>>>())).Returns(default(IList<Market31AddUserUVStatistic>));
            MockOracleRepo.Setup(x => x.Find<Market31PVStatistic>(It.IsAny<Expression<Func<Market31PVStatistic, bool>>>())).Returns(default(IList<Market31PVStatistic>));

            MockOracleRepo.Setup(x => x.Add<Market31StatisticSummary>(It.IsAny<Market31StatisticSummary>()));
            MockOracleRepo.Setup(x => x.Add<Market31AddUserUVStatistic>(It.IsAny<Market31AddUserUVStatistic>()));
            MockOracleRepo.Setup(x => x.Add<Market31ActiveUserUVStatistic>(It.IsAny<Market31ActiveUserUVStatistic>()));
            MockOracleRepo.Setup(x => x.Add<Market31PVStatistic>(It.IsAny<Market31PVStatistic>()));

            _processor.SaveStatisticData(StatisticActionType.Market_31);

            // verify
            MockOracleRepo.Verify(x => x.Add<Market31StatisticSummary>(It.IsAny<Market31StatisticSummary>()), Times.Exactly(2));
            MockOracleRepo.Verify(x => x.Add<Market31AddUserUVStatistic>(It.IsAny<Market31AddUserUVStatistic>()), Times.Exactly(4));
            MockOracleRepo.Verify(x => x.Add<Market31ActiveUserUVStatistic>(It.IsAny<Market31ActiveUserUVStatistic>()), Times.Exactly(4));
            MockOracleRepo.Verify(x => x.Add<Market31PVStatistic>(It.IsAny<Market31PVStatistic>()), Times.Exactly(4));

            var globalIMEICount = redis.GetAllItemsFromSet(globalKey);
            Assert.Equal(5, globalIMEICount.Count);
        }
        public AppStoresServiceTest()
        {
            _redisServiceMock = new Mock<IRedisService>();
            redisService = _redisServiceMock.Object;

            _redisServiceMock2 = new Mock<IRedisService2>();
            redisService2 = _redisServiceMock2.Object;

            _redisClientMock = new Mock<IRedisClient>();
            redisClient = _redisClientMock.Object;

            _appStoreUIServiceMock = new Mock<IAppStoreUIService>();
            appStoreUIService = _appStoreUIServiceMock.Object;

            _fileServiceMock = new Mock<IFileService>();
            fileService = _fileServiceMock.Object;

            _logServiceMock = new Mock<ILogger>();
            logService = _logServiceMock.Object;

            _requestRepoMock = new Mock<IRequestRepository>();
            requestRepo = _requestRepoMock.Object;

            _fullTextSearchServiceMock = new Mock<IFullTextSearchService>();
            fullTextSearchService = _fullTextSearchServiceMock.Object;
            _imeiCacheServiceMock = new Mock<IIMEICacheService>();
            imeiCacheService = _imeiCacheServiceMock.Object;

            appStoreUIRealService = new AppStoreUIService(fs, redis);
            appStoreUIRealService.RedisService2 = redis2;
            appStoreRealService = new AppStoreService(fs, redis, appStoreUIRealService, fullTextSearchService, imeiCacheService);
            appStoreRealService.RedisService2 = redis2;

            appStoreMockService = new AppStoreService(_fileServiceMock.Object, _redisServiceMock.Object,
                _appStoreUIServiceMock.Object, _fullTextSearchServiceMock.Object,_imeiCacheServiceMock.Object);
            appStoreMockService.RedisService2 = redisService2;
            redis.FlushAll();

            EntityMapping.Config();
        }
        public void GetAppDownloadUrl_return_redirectUrl_to_client_successfully()
        {
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1",
            };
            _appStoreUIServiceMock.Setup(m => m.GetAppProjectByAppNo("1")).Returns(appProj);

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1 };
            _appStoreUIServiceMock.Setup(m => m.GetMatchedAppByRequest<AppProject>("1", mobileParam)).Returns(app);
            _redisServiceMock.Setup(s => s.Get<App>("1")).Returns(app);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            string slver = string.Empty;
            EntityMapping.Config();
            var result = appStoreService.GetAppDownloadUrl("1", mobileParam, 0);

            Assert.NotEmpty(result);
        }
        public void DownloadAppImagePackage_return_data_to_client_successfully()
        {
            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService),new IMEICacheService(redisService));

            _redisServiceMock.Setup(m => m.Get<ImageInfo>("1")).Returns(new ImageInfo() { Id = "1", FileUrl = "/path/to/1.jpg" });

            _fileServiceMock.Setup(m => m.Pack(new List<string>() { "/path/to/1.jpg" }, new List<string> { "1.jpg" })).Returns(new byte[] { });

            var result = appStoreService.DownloadAppImagePackage("1.jpg", "");

            Assert.NotNull(result);
        }
        public void GetAllKeywords_return_data_to_client_successfully()
        {
            var keywords = new List<Keyword>();
            keywords.Add(new Keyword() { Id = "111", Name = "key111" });
            keywords.Add(new Keyword() { Id = "222", Name = "key222" });

            _appStoreUIServiceMock.Setup(m => m.GetAllKeywords()).Returns(keywords);
            EntityMapping.ResetMapper();
            EntityMapping.Config();
            Bootstrapper.ConfigueInjection();

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            var result = appStoreService.GetAllKeywords("1");

            Assert.Equal(2, result.Count);
        }
        public void CheckAppList_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            var deviceModel = new DeviceModel()
            {
                ModelName = "MTK_6252",
                CustomProperties = customProperties,
                Columns = columns
            };
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            _appStoreUIServiceMock.Setup(m => m.GetDeviceModelByRequest(mobileParam)).Returns(deviceModel);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1" };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123 };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppColumn column = new AppColumn()
            {
                Id = "1",
                ClientId = 1,
                CurrentVersion = 1,
                Name = "Applications"
            };
            _redisServiceMock.Setup<List<AppColumn>>(m => m.GetValuesByIds<AppColumn>(new List<string>() { "1" }, true)).Returns(new List<AppColumn>() { column });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService),new IMEICacheService(redisService));
            var result = appStoreService.CheckAppList("1~0", mobileParam);

            Assert.Equal(1, result.Count);
        }
        public void AppList_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            var deviceModel = new DeviceModel()
            {
                ModelName = "MTK_6252",
                CustomProperties = customProperties,
                Columns = columns
            };
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            _appStoreUIServiceMock.Setup(m => m.GetDeviceModelByRequest(mobileParam)).Returns(deviceModel);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1 };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);

            var settings = new AppSettingsForAppList();
            settings.CustomProperties = new Dictionary<string, object>();
            settings.CustomProperties.Add("Name", "testName");
            _redisServiceMock.Setup(m => m.GetSubModel<AppColumn, AppSettingsForAppList>(It.IsAny<string>(), It.IsAny<string>(), false)).Returns(settings);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppColumn column = new AppColumn()
            {
                Id = "1",
                ClientId = 1,
                CurrentVersion = 1,
                Name = "Applications"
            };
            _redisServiceMock.Setup<List<AppColumn>>(m => m.GetValuesByIds<AppColumn>(new List<string>() { "1" }, true)).Returns(new List<AppColumn>() { column });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            string slver = string.Empty;
            int totalCount = 0;
            var result = appStoreService.AppList(mobileParam, 1, 1, 0, 0, "0", out slver, out totalCount);

            Assert.Equal(1, result.Count);
            Assert.Equal("testName", result[0].Name);
        }
示例#10
0
        public void AppListByTags_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 8 };
            App app2 = new App() { Id = "2", Name = "APP2", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 10, Summary = "Top" };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);
            _redisServiceMock.Setup(m => m.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(new List<App>());

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);
            AppVersion version2 = new AppVersion { Id = "2", FileSize = 321, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("2")).Returns(version2);

            _appStoreUIServiceMock.Setup(m => m.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(new List<string> { app.Id, app2.Id });

            _redisServiceMock2.Setup(m => m.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), "DownloadTimes", 0, 0, true)).Returns(new List<string> { app2.Id, app.Id });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService),new IMEICacheService(redisService));
            string slver = string.Empty;
            int totalCount = 0;
            var result = appStoreService.GetAppListByTags(mobileParam, 0, 0, out totalCount, "a;b;c;Live");

            Assert.Equal(2, totalCount);
        }
示例#11
0
        public void AppListByTagIds_return_data_to_client_successfully()
        {
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New App Porj"
            };
            App app1 = new App() { Id = "1", Name = "app1", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 8 };
            App app2 = new App() { Id = "2", Name = "app2", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 10 };

            var tag1 = new Tag() { Id = "1", Name = "a" };
            var tag2 = new Tag() { Id = "2", Name = "b" };
            var tag3 = new Tag() { Id = "3", Name = "c" };
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("1")).Returns(tag3);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("2")).Returns(tag2);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("3")).Returns(tag3);
            _appStoreUIServiceMock.Setup(m => m.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(new List<string> { app1.Id, app2.Id });
            _redisServiceMock2.Setup(m => m.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), "DownloadTimes", 0, 0, true)).Returns(new List<string> { app2.Id, app1.Id });
            _redisServiceMock.Setup(m => m.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(new List<App>());

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            int totalCount = 0;
            var result = appStoreService.GetAppListByTagIds(mobileParam, 0, 0, out totalCount, "1;2;3");
            Assert.Equal(2, totalCount);
        }
示例#12
0
        public void Should_not_write_landlord_log_if_not_match_conditions()
        {
            var mockLog = new Mock<ILogger>();
            var mockParam = new Mock<MobileParam>();
            mockParam.Setup(x => x.IsTest).Returns(true);

            var svc = new AppStoreService(fs, redis, appStoreUIRealService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            svc.WriteLandlordsLog(mockParam.Object, 1, TYD.Logging.Model.Common.MobileOperatingSystemType.Android);

            mockLog.Verify(s => s.Add<LandlordLog>(It.IsAny<LandlordLog>(), It.IsAny<string>()), Times.Never());
        }