public void TestBudgetLimitService_GetLimitData_NoData() { var svc = new BudgetLimitService(_repositoryFactoryMock.Object, _userServiceMock.Object); var result = svc.GetLimitData(1, 1, 1, 1, 1); _repositoryBudgetMock.Verify(m => m.GetQueryable(), Times.Once()); _repositoryExpensesMock.Verify(m => m.GetQueryable(), Times.Never()); Assert.Null(result); }
public void TestBudgetLimitService_GetLimitData_WithData_WithExpenses() { var svc = new BudgetLimitService(_repositoryFactoryMock.Object, _userServiceMock.Object); var result = svc.GetLimitData(1, 1, 1, 2018, 3); _repositoryBudgetMock.Verify(m => m.GetQueryable(), Times.Once()); _repositoryExpensesMock.Verify(m => m.GetQueryable(), Times.Once()); Assert.NotNull(result); Assert.Equal(result.LimitAmount, 6.1M); Assert.Equal(result.LimitAmountActuallySpent, 4M); Assert.Equal(result.LimitAmountReserved, 2M); }
public void TestBudgetLimitService_GetLimitDataSummary_WithData() { var svc = new BudgetLimitService(_repositoryFactoryMock.Object, _userServiceMock.Object); var result = svc.GetLimitDataSummary(1, 1, 1, 2018); _repositoryBudgetMock.Verify(m => m.GetQueryable(), Times.Once()); _repositoryExpensesMock.Verify(m => m.GetQueryable(), Times.Once()); Assert.NotNull(result); Assert.Equal(result.Count(), 2); Assert.Equal(result.ElementAt(0).FactPlanPercent, 0); Assert.Equal(result.ElementAt(1).FactPlanPercent, 98); }
public Task Execute(IJobExecutionContext context) { try { _logger.LogInformation("Начало синхронизации с Bitrix"); var iRPCSDbAccessor = new RPCSSingletonDbAccessor(_dbContextOptions); var rPCSRepositoryFactory = new RPCSRepositoryFactory(iRPCSDbAccessor); var userService = new UserService(rPCSRepositoryFactory, _httpContextAccessor); var budgetService = new BudgetLimitService(rPCSRepositoryFactory, userService); var departmentService = new DepartmentService(rPCSRepositoryFactory, userService); var employeeService = new EmployeeService(rPCSRepositoryFactory, departmentService, userService); var projectService = new ProjectService(rPCSRepositoryFactory, userService); var costSubItemService = new CostSubItemService(rPCSRepositoryFactory, userService); var expensesRecordService = new ExpensesRecordService(rPCSRepositoryFactory, _bitrixConfigOptions); var projectRoleService = new ProjectRoleService(rPCSRepositoryFactory); var taskSyncWithBitrix = new SyncWithBitrixTask(budgetService, _bitrixConfigOptions, employeeService, projectService, departmentService, costSubItemService, expensesRecordService, projectRoleService); string id = Guid.NewGuid().ToString(); BitrixSyncResult syncWithBitrixResult = null; if (taskSyncWithBitrix.Add(id, true) == true) { try { syncWithBitrixResult = taskSyncWithBitrix.ProcessLongRunningAction("", id); var fileHtmlReport = string.Empty; foreach (var html in syncWithBitrixResult.fileHtmlReport) { fileHtmlReport += html; } _memoryCache.Set(syncWithBitrixResult.fileId, fileHtmlReport); } catch (Exception) { } taskSyncWithBitrix.Remove(id); } } catch (Exception e) { string errorMessage = e.Message; _logger.LogError(e.Message); } _logger.LogInformation("Процесс синхронизации закончен!!"); return(Task.CompletedTask); }