Ejemplo n.º 1
0
        public void TestSameHasTradeID()
        {
            //Arrange
            MockDataStore mockDataStore = new MockDataStore();
            List <Trade>  trades        = mockDataStore.GetMockedDoublicatedTradeIdList();

            //Act
            TradeLogicHelper tradeLogic       = new TradeLogicHelper();
            bool             doesntHaveSameId = tradeLogic.CheckNotSameTradeId(trades);

            //Assert
            Assert.IsTrue(!doesntHaveSameId);
        }
Ejemplo n.º 2
0
        public void TestGoodTradeList()
        {
            //Arrange
            MockDataStore mockDataStore = new MockDataStore();
            List <Trade>  trades        = mockDataStore.GetMockedGoodTradeList();

            //Act
            TradeLogicHelper   tradeLogic   = new TradeLogicHelper();
            List <TradeResult> actualResult = tradeLogic.CalculateResult(trades);

            //Assert
            List <TradeResult> expectedResult = mockDataStore.GetMockedGoodTradeResult();

            Assert.IsTrue(mockDataStore.TradeResultsAreEqual(expectedResult, actualResult));
        }
Ejemplo n.º 3
0
        public void TestHasBadData()
        {
            //Arrange
            MockDataStore mockDataStore = new MockDataStore();
            List <Trade>  trades        = mockDataStore.GetMockedWrongLimitTradeIdList();

            //Act
            TradeLogicHelper          tradeLogic    = new TradeLogicHelper();
            List <TradingGroupStatus> groupStatuses = tradeLogic.CheckGroupsError(trades);

            //Assert
            bool ErrorFound = false;

            foreach (var item in groupStatuses)
            {
                if (!item.HasNoErrors)
                {
                    ErrorFound = true;
                }
            }
            Assert.IsTrue(ErrorFound);
        }
        private void CalculateTradesResult()
        {
            TradeLogicHelper tlhlp = new TradeLogicHelper();

            //check if there is more than one item with same trade id
            if (tlhlp.CheckNotSameTradeId(TradesList))
            {
                //here to check if there are any problems discovered after grouping
                //ex: some of the groups doesn't all have the same limits
                //ex: some of the groups doesn't all have the same number of trades....
                List <TradingGroupStatus> tgStatuses = tlhlp.CheckGroupsError(TradesList);
                bool errorsFound = false;
                foreach (var item in tgStatuses)
                {
                    if (!item.HasNoErrors)
                    {
                        logger.LogError(item.ErrorMessage);
                        errorsFound = true;
                    }
                }
                if (!errorsFound)
                {
                    TradesResult = tlhlp.CalculateResult(TradesList);
                    logger.LogInfoMessage($"Calculation Done. No errors found.");
                    CalcGridVisible = true;
                }
                else
                {
                    ErrorMsg = "The data is not good. Check server.log for detailed info.";
                }
            }
            else
            {
                ErrorMsg = "Two items has the same TradeId.";
                logger.LogError($"Two items has the same TradeId. remove one of them.");
            }
        }