public void ActivityStreamSerializer_should_serialize_activity_with_actor()
        {
            var activity = new Activity {
                Title = "Some Activity", Actor = new Person {
                    DisplayName = "johncoder", Id = "SOMEUNIQUEID"
                }
            };
            var serializer = new ActivityStreamSerializer();
            var result     = serializer.Serialize(activity);

            result.ShouldEqual("{\"published\":\"0001-01-01T05:00:00Z\",\"actor\":{\"objectType\":\"person\",\"displayName\":\"johncoder\",\"id\":\"SOMEUNIQUEID\",\"published\":\"0001-01-01T05:00:00Z\",\"updated\":\"0001-01-01T05:00:00Z\"},\"title\":\"Some Activity\"}");
        }
        public void ActivityStreamSerializer_target_with_null_dynamic_property_serializes()
        {
            var activity = new Activity();

            activity.Target = new ForgivingExpandoObject {
                { "Sum", (string)null }, { "Id", 4 }
            };
            var serializer = new ActivityStreamSerializer();
            var result     = serializer.Serialize(activity);

            result.ShouldNotBeNull();
        }
Пример #3
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\"}");
        }