public async Task TestFilesMove() { var fullPath = Path.Combine(DirectoryName, FileName); var operationsFactoryMock = new Mock <IOperationsFactory>(); var operationMock = new Mock <IOperation>(); operationMock .Setup(m => m.RunAsync(It.IsAny <CancellationToken>())) .Verifiable(); operationsFactoryMock .Setup(m => m.CreateMoveOperation(It.IsAny <IList <BinaryFileOperationSettings> >())) .Callback <IList <BinaryFileOperationSettings> >(l => { var settings = l.Single(); Assert.Equal(FileName, settings.SourceFilePath); Assert.Equal(fullPath, settings.DestinationFilePath); }) .Returns(operationMock.Object); var directoryServiceMock = new Mock <IDirectoryService>(); directoryServiceMock .SetupGet(m => m.SelectedDirectory) .Returns(CurrentDirectory); var fileOpeningServiceMock = new Mock <IResourceOpeningService>(); var fileServiceMock = new Mock <IFileService>(); fileServiceMock .Setup(m => m.CheckIfExists(FileName)) .Returns(true); var pathServiceMock = new Mock <IPathService>(); pathServiceMock .Setup(m => m.GetCommonRootDirectory(It.IsAny <IList <string> >())) .Returns(string.Empty); pathServiceMock .Setup(m => m.Combine(DirectoryName, FileName)) .Returns(fullPath); pathServiceMock .Setup(m => m.GetRelativePath(string.Empty, FileName)) .Returns(FileName); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object); await operationsService.MoveFilesAsync(new[] { FileName }, DirectoryName); operationMock.Verify(m => m.RunAsync(It.IsAny <CancellationToken>()), Times.Once()); }
public void EndGetOperationById(IAsyncResult result) { OperationDto operation = OperationsService.EndGetOperationById(result); OperationViewModel operationVM = Operations.SingleOrDefault(o => o.Operation.Id == operation.Id); if (operationVM != null) { operationVM.Operation = operation; } else { Operations.Add(new OperationViewModel(operation)); } InProgress = false; }
public ActionResult Recharge(RechargeViewModel rechargeViewModel) { if (ModelState.IsValid) { if (OperationsService.RechargeBalance(User.CardId, Convert.ToDecimal(rechargeViewModel.Amount))) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Could not recharge current card. Try again!"); } } return(View()); }
public async Task TestFilesRemoving() { var operationsFactoryMock = new Mock <IOperationsFactory>(); var operationMock = new Mock <IOperation>(); operationMock .Setup(m => m.RunAsync()) .Verifiable(); operationsFactoryMock .Setup(m => m.CreateDeleteOperation(It.IsAny <UnaryFileSystemOperationSettings>())) .Callback <UnaryFileSystemOperationSettings>(s => { Assert.Equal(FileName, s.TopLevelFiles.Single()); }) .Returns(operationMock.Object); var directoryServiceMock = new Mock <IDirectoryService>(); var fileOpeningServiceMock = new Mock <IResourceOpeningService>(); var fileServiceMock = new Mock <IFileService>(); fileServiceMock .Setup(m => m.CheckIfExists(FileName)) .Returns(true) .Verifiable(); var pathServiceMock = new Mock <IPathService>(); var fileOperationsStateServiceMock = new Mock <IOperationsStateService>(); fileOperationsStateServiceMock .Setup(m => m.AddOperation(operationMock.Object)) .Verifiable(); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object, fileOperationsStateServiceMock.Object); await operationsService.RemoveAsync(new[] { FileName }); operationMock.Verify(m => m.RunAsync(), Times.Once()); fileServiceMock.Verify(m => m.CheckIfExists(FileName), Times.Once()); fileOperationsStateServiceMock .Verify(m => m.AddOperation(operationMock.Object), Times.Once()); }
public void CummulativeGrowthTest() { var bTransactionEntry = new TransactionEntry() { Saldo = 248, Date = new DateTime(2018, 06, 01).ToString("o") }; var eTransactionEntry = new TransactionEntry() { Saldo = 100, Date = new DateTime(2018, 01, 01).ToString("o") }; var change = OperationsService.CompoundGrowthRate(bTransactionEntry, eTransactionEntry); Assert.IsTrue(Math.Abs(change - 20) < 1); }
public void PercentageChangeIncreaseTest() { var bTransactionEntry = new TransactionEntry() { Saldo = 50, Date = new DateTime(2018, 01, 01).ToString("o") }; var eTransactionEntry = new TransactionEntry() { Saldo = 100, Date = new DateTime(2018, 01, 02).ToString("o") }; var change = OperationsService.PercentageIncrease(bTransactionEntry, eTransactionEntry); Assert.IsTrue(Math.Abs(change.AbsoluteIncrease - 50) < 0); Assert.IsTrue(Math.Abs(change.PercentageIncrease - 100) < 0); }
public async Task TestFilesRemoving() { var operationsFactoryMock = new Mock <IOperationsFactory>(); var operationMock = new Mock <IOperation>(); operationMock .Setup(m => m.RunAsync(It.IsAny <CancellationToken>())) .Verifiable(); operationsFactoryMock .Setup(m => m.CreateDeleteFileOperation(It.IsAny <IList <UnaryFileOperationSettings> >())) .Callback <IList <UnaryFileOperationSettings> >(l => { Assert.Equal(FileName, l.Single().FilePath); }) .Returns(operationMock.Object); var directoryServiceMock = new Mock <IDirectoryService>(); var fileOpeningServiceMock = new Mock <IResourceOpeningService>(); var fileServiceMock = new Mock <IFileService>(); fileServiceMock .Setup(m => m.CheckIfExists(FileName)) .Returns(true) .Verifiable(); var pathServiceMock = new Mock <IPathService>(); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object); await operationsService.RemoveFilesAsync(new[] { FileName }); operationMock.Verify(m => m.RunAsync(It.IsAny <CancellationToken>()), Times.Once()); fileServiceMock.Verify(m => m.CheckIfExists(FileName), Times.Once()); }
public void TestEditSelectedFiles() { var operationsFactoryMock = new Mock <IOperationsFactory>(); var directoryServiceMock = new Mock <IDirectoryService>(); var fileServiceMock = new Mock <IFileService>(); var fileOpeningServiceMock = new Mock <IFileOpeningService>(); fileOpeningServiceMock .Setup(m => m.Open(FileName)) .Verifiable(); var pathServiceMock = new Mock <IPathService>(); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object); operationsService.EditFiles(new[] { FileName }); fileOpeningServiceMock.Verify(m => m.Open(FileName), Times.Once()); }
public TransactionsRequestHundler(OperationsService service) { _service = service; }
public AccountsRequestHundler(OperationsService service) { _service = service; }
public void AddOperation(int id) { OperationsService.BeginGetOperationById(id, EndGetOperationById, null); }
public void GetOperationById(int operationID) { OperationsService.BeginGetOperationById(operationID, EndGetOperationById, null); InProgress = true; }
public OperationsController(OperationsService operationsService) { _operationsService = operationsService; }
public AuthRequestHundler(UserManager <ApplicationUser> userManager, IConfiguration configuration, OperationsService service) { _userManager = userManager; _configuration = configuration; _service = service; }
public OperationsController(OperationsService context) { this.context = context; }
public IEditorOperations3 GetOperations(ITextView textView) { return((IEditorOperations3)OperationsService.GetEditorOperations(textView)); }
public async Task TestFilesMove() { var fullPath = Path.Combine(DirectoryName, FileName); var operationsFactoryMock = new Mock <IOperationsFactory>(); var operationMock = new Mock <IOperation>(); operationMock .Setup(m => m.RunAsync()) .Verifiable(); operationsFactoryMock .Setup(m => m.CreateMoveOperation(It.IsAny <BinaryFileSystemOperationSettings>())) .Callback <BinaryFileSystemOperationSettings>(s => { var(key, value) = s.FilesDictionary.Single(); Assert.Equal(FileName, key); Assert.Equal(fullPath, value); }) .Returns(operationMock.Object); var directoryServiceMock = new Mock <IDirectoryService>(); directoryServiceMock .SetupGet(m => m.SelectedDirectory) .Returns(CurrentDirectory); var fileOpeningServiceMock = new Mock <IResourceOpeningService>(); var fileServiceMock = new Mock <IFileService>(); fileServiceMock .Setup(m => m.CheckIfExists(FileName)) .Returns(true); var fileOperationsStateServiceMock = new Mock <IOperationsStateService>(); fileOperationsStateServiceMock .Setup(m => m.AddOperation(operationMock.Object)) .Verifiable(); var pathServiceMock = new Mock <IPathService>(); pathServiceMock .Setup(m => m.GetCommonRootDirectory(It.IsAny <IReadOnlyList <string> >())) .Returns(string.Empty); pathServiceMock .Setup(m => m.Combine(DirectoryName, FileName)) .Returns(fullPath); pathServiceMock .Setup(m => m.GetRelativePath(string.Empty, FileName)) .Returns(FileName); IOperationsService operationsService = new OperationsService( operationsFactoryMock.Object, directoryServiceMock.Object, fileOpeningServiceMock.Object, fileServiceMock.Object, pathServiceMock.Object, fileOperationsStateServiceMock.Object); await operationsService.MoveAsync(new[] { FileName }, DirectoryName); operationMock.Verify(m => m.RunAsync(), Times.Once()); fileOperationsStateServiceMock .Verify(m => m.AddOperation(operationMock.Object), Times.Once()); }