Exemple #1
0
        public void PropertyDefaultsObjectTest()
        {
            var routeName = typeof(PropertyHypermediaObject).Name + "_Route";

            RouteRegister.AddHypermediaObjectRoute(typeof(PropertyHypermediaObject), routeName, HttpMethod.GET);

            var ho    = new PropertyHypermediaObject();
            var siren = SirenConverter.ConvertToJson(ho);

            AssertDefaultClassName(siren, typeof(PropertyHypermediaObject));
            AssertEmptyEntities(siren);
            AssertEmptyActions(siren);
            AssertHasOnlySelfLink(siren, routeName);

            var propertiesObject = PropertyHelpers.GetPropertiesJObject(siren);

            PropertyHelpers.CompareHypermediaPropertiesAndJson(propertiesObject, ho);
        }
Exemple #2
0
        public void PropertyObjectTest()
        {
            var routeName = typeof(PropertyHypermediaObject).Name + "_Route";

            RouteRegister.AddHypermediaObjectRoute(typeof(PropertyHypermediaObject), routeName, HttpMethod.GET);

            var ho = new PropertyHypermediaObject
            {
                ABool   = true,
                AString = "My String",
                AnInt   = 1,
                ALong   = 2,
                AFloat  = 3.1f,
                ADouble = 4.1,

                AnEnum          = TestEnum.Value1,
                ANullableEnum   = TestEnum.Value1,
                AnEnumWithNames = TestEnumWithNames.Value2,

                ADateTime       = new DateTime(2000, 11, 22, 18, 5, 32, 999),
                ADateTimeOffset = new DateTimeOffset(2000, 11, 22, 18, 5, 32, 999, new TimeSpan(0, 2, 0, 0)),
                ATimeSpan       = new TimeSpan(1, 2, 3, 4),
                AnUri           = new Uri("http://localhost/myuri"),
                ADecimal        = 12345,
                ANullableInt    = 10,
            };
            var siren = SirenConverter.ConvertToJson(ho);

            AssertDefaultClassName(siren, typeof(PropertyHypermediaObject));
            AssertEmptyEntities(siren);
            AssertEmptyActions(siren);
            AssertHasOnlySelfLink(siren, routeName);

            var propertiesObject = PropertyHelpers.GetPropertiesJObject(siren);

            PropertyHelpers.CompareHypermediaPropertiesAndJson(propertiesObject, ho);
        }