public async Task Should_Create_IncidentTypePeriodEmployeeRelationship_And_Get_ToValidate_Finally_do_Delete() { //var txOptions = new System.Transactions.TransactionOptions(); //txOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using var scope = new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Enabled); //Act Guid identityWorkId = Guid.NewGuid(); Guid instanceId = Guid.NewGuid(); var incidentTypePeriodEmployeeRelationships = await new IncidentTypeOverdraftRelationshipUT().CreateDefaultAsync <Incident>(identityWorkId, instanceId); var middlewareManager = new MiddlewareManager <Incident>(new BaseRecordManager <Incident>(), new IncidentValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(incidentTypePeriodEmployeeRelationships.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(incidentTypePeriodEmployeeRelationships.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == incidentTypePeriodEmployeeRelationships.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(incidentTypePeriodEmployeeRelationships.Select(p => p.ID).ToList(), identityWorkId); Assert.False(result2.Any()); }
public async Task Client_Should_Call_Dummy_Async() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); var iMSSFare = new List <IMSSFare>(); var companyId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var userId = Guid.NewGuid(); iMSSFare = new MemoryStorageContext().GetDefaultIMSSFare(companyId, instanceId, userId); var middlewareManager = new MiddlewareManager <IMSSFare>(new BaseRecordManager <IMSSFare>(), new IMSSFareValidator()); //Act await middlewareManager.CreateAsync(iMSSFare, companyId); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(iMSSFare.Select(p => p.ID).ToList(), companyId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(iMSSFare.Select(p => p.ID).ToList(), companyId); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(iMSSFare.Select(p => p.ID).ToList(), companyId); Assert.True(!result2.Any()); }
public async Task Should_Create_Settlement_And_Get_ToValidate_Finally_do_Delete() { var txOptions = new TransactionOptions(); txOptions.IsolationLevel = IsolationLevel.ReadUncommitted; using var scope = new TransactionScope(TransactionScopeOption.Required, txOptions, TransactionScopeAsyncFlowOption.Enabled); //Act Guid identityWorkId = Guid.NewGuid(); Guid instanceId = Guid.NewGuid(); var settlements = await new SettlementProcessManagerDBUT().CreateDefaultAsync <Settlement>(identityWorkId, instanceId); var middlewareManager = new MiddlewareManager <Settlement>(new BaseRecordManager <Settlement>(), new SettlementValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(settlements.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(settlements.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == settlements.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(settlements.Select(p => p.ID).ToList(), identityWorkId); Assert.False(result2.Any()); }
public async Task <List <Overdraft> > UpdateByEmployeesAsync(List <Employee> employees) { //all good var identityWorkId = employees.FirstOrDefault().company; //Get the overdrafts to delete var employeesID = employees.Select(p => p.ID).ToList(); var middlewareManager = new MiddlewareManager <Overdraft>(new BaseRecordManager <Overdraft>(), new OverdraftValidator()); var middlewareOverdraftDetailManager = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); var overdraftsToDelete = await middlewareManager.FindByExpressionAsync(p => employeesID.Contains(p.EmployeeID), identityWorkId); if (overdraftsToDelete.Any()) { //delete previous overdraft (no timbrados ni autorizados ni cancelados) var overdraftIds = overdraftsToDelete.Where(p => p.OverdraftStatus == OverdraftStatus.None).Select(p => p.ID).ToList(); if (overdraftIds.Any()) { await middlewareOverdraftDetailManager.DeleteByExpresssionAsync(p => overdraftIds.Contains(p.OverdraftID), identityWorkId); await middlewareManager.DeleteAsync(overdraftIds, identityWorkId); } } return(await CreateByEmployeesAsync(employees)); }
public async Task Should_Create() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceID = Guid.NewGuid(); var periodTypes = await new PeriodTypeUT().CreateDefaultAsync <PeriodType>(identityWorkId, instanceID, PaymentPeriodicity.Biweekly); //Act var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); //Assert var id = periodTypes.FirstOrDefault().ID; var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId); Assert.True(found.Any()); var register = found.FirstOrDefault(x => x.ID == id); Assert.NotNull(register); await middlewareManager.DeleteAsync(new List <Guid>() { id }, identityWorkId); found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId); Assert.True(!found.Any()); }
public async Task Should_Create_Biweekly() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); //Act var initialDate = new DateTime(DateTime.Now.Year, 1, 1); var finalDate = new DateTime(DateTime.Now.Year, 12, 31); var paymentPeriodicity = PaymentPeriodicity.Biweekly; var period = await CreateDefaultAsync <Period>(identityWorkId, instanceId, initialDate, finalDate, paymentPeriodicity); //Assert var middlewareManager = new MiddlewareManager <Period>(new BaseRecordManager <Period>(), new PeriodValidator()); var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { period.FirstOrDefault().ID }, identityWorkId, new string[] { "PeriodDetails" }); Assert.True(found.Any()); var periodDetails = found.SelectMany(p => p.PeriodDetails).OrderBy(p => p.Number); Assert.True(periodDetails.Any()); Assert.True(found.SelectMany(p => p.PeriodDetails).Count() == 24); //Delete test var middlewareManagerPeriodDetails = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), new PeriodDetailValidator()); var periodDetailsIds = found.SelectMany(p => p.PeriodDetails).Select(p => p.ID).ToList(); //details await middlewareManagerPeriodDetails.DeleteAsync(periodDetailsIds, identityWorkId); //periods await middlewareManager.DeleteAsync(new List <Guid>() { found.FirstOrDefault().ID }, identityWorkId); }
public async Task Should_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var periodTypes = new List <PeriodType>(); var identityWorkId = Guid.NewGuid(); var id = Guid.NewGuid(); var periodType = PeriodTypeBuilder.Build(id, identityWorkId, "Quincenal"); periodTypes.Add(periodType); //Act var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); await middlewareManager.CreateAsync(periodTypes, identityWorkId); //Assert var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId); Assert.True(found.Any()); var register = found.FirstOrDefault(x => x.ID == id); Assert.NotNull(register); await middlewareManager.DeleteAsync(new List <Guid>() { id }, identityWorkId); found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId); register = found.FirstOrDefault(x => x.ID == id); Assert.Null(register); }
public async Task Should_Create_Area_And_Get_ToValidate_Finally_do_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var Areas = await new AreaManagerUT().CreateDefaultAsync <Area>(identityWorkId, instanceId); //Act var middlewareManager = new MiddlewareManager <Area>(new BaseRecordManager <Area>(), new AreaValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(Areas.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(Areas.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == Areas.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(Areas.Select(p => p.ID).ToList(), identityWorkId); Assert.True(!result2.Any()); }
public async Task Should_Create_Inhability_And_Get_ToValidate_Finally_do_Delete() { var txOptions = new System.Transactions.TransactionOptions(); txOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using var scope = new TransactionScope(TransactionScopeOption.Required, txOptions, TransactionScopeAsyncFlowOption.Enabled); //Act Guid identityWorkId = Guid.NewGuid(); //Guid.Parse("7535C4E6-4712-4DD6-955D-FCA86E054D49"); Guid instanceId = Guid.NewGuid(); //Guid.Parse("33D7CA50-39E9-4B14-B482-5FCBEC07E8DB"); var inhabilities = await new InhabilityManagerUT().CreateDefaultAsync <Inhability>(identityWorkId, instanceId); var middlewareManager = new MiddlewareManager <Inhability>(new BaseRecordManager <Inhability>(), new InhabilityValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(inhabilities.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(inhabilities.Select(p => p.ID).ToList(), identityWorkId); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(inhabilities.Select(p => p.ID).ToList(), identityWorkId); Assert.False(result2.Any()); }
public async Task Should_Create_VacationNotDaysOff_Finally_do_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var employee = (await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId, instanceId)).FirstOrDefault(); var vacation = await new VacationManagerUT().CreateDefaultAsync(identityWorkId, instanceId, employee.ID, DateTime.Now, DateTime.Now.AddDays(1)); //Act var middlewareManager = new MiddlewareManager <Vacation>(new BaseRecordManager <Vacation>(), new VacationValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(new List <Guid>() { vacation.ID }, identityWorkId); Assert.True(result.Any()); Assert.True(result.FirstOrDefault().ID == vacation.ID); //Delete await middlewareManager.DeleteAsync(new List <Guid>() { vacation.ID }, identityWorkId); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(new List <Guid>() { vacation.ID }, identityWorkId); Assert.True(!result2.Any()); }
public void AfterDelete(List <Guid> lstObjectsToValidate, object parameters) { List <EmployeeConceptsRelation> listAfterDelete = (List <EmployeeConceptsRelation>)parameters; var emplRelManager = new MiddlewareManager <EmployeeConceptsRelation>(new BaseRecordManager <EmployeeConceptsRelation>(), new EmployeeConceptsRelationValidator()); emplRelManager.DeleteAsync(listAfterDelete.Select(x => x.ID).ToList(), listAfterDelete.FirstOrDefault().company).Wait(); }
public async Task DeleteAsync(List <Guid> id, Guid identityWorkID) { var nmAnswerMiddlewareManager = new MiddlewareManager <NOMAnswer>(new BaseRecordManager <NOMAnswer>(), new NOMAnswerValidator()); var answers = await nmAnswerMiddlewareManager.FindByExpressionAsync(p => id.Contains(p.NOMSurveyReplyID), identityWorkID); var middlewareManager = new MiddlewareManager <NOMSurveyReply>(new BaseRecordManager <NOMSurveyReply>(), new NOMSurveyReplyValidator()); await nmAnswerMiddlewareManager.DeleteAsync(answers.Select(p => p.ID).ToList(), identityWorkID); await middlewareManager.DeleteAsync(id, identityWorkID); }
public async Task Should_Create_Overdraft_And_Get_ToValidate_Finally_do_Delete() { var txOptions = new System.Transactions.TransactionOptions(); txOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using var scope = new TransactionScope(TransactionScopeOption.Required, txOptions, TransactionScopeAsyncFlowOption.Enabled); //Act Guid identityWorkId = Guid.NewGuid(); Guid instanceId = Guid.NewGuid(); var middlewareManager = new MiddlewareManager <Overdraft>(new BaseRecordManager <Overdraft>(), new OverdraftValidator()); var overdr = await middlewareManager.FindByExpressionAsync(p => p.ID == Guid.Parse("24062420-7C73-4453-B837-A9B25AC26595"), identityWorkId, new string[] { "OverdraftDetails" }); var detail = overdr.FirstOrDefault().OverdraftDetails .Where(p => p.ID == Guid.Parse("c1314de9-13cf-4531-8641-23b04a4ce187")); var middlewareManagerDetail = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); var detail2 = await middlewareManagerDetail.FindByExpressionAsync(p => p.ID == Guid.Parse("c1314de9-13cf-4531-8641-23b04a4ce187"), identityWorkId); var overdrafts = await new OverdraftManagerUT().CreateDefaultOverdraftAsync(identityWorkId, instanceId); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(overdrafts.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete var middlewareOverdraftDetailManager = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); await middlewareOverdraftDetailManager.DeleteAsync(overdrafts.SelectMany(p => p.OverdraftDetails).Select(p => p.ID).ToList(), identityWorkId); await middlewareManager.DeleteAsync(overdrafts.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == overdrafts.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(overdrafts.Select(p => p.ID).ToList(), identityWorkId); Assert.False(result2.Any()); }
public async Task Should_Fail_When_Payment_Periodicity_Is_BadValue() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var periodTypes = new List <PeriodType>(); var identityWorkId = Guid.NewGuid(); var id = Guid.NewGuid(); var originalName = "some"; var periodType = PeriodTypeBuilder.Build(id, identityWorkId, originalName); periodTypes.Add(periodType); var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); await middlewareManager.CreateAsync(periodTypes, identityWorkId); var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId); Assert.True(found.Any()); var register = found.FirstOrDefault(x => x.ID == id); Assert.NotNull(register); Assert.Equal(register.Name, originalName); register.PaymentPeriodicity = (PaymentPeriodicity)11; try { await middlewareManager.UpdateAsync(new List <PeriodType>() { register }, identityWorkId); } catch (CotorraException ex) { //Assert var res = ex.ValidationInfo; Assert.NotEmpty(res); Assert.Equal(9003, ex.ErrorCode); } finally { await middlewareManager.DeleteAsync(new List <Guid>() { id }, identityWorkId); } }
public async Task Should_Create_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); List <PayrollCompanyConfiguration> payrollCompanyConfigurations = new List <PayrollCompanyConfiguration>(); var identityWorkId = Guid.NewGuid(); //Fills the dummyData var payrollConfig = new PayrollCompanyConfiguration(); payrollConfig.Active = true; payrollConfig.company = identityWorkId; payrollConfig.CurrentExerciseYear = 2014; payrollConfig.ID = Guid.NewGuid(); payrollConfig.InstanceID = Guid.NewGuid(); payrollConfig.StartDate = new DateTime(2014, 1, 1).Date; payrollConfig.Timestamp = DateTime.Now; payrollConfig.user = Guid.Empty; payrollConfig.CurrencyID = Guid.NewGuid(); payrollConfig.CurrentPeriod = 1; payrollCompanyConfigurations.Add(payrollConfig); //Act var middlewareManager = new MiddlewareManager <PayrollCompanyConfiguration>(new BaseRecordManager <PayrollCompanyConfiguration>(), new PayrollCompanyConfigurationValidator()); await middlewareManager.CreateAsync(payrollCompanyConfigurations, identityWorkId); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(payrollCompanyConfigurations.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(payrollCompanyConfigurations.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == payrollCompanyConfigurations.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(payrollCompanyConfigurations.Select(p => p.ID).ToList(), identityWorkId); Assert.True(!result2.Any()); }
public async Task Should_Create_Workshift_And_Get_ToValidate_Finally_do_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var Workshifts = new List <Workshift>(); var identityWorkId = Guid.NewGuid(); Workshifts.Add(new Workshift() { ID = Guid.NewGuid(), Active = true, company = identityWorkId, Timestamp = DateTime.UtcNow, InstanceID = Guid.NewGuid(), Description = "Turno mixto", CreationDate = DateTime.Now, Name = "Mixto", StatusID = 1, Hours = 8 }); //Act var middlewareManager = new MiddlewareManager <Workshift>(new BaseRecordManager <Workshift>(), new WorkshiftValidator()); await middlewareManager.CreateAsync(Workshifts, identityWorkId); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(Workshifts.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); //Delete await middlewareManager.DeleteAsync(Workshifts.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == Workshifts.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(Workshifts.Select(p => p.ID).ToList(), identityWorkId); Assert.True(!result2.Any()); }
public async Task Should_Create_Biweekly_DeletePeriodDetail_Fail_FuturePeriodDetails() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); try { //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); //Act var initialDate = new DateTime(DateTime.Now.Year, 1, 1); var finalDate = new DateTime(DateTime.Now.Year, 12, 31); var paymentPeriodicity = PaymentPeriodicity.Biweekly; var period = await CreateDefaultAsync <Period>(identityWorkId, instanceId, initialDate, finalDate, paymentPeriodicity); //Assert var middlewareManager = new MiddlewareManager <Period>(new BaseRecordManager <Period>(), new PeriodValidator()); var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { period.FirstOrDefault().ID }, identityWorkId, new string[] { "PeriodDetails" }); Assert.True(found.Any()); var periodDetails = found.SelectMany(p => p.PeriodDetails).OrderBy(p => p.Number); Assert.True(periodDetails.Any()); Assert.True(found.SelectMany(p => p.PeriodDetails).Count() == 24); var middlewareManagerPeriodDetails = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), new PeriodDetailValidator()); var periodDetailToDelete = periodDetails.FirstOrDefault(p => p.Number == 1); await middlewareManagerPeriodDetails.DeleteAsync(new List <Guid> { periodDetailToDelete.ID }, identityWorkId); Assert.True(false); } catch (Exception ex) { Assert.True(ex is CotorraException); Assert.True((ex as CotorraException).ErrorCode.Equals(8007)); } }
public async Task Should_Create_InfonavitMovement() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); //Act var infonavitMovement = await CreateDefaultAsync <InfonavitMovement>(identityWorkId, instanceId); //Assert var middlewareManager = new MiddlewareManager <InfonavitMovement>(new BaseRecordManager <InfonavitMovement>(), new InfonavitMovementValidator()); var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { infonavitMovement.FirstOrDefault().ID }, identityWorkId, null); Assert.True(found.Any()); //Delete test await middlewareManager.DeleteAsync(new List <Guid>() { found.FirstOrDefault().ID }, identityWorkId); }
public async Task Should_Create_Employee_And_Get_ToValidate_Finally_do_Delete() { var txOptions = new System.Transactions.TransactionOptions(); txOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using var scope = new TransactionScope(TransactionScopeOption.Required, txOptions, TransactionScopeAsyncFlowOption.Enabled); //Act Guid identityWorkId = Guid.NewGuid(); //Guid.Parse("7535C4E6-4712-4DD6-955D-FCA86E054D49"); Guid instanceId = Guid.NewGuid(); //Guid.Parse("33D7CA50-39E9-4B14-B482-5FCBEC07E8DB"); var employees = await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId, instanceId, randomValues: true); var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); //Asserts //Get var result = await middlewareManager .GetByIdsAsync(employees.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.Any()); var middlewareManagerOverdraft = new MiddlewareManager <Overdraft>(new BaseRecordManager <Overdraft>(), new OverdraftValidator()); var resultOverdraft = await middlewareManagerOverdraft.FindByExpressionAsync(p => p.InstanceID == instanceId && p.EmployeeID == employees.FirstOrDefault().ID, identityWorkId); Assert.True(resultOverdraft.Any()); //Delete await middlewareManager.DeleteAsync(employees.Select(p => p.ID).ToList(), identityWorkId); Assert.True(result.FirstOrDefault().ID == employees.FirstOrDefault().ID); //Get it again to verify if the registry it was deleted var result2 = await middlewareManager .GetByIdsAsync(employees.Select(p => p.ID).ToList(), identityWorkId); Assert.False(result2.Any()); }
public async Task DeleteAsync(List <Guid> lstGuids, LicenseParams licenseParams) { var middlewareManager = new MiddlewareManager <T>(new BaseRecordManager <T>(), Validator); await middlewareManager.DeleteAsync(lstGuids, licenseParams); }
public async Task Delete(Guid instanceID, Guid userID, Guid identityWorkID, AreaValidator validator, IMapper mapper, Guid AreaID) { var mgr = new MiddlewareManager <Area>(new BaseRecordManager <Area>(), validator); await mgr.DeleteAsync(new List <Guid>() { AreaID }, identityWorkID); }
public async Task Should_Create_NOMEvaluationPhase_And_Get_ToValidate_Finally_do_Delete() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var NOMEvaluationPhases = await new PhaseManagerUT().CreateDefaultAsync <NOMEvaluationPhase>(identityWorkId, instanceId); //Act var middlewareManager = new MiddlewareManager <NOMEvaluationPhase>(new BaseRecordManager <NOMEvaluationPhase>(), new NOMEvaluationPhaseValidator()); var middlewareManagerQuestion = new MiddlewareManager <NOMEvaluationQuestion>(new BaseRecordManager <NOMEvaluationQuestion>(), new NOMEvaluationQuestionValidator()); //Asserts //Get var ids = NOMEvaluationPhases.Select(p => p.ID).ToList(); var id = NOMEvaluationPhases.Select(p => p.ID).ToList().First(); var result = middlewareManager .GetByIds(ids, identityWorkId); Assert.True(result.Count() > 0); //Act again var NOMEvaluationPhases2 = new List <NOMEvaluationQuestion>(); NOMEvaluationPhases2.Add(new NOMEvaluationQuestion() { ID = Guid.NewGuid(), Active = true, Timestamp = DateTime.UtcNow, Description = "Mi trabajo me exige hacer mucho esfuerzo físico.", CreationDate = DateTime.Now, Name = "Mi trabajo me exige hacer mucho esfuerzo físico..", StatusID = 1, NOMEvaluationPhaseID = id, }); var middlewareManager3 = new MiddlewareManager <NOMEvaluationQuestion>(new BaseRecordManager <NOMEvaluationQuestion>(), new NOMEvaluationQuestionValidator()); await middlewareManager3.CreateAsync(NOMEvaluationPhases2, identityWorkId); var NoEvalQuestion = NOMEvaluationPhases2; var ids2 = NoEvalQuestion.Select(p => p.ID).ToList(); var resultQuestions = await middlewareManagerQuestion.GetByIdsAsync(ids2, identityWorkId); Assert.True(result.Any()); Assert.True(result.FirstOrDefault().ID == NOMEvaluationPhases.FirstOrDefault().ID); Assert.True(resultQuestions.Any()); //Delete await middlewareManagerQuestion.DeleteAsync(ids2, identityWorkId); await middlewareManager.DeleteAsync(ids, identityWorkId); //Get it again to verify if the registry was deleted var result2 = await middlewareManager .GetByIdsAsync(ids, identityWorkId); Assert.True(!result2.Any()); var result3 = await middlewareManager .GetByIdsAsync(ids2, identityWorkId); Assert.True(!result3.Any()); }
public async Task DeleteAsync(List <Guid> lstGuids, Guid identityWorkId) { var middlewareManager = new MiddlewareManager <T>(new BaseRecordManager <T>(), Validator); await middlewareManager.DeleteAsync(lstGuids, identityWorkId); }