예제 #1
0
            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());
            }
예제 #2
0
            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());
            }
예제 #3
0
            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());
            }
예제 #4
0
            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());
            }
예제 #5
0
            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);
            }
예제 #6
0
            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_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());
            }
예제 #8
0
        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());
        }
예제 #9
0
            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());
            }
예제 #10
0
            public async Task Should_Change_Status_To_UnregisteredUsingClient()
            {
                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 employeeFromDB = result.FirstOrDefault();

                Assert.Equal(CotorriaStatus.Active, employeeFromDB.LocalStatus);
                Assert.Equal(DateTime.Now.Date, employeeFromDB.LastStatusChange.Date);


                //Set inactive
                DateTime?unregisteredDate = DateTime.Now.AddDays(1);
                var      employeeId       = employeeFromDB.ID;

                var statusClient = new StatusClient <Employee>("", ClientConfiguration.ClientAdapter.Local);
                await statusClient.SetUnregistered(new List <Guid>() { employeeId }, identityWorkId, unregisteredDate);

                //Asserts

                //GetAggain
                result = await middlewareManager
                         .GetByIdsAsync(employees.Select(p => p.ID).ToList(), identityWorkId);

                Assert.True(result.Any());
                employeeFromDB = result.FirstOrDefault();

                //Asserts

                Assert.Equal(CotorriaStatus.Unregistered, employeeFromDB.LocalStatus);
                Assert.Equal(DateTime.Now.Date, employeeFromDB.LastStatusChange.Date);
                Assert.Equal(unregisteredDate.GetValueOrDefault().Date, employeeFromDB.UnregisteredDate.GetValueOrDefault().Date);
            }
예제 #11
0
        public async Task <EmployeeBenefitsDTO> GetEmployeeBenefits(string instanceID, string companyID, string employeeID)
        {
            var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator());
            var employee          = (await middlewareManager.GetByIdsAsync(new List <Guid>()
            {
                Guid.Parse(employeeID)
            }, Guid.Parse(companyID),
                                                                           new string[] { })).FirstOrDefault();


            var entryDate          = employee.EntryDate;
            var employeeTrustLevel = employee.EmployeeTrustLevel == EmployeeTrustLevel.Unionized ? "Sindicalizado" : "Confianza";
            var now = DateTime.Now;

            var currentYear = entryDate.Year - now.Year + 1;

            var benefitManager = new MiddlewareManager <BenefitType>(new BaseRecordManager <BenefitType>(), new BenefitTypeValidator());
            var benefit        = (await benefitManager.FindByExpressionAsync(x => x.Name == employeeTrustLevel && x.Antiquity == currentYear, Guid.Parse(companyID),
                                                                             new string[] { })).FirstOrDefault();

            var res = new EmployeeBenefitsDTO()
            {
                VacationalBonusPerSeniority = Math.Round(benefit.HolidayPremiumPortion, 2).ToString(),
                VacationsPerSeniority       = Math.Round(benefit.Holidays, 2).ToString(),
                YearlyBonusPerSeniority     = Math.Round(benefit.DaysOfChristmasBonus, 2).ToString(),
                PendingVacationDays         = "4",
            };



            return(res);
        }
예제 #12
0
        public async Task <List <T> > GetByIdsAsync(List <Guid> lstGuids, Guid identityWorkId, string[] objectsToInclude = null)
        {
            var middlewareManager = new MiddlewareManager <T>(new BaseRecordManager <T>(), Validator);
            var lstReturn         = await middlewareManager.GetByIdsAsync(lstGuids, identityWorkId, objectsToInclude);

            return(lstReturn);
        }
예제 #13
0
        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);
        }
예제 #14
0
            public async Task Should_Fail_When_LowerLimit_is_less_than_zero()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var identityWorkId = Guid.NewGuid();
                var instanceId     = Guid.NewGuid();

                //create one uma
                var uMAs = await new UMAManagerUT().CreateDefaultAsync <UMA>(identityWorkId, instanceId);

                //Act
                var middlewareManager = new MiddlewareManager <UMA>(new BaseRecordManager <UMA>(), new UMAValidator());


                //Asserts
                //Get
                var result = (await middlewareManager
                              .GetByIdsAsync(uMAs.Select(p => p.ID).ToList(), identityWorkId)).First();

                try
                {
                    await middlewareManager.CreateAsync(new List <UMA>() { result }, identityWorkId);

                    Assert.True(false, "Debe de mandar una excepción por registro duplicado");
                }
                catch (CotorraException ex)
                {
                    Assert.Equal(9006, ex.ErrorCode);
                }
                catch
                {
                    Assert.True(true);
                }
            }
        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());
        }
