public void AddCommands_ShouldAddCommandsToEndOfCommandsCollection()
        {
            // Arrange
            IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
            var             walletManager  = new WalletManager(bitcoinLibrary);

            walletManager.AddCommands(Args);
            var newCommand = new List <string>
            {
                "show-balances",
                "wallet-file=test2.json",
                "send", "btc=1.00", "address=mq6fK8fkFyCy9p53m4GG4fiE2XCKvcwgi4", "wallet-file=test2.json",
            };

            var expectedCommands = new List <string>();

            expectedCommands.AddRange(Args);
            expectedCommands.AddRange(newCommand);

            // Act
            walletManager.AddCommands(newCommand.ToArray());
            var actualWalletManagerCommands = walletManager.Commands;

            // Assert
            actualWalletManagerCommands.Should().BeEquivalentTo(expectedCommands);
        }
        public void ProcessNextCommand_ShouldRemoveTheProcessedCommandFromCollectionOnceComplete()
        {
            // Arrange
            string[] commandsAndArgs =
            {
                "generate-wallet", "wallet-file=BitcoinWallet.json",
                "recover-wallet",  "wallet-file=test1.json",
                "show-balances",   "wallet-file=test1.json",
                "send",            "btc=0.0001",                    "address=mq6fK8fkFyCy9p53m4Gf4fiX2XCHvcwgi1","wallet-file=test1.json",
            };

            IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
            var             walletManager  = new WalletManager(bitcoinLibrary);

            walletManager.AddCommands(commandsAndArgs);

            var currentCommandCount = walletManager.Commands.Count;

            // Act
            walletManager.ProcessNextCommand();

            // Assert
            walletManager.Commands.Count.Should().NotBe(currentCommandCount);
            walletManager.Commands.Count.Should().Be(currentCommandCount - 2);
        }
        public void AddCommands_ShouldThrowExceptionForArgumentsWithNullValues()
        {
            // Arrange
            // Act
            try
            {
                var commands = new[]
                {
                    "show-balances",
                    null,
                };

                IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
                var             walletManager  = new WalletManager(bitcoinLibrary);
                walletManager.AddCommands(commands);

                // Should not get here - Force a fail if we do
                walletManager.Should().BeNull();
            }
            catch (CommandArgumentNullOrEmptyException ex)
            {
                ex.Message.Should().Contain("Received null Argument.");
            }
            catch (Exception ex)
            {
                // Should not get here
                ex.Should().BeNull();
            }
        }
        public void AddCommands_ShouldThrowExceptionForEmptyArgumentCollection()
        {
            // Arrange
            // Act
            try
            {
                var commands = new List <string>();

                IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
                var             walletManager  = new WalletManager(bitcoinLibrary);
                walletManager.AddCommands(commands.ToArray());

                // Should not get here - Force a fail if we do
                walletManager.Should().BeNull();
            }
            catch (CommandArgumentNullOrEmptyException ex)
            {
                ex.Message.Should().Contain("Argument collection is empty.");
            }
            catch (Exception ex)
            {
                // Should not get here
                ex.Should().BeNull();
            }
        }
        public void AddCommands_ShouldAddCommandsAsDefined()
        {
            // Arrange
            IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
            var             walletManager  = new WalletManager(bitcoinLibrary);

            // Act
            walletManager.AddCommands(Args);

            // Assert
            walletManager.Commands.Should().BeEquivalentTo(Args);
        }
        public void WalletManager_ShouldEnsureConfigurationLoadOnInstantiation()
        {
            // Arrange
            // Act
            IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
            var             walletManager  = new WalletManager(bitcoinLibrary);

            walletManager.AddCommands(Args);

            // Assert
            Configuration.DefaultWalletFileName.Should().NotBeNull();
            Configuration.DefaultNetwork.Should().NotBeNull();
            Configuration.DefaultConnectionType.Should().NotBeNull();
        }
        public void ProcessNextCommand_ShouldReturnTheMnemonicForProcessingGenerateNewWalletCommand()
        {
            // Arrange
            string[] commandsAndArgs =
            {
                "generate-wallet", "wallet-file=BitcoinWallet.json",
                "recover-wallet",  "wallet-file=test1.json",
                "show-balances",   "wallet-file=test1.json",
                "send",            "btc=0.0001",                    "address=mq6fK8fkFyCy9p53m4Gf4fiX2XCHvcwgi1","wallet-file=test1.json",
            };

            IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
            var             walletManager  = new WalletManager(bitcoinLibrary);

            walletManager.AddCommands(commandsAndArgs);

            // Act
            var result = walletManager.ProcessNextCommand();

            // Assert
            result.Should().NotBeNullOrEmpty();
        }
        public void AddCommands_ShouldThrowExceptionForNullArguments()
        {
            // Arrange
            // Act
            try
            {
                IBitcoinLibrary bitcoinLibrary = new BitcoinLibrary();
                var             walletManager  = new WalletManager(bitcoinLibrary);
                walletManager.AddCommands(null);

                // Should not get here - Force a fail if we do
                walletManager.Should().BeNull();
            }
            catch (CommandArgumentNullOrEmptyException ex)
            {
                ex.Message.Should().Contain("Argument contains null or empty values.");
            }
            catch (Exception ex)
            {
                // Should not get here
                ex.Should().BeNull();
            }
        }