Exemplo n.º 1
0
        public void EqualAnnotationsAreInsertedJustOnce()
        {
            var args1 = new List <KeyValuePair <string, dynamic> >();

            args1.Add(new KeyValuePair <string, dynamic>("key", "value"));
            Annotation annotation12 = new TraitAnnotation("value", args1);

            var args2 = new List <KeyValuePair <string, dynamic> >();

            args2.Add(new KeyValuePair <string, dynamic>("key", "value"));
            Annotation annotation22 = new TraitAnnotation("value", args2);

            var res = annotation12 == annotation22;


            var column = new Column("name", null);

            Annotation annotation1 = new TraitAnnotation("value");
            Annotation annotation2 = new TraitAnnotation("value");

            column.Annotations.Add(annotation1);
            column.Annotations.Add(annotation2);

            Assert.Single(column.Annotations);
        }
Exemplo n.º 2
0
        public void EqualAnnotationsAreInsertedJustOnce()
        {
            var table = new Table("name");

            var annotation1 = new TraitAnnotation("something");
            var annotation2 = new TraitAnnotation("something");

            table.Annotations.Add(annotation1);
            table.Annotations.Add(annotation2);

            Assert.Single(table.Annotations);
        }
Exemplo n.º 3
0
        public void CdmEntityDefinitionAttributeHasTraitWithNoArguments()
        {
            var generator  = BuildCdmEntityGenerator();
            var annotation = new TraitAnnotation("Customer");
            var table      = new Table("Customer")
                             .WithColumn("ID", SqlDbType.Int, annotation: annotation);

            var entity = generator.GenerateEntity(table);
            var traits = entity.Attributes.First().AppliedTraits;
            var trait  = traits.Single();

            Assert.Empty(trait.Arguments);
        }
Exemplo n.º 4
0
        public void CdmEntityDefinitionAttributeHasSingleTrait()
        {
            var generator  = BuildCdmEntityGenerator();
            var annotation = new TraitAnnotation("something");
            var table      = new Table("Customer")
                             .WithColumn("ID", SqlDbType.Int, annotation: annotation);

            var entity = generator.GenerateEntity(table);
            var traits = entity.Attributes.First().AppliedTraits;

            Assert.NotNull(traits);
            Assert.Single(traits);
        }
Exemplo n.º 5
0
        public void Process(TraitAnnotation annotation)
        {
            string            traitName = annotation.Value;
            CdmTraitReference trait     = corpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, traitName, false);

            foreach (var argument in annotation.Arguments)
            {
                if (argument.Value != null)
                {
                    trait.Arguments.Add(argument.Key, argument.Value);
                }
            }

            entityDefinition.ExhibitsTraits.Add(trait);
        }
Exemplo n.º 6
0
        public void CdmEntityDefinitionAttributeHasTraitContainsSingleArgument()
        {
            var generator  = BuildCdmEntityGenerator();
            var annotation = new TraitAnnotation("something");
            var table      = new Table("Customer")
                             .WithColumn("ID", SqlDbType.Int, annotation: annotation);

            annotation.AddArgument("key", "value");

            var entity = generator.GenerateEntity(table);
            var traits = entity.Attributes.First().AppliedTraits;
            var trait  = traits.Single();

            Assert.Single(trait.Arguments);
        }
Exemplo n.º 7
0
        public void CdmEntityDefinitionAttributeHasTraitContainsArgument(string key, dynamic value)
        {
            var generator  = BuildCdmEntityGenerator();
            var annotation = new TraitAnnotation("something");
            var table      = new Table("Customer")
                             .WithColumn("ID", SqlDbType.Int, annotation: annotation);

            annotation.AddArgument(key, value);

            var entity   = generator.GenerateEntity(table);
            var traits   = entity.Attributes.First().AppliedTraits;
            var argument = traits.Single().Arguments.Single();

            Assert.Equal(key, argument.Name);
            Assert.Equal(value, argument.Value);
        }