public ImportOperation Import(Config config) { _config = config; using (var operationTypeService = new OperationTypeService(config.TargetConnectionString)) { var importType = operationTypeService.Get(config.ImportType); var currentOperation = importType.Operation; if (currentOperation == ImportOperation.Invalid) { throw new ArgumentException("unknown Import type"); } using (var iiService = new IngredientImportService(config.TargetConnectionString)) { if (config.ImportType == "Fourth_1.3" && iiService.ValidateStandardTemplate(config.FileName) == false) { throw new ArgumentException(string.Empty); } if (config.ImportType == "Fourth_1.6") { iiService.UpdateSaltTargetConfig(); } } // execute step before the import on the target DB if (!string.IsNullOrWhiteSpace(importType.PrerequisiteQuery)) { operationTypeService.Exec(importType.PrerequisiteQuery); } Insert(currentOperation, config); return(currentOperation); } }
public void GetDefaultsOperationTypes_Should_Return_Default_Operations_Types() { var defaultsOperationsTypes = new string[] { "type1", "type2", "type3" }; var operationTypeService = new OperationTypeService() { Configuration = new AppConfiguration() { DefaultsOperationTypes = defaultsOperationsTypes } }; var operationsTypes = operationTypeService.GetDefaultsOperationTypes(); Assert.Equal(defaultsOperationsTypes.Length, operationsTypes.Count()); foreach (var operationType in defaultsOperationsTypes) { Assert.NotNull(operationsTypes.SingleOrDefault(ot => ot.Wording.Equals(operationType))); } }
public void GetBankAccountOperationsType_Should_Return_Bank_Account_Operations_Types() { var dbName = DataBaseHelper.Instance.NewDataBase(); var user = DataBaseHelper.Instance.UseNewUser(dbName); var bankAccountType = DataBaseHelper.Instance.UseNewBankAccountType(dbName); var bankAccount = DataBaseHelper.Instance.UseNewBankAccount(dbName, user.Id, bankAccountType.Id); var operationType1 = DataBaseHelper.Instance.UseNewOperationType(dbName, bankAccount.Id); var operationType2 = DataBaseHelper.Instance.UseNewOperationType(dbName, bankAccount.Id); var operationType3 = DataBaseHelper.Instance.UseNewOperationType(dbName, bankAccount.Id); var operationTypeService = new OperationTypeService(); using (var context = DataBaseHelper.Instance.CreateContext(dbName)) { var operationsTypes = operationTypeService.GetBankAccountOperationsType(context, user.UserName, bankAccount.Id); Assert.NotNull(operationsTypes); Assert.Equal(3, operationsTypes.Count()); Assert.NotNull(operationsTypes.SingleOrDefault(ot => ot.Id.Equals(operationType1.Id))); Assert.NotNull(operationsTypes.SingleOrDefault(ot => ot.Id.Equals(operationType2.Id))); Assert.NotNull(operationsTypes.SingleOrDefault(ot => ot.Id.Equals(operationType3.Id))); } }