public void ViewCertificateCommand_ShowCertificate() { // Arrange var expectedCertificatePath = @"X:\"; var selectedAssetItem = new FirstClassAssetItemBuilder() .WithCustomToken() .Build(); var processHelperMock = this.AutoMockContainer.GetMock <IProcessManager>(); var walletControllerMock = this.AutoMockContainer.GetMock <IWalletController>(); walletControllerMock .Setup(x => x.ViewCertificate(selectedAssetItem as FirstClassAssetItem)) .Returns(expectedCertificatePath); walletControllerMock .Setup(x => x.CanViewCertificate(selectedAssetItem as FirstClassAssetItem)) .Returns(true); var viewModel = this.AutoMockContainer.Create <AssetsViewModel>(); // Act viewModel.SelectedAsset = selectedAssetItem; viewModel.ViewCertificateCommand.Execute(null); // Assert processHelperMock.Verify(x => x.Run(expectedCertificatePath)); }
public void ViewSelectedAssetDetailsCommand_OpenBrowserWithAssetDetails() { // Arrange var expectedAssetURLFormat = @"https://www.xpto.com/{0}"; var tokenName = "1234"; var tokenId = UInt256.Parse("0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"); var selectedAssetItem = new FirstClassAssetItemBuilder() .WithAssetId(tokenId) .WithName(tokenName) .Build(); var processHelperMock = this.AutoMockContainer.GetMock <IProcessManager>(); var settingsManagerMock = this.AutoMockContainer.GetMock <ISettingsManager>(); settingsManagerMock .SetupGet(x => x.AssetURLFormat) .Returns(expectedAssetURLFormat); var viewModel = this.AutoMockContainer.Create <AssetsViewModel>(); // Act viewModel.SelectedAsset = selectedAssetItem; viewModel.ViewSelectedAssetDetailsCommand.Execute(null); // Assert processHelperMock.Verify(x => x.OpenInExternalBrowser(string.Format(expectedAssetURLFormat, tokenName.Substring(2)))); }
public void DeleteAssetCommand_ShowCertificate() { // Arrange var tokenId = UInt256.Parse("0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"); var selectedAssetItem = new FirstClassAssetItemBuilder() .WithAssetId(tokenId) .WithCustomToken() .Build(); var walletControllerMock = this.AutoMockContainer.GetMock <IWalletController>(); walletControllerMock .Setup(x => x.GetAvailable(tokenId)) .Returns(Fixed8.Zero); var dialogManagerMock = this.AutoMockContainer.GetMock <IDialogManager>(); dialogManagerMock .Setup(x => x.ShowMessageDialog(Strings.DeleteConfirmation, It.IsAny <string>(), MessageDialogType.YesNo, MessageDialogResult.No)) .Returns(MessageDialogResult.Yes); var viewModel = this.AutoMockContainer.Create <AssetsViewModel>(); // Act viewModel.SelectedAsset = selectedAssetItem; viewModel.DeleteAssetCommand.Execute(null); // Assert walletControllerMock.Verify(x => x.DeleteFirstClassAsset(selectedAssetItem as FirstClassAssetItem)); }
public void AssetAddedMessageReceived_AssetAdded() { // Arrange var expectedAssetItem = new FirstClassAssetItemBuilder().Build(); var viewModel = this.AutoMockContainer.Create <AssetsViewModel>(); var assetAddedMessageHandler = viewModel as IMessageHandler <AssetAddedMessage>; // Act assetAddedMessageHandler.HandleMessage(new AssetAddedMessage(expectedAssetItem)); // Assert Assert.True(viewModel.Assets.Count == 1); Assert.Same(expectedAssetItem, viewModel.Assets.Single()); }
public void ClearAssetsMessageReceived_AssetRemoved() { // Arrange var expectedAssetItem = new FirstClassAssetItemBuilder().Build(); var viewModel = this.AutoMockContainer.Create <AssetsViewModel>(); var assetAddedMessageHandler = viewModel as IMessageHandler <AssetAddedMessage>; var clearAssetsMessageHandler = viewModel as IMessageHandler <ClearAssetsMessage>; // Act assetAddedMessageHandler.HandleMessage(new AssetAddedMessage(expectedAssetItem)); clearAssetsMessageHandler.HandleMessage(new ClearAssetsMessage()); // Assert Assert.Empty(viewModel.Assets); }