public void CreateWalletSuccessfullyReturnsMnemonic()
        {
            Mnemonic mnemonic         = new Mnemonic(Wordlist.English, WordCount.Twelve);
            var      mockWalletCreate = new Mock <IWalletManager>();

            mockWalletCreate.Setup(wallet => wallet.CreateWallet(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(mnemonic);

            string dir        = AssureEmptyDir("TestData/ControllersTests/CreateWalletSuccessfullyReturnsMnemonic");
            var    dataFolder = new DataFolder(new NodeSettings {
                DataDir = dir
            });

            var controller = new WalletController(mockWalletCreate.Object, new Mock <IWalletSyncManager>().Object, It.IsAny <ConnectionManager>(), Network.Main, new Mock <ConcurrentChain>().Object, dataFolder);

            // Act
            var result = controller.Create(new WalletCreationRequest
            {
                Name       = "myName",
                FolderPath = "",
                Password   = "",
                Network    = ""
            });

            // Assert
            mockWalletCreate.VerifyAll();
            var viewResult = Assert.IsType <JsonResult>(result);

            Assert.Equal(mnemonic.ToString(), viewResult.Value);
            Assert.NotNull(result);
        }
Example #2
0
        public void CreateWalletSuccessfullyReturnsMnemonic()
        {
            Mnemonic mnemonic         = new Mnemonic(Wordlist.English, WordCount.Twelve);
            var      mockWalletCreate = new Mock <IWalletManager>();

            mockWalletCreate.Setup(wallet => wallet.CreateWallet(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null)).Returns(mnemonic);

            var controller = new WalletController(mockWalletCreate.Object, new Mock <ITracker>().Object);

            // Act
            var result = controller.Create(new WalletCreationRequest
            {
                Name       = "myName",
                FolderPath = "",
                Password   = "",
                Network    = ""
            });

            // Assert
            mockWalletCreate.VerifyAll();
            var viewResult = Assert.IsType <JsonResult>(result);

            Assert.Equal(mnemonic.ToString(), viewResult.Value);
            Assert.NotNull(result);
        }
Example #3
0
        public async Task CreateShouldCallCreateWalletInBlOnce()
        {
            //Arrange
            WalletViewModel walletVM = new WalletViewModel
            {
                PersonId    = 1,
                Description = "Description",
                Balance     = 100
            };
            var mockPerson = new Mock <IPersonWebService>();
            var mockWallet = new Mock <IWalletWebService>();
            var controller = new WalletController(mockWallet.Object, mockPerson.Object);

            mockWallet.Setup(x => x.Create(It.IsAny <WalletViewModel>())).ReturnsAsync(It.IsAny <WalletViewModel>());

            //Act
            await controller.Create(walletVM);

            //Assert
            mockWallet.Verify(x => x.Create(It.IsAny <WalletViewModel>()), Times.Once);
        }
Example #4
0
        public void CreateWalletSuccessfullyReturnsMnemonic()
        {
            var mockWalletCreate = new Mock <IWalletWrapper>();

            mockWalletCreate.Setup(wallet => wallet.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns("mnemonic");

            var controller = new WalletController(mockWalletCreate.Object);

            // Act
            var result = controller.Create(new WalletCreationRequest
            {
                Name       = "myName",
                FolderPath = "",
                Password   = "",
                Network    = ""
            });

            // Assert
            mockWalletCreate.VerifyAll();
            var viewResult = Assert.IsType <JsonResult>(result);

            Assert.Equal("mnemonic", viewResult.Value);
            Assert.NotNull(result);
        }