예제 #1
0
        public void JsonDataConverter_deserializedUnits()
        {
            string Testunits           = "[{ \"units\":[\"0000A1,test01\",\"0000A2,test02\",\"0000A3,test03\",\"0000A4,null\"]}]";
            string expectedoutput_01   = "0000A1,test01";
            string expectedoutput_02   = "0000A2,test02";
            string expectedoutput_03   = "0000A3,test03";
            string expectedoutput_04   = "0000A4,null";
            int    expectedoutputcount = 3;

            List <Userunits> unitsWithNull    = JsonDataConverter.deserializedUnits(Testunits, false);
            List <Userunits> unitsWithOutNull = JsonDataConverter.deserializedUnits(Testunits, true);

            string[] unitsarray = new string[unitsWithNull.Count];

            for (int i = 0; i < unitsWithNull.Count; i++)
            {
                unitsarray[i] = unitsWithNull[i].id + "," + unitsWithNull[i].name;
            }

            Assert.AreEqual(expectedoutput_01, unitsarray[0]);
            Assert.AreEqual(expectedoutput_02, unitsarray[1]);
            Assert.AreEqual(expectedoutput_03, unitsarray[2]);
            Assert.AreEqual(expectedoutput_04, unitsarray[3]);
            Assert.AreEqual(expectedoutputcount, unitsWithOutNull.Count);
        }
예제 #2
0
        /// <summary>
        /// Function used to getunits with and without null in unit names
        /// </summary>
        /// <param name="FilterNull">true is no units with null in unit names</param>
        /// <returns>return a list of the units</returns>
        private List <Userunits> GetUnits(bool FilterNull)
        {
            string JSONunits = HttpApiRequest.Userunits(UserInformation.ApiKey, UserInformation.Mail, UserInformation.Password);

            return(JsonDataConverter.deserializedUnits(JSONunits, FilterNull));
        }