Ejemplo n.º 1
0
        public void ForgivingExpando_can_set_extra_properties()
        {
            dynamic forgivingExpando = new ForgivingExpandoObject();

            forgivingExpando.SomeUndefinedProperty = "unknown";

            string value = forgivingExpando.SomeUndefinedProperty;

            value.ShouldEqual("unknown");
        }
Ejemplo n.º 2
0
        public void Activity_can_be_created()
        {
            dynamic blog = new ForgivingExpandoObject();

            blog.ObjectType = "blog";
            blog.Url        = "http://somefarawayserver/blog/johncoder";

            dynamic person = new Person
            {
                DisplayName = "johncoder",
                Id          = "users/1",
                Image       = new MediaLink {
                    Height = 50, Width = 50, Url = "http://somefarawayserver/johncoder.png"
                },
                Published = new DateTime(2012, 1, 1),
                Updated   = new DateTime(2012, 1, 1)
            };

            person.Tags = new[] { "Person", "Developer", "Employee" };

            var activity = new Activity
            {
                Actor   = person,
                Id      = "activity/johncoder/1",
                Content = "something",
                Verb    = Verbs.Post,
                Object  = new Article
                {
                    Content   = "This is my post",
                    Id        = "posts/johncoder/1",
                    Published = new DateTime(2012, 1, 1),
                    Updated   = new DateTime(2012, 1, 1),
                    Url       = "http://somefarawayserver/blogs/johncoder/new-post"
                },
                Target    = blog,
                Title     = "John posted a new article to his blog.",
                Url       = "http://somefarawayserver/blogs/johncoder",
                Provider  = "http://somefarawayserver/blogs/johncoder/feed",
                Published = new DateTime(2012, 1, 1)
            };

            var serializer = new ActivityStreamSerializer();
            var result     = serializer.Serialize(activity);

            result.ShouldEqual("{\"published\":\"2012-01-01T05:00:00Z\",\"actor\":{\"objectType\":\"person\",\"displayName\":\"johncoder\",\"image\":{\"objectType\":\"medialink\",\"duration\":0,\"height\":50,\"url\":\"http://somefarawayserver/johncoder.png\",\"width\":50},\"id\":\"users/1\",\"published\":\"2012-01-01T05:00:00Z\",\"updated\":\"2012-01-01T05:00:00Z\",\"tags\":[\"Person\",\"Developer\",\"Employee\"]},\"content\":\"something\",\"id\":\"activity/johncoder/1\",\"object\":{\"objectType\":\"article\",\"content\":\"This is my post\",\"id\":\"posts/johncoder/1\",\"published\":\"2012-01-01T05:00:00Z\",\"updated\":\"2012-01-01T05:00:00Z\",\"url\":\"http://somefarawayserver/blogs/johncoder/new-post\"},\"provider\":\"http://somefarawayserver/blogs/johncoder/feed\",\"target\":{\"objectType\":\"blog\",\"url\":\"http://somefarawayserver/blog/johncoder\"},\"title\":\"John posted a new article to his blog.\",\"url\":\"http://somefarawayserver/blogs/johncoder\",\"verb\":\"post\"}");
        }
Ejemplo n.º 3
0
 public void ForgivingExpando_can_be_initialized()
 {
     var forgivingExpando = new ForgivingExpandoObject();
 }