Esempio n. 1
0
        public void _01_ETF50Tests()
        {
            var htmlService       = new HtmlService();
            var instrumentService = new InstrumentService(htmlService);
            var etf50Insts        = instrumentService.GetInstruments(SinaInstrumentCategory.Index.Index_Sh_50).Take(10);

            // Category
            var categService = new CategorizationService(htmlService);
            var categorizes  = new HashSet <string>();

            foreach (var inst in etf50Insts)
            {
                var cates = categService.GetCateogories(inst.SymbolShort);
                foreach (var cate in cates)
                {
                    categorizes.Add(cate);
                }
                inst.AsDynamic().Categories = cates;
            }

            // Equity structure
            var structureService = new EquityStructureService(htmlService);

            foreach (var inst in etf50Insts)
            {
                var structure = structureService.GetEquityStructure(inst.SymbolShort);
                inst.AsDynamic().EquityStructure = structure;
            }

            var str = JsonUtil.Serialize(etf50Insts);
        }
Esempio n. 2
0
        public void _01_InstrumentServiceTest_GetInstruments()
        {
            var html        = new HtmlService();
            var service     = new InstrumentService(html);
            var instruments = service.GetInstruments();

            Assert.IsTrue(instruments.Length > 2000);
        }
Esempio n. 3
0
        public ActionResult Create(Guid id)
        {
            var viewmodel = new JobItemViewModel()
            {
                Fields      = _listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).OrderBy(li => li.Name).ToSelectList(),
                Instruments = _instrumentService.GetInstruments().ToSelectList(),
                Status      = _listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).OrderBy(li => li.Name).ToSelectList(),
                JobId       = id
            };

            return(View(viewmodel));
        }
Esempio n. 4
0
 public void GetInstruments_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
 {
     try
     {
         var id = Guid.NewGuid();
         var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>();
         _instrumentService = InstrumentServiceFactory.Create(
             MockRepository.GenerateMock <IInstrumentRepository>(), TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Public));
         _instrumentService.GetInstruments();
     }
     catch (DomainValidationException dex)
     {
         _domainValidationException = dex;
     }
     Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance));
 }
Esempio n. 5
0
        public ActionResult Index(int page = 1)
        {
            var pageSize    = 15;
            var instruments = _instrumentService.GetInstruments().Select(
                i => new InstrumentViewModel
            {
                Id              = i.Id,
                Description     = i.Description,
                Manufacturer    = i.Manufacturer,
                ModelNo         = i.ModelNo,
                Range           = i.Range,
                CalibrationTime = i.AllocatedCalibrationTime
            }).OrderBy(i => i.Manufacturer).Skip((page - 1) * pageSize).Take(pageSize);
            var viewModel = new InstrumentListViewModel
            {
                Instruments     = instruments,
                CreateViewModel = new InstrumentViewModel(),
                Page            = page,
                PageSize        = pageSize,
                Total           = _instrumentService.GetInstrumentsCount()
            };

            return(View(viewModel));
        }