Esempio n. 1
0
        public async Task Constructor_initializes_page_title_correctly()
        {
            var web3Service = new Web3Service();
            await web3Service.TrySetAccountPrivateKey(privateKey);

            var model = new WalletRootViewModel(web3Service);

            Assert.True(!string.IsNullOrEmpty(model.RootNavigationBarTitle) &&
                        model.RootNavigationBarTitle.Length > 0);
        }
Esempio n. 2
0
        public async Task InitializeAsync_working_correctly()
        {
            App.Settings.Endpoint = Endpoint.Mainnet;
            var web3Service = new Web3Service();
            await web3Service.TrySetAccountPrivateKey(privateKey);

            var model = new WalletInfoViewModel(web3Service, new NetworkService(), new Mock <INavigationService>().Object);

            await model.InitializeAsync(null);

            Assert.True(model.Tokens.Count == 0);
        }
Esempio n. 3
0
        public async Task RefreshPressed_executing_correctly()
        {
            App.Settings.Endpoint = Endpoint.Mainnet;
            var web3Service = new Web3Service();
            await web3Service.TrySetAccountPrivateKey(privateKey);

            var model = new WalletInfoViewModel(web3Service, new NetworkService(), new Mock <INavigationService>().Object);

            model.RefreshPressed.Execute(null);
            await Task.Delay(TimeSpan.FromSeconds(0.5));

            Assert.True(model.Tokens.Count == 0);
        }
Esempio n. 4
0
        private async Task <bool> TrySetPrivateKey(string privateKey)
        {
            if (string.IsNullOrEmpty(privateKey))
            {
                return(false);
            }

            if (privateKey.Length < 64)
            {
                return(false);
            }
            else if (privateKey.Length == 64)
            {
                var result = await _web3Service.TrySetAccountPrivateKey(privateKey);

                return(result);
            }

            return(false);
        }