public PricesHttpClientV1Test()
        {
            _persistence = new PricesMemoryPersistence();
            _controller  = new PricesController();
            _client      = new PricesHttpClientV1();
            _service     = new PricesHttpServiceV1();

            IReferences references = References.FromTuples(
                new Descriptor("prices", "persistence", "memory", "default", "1.0"), _persistence,
                new Descriptor("prices", "controller", "default", "default", "1.0"), _controller,
                new Descriptor("prices", "client", "http", "default", "1.0"), _client,
                new Descriptor("prices", "service", "http", "default", "1.0"), _service
                );

            _controller.SetReferences(references);

            _service.Configure(HttpConfig);
            _service.SetReferences(references);

            _client.Configure(HttpConfig);
            _client.SetReferences(references);

            _fixture = new PricesClientV1Fixture(_client);

            _service.OpenAsync(null).Wait();
            _client.OpenAsync(null).Wait();
        }
Exemplo n.º 2
0
 public void HistoricalSystemPriceTest()
 {
     var x = new PricesController();
     //var z = x.SpotMarketCurvesObject(null, 1);
     //x.HistoricalSystemPrice(true, null);
     AppData.ExcelToJson();
 }
Exemplo n.º 3
0
        public ActionResult Delete(FormCollection _form)
        {
            PricesController pc = new PricesController(Server);

            return((ActionResult)pc.Delete(Request)["view"]);
            //return null;
        }
Exemplo n.º 4
0
        public void SpikesTest()
        {
            var xx = new PricesController();
            var res = xx.EstimateSpikes("", "SimilarDay", 1.4);

            Assert.IsNotNull(res);
        }
Exemplo n.º 5
0
        public void SpikesTest()
        {
            var xx  = new PricesController();
            var res = xx.EstimateSpikes("", "SimilarDay", 1.4);

            Assert.IsNotNull(res);
        }
Exemplo n.º 6
0
        public void GetPrices_FourMonths()
        {
            // Arrange
            List <SecurityDaily> dataFromQuandl = new List <SecurityDaily>()
            {
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-04", Open = (Decimal)762.2, High = (Decimal)762.2, Low = (Decimal)747.54, Close = (Decimal)759.44, Volume = (Decimal)3369068.0
                  } }
            };

            // Quandl should be called 4 times: for 2016-01, 2016-02, 2016-03, 2016-04
            String ticker = "GOOGL";
            String start  = "2016-01-12";
            String end    = "2016-04-23";

            // Act
            _mockQuandlConsumer.Setup(x => x.GetDailyPrices(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>()))
            .Returns(Task.FromResult(dataFromQuandl));

            var controller = new PricesController(_mockQuandlConsumer.Object);
            var result     = controller.GetPrices(ticker, start, end);

            // Assert
            _mockQuandlConsumer.Verify(x => x.GetDailyPrices(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>()), Times.Exactly(4));
        }
Exemplo n.º 7
0
        /*protected override void OnActionExecuting(ActionExecutingContext filterContext)
         * {
         *  // Do whatever here...
         *  pc = new PricesController(Server);
         *  var cusid = filterContext.RequestContext.HttpContext.Request["_id"];
         *  if (cusid == null)
         *  {
         *      filterContext.Result = RedirectToAction("Index", "Cus", new { area = "crm" });
         *      return;
         *  }
         * }*/
        public ActionResult Index()
        {
            //Server.GetType();
            PricesController pc = new PricesController(Server);

            return((ActionResult)pc.Index(Request)["view"]);
        }
Exemplo n.º 8
0
        public void HistoricalSystemPriceTest()
        {
            var x = new PricesController();

            //var z = x.SpotMarketCurvesObject(null, 1);
            //x.HistoricalSystemPrice(true, null);
            AppData.ExcelToJson();
        }
 public PricesControllerTests()
 {
     this.mapperMock   = new Mock <IMapper>();
     this.mediatorMock = new Mock <IMediator>();
     this.sut          = new PricesController(
         this.mapperMock.Object,
         this.mediatorMock.Object);
 }
        public void FetchPricesBySource_ShouldReturn_Price()
        {
            _priceItemRepository
            .Setup(x => x.SavePriceItem(DataServices.PriceItemHistoryMockData.getPriceItem()))
            .Returns(Task.FromResult(DataServices.PriceItemHistoryMockData.getPriceItem()));
            var controllerInit = new PricesController(_priceService.Object, _priceItemRepository.Object);
            var response       = controllerInit.FetchPricesBySource(DataServices.SourcesMockData.getSource());

            Assert.True(response != null);
        }