예제 #16
0
            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());
            }
예제 #17
0
            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());
            }
예제 #18
0
            public async Task Should_Not_Create_Duplicate_DB_JobPosition_And_Get_ToValidate_Finally_do_Delete()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                var         middlewareManager = new MiddlewareManager <JobPosition>(new BaseRecordManager <JobPosition>(), new JobPositionValidator());
                List <Guid> lstIds            = new List <Guid>();
                var         identityWorkId    = Guid.NewGuid();

                try
                {
                    //Arrange
                    var JobPositions = new List <JobPosition>();
                    JobPositions.Add(new JobPosition()
                    {
                        ID           = Guid.NewGuid(),
                        Active       = true,
                        company      = identityWorkId,
                        Timestamp    = DateTime.UtcNow,
                        InstanceID   = identityWorkId,
                        Description  = "Supervisor de ventas general",
                        CreationDate = DateTime.Now,
                        Name         = "Supervisor de Ventas",
                        StatusID     = 1,
                    });
                    lstIds.Add(JobPositions.FirstOrDefault().ID);

                    //Act
                    await middlewareManager.CreateAsync(JobPositions, identityWorkId);

                    //Asserts
                    //Get
                    var result = await middlewareManager
                                 .GetByIdsAsync(JobPositions.Select(p => p.ID).ToList(), identityWorkId);

                    Assert.True(result.Any());

                    //Act
                    await middlewareManager.CreateAsync(JobPositions, identityWorkId);

                    Assert.True(false, "No debió de pasar");
                }
                catch (Exception ex)
                {
                    Assert.True(ex is CotorraException);
                    Assert.True((ex as CotorraException).ErrorCode.Equals(1002));
                }
            }
예제 #19
0
            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);
                }
            }
예제 #20
0
        public async Task Should_Create_Biweekly_UpdatePeriodDetail_Fail_FuturePeriodDetails_All()
        {
            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());

                //Update
                var finalDateToUpdate = periodDetails.FirstOrDefault(p => p.Number == 1).FinalDate;
                periodDetails.FirstOrDefault(p => p.Number == 2).InitialDate = finalDateToUpdate;
                await middlewareManagerPeriodDetails.UpdateAsync(periodDetails.ToList(), identityWorkId);

                Assert.True(false, "Se espera que no se pueda actualizar");
            }
            catch (Exception ex)
            {
                Assert.True(ex is CotorraException);
                Assert.True((ex as CotorraException).ErrorCode.Equals(8008));
            }
        }
        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);
        }
예제 #22
0
            public async Task Should_Fail_When_LowerLimit_is_less_than_zero()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var identityWorkId = Guid.NewGuid();
                var instanceId     = Guid.NewGuid();

                //create one uma
                var MonthlyIncomeTaxs = await new MonthlyEmploymentSubsidyManagerUT().CreateDefaultAsync <MonthlyEmploymentSubsidy>(identityWorkId, instanceId);

                //Act
                var middlewareManager = new MiddlewareManager <MonthlyEmploymentSubsidy>(new BaseRecordManager <MonthlyEmploymentSubsidy>(), new MonthlyEmploymentSubsidyValidator());


                //Asserts
                //Get
                var result = await middlewareManager
                             .GetByIdsAsync(MonthlyIncomeTaxs.Select(p => p.ID).ToList(), identityWorkId);

                Assert.True(null != result && result.Any());

                try
                {
                    await middlewareManager.CreateAsync(new List <MonthlyEmploymentSubsidy>() { result.FirstOrDefault() }, identityWorkId);

                    Assert.True(false, "Debe de mandar error");
                }
                catch (CotorraException ex)
                {
                    Assert.Equal(9006, ex.ErrorCode);
                }
                catch (Exception)
                {
                    //duplicated
                    Assert.True(true);
                }
            }
예제 #23
0
            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());
            }