Ejemplo n.º 1
0
        public void DeleteAccountCommand_MessageResultDialogNo_AccountIsDeleted()
        {
            // Arrange
            var dialogManagerMock = this.AutoMockContainer.GetMock <IDialogManager>();

            dialogManagerMock
            .Setup(x =>
                   x.ShowMessageDialog(
                       Strings.DeleteAddressConfirmationCaption,
                       Strings.DeleteAddressConfirmationMessage,
                       MessageDialogType.YesNo,
                       MessageDialogResult.No))
            .Returns(MessageDialogResult.No);

            var selectedAccount = new AccountItemBuilder()
                                  .StandardAccount()
                                  .WithHash("d3cce84d0800172d09c88ccad61130611bd047a4")
                                  .Build();

            var walletControllerMock = this.AutoMockContainer.GetMock <IWalletController>();

            var viewModel = this.AutoMockContainer.Create <AccountsViewModel>();
            var accountAddedMessageHandler = viewModel as IMessageHandler <AccountAddedMessage>;

            viewModel.SelectedAccount = selectedAccount;

            // Act
            accountAddedMessageHandler.HandleMessage(new AccountAddedMessage(selectedAccount));
            viewModel.DeleteAccountCommand.Execute(null);

            // Assert
            walletControllerMock.Verify(x => x.DeleteAccount(selectedAccount), Times.Never);
            walletControllerMock.Verify(x => x.DeleteAccount(selectedAccount), Times.Never);
            Assert.Single(viewModel.Accounts);
        }
Ejemplo n.º 2
0
        public void CopyAddressToClipboardCommand_TextSetInClipboardManager()
        {
            // Arrange
            var walletAddress = "walletAddress";

            var clipboardManagetMock = this.AutoMockContainer.GetMock <IClipboardManager>();

            var selectedAccount = new AccountItemBuilder()
                                  .StandardAccount()
                                  .WithHash("d3cce84d0800172d09c88ccad61130611bd047a4")
                                  .Build();

            var walletControllerMock = this.AutoMockContainer.GetMock <IWalletController>();

            walletControllerMock
            .Setup(x => x.ScriptHashToAddress(selectedAccount.ScriptHash))
            .Returns(walletAddress);

            var viewModel = this.AutoMockContainer.Create <AccountsViewModel>();

            viewModel.SelectedAccount = selectedAccount;

            // Act
            viewModel.CopyAddressToClipboardCommand.Execute(null);

            // Assert
            clipboardManagetMock.Verify(x => x.SetText(walletAddress));
        }
Ejemplo n.º 3
0
        public void ShowVotingDialogCommand_ShowVotingDialogIsNotEnabledwatchOnlyAccountNoBalance_ShowNothing()
        {
            // Arrange
            var dialogManagerMock = this.AutoMockContainer.GetMock <IDialogManager>();

            var selectedAccount = new AccountItemBuilder()
                                  .WatchOnlyAccount()
                                  .WithHash("d3cce84d0800172d09c88ccad61130611bd047a4")
                                  .Build();

            var viewModel = this.AutoMockContainer.Create <AccountsViewModel>();

            viewModel.SelectedAccount = selectedAccount;

            // Act
            viewModel.ShowVotingDialogCommand.Execute(null);

            // Assert
            dialogManagerMock.Verify(x => x.ShowDialog <VotingDialogResult, VotingLoadParameters>(It.Is <VotingLoadParameters>(p => p.ScriptHash == selectedAccount.ScriptHash)), Times.Never);
        }
Ejemplo n.º 4
0
        public void ViewContractCommand_ViewContractIsEnabled_ViewPrivateKeyIsNotEnabled_ShowViewContractDialog()
        {
            // Arrange
            var dialogManagerMock = this.AutoMockContainer.GetMock <IDialogManager>();

            var selectedAccount = new AccountItemBuilder()
                                  .StandardAccount()
                                  .WithHash("d3cce84d0800172d09c88ccad61130611bd047a4")
                                  .Build();

            var viewModel = this.AutoMockContainer.Create <AccountsViewModel>();

            viewModel.SelectedAccount = selectedAccount;

            // Act
            viewModel.ViewContractCommand.Execute(null);

            // Assert
            dialogManagerMock.Verify(x => x.ShowDialog <ViewContractDialogResult, ViewContractLoadParameters>(It.Is <ViewContractLoadParameters>(p => p.ScriptHash == selectedAccount.ScriptHash)));
        }
Ejemplo n.º 5
0
        public void ViewSelectedAccountDetailsCommand_MessageResultDialogNo_AccountIsDeleted()
        {
            // Arrange
            var walletAddress = "walletAddress";
            var urlFormat     = @"x:\test\{0}";
            var expectedUrl   = string.Format(urlFormat, walletAddress);

            var settingsManagerMock = this.AutoMockContainer.GetMock <ISettingsManager>();

            settingsManagerMock
            .SetupGet(x => x.AddressURLFormat)
            .Returns(urlFormat);

            var processManagerMock = this.AutoMockContainer.GetMock <IProcessManager>();

            var selectedAccount = new AccountItemBuilder()
                                  .StandardAccount()
                                  .WithHash("d3cce84d0800172d09c88ccad61130611bd047a4")
                                  .Build();

            var walletControllerMock = this.AutoMockContainer.GetMock <IWalletController>();

            walletControllerMock
            .Setup(x => x.ScriptHashToAddress(selectedAccount.ScriptHash))
            .Returns(walletAddress);

            var viewModel = this.AutoMockContainer.Create <AccountsViewModel>();

            viewModel.SelectedAccount = selectedAccount;

            // Act
            viewModel.ViewSelectedAccountDetailsCommand.Execute(null);

            // Assert
            processManagerMock.Verify(x => x.OpenInExternalBrowser(expectedUrl));
        }