Exemplo n.º 1
0
        public void Start(IExchange exchange, ExchangeWorkerConfiguration configuration) => Task.Run(async() =>
        {
            var limit = 1000;

            Exchange = exchange;

            Configuration = configuration;

            Logger = LoggerFactory.CreateLogger($"Historian.{exchange.Name}.Worker");

            using (Logger.BeginExchangeScope(exchange.Name))
            {
                await Ping(true);

                Heartbeat();
            }

            TradeWorker.Start(this, limit);
            TradeAggregateWorker.Start(this, limit);

            if (Exchange.SupportedStatKeys != null)
            {
                TradeStatWorker.Start(this);
                TradeStatAggregateWorker.Start(this, limit);
            }
        });
        public void GetTradesMethodCallCheck_Success()
        {
            var adapterMock      = new Mock <ITradingService>();
            var periodWorkerMock = new Mock <IPeriodWorker>();

            var tradeWorker = new TradeWorker(adapterMock.Object, periodWorkerMock.Object);

            tradeWorker.GetPowerPeriodsSummary(It.IsAny <DateTime>());

            adapterMock.Verify(m => m.GetTrades(It.IsAny <DateTime>()), Times.Once);
        }
Exemplo n.º 3
0
        private TradeOffer AddTradeOffer(Ship creator)
        {
            ClientTrade TradeStub = new ClientTrade();

            TradeStub.Offered.Add(new GoodsTransfer(1, 5));        //building material
            TradeStub.Offered.Add(new GoodsTransfer(2, 10));       //food
            TradeStub.Requested.Add(new GoodsTransfer(10, 12));    //metal
            TradeStub.SenderId   = creator.id;
            TradeStub.SenderType = 0;

            return(TradeWorker.createTrade(TradeStub, creator.userid));
        }
Exemplo n.º 4
0
        public void TestDeleteTrade()
        {
            //Assert.IsTrue(instance.tradeOffer.Count == 0);
            int count = instance.tradeOffer.Count;

            var NewTrade = this.CreateTradersAndTrade();

            Assert.IsTrue(instance.tradeOffer.Count == count + 1);
            Assert.IsNotNull(NewTrade);

            var Ship = NewTrade.TradingShip;

            TradeWorker.DeleteTrade(NewTrade.tradeOfferId, NewTrade.userId);
            Assert.IsTrue(instance.tradeOffer.Count == count);
            Assert.IsTrue(Ship.TradeOffers.Count == 0);
        }