Example #1
0
        public HoardExchangeFixture()
        {
            base.Initialize(HoardGameTestName);

            Users = GetUsers();

            RunExchangeServer();

            BCExchangeService = new BCExchangeService(HoardService);
            BCExchangeService.Init().Wait();

            HoardExchangeService = new HoardExchangeService(HoardService);
            HoardExchangeService.Init().Wait();

            try
            {
                GameIDs = HoardService.GetAllHoardGames().Result;
                foreach (var game in GameIDs)
                {
                    HoardService.RegisterHoardGame(game);
                }
            }
            catch (Exception)
            {
                Assert.True(false);
            }

            Items = GetGameItems(Users[0]).Result;
            Assert.Equal(3, Items.Count);
            Assert.True(Items[0].Metadata is ERC223GameItemContract.Metadata);
            Assert.True(Items[1].Metadata is ERC223GameItemContract.Metadata);
            Assert.True(Items[2].Metadata is ERC721GameItemContract.Metadata);
        }
        public HoardExchangeTests(HoardExchangeFixture _hoardExchange)
        {
            HoardExchangeFixture = _hoardExchange;
            HoardService         = _hoardExchange.HoardService;

            BCExchangeService    = _hoardExchange.BCExchangeService;
            HoardExchangeService = _hoardExchange.HoardExchangeService;

            gameIDs = _hoardExchange.GameIDs;
            users   = _hoardExchange.Users;
            items   = _hoardExchange.Items;
        }
Example #3
0
        /// <summary>
        /// Connects to BC and fills missing options.
        /// </summary>
        /// <param name="options">Hoard service options.</param>
        /// <returns></returns>
        public async Task Initialize(HoardServiceOptions options)
        {
            Options = options;

            //access point to block chain - a must have
            BCComm = BCCommFactory.Create(Options);
            string result = await BCComm.Connect();

            ErrorCallbackProvider.ReportInfo(result);

            //our default GameItemProvider
            if (Options.Game != GameID.kInvalidID)
            {
                await RegisterHoardGame(Options.Game);
            }

            DefaultGame = Options.Game;

            //init exchange service
            IExchangeService exchange = new HoardExchangeService(this);
            await exchange.Init();

            ExchangeService = exchange;
        }