Example #1
0
 /// <summary>
 /// Get field name by value
 /// </summary>
 /// <param name="fieldValue"></param>
 /// <returns></returns>
 public string GetFieldName(object fieldValue)
 {
     if (TestDatas.ContainsValue(fieldValue))
     {
         return(TestDatas.Where(v => v.Value.Equals(fieldValue)).Select(k => k.Key).ToString());
     }
     else
     {
         throw new Exception("Value is not found:" + fieldValue);
     }
 }
Example #2
0
 /// <summary>
 /// Modify existing field value
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="fieldValue"></param>
 public void SetFieldValue(string fieldName, object fieldValue)
 {
     if (TestDatas.ContainsKey(fieldName))
     {
         TestDatas[fieldName] = fieldValue;
     }
     else
     {
         throw new KeyNotFoundException("Key Name is not found:" + fieldName);
     }
 }
Example #3
0
        /// <summary>
        /// Get field value by field name
        /// </summary>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public object GetFieldValue(string fieldName)
        {
            object value;

            if (TestDatas.ContainsKey(fieldName))
            {
                TestDatas.TryGetValue(fieldName, out value);
                return(value);
            }
            else
            {
                throw new KeyNotFoundException("Key Name is not found:" + fieldName);
            }
        }
        /// <summary>
        /// 删除测试数据
        /// </summary>
        public void DeleteTestData()
        {
            lock (lockObject)
            {
                if (IsMeasuring)
                {
                    return;
                }
            }

            if (TestDatasIndex < 0)
            {
                return;
            }

            TestDatas.RemoveAt(TestDatasIndex);
        }
        /// <summary>
        /// 插入测试数据
        /// </summary>
        public void InsertTestData()
        {
            lock (lockObject)
            {
                if (IsMeasuring)
                {
                    return;
                }
            }

            if (TestDatasIndex < 0)
            {
                return;
            }

            TestDatas.Insert(TestDatasIndex, new FrequencyTestData(0, 0));
        }
        public async Task Index_ReturnsAViewResult_WithAListOfRxJobs()
        {
            // Arrange
            var mockRepo = new Mock <RxJobRepository>(new RxDbContext());

            mockRepo.Setup(r => r.ListAsync())
            .ReturnsAsync(TestDatas.GetTestRxJobs());
            var controller = new RxJobController(mockRepo.Object);

            // Act
            var result = await controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <RxJob> >(
                viewResult.ViewData.Model);

            Assert.Equal(TestDatas.GetTestRxJobs().Count(), model.Count());
        }
Example #7
0
        public void BuildTestDatas(WordDictionary wordDictionary)
        {
            string[] directories = Directory.GetDirectories(Path.Combine(Program.myPath, "res", "TestData"));
            foreach (string directory in directories)
            {
                // Get Files
                string[] files = Directory.GetFiles(directory);
                foreach (string file in files)
                {
                    // Instantiate TestData
                    string[] realClass = directory.Split("\\");
                    TestData testData  = new TestData(realClass[realClass.Length - 1], wordDictionary.Words.Count);

                    // Create WordVector n
                    CreateWordVector(wordDictionary, file, testData);
                    TestDatas.Add(testData);
                }
            }
        }
        public void Return()
        {
            // Arrange
            string key = "key";

            var expectedData = TestDatas.GetFakeTestPhaseModels();

            byte[]          sessionValue  = null;
            Mock <ISession> mockedSession = new Mock <ISession>();

            mockedSession
            .Setup(x => x.Set(It.IsAny <string>(), It.IsAny <byte[]>()))
            .Callback((string k, byte[] v) => sessionValue = v);

            mockedSession
            .Setup(x => x.TryGetValue(It.IsAny <string>(), out sessionValue))
            .OutCallback((string k, out byte[] v) => v = sessionValue)
            .Returns(true);


            Mock <HttpContext> mockedHttpContext = new Mock <HttpContext>();

            mockedHttpContext.Setup(x => x.Session)
            .Returns(mockedSession.Object);

            var _mockHttpContextAccessor = new Mock <IHttpContextAccessor>();

            _mockHttpContextAccessor
            .Setup(x => x.HttpContext)
            .Returns(mockedHttpContext.Object);

            ISessionStorage _sessionStorage = new SessionStorage(_mockHttpContextAccessor.Object);

            // Act
            _sessionStorage.SetObjectAsJson(key, expectedData);
            var actual = _sessionStorage.GetObjectFromJson <List <TestPhaseModel> >(key);

            // Assert
            //Assert.Equal(expectedData, actual);
            actual.Should().BeEquivalentTo(expectedData);
        }
