public void use_congrete_generic_repository_classes_no_MEF_and_read_create_records() { GenericEntityRepository <JarsJob, IDataContextNhJars> jarsRepo = new GenericEntityRepository <JarsJob, IDataContextNhJars>(new DataContextNhJars()); //GenericEntityRepository<ExternalJobHeader, IDataContextNhExternal> extRepo = new GenericEntityRepository<ExternalJobHeader, IDataContextNhExternal>(new DataContextExternalNh()); Assert.IsNotNull(jarsRepo); // Assert.IsNotNull(extRepo); IList <JarsJob> jarsJobs = jarsRepo.GetAll(); Assert.IsTrue(jarsJobs != null); //IList<ExternalJobHeader> extHeads = extRepo.GetAll(); // Assert.IsTrue(extHeads != null); //greate a record JarsJob jj = jarsRepo.CreateUpdate(new JarsJob(), "CONC_GENREP_TEST"); Assert.IsTrue(jj.Id > 0); // ExternalJobHeader xj = extRepo.CreateUpdate(new ExternalJobHeader(), "CONC_GENREP_TEST"); // Assert.IsTrue(xj.Id > 0); //get a record from each repository JarsJob job = jarsRepo.GetById((long)1); Assert.IsTrue(job.Id == 1); // ExternalJobHeader header = extRepo.GetById(1); // Assert.IsTrue(header.Id == 1); }
public void AssignRulesToEntities() { JarsResource resource = FakeDataHelper.FakeResources[0]; JarsJob testJob = FakeDataHelper.FakeJarsJobs[1]; //set up a rule for a target entity where target entity can not be changed IJarsRule singleEntityRule = JarsRulePopupForm.AddRuleOnEntity(resource, testJob.GetType()); Assert.IsTrue(!string.IsNullOrEmpty(singleEntityRule.TargetCriteriaString)); ////set up a rule for an entity type instead of a certain entity //IEntityRule singleTypeRule = EntityRuleForm.AddRuleOnEntity(resource); //Assert.IsTrue(singleTypeRule.TargetTypeName == typeof(Resource).Name && singleTypeRule.SourceTypeName == typeof(Resource).Name); ////set up a rule for an entity type that relies on values from another entity type //IEntityRule linkedTypeRule = EntityRuleForm.AddRuleOnEntity(resource, typeof(JarsJob)); //Assert.IsTrue(linkedTypeRule.TargetTypeName == typeof(Resource).Name // && linkedTypeRule.SourceTypeName == typeof(JarsJob).Name // && !string.IsNullOrEmpty(linkedTypeRule.SourceCriteriaString) // && !string.IsNullOrEmpty(linkedTypeRule.TargetCriteriaString)); singleEntityRule = JarsRulePopupForm.EditRuleOnEntity(resource, singleEntityRule); Assert.IsTrue(!string.IsNullOrEmpty(singleEntityRule.TargetCriteriaString)); }
public void Create_Jobs_Base_and_QL() { //IJobRepository rep = _repFactory.GetDataRepository<IJobRepository>(); IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>(); for (int i = 0; i < 100; i++) { JarsJob baseJob = new JarsJob { StartDate = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)), EndDate = DateTime.Now, Description = $"IJobBase Job {i}", Location = $" IJobBase from QL job {i}", //AdditionalJobProperty = $"This {i}" }; JarsJob jobQl = new JarsJob { StartDate = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)), EndDate = DateTime.Now, Description = $"QL Job {i}", Location = $"Test QL {i}" }; nhRep.CreateUpdate(baseJob, "DataCRUDTest"); Assert.AreNotEqual(baseJob.Id, 0); nhRep.CreateUpdate(jobQl, "DataCRUDTest"); Assert.AreNotEqual(jobQl.Id, 0); } }
/// <summary> /// Generate a new job from the External job information /// </summary> /// <param name="jex">The External job information used to generate the basic job details.</param> /// <returns></returns> public JarsJob CreateJarsEntityFromExternalEntity(IExternalEntityBase <int> jex) { JarsJob job = new JarsJob(); job.Location = jex.Location; job.Description = jex.Description; job.ExtRefId = jex.ExtRefId; job.LineOfWork = jex.LineOfWork; job.TargetDate = jex.TargetDate; return(job); }
public void LinqQueryBuilder_select_data_test_with_nHibernate_Eager() { JarsJob jj = new JarsJob(); var _repository = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> >(); Expression <Func <JarsJob, bool> > query = null; bool hasWhere = false; int Id = 1; string ExtRefId = "11"; //Id if (Id != 0) { query = LinqExpressionBuilder.True <JarsJob>().And(j => j.Id == Id); hasWhere = true; } //ExtRefId if (ExtRefId != "0") { if (!hasWhere) { query = LinqExpressionBuilder.True <JarsJob>().And(j => j.ExtRefId == ExtRefId); hasWhere = true; } else { query.And(j => j.ExtRefId == ExtRefId); } } var res = _repository.Where(query, true); Assert.IsNotNull(res); int[] ids = new[] { 1, 2, 3 }; query = LinqExpressionBuilder.True <JarsJob>().And(j => ids.ToList().Contains(j.Id)); var rIn = _repository.Where(query, true); Assert.IsNotNull(rIn); string[] refs = new[] { "11", "33", "55" }; query = LinqExpressionBuilder.True <JarsJob>().And(j => j.LineOfWork.Like("MU%")); var rLike = _repository.Where(query, true); Assert.IsNotNull(rLike); }
public void Create_JarsJobs_Service() { var client = CreateClient(); JarsJob jj = new JarsJob { Description = $"Test Jars Job 0", Location = $"Test Location JarsJob 0", ExtRefId = "0", StatusKey = "0", LabelKey = "0", CreatedBy = $"TEST 0" }; jj.JobLines.Add(new JarsJobLine { ShortDescription = $"Test JarsJobLine on Job 0", LineNum = 1, LineCode = "CODE0", OriginalQty = 0 }); List <JarsJob> jjl = new List <JarsJob>(); for (int i = 1; i <= 5; i++) { JarsJob jji = new JarsJob { Description = $"Test Jars Job {i}", Location = $"Test Location JarsJob {i}", ExtRefId = i.ToString(), StatusKey = $"{i}", LabelKey = $"{i}", CreatedBy = $"TEST {i}" }; jji.JobLines.Add(new JarsJobLine { ShortDescription = $"Test JarsJobLine on Job {i}", LineNum = 1, LineCode = "CODE1", OriginalQty = i }); jjl.Add(jji); } //store only takes Full jobs var rs = client.Post(new StoreJobs { Jobs = new List <JarsJobDto>(new[] { jj.ConvertTo <JarsJobDto>() }) }); Assert.IsTrue(rs.Jobs[0].Id > 0); rs = client.Post(new StoreJobs { Jobs = jjl.ConvertAllTo <JarsJobDto>().ToList() }); Assert.IsTrue(rs.Jobs.Count > 0); var rg = client.Get(new GetJarsJob { Id = 1 }); Assert.IsTrue(rg.Jobs != null); rg = client.Get(new GetJarsJob { Id = 1 }); Assert.IsTrue(rg.Jobs != null); }
public void Create_Resource_Jobs_Attachment_and_Lines() { IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>(); //create op for (int i = 0; i < 5; i++) { JarsResource res = new JarsResource { DisplayName = $"Test{i}", ExtRef1 = $"T00{i}", IsActive = true, Skills = new List <JarsResourceSkill> { new JarsResourceSkill { MaxLevel = 10, Description = "Test Skill", DocumentCode = $"SK0{i}T" } }, MobileNo = $"0{i}234{i}2312{i}" }; //res = resrep.CreateUpdate(res, "TEST"); JarsJobAttachment ja = new JarsJobAttachment { Name = "Attach Test" }; JarsJob baseJob = new JarsJob { StartDate = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)), EndDate = DateTime.Now, Description = $"IJob Job{i}", Location = $" IJob for Testing job {i}", ExtRefId = $"0{i}{i}{i}", ResourceId = res.Id }; baseJob.Attachments.Add(ja); JarsJobLine line = new JarsJobLine { Resource = res, LineCode = $"TEST0{i}", OriginalQty = 1, LineNum = 1, ExternalJobRef = baseJob.ExtRefId }; baseJob.JobLines.Add(line); nhRep.CreateUpdate(baseJob, "TEST_LOOP"); } }
public void Convert_To_Test() { //see if all properties are changed simpleJob sj = new simpleJob(); sj.ActualStartDate = DateTime.Now.AddDays(-0.5); sj.ActualEndDate = DateTime.Now.AddDays(-1); //see if only passes properties are changed JarsJob job = FakeDataHelper.FakeJarsJobs[0]; job.LabelKey = "6"; job.StatusKey = "6"; sj = job.ConvertTo(sj); Assert.IsTrue(job.ActualStartDate == sj.ActualStartDate); }
void use_repository_factory_to_get_non_generic_repositories_and_create_record() { IJarsJobRepository jarsRep = _repFactory.GetDataRepository <IJarsJobRepository>(); Assert.IsNotNull(jarsRep); //Assert.IsNotNull(qlRep); //test create JarsJob jj = jarsRep.CreateUpdate(new JarsJob(), "NONGEN_FACT_TEST"); Assert.IsTrue(jj.Id > 0); //test read jj = jarsRep.GetById((long)1); Assert.IsTrue(jj.Id == 0); }
public void Populate_With_Test() { simpleJob sj = new simpleJob(); sj.ActualStartDate = DateTime.Now.AddDays(-0.8); sj.ActualEndDate = DateTime.Now.AddDays(-1); //see if only passes properties are changed JarsJob job = FakeDataHelper.FakeJarsJobs[0]; job.LabelKey = "6"; job.Priority = "10"; job = job.PopulateWith(sj); Assert.IsTrue(job.ActualStartDate == sj.ActualStartDate); }
public void Get_SubList_properties_and_types() { JarsJob job = FakeDataHelper.FakeJarsJobs[0]; IList <Type> jarsTypes = job.GetGenericListTypes(); Assert.AreNotEqual(0, jarsTypes.Count); //QLJob qlJob = FakeDataHelper.FakeQLJobs[0]; //IList<Type> qlTypes = job.GetGenericListTypes(); //Assert.AreNotEqual(0, qlTypes.Count); IList <Type> oneSubs = FakeDataHelper.FakeUserAccount.GetGenericListTypes(); Assert.AreNotEqual(0, oneSubs.Count); //IList<Type> noSubs = FakeDataHelper.FakeExternalLines[0].GetGenericListTypes(); //Assert.AreEqual(0, noSubs.Count); }
public void obtain_generic_repository_using_MEF_and_read_and_create_records() { //now only using mef test the obtainment IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> jarsRep = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> >(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> extRep = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); //assert creation //Assert.IsNotNull(qlRep); Assert.IsNotNull(jarsRep); Assert.IsNotNull(extRep); //list the jobs from each repository IList <JarsJob> jarsJobs = jarsRep.GetAll(); Assert.IsTrue(jarsJobs != null); IList <BOSEntity> extHeads = extRep.GetAll(); Assert.IsTrue(extHeads != null); //greate a record JarsJob jj = jarsRep.CreateUpdate(new JarsJob(), "MEF_GEN_TEST"); Assert.IsTrue(jj.Id > 0); BOSEntity xj = extRep.CreateUpdate(new BOSEntity(), "MEF_GEN_TEST"); Assert.IsTrue(xj.Id > 0); //get a record from each repository JarsJob job = jarsRep.GetById((long)1); Assert.IsTrue(job.Id == 1); BOSEntity header = extRep.GetById(1); Assert.IsTrue(header.Id == 1); }
public void use_congrete_repository_classes_no_MEF_and_read_create_records() { JarsJobRepository jarsRepo = new JarsJobRepository(new DataContextNhJars()); Assert.IsNotNull(jarsRepo); IList <JarsJob> jarsJobs = jarsRepo.GetAll(); Assert.IsTrue(jarsJobs != null); //greate a record JarsJob jj = jarsRepo.CreateUpdate(new JarsJob(), "CONC_REP_TEST"); Assert.IsTrue(jj.Id > 0); //get a record from each repository JarsJob job = jarsRepo.GetById((long)1); Assert.IsTrue(job.Id == 1); }