public void Test_NewDefinition_GetEntitiesUsingInstancesOfType() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("instancesOfType.{alias,name,description}"); var svc = GetService(); // Check before create var result = svc.GetEntityData(new EntityRef("core:definition"), request); int count = result.Relationships[0].Instances.Count; Assert.IsTrue(count > 1); // Create the instance using (var ctx = DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { Create("core:definition", "Our test defn"); ctx.CommitTransaction(); } // Check after create var result2 = svc.GetEntityData(new EntityRef("core:definition"), request); int count2 = result2.Relationships[0].Instances.Count; Assert.AreEqual(count + 1, count2); }
public void Test_AfterDeleteRelated_Forward() { var from = Create("test:allFields"); var to = Create("test:herb"); from.GetRelationships("test:herbs").Add(to); from.Save(); EntityMemberRequest request = EntityRequestHelper.BuildRequest("id, test:herbs.id"); var svc = GetService(); // Check create EntityData result = svc.GetEntityData(from.Id, request); Assert.AreEqual(from.Id, result.Id.Id, "Expect from"); Assert.AreEqual(to.Id, result.Relationships[0].Instances[0].Entity.Id.Id, "Expect to"); // Delete Entity.Delete(to.Id); // Check deleted result = svc.GetEntityData(from.Id, request); Assert.AreEqual(from.Id, result.Id.Id, "Expect from again"); Assert.AreEqual(0, result.Relationships[0].Instances.Count, "Expect no to"); }
public void Test_NewHerbByAlias_GetEntitiesUsingInstancesOfType() { EntityRef typeId = new EntityRef("test:herb"); EntityMemberRequest request = EntityRequestHelper.BuildRequest("instancesOfType.{alias,name,description}"); var svc = GetService(); // Check before create var result = svc.GetEntityData(typeId, request); int count = result.Relationships[0].Instances.Count; Assert.IsTrue(count > 1); // Create the instance var entity = Entity.Create(typeId); entity.SetField("core:name", "AAA"); _toDelete.Add(entity); using (var ctx = DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { entity.Save(); ctx.CommitTransaction(); } // Check after create var result2 = svc.GetEntityData(typeId, request); int count2 = result2.Relationships[0].Instances.Count; Assert.AreEqual(count + 1, count2); }
public void Test_NewInstance_GetEntitiesByType() { if (_runner == "EntityInfoService") { Assert.Ignore(); } var typeId = Entity.GetId("test:herb"); EntityMemberRequest request = EntityRequestHelper.BuildRequest("id"); var svc = GetService(); // Check before create var result = svc.GetEntitiesByType(typeId, false, request); int count = result.Count(); // Create the instance Create("test:herb", "AAA"); // Check after create result = svc.GetEntitiesByType(typeId, false, request); int count2 = result.Count(); Assert.AreEqual(count + 1, count2); }
public void Test_NewInstance_GetInstancesOfTypeManual() { if (_runner == "EntityInfoService") { Assert.Ignore(); } var typeId = Entity.GetId("test:herb"); EntityMemberRequest request = EntityRequestHelper.BuildRequest("instancesOfType.id"); var svc = GetService(); // Check before create EntityData result = svc.GetEntityData(typeId, request); int count = result.Relationships[0].Instances.Count; // Create the instance using (var ctx = DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { Create("test:herb", "AAA"); ctx.CommitTransaction(); } // Check after create result = svc.GetEntityData(typeId, request); int count2 = result.Relationships[0].Instances.Count; Assert.AreEqual(count + 1, count2); }
public void RelationTwoFields() { var rq = EntityRequestHelper.BuildRequest("isOfType.{name,description}"); Assert.IsTrue(rq.Relationships.Count == 1); Assert.IsTrue(rq.Relationships[0].RequestedMembers.Fields.Count == 2); }
public void TwoStringFields() { var request = "name, description"; var rqObj = EntityRequestHelper.BuildRequest(request); var res = BulkRequestSqlBuilder.BuildSql(rqObj); }
public void CreateInstance( ) { // Define a new entity var data = new EntityData { Fields = new List <FieldData>( ), TypeIds = new EntityRef("test", "person").ToEnumerable( ).ToList( ) }; data.Fields.Add(new FieldData { FieldId = new EntityRef("name"), Value = new TypedValue("Isaac Newton") }); // Create it var svc = new EntityInfoService( ); EntityRef id = svc.CreateEntity(data); // Verify it was created Assert.IsTrue(id.Id > 0, "Positive Id"); // Select the data EntityMemberRequest request = EntityRequestHelper.BuildRequest("name"); EntityData result = svc.GetEntityData(id, request); // Verify results Assert.AreEqual("Isaac Newton", result.Fields[0].Value.Value); svc.DeleteEntity(id); }
public void ForwardRelationship() { var request = "name, maxInt, isOfType.{name, description}"; var rqObj = EntityRequestHelper.BuildRequest(request); var res = BulkRequestSqlBuilder.BuildSql(rqObj); }
public void Test_AfterFieldChangeFromNull_GetField() { var entity = Create("test:allFields", "AAA"); EntityMemberRequest request = EntityRequestHelper.BuildRequest("test:afString"); var svc = GetService(); // Check create EntityData result = svc.GetEntityData(entity.Id, request); Assert.AreEqual(entity.Id, result.Id.Id, "Expect created"); Assert.AreEqual(null, result.Fields[0].Value.ValueString); // Change field entity.SetField("test:afString", "ZZZ"); using (var ctx = DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { entity.Save(); ctx.CommitTransaction(); } // Check updated result = svc.GetEntityData(entity.Id, request); Assert.AreEqual("ZZZ", result.Fields[0].Value.ValueString); }
public void StringFieldAndIntField() { var request = "name, maxInt"; var rqObj = EntityRequestHelper.BuildRequest(request); var res = BulkRequestSqlBuilder.BuildSql(rqObj); }
public void TestRecursiveRelationship3() { EntityMemberRequest rq = EntityRequestHelper.BuildRequest(@" relationships.fromType.inherits*.id, inherits*.id " ); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("test", "employee"), rq); // Note: this test causes some instances to be revisited for the same relationship, // and can be used to ensure that multiple entries do not appear in the RelationshipData array. EntityData p1 = result.GetRelationship("core:inherits").Instances[0].Entity; // person #pragma warning disable 168 int k1 = p1.GetRelationship("core:relationships").Instances.Count(); EntityData p2 = p1.GetRelationship("core:inherits").Instances[0].Entity; // actor int k2 = p2.GetRelationship("core:relationships").Instances.Count(); EntityData p3 = p2.GetRelationship("core:inherits").Instances[0].Entity; // editable resource int k3 = p3.GetRelationship("core:relationships").Instances.Count(); EntityData p4 = p3.GetRelationship("core:inherits").Instances[0].Entity; // resource int k4 = p4.GetRelationship("core:relationships").Instances.Count(); #pragma warning restore 168 Assert.IsTrue(k4 > 0); }
public void Star() { var rq = EntityRequestHelper.BuildRequest("*", RequestParserSettings.NoVerify); Assert.IsTrue(rq.AllFields); Assert.IsTrue(rq.Relationships.Count == 0, "Relationships"); }
public void Test_SameRelInFwdAndRev(string requestString, string metadataOnlyDir) { EntityMemberRequest request = EntityRequestHelper.BuildRequest("id"); var svc = GetService(); var resource = new EntityRef("core", "chart"); // get 'isOfType' relationship Id long relId = Entity.GetId("core:isOfType"); Assert.IsTrue(relId > 0); // build request string to get relationship fields in fwd direction and then metaData for the same relationship in reverse direction var relRequestString = string.Format(requestString, relId); EntityMemberRequest relRequest = EntityRequestHelper.BuildRequest(relRequestString); EntityData result = svc.GetEntityData(resource, relRequest); if (metadataOnlyDir == "fwd") { Assert.IsTrue(!result.GetRelationship(relId, Direction.Forward).Entities.Any()); Assert.IsTrue(result.GetRelationship(relId, Direction.Reverse).Entities.Any()); } else { Assert.IsTrue(result.GetRelationship(relId, Direction.Forward).Entities.Any()); Assert.IsTrue(!result.GetRelationship(relId, Direction.Reverse).Entities.Any()); } }
public void Variables_TwoDependentVariables() { var rq = EntityRequestHelper.BuildRequest("let @VAR1 = { rel12.@VAR2, field1 } let @VAR2 = { rel21.@VAR1, field2 } @VAR1", RequestParserSettings.NoVerify); var var1rq = rq; Assert.That(var1rq, Is.Not.Null); Assert.That(var1rq, Has.Property("Relationships").Count.EqualTo(1)); Assert.That(var1rq, Has.Property("Fields").Count.EqualTo(1)); Assert.That(var1rq.Fields[0].Alias, Is.EqualTo("field1")); var rel12 = rq.Relationships[0]; var var2rq = rel12.RequestedMembers; Assert.That(rel12.RelationshipTypeId.Alias, Is.EqualTo("rel12")); Assert.That(var2rq, Has.Property("Relationships").Count.EqualTo(1)); Assert.That(var2rq, Has.Property("Fields").Count.EqualTo(1)); Assert.That(var2rq.Fields[0].Alias, Is.EqualTo("field2")); var rel21 = var2rq.Relationships[0]; var var1rqB = rel21.RequestedMembers; Assert.That(rel21.RelationshipTypeId.Alias, Is.EqualTo("rel21")); Assert.That(var1rqB, Is.EqualTo(var1rq)); }
public void TestTempDeletedChildItemIgnored( ) { var svc = new EntityInfoService( ); EntityRef orgRef = null; try { var o = new Report { Name = "org rpt", Alias = "shared:a" + Guid.NewGuid( ) }; var b = new ReportColumn { Name = "bob", Alias = "shared:a" + Guid.NewGuid( ), ColumnForReport = o }; EntityData result = svc.GetEntityData(b, EntityRequestHelper.BuildRequest("name, columnForReport.name")); result.Relationships[0].Instances[0].DataState = DataState.Delete; orgRef = svc.CreateEntity(result); } finally { if (orgRef != null) { Entity.Delete(orgRef); } } }
public void ForwardRelationshipIdOnly() { var request = "isOfType.id"; var rqObj = EntityRequestHelper.BuildRequest(request); var res = BulkRequestSqlBuilder.BuildSql(rqObj); }
public void Test_AfterAddAtomicRelated_Reverse() { var to = Create("test:herb"); EntityMemberRequest request = EntityRequestHelper.BuildRequest("id, test:herbAllFields.id"); var svc = GetService(); // Check absent EntityData result = svc.GetEntityData(to.Id, request); Assert.AreEqual(to.Id, result.Id.Id, "Expect to"); Assert.AreEqual(0, result.Relationships[0].Instances.Count, "Expect no from"); // Add relationship var from = CreateNoSave("test:allFields"); from.GetRelationships("test:herbs").Add(to); using (var ctx = DatabaseContext.GetContext(true, preventPostSaveActionsPropagating: true)) { from.Save(); ctx.CommitTransaction(); } // Check add relationship result = svc.GetEntityData(to.Id, request); Assert.AreEqual(to.Id, result.Id.Id, "Expect to again"); Assert.AreEqual(from.Id, result.Relationships[0].Instances[0].Entity.Id.Id, "Expect from"); }
public void TestId() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("id"); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("test", "employee"), request); Assert.IsTrue(result.Id.Id > 0); }
public void TestRelatedMetadata() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("fields.?"); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("test", "employee"), request); Assert.IsTrue(result.Relationships[0].Instances.Count == 0); }
public void TwoRelationTwoFields() { var rq = EntityRequestHelper.BuildRequest("{isOfType,whatever}.{name,description} /* with a comment */", RequestParserSettings.NoVerify); Assert.IsTrue(rq.Relationships.Count == 2); Assert.IsTrue(rq.Relationships[0].RequestedMembers.Fields.Count == 2); Assert.IsTrue(rq.Relationships[1].RequestedMembers.Fields.Count == 2); }
public void TestRelationshipDirections() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("inherits.id,derivedTypes.id"); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("test", "person"), request); Assert.AreEqual(2, result.Relationships.Count); }
public void Test_InvalidZeroList() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("name"); var svc = GetService(); var result = svc.GetEntitiesData((new EntityRef(0)).ToEnumerable(), request); Assert.AreEqual(0, result.Count()); }
public void Test_InvalidAlias() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("name"); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("invalidblah", "invalidblah"), request); Assert.IsNull(result); }
public void Variables_Simple() { var rq = EntityRequestHelper.BuildRequest("let @VAR = {name} @VAR", RequestParserSettings.NoVerify); Assert.That(rq, Is.Not.Null); Assert.That(rq, Has.Property("Relationships").Empty); Assert.That(rq, Has.Property("Fields").Count.EqualTo(1)); Assert.That(rq.Fields[0].Alias, Is.EqualTo("name")); }
public void Test_GetFieldsRelationshipsControlsStructuredQueryString( ) { EntityMemberRequest request = EntityRequestHelper.BuildRequest("k:context.name"); var svc = new EntityInfoService( ); EntityData result = svc.GetEntityData(new EntityRef("console", "singleLineTextControl"), request); Assert.IsNotNull(FindEntity(result, new EntityRef("console", "uiContextHtml").Id)); }
public void SimpleAliasRelation() { var rq = EntityRequestHelper.BuildRequest("isOfType.name"); Assert.IsTrue(rq.Relationships.Count == 1); Assert.AreEqual("isOfType", rq.Relationships[0].RelationshipTypeId.Alias); Assert.IsFalse(rq.Relationships[0].IsReverse); Assert.IsTrue(rq.Relationships[0].RequestedMembers.Fields.Count == 1); }
public void TestFollowSameRelationshipTwice() { EntityMemberRequest request = EntityRequestHelper.BuildRequest("isOfType.isOfType.id,isOfType.isOfType.id"); var svc = GetService(); EntityData result = svc.GetEntityData(new EntityRef("test", "employee"), request); Assert.IsTrue(result.Relationships[0].Instances.Count == 1); Assert.IsTrue(result.Relationships[0].Instances[0].Entity.Relationships[0].Instances.Count == 1); }
public void ReportBuilderQueryTest3() { var rq = EntityRequestHelper.BuildRequest(@" name, alias, fieldInGroup.{name,alias}, isOfType.{alias,readiNowType}, {toType,fromType}.name"); }
public void ReverseIdRelation() { var rq = EntityRequestHelper.BuildRequest("-#123.name", RequestParserSettings.NoVerify); Assert.IsTrue(rq.Relationships.Count == 1); Assert.AreEqual(123, rq.Relationships[0].RelationshipTypeId.Id); Assert.IsTrue(rq.Relationships[0].IsReverse); Assert.IsTrue(rq.Relationships[0].RequestedMembers.Fields.Count == 1); }