Example #9
0
        public int SendData(string dataJson)
        {
            HealthData hd = new HealthData();

            try
            {
                hd = JsonConvert.DeserializeObject <HealthData>(dataJson);
                TestDatas tds                 = hd.TestDatas;
                HeadData  head                = hd.HeadData;
                string    healthData          = JsonConvert.SerializeObject(tds);
                string    uploadTime          = head.uploadTime;
                string    verifyCode          = head.verifyCode;
                string    orgID               = head.organizationID;
                string    devNo               = head.deviceNo;
                DJK.Model.djk_cloudData model = new DJK.Model.djk_cloudData();
                model.healthData    = healthData;
                model.orgnizationID = orgID;
                model.deviceNo      = devNo;
                model.verifyCode    = verifyCode;
                model.savedDate     = Convert.ToDateTime(uploadTime);
                DJK.DAL.djk_cloudData dalCloud = new djk_cloudData();
                int rtn = dalCloud.Add(model);
                if (rtn > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                string ss = ex.ToString();
                return(0);
            }
        }
Example #10
0
    public void RepositionChildPanel(int idx, bool autoChangeLine = false)
    {
        RectTransform curChild = null;

        curChild = transform.GetChild(idx) as RectTransform;
        if (!curChild.gameObject.activeInHierarchy)
        {
            return;
        }

        curChild.localPosition = nowPlacePos;

        TestDatas data = null;

        if (curChild.GetComponent <TestListItem>() != null)
        {
            data = curChild.GetComponent <TestListItem>().data;
            //Debug.LogError(string.Format("child:{0} localPos:{1} dataIndex:{2}",
            //    idx, nowPlacePos, data.dataIndex));
        }
        ApplyPaddingToNowPos();

        ManageNowPos(curChild, autoChangeLine);
    }
Example #11
0
        public string getResult()
        {
            modelData = dal.GetModel(verifyCode);
            if (modelData == null)
            {
                return("");
            }
            healthData = modelData.healthData;
            TestDatas tds = JsonConvert.DeserializeObject <TestDatas>(healthData);

            mpList = tds.MatrixDatas;
            ipList = tds.InfoDatas;
            string rtn = "";
            List <DJK.Model.admin_MedicalData> result = new List <DJK.Model.admin_MedicalData>();
            List <TestData> resultList = new List <TestData>();

            result = dalData.getModelList();
            foreach (DJK.Model.admin_MedicalData model in result)
            {
                if (model.DataFormula != null && model.DataFormula > 0)
                {
                    int formula = (int)model.DataFormula;
                    int dataMin = (int)(model.DataMin == null ? 0 : model.DataMin);
                    int dataMax = (int)(model.DataMax == null ? 5 : model.DataMax);
                    model.DataValue = getDataValue(formula, model.ID, dataMin, dataMax);
                    TestData td = new TestData();
                    td.no    = model.Code;
                    td.name  = model.Item;
                    td.value = model.DataValue.ToString();
                    resultList.Add(td);
                }
                rtn = JsonConvert.SerializeObject(resultList);
            }

            return(rtn);
        }
Example #12
0
        private string GetXmlData(string verifyCode)
        {
            string     infoData   = System.Windows.Forms.Application.StartupPath + "/info.xml";
            string     matrixData = System.Windows.Forms.Application.StartupPath + "/matrix.xml";
            string     data       = "";
            HealthData hdata      = new HealthData();
            HeadData   head       = new HeadData();

            head.deviceNo       = "testDevice";
            head.organizationID = "testOrgID";
            head.uploadTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            head.verifyCode     = verifyCode;
            TestDatas   tds         = new TestDatas();
            XmlDocument xmlDocument = new XmlDocument();

            if (File.Exists(infoData))
            {
                List <TestData> infoDataList = new List <TestData>();
                xmlDocument.Load(infoData);
                XmlElement  xmlElement = xmlDocument.DocumentElement;
                XmlNodeList nodeList   = xmlElement.ChildNodes;
                XmlNodeList nodeList2  = nodeList[1].ChildNodes;
                foreach (XmlNode item in nodeList2)
                {
                    TestData rd = new TestData();
                    if (item.Attributes["No"].Value == "0")
                    {
                        continue;
                    }
                    else
                    {
                        rd.value = item.Attributes["No"].Value;
                        if (item.Attributes["Name"] != null)
                        {
                            rd.name = item.Attributes["Name"].Value.Replace("'", "''");
                        }
                        else
                        {
                            rd.name = "";
                        }
                        if (item.Attributes["Value"] != null)
                        {
                            rd.value = item.Attributes["Value"].Value;
                        }
                        else
                        {
                            rd.value = "0";
                        }
                        infoDataList.Add(rd);
                    }
                }
                tds.InfoDatas = infoDataList;
                //data = JsonConvert.SerializeObject(rl);
            }
            if (File.Exists(matrixData))
            {
                List <TestData> matrixDataList = new List <TestData>();
                xmlDocument.Load(matrixData);
                XmlElement  xmlElement = xmlDocument.DocumentElement;
                XmlNodeList nodeList   = xmlElement.ChildNodes;
                XmlNodeList nodeList2  = nodeList[1].ChildNodes;
                foreach (XmlNode item in nodeList2)
                {
                    TestData rd = new TestData();
                    rd.name  = item.Attributes["Name"].Value.Replace("'", "''");
                    rd.no    = item.Attributes["No"].Value;
                    rd.value = item.Attributes["Value"].Value;
                    matrixDataList.Add(rd);
                }
                tds.MatrixDatas = matrixDataList;
            }
            hdata.HeadData  = head;
            hdata.TestDatas = tds;
            data            = JsonConvert.SerializeObject(hdata);
            return(data);
        }
Example #13
0
 public override void FillView(object data)
 {
     this.data       = data as TestDatas;
     text.text       = string.Format("s:{0}  i:{1}", this.data.choice, this.data.dataIndex);
     gameObject.name = string.Format("{0}dataIdx:{1}", gameObject.name, this.data.dataIndex);
 }
Example #14
0
 /// <summary>
 /// 实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public MenuView Menu(int id)
 {
     return(TestDatas.Where(m => m.Id == id).Select(s => new MenuView {
         Id = s.Id, Name = s.Name
     }).FirstOrDefault());
 }
Example #15
0
 /// <summary>
 /// 列表集合
 /// </summary>
 /// <returns></returns>
 public List <MenuView> Menus()
 {
     return(TestDatas.Select(s => new MenuView {
         Id = s.Id, Name = s.Name
     }).ToList());
 }