public DeviceModel GetMatchedDeviceModel(string valuePattern, string actualValue) { List<string> allDeviceModelIds = new List<string>() { "1" }; _redisServiceMock.Setup<List<string>>(m => m.GetAllActiveModelIds<DeviceModel>()).Returns(allDeviceModelIds); Dictionary<string, object> customProperties = new Dictionary<string, object>(); customProperties["7"] = valuePattern; var deviceModel = new DeviceModel() { ModelName = "MTK_6252", CustomProperties = customProperties }; _redisServiceMock.Setup<DeviceModel>(m => m.GetModelWithCustomProperties<DeviceModel, CustomProperty>("1")).Returns(deviceModel); Element lcdAttr = new Element(); lcdAttr.Id = "7"; lcdAttr.Name = "lcd"; _redisServiceMock.Setup<Element>(m => m.Get<Element>("7")).Returns(lcdAttr); AppStoreUIService appStoreService = new AppStoreUIService(fileService, redisService); var namevalues = new NameValueCollection(); namevalues[MobileParam.Key_Resolution] = actualValue; _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues); MobileParam mobileParam = new MobileParam(requestRepo); return appStoreService.GetDeviceModelByRequest(mobileParam); }
public void GetDeviceModelByRequest_not_matched_by_string_value() { List<string> allDeviceModelIds = new List<string>() { "1" }; _redisServiceMock.Setup<List<string>>(m => m.GetAllActiveModelIds<DeviceModel>()).Returns(allDeviceModelIds); Dictionary<string, object> customProperties = new Dictionary<string, object>(); customProperties["7"] = "240x321"; var deviceModel = new DeviceModel() { ModelName = "MTK_6252", CustomProperties = customProperties }; _redisServiceMock.Setup<DeviceModel>(m => m.GetModelWithCustomProperties<DeviceModel, CustomProperty>("1")).Returns(deviceModel); Element lcdAttr = new Element(); lcdAttr.Id = "7"; lcdAttr.Name = "lcd"; _redisServiceMock.Setup<Element>(m => m.Get<Element>("7")).Returns(lcdAttr); AppStoreUIService appStoreService = new AppStoreUIService(fileService, redisService); var namevalues = new NameValueCollection(); namevalues[MobileParam.Key_Resolution] = "240x320"; _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues); MobileParam mobileParam = new MobileParam(requestRepo); var result = appStoreService.GetDeviceModelByRequest(mobileParam); Assert.Null(result); }