public void Should_not_be_able_to_convert_non_attribute_marked_model()
        {
            var model = new object();
            var converter = new HALAttributeConverter();

            Assert.False(converter.CanConvert(model.GetType()));
        }
        public void Should_be_able_to_convert_attribute_marked_model()
        {
            var model = new PersonModelWithAttributes();
            var converter = new HALAttributeConverter();

            Assert.True(converter.CanConvert(model.GetType()));
        }
        public void Should_not_be_able_to_convert_HalReponse_with_attribute_marked_model()
        {
            var model = new PersonModelWithAttributes();
            var halResponse = new HALResponse(model);
            var converter = new HALAttributeConverter();

            Assert.False(converter.CanConvert(halResponse.GetType()));
        }
示例#4
0
        public void Link_Constructed_From_Attribute()
        {
            var model = new PersonModelWithAttributes();
            var converter = new HALAttributeConverter();

            var halResponse = converter.Convert(model);

            Assert.True(halResponse.HasSelfLink());
        }
示例#5
0
        public void Sets_Config_From_Attribute()
        {
            var model = new PersonModelWithAttributes();

            var converter = new HALAttributeConverter();
            var serializer = new JsonSerializer();

            var hal = converter.Convert(model);
            var jObject = hal.ToJObject(serializer);

            var selfLink = jObject["_links"]["self"]["href"];
            Assert.StartsWith("~/api", selfLink.ToString());
        }