Beispiel #1
0
        public void TestSerialize()
        {
            var ifi1   = new Mailbox(new Uri("mailto:[email protected]"));
            var ifi2   = new MailboxSha1Sum(new SHAHash("*****@*****.**"));
            var ifi3   = new OpenID(new Uri("https://www.gowithfloat.com"));
            var ifi4   = new Account("test", new Uri("http://example.com"));
            var agent1 = new Agent(ifi1, "Jane Doe");
            var agent2 = new Agent(ifi2, "Sue Schmoe");
            var agent3 = new Agent(ifi3, "Learner, Example");
            var agent4 = new Agent(ifi4);

            Assert.Equal(FormatJson("{\"objectType\":\"Agent\",\"name\":\"Jane Doe\",\"mbox\":\"mailto:[email protected]\"}"),
                         FormatJson(Serialize.Actor(Actor.From(agent1))));
            Assert.Equal(FormatJson("{\"objectType\":\"Agent\",\"name\":\"Sue Schmoe\",\"mbox_sha1sum\":\"0e3372390b51c30c2fa4d2e0fd7b2b2009fc5692\"}"),
                         FormatJson(Serialize.Actor(Actor.From(agent2))));
            Assert.Equal(FormatJson("{\"objectType\":\"Agent\",\"name\":\"Learner, Example\",\"openid\":\"https://www.gowithfloat.com/\"}"),
                         FormatJson(Serialize.Actor(Actor.From(agent3))));
            Assert.Equal(FormatJson("{\"objectType\":\"Agent\",\"account\":{\"homePage\":\"http://example.com/\",\"name\":\"test\"}}"),
                         FormatJson(Serialize.Actor(Actor.From(agent4))));
        }