Esempio n. 1
0
        public void ShouldBuildANonResource()
        {
            var model = new List <int>();

            serializer.Setup(s => s.Serialize(model)).Returns("some list of integers");

            var builder        = new RestfulieMarshaller(relationsFactory.Object, serializer.Object, hypermedia.Object);
            var representation = builder.Build(model, requestInfo.Object);

            serializer.VerifyAll();
            Assert.AreEqual("some list of integers", representation);
        }
Esempio n. 2
0
        public void ShouldBuildResourceRepresentation()
        {
            var resource = new SomeResource();

            serializer.Setup(s => s.Serialize(resource)).Returns(SerializedResource());
            hypermedia.Setup(h => h.Inject(SerializedResource(), relations.Object, requestInfo.Object)).Returns(HypermediaResource());

            var builder        = new RestfulieMarshaller(relationsFactory.Object, serializer.Object, hypermedia.Object);
            var representation = builder.Build(resource, requestInfo.Object);

            serializer.VerifyAll();
            hypermedia.VerifyAll();

            Assert.AreEqual(HypermediaResource(), representation);
        }
Esempio n. 3
0
        public void ShouldBuildListRepresentation()
        {
            var resources = new List <IBehaveAsResource> {
                new SomeResource(), new SomeResource()
            };

            hypermedia.Setup(h => h.Inject(SerializedListOfResources(), It.IsAny <IList <Relations> >(), requestInfo.Object)).Returns(
                SerializedHypermediaList());
            serializer.Setup(s => s.Serialize(resources)).Returns(SerializedListOfResources());

            var builder        = new RestfulieMarshaller(relationsFactory.Object, serializer.Object, hypermedia.Object);
            var representation = builder.Build(resources, requestInfo.Object);

            serializer.VerifyAll();
            hypermedia.VerifyAll();
            Assert.AreEqual(representation, SerializedHypermediaList());
        }