Beispiel #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);
        }
Beispiel #2
0
        public void DiscoverYahooOpenIDServer()
        {
            var info   = OpenID.GetIdentityServer("http://www.yahoo.com/".ToUri()).ToArray();
            var server = info.FirstOrDefault();

            server.Should().Not.Be.Null();
            server.Server.ToString().Should().Equal("https://open.login.yahooapis.com/openid/op/auth");
        }
Beispiel #3
0
        public void DiscoverGoogleOpenIDServer()
        {
            var info   = OpenID.GetIdentityServer("https://www.google.com/accounts/o8/id".ToUri()).ToArray();
            var server = info.FirstOrDefault();

            server.Should().Not.Be.Null();
            server.Server.ToString().Should().Equal("https://www.google.com/accounts/o8/ud");
        }
        public AnonymousGroup TestValidInit()
        {
            var ifi     = new OpenID(new Uri("a://b.c"));
            var members = new List <IAgent>
            {
                new Agent(ifi, "Agent Name"),
            };

            return(new AnonymousGroup(members, "Group Name"));
        }
Beispiel #5
0
 public static void ToString(OpenID obj, MethodReturnEventArgs<string> e)
 {
     if (string.IsNullOrWhiteSpace(obj.Provider) && string.IsNullOrWhiteSpace(obj.UserID))
     {
         e.Result = string.Empty;
     }
     else
     {
         e.Result = string.Format("{0} - {1}", obj.Provider, obj.UserID);
     }
 }
Beispiel #6
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");
 }
Beispiel #7
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);
        }
        public void TestInvalidInit()
        {
            var ifi      = new OpenID(new Uri("a://b.c"));
            var members1 = new List <IAgent>();
            var members2 = new List <IAgent>
            {
                new Agent(ifi, "Agent Name"),
            };

            Assert.Throws <ArgumentNullException>(() => new AnonymousGroup(null, "Group Name"));
            Assert.Throws <ArgumentException>(() => new AnonymousGroup(members1, "Group Name"));
            Assert.Throws <ArgumentException>(() => new AnonymousGroup(members2, string.Empty));
            Assert.Throws <ArgumentException>(() => new AnonymousGroup(members2, " "));
        }
Beispiel #9
0
        public IdentifiedGroup TestValidInit()
        {
            var ifi    = new OpenID(new Uri("https://www.gowithfloat.com"));
            var group1 = new IdentifiedGroup(ifi);

            var ifi2    = new Account("Example", new Uri("http://www.example.com"));
            var members = new List <IAgent>
            {
                new Agent(ifi2),
                new Agent(ifi2)
            };

            var group2 = new IdentifiedGroup(ifi, members);

            return(new IdentifiedGroup(ifi, members, "Identified Group"));
        }
Beispiel #10
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());
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
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))));
        }