Exemplo n.º 1
0
        public void it_can_create_an_embedded_representation()
        {
            var builder = _template.ToRepresentation(_person);

            Assert.IsInstanceOf <EmbeddedRepresentationBuilder>(builder);

            var entity = builder.WithRel("rel").Build();

            Assert.That(entity.Rel.Single(), Is.EqualTo("rel"));
            Assert.That(entity.Properties["id"], Is.EqualTo(_person.Id));
            Assert.That(entity.Properties["name"], Is.EqualTo(_person.Name));
            Assert.That(entity.Properties["date.of.birth"], Is.EqualTo(_person.DateOfBirth));
        }
Exemplo n.º 2
0
        public void Test()
        {
            var items = new List <Person>
            {
                new Person(Guid.NewGuid(), "", DateTime.UtcNow),
                new Person(Guid.NewGuid(), "", DateTime.UtcNow),
                new Person(Guid.NewGuid(), "", DateTime.UtcNow)
            };

            var template = new PersonEntityTemplate();

            var entity = template
                         .ToEntity(items.First())
                         .WithClass("person")
                         .WithClass("collection")
                         .WithProperty("count", items.Count);

            foreach (var item in items)
            {
                entity.WithSubEntity(template.ToRepresentation(item).WithRel("item"));
            }

            entity.Build();
        }