Beispiel #1
0
        public void CleanBasicDataTest()
        {
            // compose basic data
            IEnumerable <BasicData> o = Cleaners.ConvertHistoryToBasic(history, "O");
            IEnumerable <BasicData> h = Cleaners.ConvertHistoryToBasic(history, "H");
            IEnumerable <BasicData> l = Cleaners.ConvertHistoryToBasic(history, "L");
            IEnumerable <BasicData> c = Cleaners.ConvertHistoryToBasic(history, "C");
            IEnumerable <BasicData> v = Cleaners.ConvertHistoryToBasic(history, "V");

            // remove index
            foreach (BasicData x in c)
            {
                x.Index = null;
            }

            // re-clean index
            c = Cleaners.PrepareBasicData(c);

            // assertions

            // should always be the same number of results as there is history
            Assert.AreEqual(502, c.Count());

            // should always have index
            Assert.IsFalse(c.Where(x => x.Index == null || x.Index <= 0).Any());

            // samples
            BasicData ro = o.Where(x => x.Index == 502).FirstOrDefault();
            BasicData rh = h.Where(x => x.Index == 502).FirstOrDefault();
            BasicData rl = l.Where(x => x.Index == 502).FirstOrDefault();
            BasicData rv = v.Where(x => x.Index == 502).FirstOrDefault();

            // use close as special case to evaluate index
            BasicData rc = c
                           .Where(x => x.Date == DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", cultureProvider))
                           .FirstOrDefault();

            // last index should be 502
            Assert.AreEqual(502, rc.Index);

            // last values should be correct
            Assert.AreEqual(244.92m, ro.Value);
            Assert.AreEqual(245.54m, rh.Value);
            Assert.AreEqual(242.87m, rl.Value);
            Assert.AreEqual(245.28m, rc.Value);
            Assert.AreEqual(147031456, rv.Value);
        }
Beispiel #2
0
        public void DuplicateBasicData()
        {
            List <BasicData> bd = new List <BasicData>
            {
                new BasicData {
                    Date = DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", cultureProvider), Value = 214.86m
                },
                new BasicData {
                    Date = DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", cultureProvider), Value = 214.75m
                },
                new BasicData {
                    Date = DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", cultureProvider), Value = 226.42m
                },
                new BasicData {
                    Date = DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", cultureProvider), Value = 226.93m
                },
                new BasicData {
                    Date = DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", cultureProvider), Value = 228.97m
                }
            };

            Cleaners.PrepareBasicData(bd);
        }
        public void DuplicateBasicData()
        {
            List <BasicData> bd = new List <BasicData>
            {
                new BasicData {
                    Date = DateTime.Parse("2017-01-03"), Value = (decimal)214.86
                },
                new BasicData {
                    Date = DateTime.Parse("2017-01-04"), Value = (decimal)214.75
                },
                new BasicData {
                    Date = DateTime.Parse("2017-01-05"), Value = (decimal)226.42
                },
                new BasicData {
                    Date = DateTime.Parse("2017-01-06"), Value = (decimal)226.93
                },
                new BasicData {
                    Date = DateTime.Parse("2017-01-06"), Value = (decimal)228.97
                }
            };

            Cleaners.PrepareBasicData(bd);
        }
Beispiel #4
0
        public void NoBasicData()
        {
            List <BasicData> bd = new List <BasicData>();

            Cleaners.PrepareBasicData(bd);
        }
Beispiel #5
0
 public object PrepareBasicData()
 {
     return(Cleaners.PrepareBasicData(b));
 }