public void RecoverWalletSuccessfullyReturnsWalletModel() { Bitcoin.Wallet.Wallet wallet = new Bitcoin.Wallet.Wallet { Name = "myWallet", Network = WalletHelpers.GetNetwork("mainnet") }; var mockWalletWrapper = new Mock <IWalletManager>(); mockWalletWrapper.Setup(w => w.LoadWallet(It.IsAny <string>(), It.IsAny <string>())).Returns(wallet); string dir = AssureEmptyDir("TestData/ControllersTests/RecoverWalletSuccessfullyReturnsWalletModel"); var dataFolder = new DataFolder(new NodeSettings { DataDir = dir }); var controller = new WalletController(mockWalletWrapper.Object, new Mock <IWalletSyncManager>().Object, It.IsAny <ConnectionManager>(), Network.Main, new Mock <ConcurrentChain>().Object, dataFolder); // Act var result = controller.Load(new WalletLoadRequest { Name = "myWallet", FolderPath = "", Password = "" }); // Assert mockWalletWrapper.VerifyAll(); var viewResult = Assert.IsType <OkResult>(result); Assert.Equal(200, viewResult.StatusCode); }
public void FileNotFoundExceptionandReturns404() { var mockWalletWrapper = new Mock <IWalletManager>(); mockWalletWrapper.Setup(wallet => wallet.LoadWallet(It.IsAny <string>(), It.IsAny <string>())).Throws <FileNotFoundException>(); string dir = AssureEmptyDir("TestData/ControllersTests/FileNotFoundExceptionandReturns404"); var dataFolder = new DataFolder(new NodeSettings { DataDir = dir }); var controller = new WalletController(mockWalletWrapper.Object, new Mock <IWalletSyncManager>().Object, It.IsAny <ConnectionManager>(), Network.Main, new Mock <ConcurrentChain>().Object, dataFolder); // Act var result = controller.Load(new WalletLoadRequest { Name = "myName", FolderPath = "", Password = "" }); // Assert mockWalletWrapper.VerifyAll(); var viewResult = Assert.IsType <ErrorResult>(result); Assert.NotNull(viewResult); Assert.Equal(404, viewResult.StatusCode); }
public void RecoverWalletSuccessfullyReturnsWalletModel() { WalletModel walletModel = new WalletModel { FileName = "myWallet", Network = "MainNet", Addresses = new List <string> { "address1", "address2", "address3", "address4", "address5" } }; var mockWalletWrapper = new Mock <IWalletWrapper>(); mockWalletWrapper.Setup(wallet => wallet.Load(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(walletModel); var controller = new WalletController(mockWalletWrapper.Object); // Act var result = controller.Load(new WalletLoadRequest { Name = "myName", FolderPath = "", Password = "" }); // Assert mockWalletWrapper.VerifyAll(); var viewResult = Assert.IsType <JsonResult>(result); Assert.NotNull(viewResult.Value); Assert.IsType <WalletModel>(viewResult.Value); var model = viewResult.Value as WalletModel; Assert.Equal("myWallet", model.FileName); }
public void RecoverWalletSuccessfullyReturnsWalletModel() { Wallet.Wallet wallet = new Wallet.Wallet { Name = "myWallet", Network = WalletHelpers.GetNetwork("mainnet") }; var mockWalletWrapper = new Mock <IWalletManager>(); mockWalletWrapper.Setup(w => w.LoadWallet(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(wallet); var controller = new WalletController(mockWalletWrapper.Object, new Mock <ITracker>().Object); // Act var result = controller.Load(new WalletLoadRequest { Name = "myWallet", FolderPath = "", Password = "" }); // Assert mockWalletWrapper.VerifyAll(); var viewResult = Assert.IsType <JsonResult>(result); Assert.NotNull(viewResult.Value); Assert.IsType <WalletModel>(viewResult.Value); var model = viewResult.Value as WalletModel; Assert.Equal("Main", model.Network); }
public void FileNotFoundExceptionandReturns404() { var mockWalletWrapper = new Mock <IWalletWrapper>(); mockWalletWrapper.Setup(wallet => wallet.Load(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Throws <FileNotFoundException>(); var controller = new WalletController(mockWalletWrapper.Object); // Act var result = controller.Load(new WalletLoadRequest { Name = "myName", FolderPath = "", Password = "" }); // Assert mockWalletWrapper.VerifyAll(); var viewResult = Assert.IsType <ObjectResult>(result); Assert.NotNull(viewResult); Assert.Equal(404, viewResult.StatusCode); }