Skip to content

Commit

Permalink
Added an Add method to IdentityProviderDictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAbel committed Jan 15, 2015
1 parent 593f293 commit 5977087
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Kentor.AuthServices.Configuration;
using FluentAssertions;
using System.IdentityModel.Metadata;

namespace Kentor.AuthServices.Tests.Configuration
{
Expand All @@ -17,5 +18,28 @@ public void IdentityProviderDictionary_Indexer_Nullcheck()

a.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("entityId");
}

[TestMethod]
public void IdentityProviderDictionary_Add()
{
var subject = new IdentityProviderDictionary();

var entityId = new EntityId("http://idp.example.com");
var idp = new IdentityProvider(entityId, StubFactory.CreateSPOptions());

subject.Add(idp);

subject[entityId].Should().BeSameAs(idp);
}

[TestMethod]
public void IdentityProviderDictionary_Add_Nullcheck()
{
var subject = new IdentityProviderDictionary();

Action a = () => subject.Add(null);

a.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("idp");
}
}
}
17 changes: 17 additions & 0 deletions Kentor.AuthServices/Configuration/IdentityProviderDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ public IdentityProvider this[EntityId entityId]
}
}

/// <summary>
/// Add an identity provider to the collection..
/// </summary>
/// <param name="idp">Identity provider to add.</param>
public void Add(IdentityProvider idp)
{
if(idp == null)
{
throw new ArgumentNullException("idp");
}

lock(dictionary)
{
dictionary.Add(idp.EntityId, idp);
}
}

/// <summary>
/// The default identity provider; i.e. the first registered of the currently known.
/// </summary>
Expand Down

0 comments on commit 5977087

Please sign in to comment.