private void TestEvent3() { var pb = new PigBank(); var bl = new BalanceLogger(); var bw = new BalanceWatcher(300m); string word; pb.BalanceChanged += bl.BalanceLog; pb.BalanceChanged += bw.BalanceWatch; do { Console.WriteLine("Inform your amount: "); word = Console.ReadLine(); if (word == "exit") { return; } if (decimal.TryParse(word, out decimal amount)) { pb.ChangeBalance(amount); } else { Console.WriteLine("Not a valid amount!!"); } } while (true); }
public BalanceWatcherTests() { this.handler = new Mock <IBalanceWatcherHandler <object, int> >(); this.blocks = new Mock <IBlocksStorage>(); this.subject = new BalanceWatcher <object, int>(this.handler.Object, this.blocks.Object); }
public TokenReceivingWatcher( PropertyId property, ILogger <TokenReceivingWatcher> logger, IBlocksStorage blocks, IReceivingAddressPool addressPool, ITransactionRetriever exodusRetriever, IRuleRepository rules, IWatchRepository watches, ICallbackRepository callbacks, ICallbackExecuter callbackExecutor, ITimerScheduler timerScheduler) { if (property == null) { throw new ArgumentNullException(nameof(property)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (addressPool == null) { throw new ArgumentNullException(nameof(addressPool)); } if (exodusRetriever == null) { throw new ArgumentNullException(nameof(exodusRetriever)); } if (rules == null) { throw new ArgumentNullException(nameof(rules)); } if (watches == null) { throw new ArgumentNullException(nameof(watches)); } if (callbacks == null) { throw new ArgumentNullException(nameof(callbacks)); } if (callbackExecutor == null) { throw new ArgumentNullException(nameof(callbackExecutor)); } if (timerScheduler == null) { throw new ArgumentNullException(nameof(timerScheduler)); } this.property = property; this.logger = logger; this.addressPool = addressPool; this.exodusRetriever = exodusRetriever; this.rules = rules; this.watches = watches; this.callbacks = callbacks; this.callbackExecutor = callbackExecutor; this.timerScheduler = timerScheduler; this.watchings = new Dictionary <BitcoinAddress, Watching>(); this.engine = new BalanceWatcher <Rule, PropertyAmount>(this, blocks); this.semaphore = new SemaphoreSlim(1, 1); this.stopped = true; }