-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from cBrain-dk/master
Fixes issue #58
- Loading branch information
Showing
7 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Net.Http.Headers; | ||
using NUnit.Framework; | ||
|
||
|
||
namespace Ramone.Tests | ||
{ | ||
[TestFixture] | ||
public class AuthenticationHeaderValueTests | ||
{ | ||
private void CanParseBase(string authenticationHeader, string expectedScheme, string expectedParameters) | ||
{ | ||
// Act | ||
AuthenticationHeaderValue authenticationHeaderValue = AuthenticationHeaderValue.Parse(authenticationHeader); | ||
|
||
// Assert | ||
Assert.That(authenticationHeaderValue.Scheme, Is.EqualTo(expectedScheme)); | ||
Assert.That(authenticationHeaderValue.Parameter, Is.EqualTo(expectedParameters)); | ||
} | ||
|
||
|
||
[Test] | ||
public void CanParseWithNoParameters() => CanParseBase( | ||
authenticationHeader: "Basic", | ||
expectedScheme: "Basic", | ||
expectedParameters: null); | ||
|
||
|
||
[Test] | ||
public void CanParseSchemeWithTrailingWhitespace() => CanParseBase( | ||
authenticationHeader: "Basic ", | ||
expectedScheme: "Basic", | ||
expectedParameters: null); | ||
|
||
|
||
[Test] | ||
public void CanParseSchemeWithTrailingWhitespaces() => CanParseBase( | ||
authenticationHeader: "Basic ", | ||
expectedScheme: "Basic", | ||
expectedParameters: null); | ||
|
||
|
||
[Test] | ||
public void CanParseSchemeAndParameter() => CanParseBase( | ||
authenticationHeader: "Basic dGVzdDoxMjPCow==", | ||
expectedScheme: "Basic", | ||
expectedParameters: "dGVzdDoxMjPCow=="); | ||
|
||
|
||
[Test] | ||
public void CanParseSchemeAndParameters() => CanParseBase( | ||
authenticationHeader: "Basic dGVzdDoxMjPCow==, charset=\"UTF-8\"", | ||
expectedScheme: "Basic", | ||
expectedParameters: "dGVzdDoxMjPCow==, charset=\"UTF-8\""); | ||
|
||
|
||
[TestCase(null)] | ||
[TestCase("")] | ||
[TestCase(" ")] | ||
public void CannotParse(string authenticationHeader) => | ||
Assert.That(() => AuthenticationHeaderValue.Parse(authenticationHeader), Throws.InstanceOf<FormatException>()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters