public void ViewOpenOrders_Shows_All_Open_Orders()
        {
            //Because the database is already in memory, it just calls this directly. Normally would use an in memory database to mock out the real one.
            var fillOrderRepo    = new FillOrderRepo();
            var fillOrderService = new FillOrderService(fillOrderRepo);

            fillOrderService.CreateFillOrder();
            fillOrderService.CreateFillOrder();
            fillOrderService.CreateFillOrder();
            fillOrderService.CreateFillOrder();
            Assert.True(fillOrderService.ViewOpenOrders().Count == 4);
        }
        public void CreateFillOrder_Create_New_Fill_Order_2()
        {
            //Because it is in memory as it is and I do not have a mocked DB, I wanted to also show the tests would catch if it generated a fill order
            var fillOrderRepo    = new FillOrderRepo();
            var fillOrderService = new FillOrderService(fillOrderRepo);
            var newOrder         = fillOrderService.CreateFillOrder();

            Assert.IsType <DateTime>(newOrder.OrderCreated);
            Assert.False(newOrder.OrderClosed);
            Assert.NotNull(newOrder.Id);
        }
Пример #3
0
 public IActionResult CreateFillOrder([FromBody] FillOrder createdFillOrder)
 {
     try
     {
         return(Created("", _fillOrderService.CreateFillOrder(createdFillOrder)));
     }
     catch (Exception exception)
     {
         return(NotFound(exception.Message));
     }
 }
        public void CreateFillOrder_Create_New_Fill_Order()
        {
            //Because I did not mock the database fully, this returns an empty object.
            //wanted to show I can mock out things however.
            var fillOrderRepo = new Mock <IFillOrderRepo>();

            fillOrderRepo.Setup(f => f.CreateFillOrder()).Returns(new FillOrder());
            var fillOrderService = new FillOrderService(fillOrderRepo.Object);
            var newOrder         = fillOrderService.CreateFillOrder();

            Assert.IsType <DateTime>(newOrder.OrderCreated);
            Assert.False(newOrder.OrderClosed);
        }
Пример #5
0
 //GET: FillOrders/Create
 public IActionResult Create()
 {
     return(View(_service.CreateFillOrder()));
 }
 public IActionResult CreateFillOrder([FromBody] FillOrder fillOrder)
 {
     _fillOrderService.CreateFillOrder(fillOrder);
     return(Ok());
 }