public void RelatedEntityForeignNavigationPropertyBuilder_Build_ForeignKeyPropertyDefault_Test()
        {
            // Arrange
            var funcs                  = new FuncList <string, string>();
            var unitUnderTest          = new RelatedEntityForeignNavigationPropertyBuilder(funcs);
            var relatedEntityAttribute = new RelatedEntityForeignAttribute("Entity2", "Entity1", "Entity1Id");

            // Act
            var result = unitUnderTest.Build(relatedEntityAttribute);

            // Assert
            Assert.IsFalse(result.CustomData.TryGetValue(CsdlConstants.EAFRelatedEntityForeignKeyProperty, out object prop));
        }
        public void RelatedEntityForeignNavigationPropertyBuilder_Build_NullAttribute_Test()
        {
            // Arrange
            var funcs         = new FuncList <string, string>();
            var unitUnderTest = new RelatedEntityForeignNavigationPropertyBuilder(funcs);
            RelatedEntityForeignAttribute relatedEntityAttribute = null;

            // Act
            var result = unitUnderTest.Build(relatedEntityAttribute);

            // Assert
            Assert.IsNull(result);
        }
        public void RelatedEntityForeignNavigationPropertyBuilder_Build_ValidAttribute_Test()
        {
            // Arrange
            var funcs                  = new FuncList <string, string>();
            var unitUnderTest          = new RelatedEntityForeignNavigationPropertyBuilder(funcs);
            var relatedEntityAttribute = new RelatedEntityForeignAttribute("Entity2", "Entity1");

            // Act
            var result = unitUnderTest.Build(relatedEntityAttribute);

            // Assert
            Assert.IsTrue(result is CsdlNavigationProperty);
            Assert.AreEqual("self.Entity2", result.Type);
            Assert.AreEqual(CsdlConstants.NavigationProperty, result.Kind);
            Assert.IsTrue(result.IsCollection);
            Assert.IsTrue(result.Nullable);
        }
        public void RelatedEntityForeignNavigationPropertyBuilder_Build_ForeignKeyProperty_Test()
        {
            // Arrange
            var          funcs                  = new FuncList <string, string>();
            var          unitUnderTest          = new RelatedEntityForeignNavigationPropertyBuilder(funcs);
            const string filter                 = "A eq 1";
            const string displayCondition       = "B eq 2";
            var          relatedEntityAttribute = new RelatedEntityForeignAttribute("Entity2", "Entity1", "CustomProp")
            {
                Filter = filter, DisplayCondition = displayCondition
            };

            // Act
            var result = unitUnderTest.Build(relatedEntityAttribute);

            // Assert
            Assert.IsTrue(result.CustomData.TryGetValue(CsdlConstants.EAFRelatedEntityForeignKeyProperty, out object prop));
            Assert.AreEqual(prop, "CustomProp");
            Assert.IsTrue(result.CustomData.TryGetValue(CsdlConstants.OdataFilter, out object odataFilter));
            Assert.AreEqual(odataFilter, filter);
            Assert.IsTrue(result.CustomData.TryGetValue(CsdlConstants.OdataDisplayCondition, out object odataDisplayCondition));
            Assert.AreEqual(odataDisplayCondition, displayCondition);
        }
 internal async Task <List <RelatedEntity> > GetRelatedMappingEntitiesByAttribute(IEnumerable <TInterface> entities, RelatedEntityForeignAttribute a)
 {
     //IMappingEntityClientAsync mapClient;
     //var key = $"{a.MappingEntity}:{a.RelatedEntity}:{a.Entity}";
     //if (!MappingClientsCache.TryGetValue(key, out mapClient))
     //{
     //    mapClient = new MappingEntityClientAsync(a.MappingEntity, a.RelatedEntity, a.Entity);
     //    MappingClientsCache.Add(key, mapClient);
     //}
     //var entityIds = entities.Select(e => e.Id.ToString());
     //var mappingsJson = await mapClient.GetByE2IdsAsync(entityIds, $"$expand={a.RelatedEntity}");
     //var mappingsList = JsonConvert.DeserializeObject<List<RelatedEntity>>(mappingsJson);
     //return mappingsList;
     return(null);
 }
Beispiel #6
0
 public static CsdlNavigationProperty ToNavigationProperty(this RelatedEntityForeignAttribute relatedEntityAttribute, string schemaOrAlias = CsdlConstants.DefaultSchemaOrAlias, CustomPropertyDataFuncs CustomPropertyDataFuncs = null)
 {
     CustomPropertyDataFuncs = CustomPropertyDataFuncs ?? new CustomPropertyDataFuncs();
     return(new RelatedEntityForeignNavigationPropertyBuilder(CustomPropertyDataFuncs).Build(relatedEntityAttribute, schemaOrAlias));
 }