Exemple #1
0
        public void SaveGet_insert_getEqualTickSource()
        {
            IInstrumBL    instrumBL    = new InstrumBLMock();
            ITickSourceDA tickSourceDA = new TickSourceDAMock();
            TickSourceBL  tickSourceBL = new TickSourceBL(instrumBL, tickSourceDA, null, null);

            var ts0 = new TickSource(instrumBL, null, null);

            ts0.Name      = "наименование";
            ts0.StartDate = new DateTime(2010, 1, 1);
            ts0.EndDate   = new DateTime(2010, 12, 31);
            ts0.Timeframe = Timeframes.Hour;
            ts0.AddInstrum(1);
            ts0.AddInstrum(2);
            ts0.AddInstrum(3);
            tickSourceBL.SaveTickSource(ts0);

            var ts = tickSourceBL.GetTickSourceByID(ts0.TickSourceID);

            Assert.Equal(ts0.TickSourceID, ts.TickSourceID);
            Assert.Equal(ts0.Name, ts.Name);
            Assert.Equal(ts0.StartDate, ts.StartDate);
            Assert.Equal(ts0.EndDate, ts.EndDate);
            Assert.Equal(ts0.Timeframe, ts.Timeframe);

            string ids0 = string.Join(',', ts0.GetInstrums().Select(r => r.InsID.ToString()).OrderBy(r => r));
            string ids  = string.Join(',', ts.GetInstrums().Select(r => r.InsID.ToString()).OrderBy(r => r));

            Assert.Equal(ids0, ids);
        }
Exemple #2
0
        public void Delete_createAndDelete_emptyList()
        {
            IInstrumBL    instrumBL    = new InstrumBLMock();
            ITickSourceDA tickSourceDA = new TickSourceDAMock();
            ITickSourceBL tickSourceBL = new TickSourceBL(instrumBL, tickSourceDA, null, null);

            var ts = new TickSource(instrumBL, null, null);

            ts.Name      = "наименование";
            ts.StartDate = new DateTime(2010, 1, 1);
            ts.EndDate   = new DateTime(2010, 12, 31);
            ts.Timeframe = Timeframes.Hour;
            ts.AddInstrum(1);
            ts.AddInstrum(2);
            ts.AddInstrum(3);
            tickSourceBL.SaveTickSource(ts); // insert

            var list = tickSourceBL.GetTickSourceList().ToList();

            Assert.Single(list);

            tickSourceBL.DeleteTickSourceByID(ts.TickSourceID);

            var list1 = tickSourceBL.GetTickSourceList().ToList();

            Assert.Empty(list1);
        }
Exemple #3
0
        public void SerializeInitialize_tsclone_equalCloned()
        {
            IInstrumBL instrumBL = new InstrumBLMock();
            TickSource ts        = new TickSource(instrumBL, null, null);

            ts.Name      = "наименование";
            ts.StartDate = new DateTime(2010, 1, 1);
            ts.EndDate   = new DateTime(2010, 12, 31);
            ts.Timeframe = Timeframes.Min;
            ts.AddInstrum(1);
            ts.AddInstrum(2);
            ts.AddInstrum(3);

            var xdoc = ts.Serialize();
            var ts1  = new TickSource(instrumBL, null, null);

            ts1.Initialize(xdoc);

            Assert.Equal(ts.StartDate, ts1.StartDate);
            Assert.Equal(ts.EndDate, ts1.EndDate);
            Assert.Equal(ts.Timeframe, ts1.Timeframe);
            var ts1_instrums = ts1.GetInstrums();

            Assert.Equal(3, ts1_instrums.Count());
            Assert.Contains(ts1_instrums, r => r.InsID == 1);
            Assert.Contains(ts1_instrums, r => r.InsID == 2);
            Assert.Contains(ts1_instrums, r => r.InsID == 3);
        }
Exemple #4
0
        private void Add(List <string> args)
        {
            if (args.Count == 0)
            {
                _console.WriteError("Неверное число аргументов");
                return;
            }

            foreach (var ticker in args)
            {
                var isSuccess = _tickSource.AddInstrum(ticker);
                if (isSuccess)
                {
                    _console.WriteLine("Добавлен: " + ticker);
                }
                else
                {
                    _console.WriteError("Неверный тикер: " + ticker);
                }
            }
            View();
        }