Example #1
0
        public void TestAcquireDataNoParam()
        {
            List <IndicatorSettings> indicatorSettings = osPlugin.GetIndicatorSettings();

            List <Tuple <string, Object, DataType> > resultList;

            resultList = osPlugin.AcquireData();

            Assert.NotNull(resultList, "OsTest:TestAcquireDataNoParam() #01");
            Assert.IsNotEmpty(resultList, "OsTest:TestAcquireDataNoParam() #02");
            foreach (Tuple <string, Object, DataType> tuple in resultList)
            {
                Assert.NotNull(tuple, "OsTest:TestAcquireDataNoParam() #03");
                Assert.IsNotEmpty(tuple.Item1, "OsTest:TestAcquireDataNoParam() #04");
                Assert.NotNull(tuple.Item3, "OsTest:TestAcquireDataNoParam() #05");
                bool validDataType = false;
                foreach (var dataType in Enum.GetValues(typeof(MISD.Core.DataType)))
                {
                    if (tuple.Item3.Equals(dataType))
                    {
                        validDataType = true;
                        break;
                    }
                }
                Assert.True(validDataType, "OsTest:TestAcquireDataNoParam() #06");

                foreach (IndicatorSettings indicatorSetting in indicatorSettings)
                {
                    if (indicatorSetting.IndicatorName == tuple.Item1)
                    {
                        Assert.True(indicatorSetting.DataType.Equals(tuple.Item3), "OsTest:TestAcquireDataNoParam() #07");
                    }
                }

                if (tuple.Item2 != null)
                {
                    System.Type sollType;
                    switch (tuple.Item3.ToString())
                    {
                    case "String":
                        sollType = typeof(string);
                        break;

                    case "Byte":
                        sollType = typeof(byte);
                        break;

                    case "Int":
                        sollType = typeof(int);
                        break;

                    case "Float":
                        sollType = typeof(float);
                        break;

                    default:
                        sollType = null;
                        break;
                    }
                    if (sollType != null)
                    {
                        Assert.AreEqual(sollType, tuple.Item2.GetType(), "OsTest:TestAcquireDataNoParam() #08" + ":" + tuple.Item1.ToString());
                    }
                    else
                    {
                        throw new Exception("Old test code cause of new datatypes in MISD.Core.DataType. Please update the test code!");
                    }
                }
            }
        }