Пример #1
0
        public void CreateAHintByName()
        {
            var hf   = new HintFactory();
            var hint = hf.CreateHint("formats");

            Assert.IsType <FormatsHint>(hint);
        }
Пример #2
0
        public void CreateAHintByName()
        {
            var hf = new HintFactory();
            var hint = hf.CreateHint("formats");

            Assert.IsType<FormatsHint>(hint);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 public LinkFactory(bool includeIANALinks = true)
 {
     if (includeIANALinks)
     {
         RegisterIANALinks();
     }
     HintFactory = new HintFactory();  // Default hintfactory
 }
Пример #4
0
        public void CreateFormatHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint <FormatsHint>();

            hint.AddMediaType("application/json");

            var obj = (JObject)hint.Content;

            Assert.NotNull(obj.Property("application/json"));
        }
Пример #5
0
        public void CreatePreferHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint <AcceptPreferHint>();

            hint.AddPreference("handling");

            var arr = (JArray)hint.Content;

            Assert.Equal("handling", arr[0]);
        }
Пример #6
0
        public void CreateDeprecatedFormatHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint <FormatsHint>();

            hint.AddMediaType("application/json", true);

            var obj = (JObject)hint.Content;

            Assert.NotNull(obj.Property("application/json"));
            var thing = obj.Property("application/json").Value as JObject;

            Assert.Equal(true, (bool)thing.Property("deprecated").Value);
        }
Пример #7
0
        public void SpecifyHandlerForAllowhint()
        {
            var foo = false;

            var registry = new HintFactory();
            registry.SetHandler<AllowHint>((h, r) =>
                { foo = true;
                    return r;
                });

            var hint = registry.CreateHint<AllowHint>();

            var link = new Link();
            link.AddHint(hint);

            // Act
            var request = link.CreateRequest();

            Assert.Equal(foo,true);
        }
Пример #8
0
        public void SpecifyHandlerForAllowhint()
        {
            var foo = false;

            var registry = new HintFactory();

            registry.SetHandler <AllowHint>((h, r) =>
                                            { foo = true;
                                              return(r); });

            var hint = registry.CreateHint <AllowHint>();

            var link = new Link();

            link.AddHint(hint);

            // Act
            var request = link.CreateRequest();

            Assert.Equal(foo, true);
        }
Пример #9
0
        public void CreateFormatHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint<FormatsHint>();
            hint.AddMediaType("application/json");

            var obj = (JObject) hint.Content;
            Assert.NotNull(obj.Property("application/json"));   
        }
Пример #10
0
        public void CreatePreferHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint<AcceptPreferHint>();
            hint.AddPreference("handling");

            var arr = (JArray)hint.Content;
            Assert.Equal("handling", arr[0]);
        }
Пример #11
0
        public void CreateDeprecatedFormatHint()
        {
            var registry = new HintFactory();

            var hint = registry.CreateHint<FormatsHint>();
            hint.AddMediaType("application/json",true);

            var obj = (JObject)hint.Content;
            Assert.NotNull(obj.Property("application/json"));
            var thing = obj.Property("application/json").Value as JObject;
            Assert.Equal(true,(bool)thing.Property("deprecated").Value);
        }