Exemplo n.º 11
0
        public void TestPostDeletePriceNotExsist()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            // ACt
            var result = controller.Delete(100) as HttpNotFoundResult;

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
Exemplo n.º 12
0
        public void TestGetAdd()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            // ACt
            var result = (ViewResult)controller.Add();

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 13
0
        public void TestPostDeleteConfirmed()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            // ACt
            var result = (RedirectToRouteResult)controller.DeleteConfirmed(1);

            // Assert
            Assert.AreEqual("", result.RouteName);
            Assert.AreEqual("Index", result.RouteValues.Values.First());
        }
Exemplo n.º 14
0
        public ActionResult Index(tblquote c)
        {
            /*try {
             *  pc.SaveFiles(Request, null, ConstCRM.PATHQUOTE);
             * } catch (Exception e) {
             *
             * }*/

            PricesController pc = new PricesController(Server);

            return((ActionResult)pc.IndexPost(Request, c)["view"]);
            //return null;
        }
Exemplo n.º 15
0
        public void TestPostEditDBError()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var OnePrice   = new Price {
                PriceID = 0, TicketPrice = 0.0f
            };

            // ACt
            var result = (ViewResult)controller.Edit(OnePrice);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 16
0
        public void TestPostEditValidationError()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            controller.ViewData.ModelState.AddModelError("PriceID", "Price ID should string!");
            var OnePrice = new Price();

            // ACt
            var result = (ViewResult)controller.Edit(OnePrice);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 17
0
        public void TestPostEdit()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var OnePrice   = new Price {
                PriceID = 6, RouteID = 2, PassengerType = "Child", TicketPrice = 75
            };

            // ACt
            var result = (RedirectToRouteResult)controller.Edit(OnePrice);

            // Assert
            Assert.AreEqual("", result.RouteName);
            Assert.AreEqual("Index", result.RouteValues.Values.First());
        }
Exemplo n.º 18
0
        public void TestPostAdd()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var NewPrice   = new Price {
                PriceID = 7, RouteID = 3, PassengerType = "Adult", TicketPrice = 200
            };

            // ACt
            var result = (RedirectToRouteResult)controller.Add(NewPrice);

            // Assert
            Assert.AreEqual("", result.RouteName);
            Assert.AreEqual("Index", result.RouteValues.Values.First());
        }
Exemplo n.º 19
0
        public PricesControllerTest()
        {
            _persistence = new PricesMemoryPersistence();
            _persistence.Configure(new ConfigParams());

            _controller = new PricesController();

            var references = References.FromTuples(
                new Descriptor("prices", "persistence", "memory", "*", "1.0"), _persistence,
                new Descriptor("prices", "controller", "default", "*", "1.0"), _controller
                );

            _controller.SetReferences(references);

            _persistence.OpenAsync(null).Wait();
        }
Exemplo n.º 20
0
        public PricesControllerTests()
        {
            MockOrderService = new Mock <IOrderService>();

            TestItems = new List <TestItemModel>();
            for (int i = 0; i < 5; i++)
            {
                TestItems.Add(CreateValidEntities.TestItemModel(i + 1));
            }
            TestItems[1].Public = false;

            MockOrderService.Setup(a => a.PopulateTestItemModel(It.IsAny <bool>())).ReturnsAsync(TestItems);

            //The controller
            Controller = new PricesController(MockOrderService.Object); //Don't need identity of view bag stuff
        }
