Beispiel #1
0
        public ActionResult RunProcess(string asset, string timeframe, bool fromScratch, string analysisTypes)
        {
            //Convert the given names of analysis into enumerations.
            Asset _asset = Asset.GetAssetByName(asset);
            Timeframe _timeframe = Timeframe.GetTimeframeByShortName(timeframe);
            ProcessService service = new ProcessService(_asset, _timeframe);
            var types = AnalysisTypeHelper.StringToTypesList(analysisTypes, ',');

            service.Setup(types);
            var result = service.Run(fromScratch);
            var json = new { value = result };
            return Json(json, JsonRequestBehavior.AllowGet);
        }
        public void after_setup_properties_are_correctly_set()
        {
            Asset asset = new Asset(1, "USD");
            Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M5);
            AnalysisType[] types = new AnalysisType[] { AnalysisType.Price };

            Mock<IQuotationService> mockQuotationService = UnitTestTools.mockedQuotationService();
            mockQuotationService.Setup(q => q.getLastCalculationDate(It.IsAny<string>(), It.IsAny<string>())).Returns(new DateTime());

            var service = new ProcessService(asset, timeframe);
            service.Setup(types);

            Assert.AreEqual(service.getAsset(), asset);
            Assert.AreEqual(service.getTimeframe(), timeframe);
        }
        public void if_quotationService_returns_empty_array_of_data_items_Run_returns_false()
        {
            var mockQuotationService = UnitTestTools.mockedQuotationService();
            DataItem[] items = new DataItem[] { };
            mockQuotationService.Setup(q => q.fetchData(It.IsAny<Dictionary<AnalysisType, IAnalyzer>>())).Returns(items);

            Asset asset = new Asset(1, "USD");
            Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M15);
            ProcessService service = new ProcessService(asset, timeframe);
            AnalysisType[] types = new AnalysisType[] { AnalysisType.Price };
            service.Setup(types);

            Assert.IsFalse(service.Run(true));
        }
 public void run_if_timeframe_is_empty_exception_is_thrown()
 {
     Asset asset = new Asset(1, "USD");
     Timeframe timeframe = null;
     var service = new ProcessService(asset, timeframe);
     AnalysisType[] types = new AnalysisType[] { AnalysisType.MACD, AnalysisType.Price };
     service.Setup(types);
     service.Run(true);
 }
 public void run_if_there_is_no_analyzers_assigned_exception_is_thrown()
 {
     Asset asset = new Asset(1, "USD");
     Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M5);
     var service = new ProcessService(asset, timeframe);
     AnalysisType[] types = new AnalysisType[] { };
     service.Setup(types);
     service.Run(true);
 }
 public void run_if_asset_is_empty_exception_is_thrown()
 {
     Asset asset = null;
     Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M15);
     var service = new ProcessService(asset, timeframe);
     AnalysisType[] types = new AnalysisType[] { AnalysisType.MACD, AnalysisType.Price };
     service.Setup(types);
     service.Run(true);
 }
        public void quotationProcessor_is_called_once_for_loading_data()
        {
            Asset asset = new Asset(1, "USD");
            Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M15);
            ProcessService service = new ProcessService(asset, timeframe);
            var mockQuotationService = UnitTestTools.mockedQuotationService();
            AnalysisType[] types = new AnalysisType[] { AnalysisType.Price };
            service.injectQuotationService(mockQuotationService.Object);
            service.Setup(types);
            service.Run(true);

            mockQuotationService.Verify(x => x.fetchData(It.IsAny<Dictionary<AnalysisType, IAnalyzer>>()), Times.Exactly(1));
        }