Ejemplo n.º 1
0
        public void TestEquality()
        {
            var ifi1    = new Mailbox(new MailAddress("*****@*****.**"));
            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 agent1a = new Agent(ifi1, "Example Learner");
            var agent1b = new Agent(ifi1, "Learner, Example");
            var agent2a = new Agent(ifi2, "Jane Doe");
            var agent2b = new Agent(ifi2, "Sue Schmoe");
            var agent3a = new Agent(ifi3, "App User");
            var agent3b = new Agent(ifi3, "xAPI Example");
            var agent4a = new Agent(ifi4, "Virtual Instructor");
            var agent4b = new Agent(ifi4, "Student");

            Assert.Equal(agent1a, agent1b);
            Assert.Equal(agent2a, agent2b);
            Assert.Equal(agent3a, agent3b);
            Assert.Equal(agent4a, agent4b);
            Assert.Equal(agent1a.GetHashCode(), agent1b.GetHashCode());
            Assert.True(agent1a == agent1b);
            Assert.True(agent2a == agent2b);
            Assert.True(agent3a == agent3b);
            Assert.True(agent4a == agent4b);
        }
Ejemplo n.º 2
0
 public void TestSerialize()
 {
     var ifi1   = new Mailbox(new MailAddress("*****@*****.**"));
     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, "Student");
 }
Ejemplo n.º 3
0
        public Agent TestValidInit()
        {
            var ifi1   = new Mailbox(new MailAddress("*****@*****.**"));
            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, "example");
            var agent2 = new Agent(ifi2, "example");
            var agent3 = new Agent(ifi3, "example");
            var agent4 = new Agent(ifi4, "example");

            return(agent1);
        }
Ejemplo n.º 4
0
        public void TestToString()
        {
            var ifi1    = new Mailbox(new MailAddress("*****@*****.**"));
            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 agent1a = new Agent(ifi1, "Jane Doe");
            var agent2a = new Agent(ifi2, "Sue Schmoe");
            var agent3a = new Agent(ifi3, "Learner, Example");
            var agent4a = new Agent(ifi4, "Student");

            Assert.Equal("<Agent: Name \"Jane Doe\" IFI mailto:[email protected]>", agent1a.ToString());
            Assert.Equal("<Agent: Name \"Sue Schmoe\" IFI mbox_sha1sum: 0e3372390b51c30c2fa4d2e0fd7b2b2009fc5692>", agent2a.ToString());
            Assert.Equal("<Agent: Name \"Learner, Example\" IFI <OpenID: https://www.gowithfloat.com/>>", agent3a.ToString());
            Assert.Equal("<Agent: Name \"Student\" IFI <Account: Name \"test\" HomePage http://example.com/>>", agent4a.ToString());
        }
Ejemplo n.º 5
0
        public void TestInequality()
        {
            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 agent1a = new Agent(ifi1, "Jane Doe");
            var agent2a = new Agent(ifi2, "Jane Doe");
            var agent3a = new Agent(ifi3, "Jane Doe");
            var agent4a = new Agent(ifi4, "Jane Doe");

            AssertHelper.Inequality <Agent, IAgent, IIdentifiedActor>(agent1a, agent2a, (a, b) => a != b);
            AssertHelper.Inequality <Agent, IAgent, IIdentifiedActor>(agent2a, agent3a, (a, b) => a != b);
            AssertHelper.Inequality <Agent, IAgent, IIdentifiedActor>(agent3a, agent4a, (a, b) => a != b);
            AssertHelper.Inequality <Agent, IAgent, IIdentifiedActor>(agent4a, agent1a, (a, b) => a != b);
        }
Ejemplo n.º 6
0
        public void TestEquality()
        {
            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 agent1a = new Agent(ifi1, "Example Learner");
            var agent1b = new Agent(ifi1, "Learner, Example");
            var agent2a = new Agent(ifi2, "Jane Doe");
            var agent2b = new Agent(ifi2, "Sue Schmoe");
            var agent3a = new Agent(ifi3, "App User");
            var agent3b = new Agent(ifi3, "xAPI Example");
            var agent4a = new Agent(ifi4, "Virtual Instructor");
            var agent4b = new Agent(ifi4, "Student");

            AssertHelper.Equality <Agent, IAgent, IIdentifiedActor>(agent1a, agent1b, (a, b) => a == b);
            AssertHelper.Equality <Agent, IAgent, IIdentifiedActor>(agent2a, agent2b, (a, b) => a == b);
            AssertHelper.Equality <Agent, IAgent, IIdentifiedActor>(agent3a, agent3b, (a, b) => a == b);
            AssertHelper.Equality <Agent, IAgent, IIdentifiedActor>(agent4a, agent4b, (a, b) => a == b);
        }
Ejemplo n.º 7
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))));
        }