public void CanWrite_Returns_True_For_Model_With_Attributes()
        {
            var model = new PersonModelWithAttributes();
            var formatter = new JsonHALMediaTypeFormatter();

            Assert.True(formatter.CanWriteType(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());
        }