Beispiel #1
0
        public void Find_IndirectAttributeByEntityAndPropertyName_MatchesLambdaResult()
        {
            var target = new EntityDefinition(
                new DataAnnotationsDefinitionProvider(),
                new EntityReference {
                EntityType = typeof(DomainAggregateRow)
            });

            // Test that the behavior of Find with an AttributeLocation is the same of that with a LambdaExpression.
            var expected = target.Find(CreateExpression <DomainAggregateRow, string>(item => item.SubContainer.Name));
            var actual   = target.Find("SubContainer", "Name");

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void Find_RelatedAttributeAliasedEntity_MatchesExpected()
        {
            var entityReference = new EntityReference {
                EntityType = typeof(ChildRaisedRow)
            };
            var definitionProvider = new DataAnnotationsDefinitionProvider();
            var target             = new EntityDefinition(definitionProvider, entityReference);

            var relationReference = new EntityReference {
                EntityType = typeof(SubRow), EntityAlias = "SubEntity"
            };
            var attributeLocation = definitionProvider.GetEntityLocation(relationReference);
            var attributePath     = new LinkedList <EntityLocation>();

            attributePath.AddLast(attributeLocation);
            var expected = new EntityAttributeDefinition(
                attributePath,
                relationReference.EntityType.GetProperty(nameof(SubRow.FakeSubEntityId), BindingFlags.Public | BindingFlags.Instance),
                nameof(SubRow.FakeSubEntityId),
                EntityAttributeTypes.RelatedAutoNumberKey,
                1,
                $"SubEntity.{nameof(SubRow.FakeSubEntityId)}");

            var actual = target.Find(CreateExpression <ChildRaisedRow, int>(row => row.ComplexEntity.SubEntity.FakeSubEntityId));

            Assert.AreEqual(expected, actual, string.Join(Environment.NewLine, expected.GetDifferences(actual)));
        }
Beispiel #3
0
        public void IsUpdateable_IndirectUpdateableAttribute_ReturnsFalse()
        {
            var target = new EntityDefinition(
                new DataAnnotationsDefinitionProvider(),
                new EntityReference {
                EntityType = typeof(DomainAggregateRow)
            });

            var actual = target.IsUpdateable(target.Find(CreateExpression <DomainAggregateRow, string>(row => row.SubContainer.Name)));

            Assert.IsFalse(actual);
        }
Beispiel #4
0
        public void IsUpdateable_DirectIdentityAttribute_ReturnsFalse()
        {
            var target = new EntityDefinition(
                new DataAnnotationsDefinitionProvider(),
                new EntityReference {
                EntityType = typeof(DomainAggregateRow)
            });

            var actual = target.IsUpdateable(target.Find(CreateExpression <DomainAggregateRow, int>(row => row.DomainAggregateId)));

            Assert.IsFalse(actual);
        }