public FederationWalletControllerTests() { this.loggerFactory = Substitute.For <ILoggerFactory>(); this.walletManager = Substitute.For <IFederationWalletManager>(); this.walletSyncManager = Substitute.For <IFederationWalletSyncManager>(); this.connectionManager = Substitute.For <IConnectionManager>(); this.network = new StratisTest(); this.chainIndexer = new ChainIndexer(this.network); ChainedHeader tip = ChainedHeadersHelper.CreateConsecutiveHeaders(100, ChainedHeadersHelper.CreateGenesisChainedHeader(this.network), true, null, this.network).Last(); this.chainIndexer.SetTip(tip); this.dateTimeProvider = Substitute.For <IDateTimeProvider>(); this.withdrawalHistoryProvider = Substitute.For <IWithdrawalHistoryProvider>(); this.controller = new FederationWalletController(this.loggerFactory, this.walletManager, this.walletSyncManager, this.connectionManager, this.network, this.chainIndexer, this.dateTimeProvider, this.withdrawalHistoryProvider); this.fedWallet = new FederationWallet(); this.fedWallet.Network = this.network; this.fedWallet.LastBlockSyncedHeight = 999; this.fedWallet.CreationTime = DateTimeOffset.Now; this.walletManager.GetWallet().Returns(this.fedWallet); }
public FederationWalletControllerTests() { this.loggerFactory = Substitute.For <ILoggerFactory>(); this.walletManager = Substitute.For <IFederationWalletManager>(); this.walletSyncManager = Substitute.For <IFederationWalletSyncManager>(); this.connectionManager = Substitute.For <IConnectionManager>(); this.network = new StraxTest(); this.chainIndexer = new ChainIndexer(this.network); ChainedHeader tip = ChainedHeadersHelper.CreateConsecutiveHeaders(100, ChainedHeadersHelper.CreateGenesisChainedHeader(this.network), true, null, this.network).Last(); this.chainIndexer.SetTip(tip); ICrossChainTransferStore crossChainTransferStore = Substitute.For <ICrossChainTransferStore>(); crossChainTransferStore.GetCompletedWithdrawals(5).ReturnsForAnyArgs(new List <WithdrawalModel>() { new WithdrawalModel() }); this.controller = new FederationWalletController(this.walletManager, this.walletSyncManager, this.connectionManager, this.network, this.chainIndexer, crossChainTransferStore); this.fedWallet = new FederationWallet { Network = this.network, LastBlockSyncedHeight = 999, CreationTime = DateTimeOffset.Now }; this.walletManager.GetWallet().Returns(this.fedWallet); var federationWalletManager = (FederationWalletManager)FormatterServices.GetUninitializedObject(typeof(FederationWalletManager)); PropertyInfo lockProp = typeof(LockProtected).GetProperty("lockObject", BindingFlags.NonPublic | BindingFlags.Instance); lockProp.SetValue(federationWalletManager, new object()); federationWalletManager.Wallet = this.fedWallet; this.walletManager.GetSpendableAmount().Returns((x) => { return(federationWalletManager.GetSpendableAmount()); }); }
public FederationWalletControllerTests() { this.loggerFactory = Substitute.For <ILoggerFactory>(); this.walletManager = Substitute.For <IFederationWalletManager>(); this.walletSyncManager = Substitute.For <IFederationWalletSyncManager>(); this.connectionManager = Substitute.For <IConnectionManager>(); this.network = new StratisTest(); this.chainIndexer = new ChainIndexer(this.network); ChainedHeader tip = ChainedHeadersHelper.CreateConsecutiveHeaders(100, ChainedHeadersHelper.CreateGenesisChainedHeader(this.network), true, null, this.network).Last(); this.chainIndexer.SetTip(tip); this.dateTimeProvider = Substitute.For <IDateTimeProvider>(); this.withdrawalHistoryProvider = Substitute.For <IWithdrawalHistoryProvider>(); this.controller = new FederationWalletController(this.loggerFactory, this.walletManager, this.walletSyncManager, this.connectionManager, this.network, this.chainIndexer, this.dateTimeProvider, this.withdrawalHistoryProvider); this.fedWallet = new FederationWallet(); this.fedWallet.Network = this.network; this.fedWallet.LastBlockSyncedHeight = 999; this.fedWallet.CreationTime = DateTimeOffset.Now; this.walletManager.GetWallet().Returns(this.fedWallet); var federationWalletManager = (FederationWalletManager)FormatterServices.GetUninitializedObject(typeof(FederationWalletManager)); PropertyInfo lockProp = typeof(LockProtected).GetProperty("lockObject", BindingFlags.NonPublic | BindingFlags.Instance); lockProp.SetValue(federationWalletManager, new object()); federationWalletManager.Wallet = this.fedWallet; this.walletManager.GetSpendableAmount().Returns((x) => { return(federationWalletManager.GetSpendableAmount()); }); }