Ejemplo n.º 1
0
        public void Setup()
        {
            _basicResource = new BasicResource
            {
                Name = "Pat Smith"
            };

            _formatter = new HalJsonMediaTypeFormatter();
        }
Ejemplo n.º 2
0
        public void formatter_withIndentOverrideToFalse_jsonIsOneLine()
        {
            // arrange
            var noIndentFormatter = new HalJsonMediaTypeFormatter {
                Indent = false
            };

            // act
            var result = TestHelpers.Format.FormatObject(_basicResource, noIndentFormatter);
            var lines  = result.Count(c => c == '\n');

            // assert
            lines.Should().BeLessOrEqualTo(1);
        }
Ejemplo n.º 3
0
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new {
                id = RouteParameter.Optional
            }
                );

            setSerializerSettings(config.Formatters.JsonFormatter.SerializerSettings);

            var formatter = new HalJsonMediaTypeFormatter();

            setSerializerSettings(formatter.SerializerSettings);
            config.Formatters.Add(formatter);
        }
Ejemplo n.º 4
0
        public void Setup()
        {
            _list = new SimpleResourceList
            {
                Relations = new LinkCollection {
                    { "self", new Link {
                          Href = "selfhref"
                      } }
                },
                Items = new List <IResource>()
            };

            _list.Items.Add(new BasicResource
            {
                Name      = "alpha",
                Relations = new LinkCollection {
                    { "self", new Link {
                          Href = "alphahref"
                      } }
                }
            });

            _list.Items.Add(new BasicResource
            {
                Name      = "beta",
                Relations = new LinkCollection {
                    { "self", new Link {
                          Href = "betahref"
                      } }
                }
            });

            _list.Items.Add(new BasicResource
            {
                Name      = "gamma",
                Relations = new LinkCollection {
                    { "self", new Link {
                          Href = "gammahref"
                      } }
                }
            });


            _formatter = new HalJsonMediaTypeFormatter();
        }
Ejemplo n.º 5
0
 public void SetUp()
 {
     this.formatter = new HalJsonMediaTypeFormatter();
 }
 public void Setup()
 {
     _formatter = new HalJsonMediaTypeFormatter();
 }