Beispiel #1
0
        public void AddToQueueTest()
        {
            var order = new Order();

            bool sucessfullAdded = EntryQueue.AddToQueue(order);

            Assert.IsTrue(sucessfullAdded);
            Assert.IsTrue(EntryQueue.TransactionQueue.Contains(order));
        }
Beispiel #2
0
        public void AddToQueueTest_Duplicated()
        {
            var order = new Order();

            var sucessfullAdded = EntryQueue.AddToQueue(order);

            sucessfullAdded = EntryQueue.AddToQueue(order);

            Assert.IsFalse(sucessfullAdded);
            Assert.IsTrue(EntryQueue.TransactionQueue.Count == 1);
        }
Beispiel #3
0
        public void GetNextTransactionTest()
        {
            var order            = new Order();
            var orderTwo         = new Order();
            var sucessfullAdded1 = EntryQueue.AddToQueue(order);
            var sucessfullAdded2 = EntryQueue.AddToQueue(orderTwo);

            if (EntryQueue.TransactionQueue.Count == 0)
            {
                Assert.Fail("Something went wrong woth adding ordet to list");
            }

            var orderFromQueue = EntryQueue.GetNextTransaction();

            Assert.IsTrue(order.Id == orderFromQueue.Id);
            Assert.IsTrue(EntryQueue.TransactionQueue.Count == 1);
        }
Beispiel #4
0
        public async Task <bool> AcceptOrder(OrderForm orderForm)
        {
            try
            {
                Log.Information($"Received order {orderForm.Id}, from {orderForm.UserId}, operation : {orderForm.OrderType.ToString()}, {orderForm.Ticker}, {orderForm.Price}, {orderForm.Volumen}");

                var orderAccepted = false;

                var order = new Order
                {
                    Id         = new Guid(),
                    OrderForm  = orderForm,
                    ReceivedDT = DateTime.UtcNow,
                    Status     = OrderStatus.New,
                };

                var orderIsValid = await ValidateOrderForm(orderForm);

                if (orderIsValid)
                {
                    order.IsValid = orderIsValid;
                    orderAccepted = EntryQueue.AddToQueue(order);
                }
                else
                {
                    Log.Warning($"Order {orderForm.Id} is not valid");
                }

                await DB.AddOrderToDb(order);

                return(orderAccepted);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                throw;
            }
        }