Esempio n. 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);
        }
Esempio n. 2
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;
        }