Exemplo n.º 21
0
        public void GetBusyDays()
        {
            // Arrange
            List <SecurityDaily> dataFromQuandl = new List <SecurityDaily>()
            {
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-04", Open = (Decimal)762.2, High = (Decimal)762.2, Low = (Decimal)747.54, Close = (Decimal)759.44, Volume = (Decimal)3369068.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-05", Open = (Decimal)764.1, High = (Decimal)769.2, Low = (Decimal)755.65, Close = (Decimal)761.53, Volume = (Decimal)2260795.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-06", Open = (Decimal)745.3, High = (Decimal)749.7, Low = (Decimal)745.0, Close = (Decimal)751.44, Volume = (Decimal)2561354.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-07", Open = (Decimal)755.7, High = (Decimal)758.8, Low = (Decimal)749.0, Close = (Decimal)757.21, Volume = (Decimal)2865324.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-08", Open = (Decimal)760.4, High = (Decimal)762.5, Low = (Decimal)751.0, Close = (Decimal)759.38, Volume = (Decimal)2410301.0
                  } }
            };

            String ticker = "GOOGL";
            String start  = "2016-01-05";
            String end    = "2016-01-23";

            // Average Volume is close to 1 of 5 mock days volumes, so we should collect only 4 days
            Decimal averageVolume  = 2154683.35m;
            String  startMonth     = "2016-01-01";
            String  startNextMonth = "2016-02-01";

            // Act
            _mockQuandlConsumer.Setup(x => x.GetDailyPrices(ticker, startMonth, startNextMonth))
            .Returns(Task.FromResult(dataFromQuandl));

            var controller = new PricesController(_mockQuandlConsumer.Object);
            var result     = controller.GetBusyDays(ticker, start, end, averageVolume);

            // Assert
            _mockQuandlConsumer.Verify(x => x.GetDailyPrices(ticker, startMonth, startNextMonth), Times.Once());
            var okResult     = result.Should().BeOfType <OkObjectResult>().Subject;
            var busyDaysList = okResult.Value.Should().BeAssignableTo <List <PricesController.DailyVolume> >().Subject;

            busyDaysList.Count().Should().Be(4);
            busyDaysList.First().As <PricesController.DailyVolume>()._date.Should().Be("2016-01-04");
            busyDaysList.First().As <PricesController.DailyVolume>()._volume.Should().Be(3369068.0m);
        }
Exemplo n.º 22
0
        public void TestGetDetails()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));
            var OnePrice   = new Price {
                PriceID = 6, RouteID = 2, PassengerType = "Child", TicketPrice = 75
            };
            var PriceID = 6;

            // ACt
            var result      = (ViewResult)controller.Details(PriceID);
            var resultPrice = (Price)result.Model;

            // Assert
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(OnePrice.PriceID, resultPrice.PriceID);
            Assert.AreEqual(OnePrice.RouteID, resultPrice.RouteID);
            Assert.AreEqual(OnePrice.PassengerType, resultPrice.PassengerType);
            Assert.AreEqual(OnePrice.TicketPrice, resultPrice.TicketPrice);
        }
        public PricesHttpServiceV1Test()
        {
            _persistence = new PricesMemoryPersistence();
            _controller  = new PricesController();
            _service     = new PricesHttpServiceV1();

            IReferences references = References.FromTuples(
                new Descriptor("prices", "persistence", "memory", "default", "1.0"), _persistence,
                new Descriptor("prices", "controller", "default", "default", "1.0"), _controller,
                new Descriptor("prices", "service", "http", "default", "1.0"), _service
                );

            _controller.SetReferences(references);

            _service.Configure(HttpConfig);
            _service.SetReferences(references);

            Task.Run(() => _service.OpenAsync(null));
            Thread.Sleep(1000);
        }
        public PricesDirectClientV1Test()
        {
            _persistence = new PricesMemoryPersistence();
            _controller  = new PricesController();
            _client      = new PricesDirectClientV1();

            IReferences references = References.FromTuples(
                new Descriptor("prices", "persistence", "memory", "default", "1.0"), _persistence,
                new Descriptor("prices", "controller", "default", "default", "1.0"), _controller,
                new Descriptor("prices", "client", "direct", "default", "1.0"), _client
                );

            _controller.SetReferences(references);

            _client.SetReferences(references);

            _fixture = new PricesClientV1Fixture(_client);

            _client.OpenAsync(null).Wait();
        }
