public void GivenAValidProviderKey_RedirectToAuthenticate_ReturnsAUri() { // Arrange. var authenticationService = new AuthenticationService(); authenticationService.AddProvider(new FacebookProvider("aa", "bb", new Uri("http://www.google.com"))); // Act. var result = authenticationService.RedirectToAuthenticationProvider("Facebook", "abc"); // Assert. Assert.NotNull(result); Assert.Equal(result.AbsoluteUri, "https://www.facebook.com/dialog/oauth?client_id=aa&redirect_uri=http://www.google.com/&state=abc"); }
public void GivenAnInvalidProviderKey_RedirectToAuthenticationProvider_ThrowsAnException() { // Arrange. const string providerKey = "aaa"; const string state = "asd"; var authenticationService = new AuthenticationService(); // Act and Assert. var result = Assert.Throws<AuthenticationException>( () => authenticationService.RedirectToAuthenticationProvider(providerKey, state)); Assert.NotNull(result); Assert.Equal("No 'aaa' provider has been added.", result.Message); }