예제 #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);
        }
예제 #2
0
        private void View()
        {
            if (_tickSource == null)
            {
                return;
            }
            if (_tickSource.TickSourceID <= 0)
            {
                _console.WriteLine("Новый тиковый источник");
            }
            else
            {
                _console.WriteLine("Тиковый источник");
            }
            _console.WriteSeparator();
            string header = string.Format("Name: {0}\nTickSourceID: {1}, Start Date: {2}, End Date: {3}, Timeframe: {4}",
                                          _tickSource.Name,
                                          _tickSource.TickSourceID.ToString(),
                                          _tickSource.StartDate.ToString("dd.MM.yyyy"),
                                          _tickSource.EndDate.ToString("dd.MM.yyyy"),
                                          _tickSource.Timeframe.ToString());

            _console.WriteLine(header);
            _console.WriteTitle("Instrums");
            var instrums = _tickSource.GetInstrums();

            foreach (var instrum in instrums)
            {
                string item = string.Format("Ticker = {0}\tShortName = {1}",
                                            instrum.Ticker,
                                            instrum.ShortName);
                _console.WriteLine(item);
            }
        }
예제 #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);
        }
예제 #4
0
        public void SerializeInitialize_tsWithEmptyInstrums_clonedWithEmptyInstrums()
        {
            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;

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

            ts1.Initialize(xdoc);

            var ts1_instrums = ts1.GetInstrums();

            Assert.Empty(ts1_instrums);
        }