Exemplo n.º 25
0
        public void TestGetIndex()
        {
            // Arrange
            var controller = new PricesController(new PriceLogic(new PriceRepositoryStub()), new RouteLogic(new RouteRepositoryStub()));

            var PriceList = new List <Price>
            {
                new Price {
                    PriceID = 1, RouteID = 1, PassengerType = "Adult", TicketPrice = 50
                },
                new Price {
                    PriceID = 2, RouteID = 1, PassengerType = "Student", TicketPrice = 30
                },
                new Price {
                    PriceID = 3, RouteID = 1, PassengerType = "Child", TicketPrice = 15
                },
                new Price {
                    PriceID = 4, RouteID = 2, PassengerType = "Adult", TicketPrice = 300
                },
                new Price {
                    PriceID = 5, RouteID = 2, PassengerType = "Student", TicketPrice = 150
                },
                new Price {
                    PriceID = 6, RouteID = 2, PassengerType = "Child", TicketPrice = 75
                }
            };

            // ACt
            var result     = (ViewResult)controller.Index();
            var resultList = (List <Price>)result.Model;

            // Assert
            Assert.AreEqual("", result.ViewName);
            for (int i = 0; i < resultList.Count(); i++)
            {
                Assert.AreEqual(PriceList[i].PriceID, resultList[i].PriceID);
                Assert.AreEqual(PriceList[i].PassengerType, resultList[i].PassengerType);
                Assert.AreEqual(PriceList[i].RouteID, resultList[i].RouteID);
                Assert.AreEqual(PriceList[i].TicketPrice, resultList[i].TicketPrice);
            }
        }
Exemplo n.º 26
0
        public void GetPrices_MonthlyAverage()
        {
            // Arrange
            List <SecurityDaily> dataFromQuandl = new List <SecurityDaily>()
            {
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-04", Open = (Decimal)762.2, High = (Decimal)762.2, Low = (Decimal)747.54, Close = (Decimal)759.44, Volume = (Decimal)3369068.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-05", Open = (Decimal)764.1, High = (Decimal)769.2, Low = (Decimal)755.65, Close = (Decimal)761.53, Volume = (Decimal)2260795.0
                  } },
                { new SecurityDaily {
                      Ticker = "GOOGL", Date = "2016-01-06", Open = (Decimal)750.37, High = (Decimal)765.73, Low = (Decimal)748.0, Close = (Decimal)759.33, Volume = (Decimal)2410301.0
                  } }
            };

            String ticker = "GOOGL";
            // Quandl should be called only once: for 2016-01
            String start = "2016-01-05";
            String end   = "2016-01-23";

            String startMonth     = "2016-01-01";
            String startNextMonth = "2016-02-01";

            // Act
            _mockQuandlConsumer.Setup(x => x.GetDailyPrices(ticker, startMonth, startNextMonth))
            .Returns(Task.FromResult(dataFromQuandl));

            var controller = new PricesController(_mockQuandlConsumer.Object);
            var result     = controller.GetPrices(ticker, start, end);

            // Assert
            _mockQuandlConsumer.Verify(x => x.GetDailyPrices(ticker, startMonth, startNextMonth), Times.Once());
            var okResult        = result.Should().BeOfType <OkObjectResult>().Subject;
            var securitySummary = okResult.Value.Should().BeAssignableTo <PricesController.SecuritySummary>().Subject;

            securitySummary._monthlyAverages.Count().Should().Be(1);
            securitySummary._monthlyAverages.First().As <PricesController.MonthlyAverage>()._month.Should().Be("2016-01");
            securitySummary._monthlyAverages.First().As <PricesController.MonthlyAverage>()._open.Should().Be((Decimal)758.89);
            securitySummary._monthlyAverages.First().As <PricesController.MonthlyAverage>()._close.Should().Be((Decimal)760.1);
        }
Exemplo n.º 27
0
 public PricesControllerTests()
 {
     _coinRepository  = new Mock <ICoinRepository>();
     _priceRepository = new Mock <IPriceRepository>();
     _controller      = new PricesController(_coinRepository.Object, _priceRepository.Object);
 }
Exemplo n.º 28
0
 public PricesControllerTests()
 {
     _pricesController = new PricesController(_mediator.Object);
 }